Skip to content

WindowsError: exception: access violation when using _MEMCPY #85

Closed
@inatuwe

Description

@inatuwe

I get an access violation when using the following methods:

File "site-packages\msal\application.py", line 1168, in acquire_token_by_device_flow
File "site-packages\msal\oauth2cli\oauth2.py", line 384, in obtain_token_by_device_flow
File "site-packages\msal\oauth2cli\oauth2.py", line 347, in _obtain_token_by_device_flow
File "site-packages\msal\oauth2cli\oidc.py", line 102, in _obtain_token
File "site-packages\msal\oauth2cli\oauth2.py", line 765, in _obtain_token
File "site-packages\msal\application.py", line 308, in
File "site-packages\msal\token_cache.py", line 297, in add
File "site-packages\msal\token_cache.py", line 113, in add
File "site-packages\msal\token_cache.py", line 176, in __add
File "site-packages\msal_extensions\token_cache.py", line 49, in modify
File "site-packages\msal_extensions\persistence.py", line 163, in save
File "site-packages\msal_extensions\windows.py", line 80, in protect
File "site-packages\msal_extensions\windows.py", line 39, in raw
WindowsError: exception: access violation writing 0x0000028F4B081000

I use the device flow and it properly redirects me to the browser, I enter the credentials, everything works fine, but when returning to the Windows application written in python, I receive the error.

Edit: The Windows version doesn't affect this issue:
Note: This error does not occur on Windows 10 Version 2004 (May 2020 Update), 19041, but is present with the newer Windows 10 Version 20H2 (October 2020 Update), 19042.

I have been able to fix the issue for both Windows Versions by adding the following line in windows.py (0.3.0):
Line 8 (directly after: "_MEMCPY = ctypes.cdll.msvcrt.memcpy")
_MEMCPY.argtypes = [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_size_t]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions