Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when modifying DLL function pointers conconcurrently #127946

Closed
Tracked by #127945
ZeroIntensity opened this issue Dec 14, 2024 · 1 comment
Closed
Tracked by #127945

Crash when modifying DLL function pointers conconcurrently #127946

ZeroIntensity opened this issue Dec 14, 2024 · 1 comment
Assignees
Labels
3.13 bugs and security fixes 3.14 new features, bugs and security fixes extension-modules C modules in the Modules dir topic-ctypes topic-free-threading type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@ZeroIntensity
Copy link
Member

ZeroIntensity commented Dec 14, 2024

It seems that ctypes doesn't like having function pointers on a CDLL modified concurrently. Here's a reproducer (for Linux):

import ctypes
from threading import Thread

dll = ctypes.CDLL("libc.so.6")

def main():
    for _ in range(100):
        dll.puts.argtypes = ctypes.c_char_p,
        dll.puts.restype = ctypes.c_int

threads = [Thread(target=main) for _ in range(100)]
for thread in threads:
    thread.start()

Linked PRs

@ZeroIntensity ZeroIntensity changed the title Crash when modifying DLL function pointers conconcurrently (report incoming) Crash when modifying DLL function pointers conconcurrently Dec 14, 2024
@ZeroIntensity ZeroIntensity added topic-ctypes extension-modules C modules in the Modules dir 3.13 bugs and security fixes topic-free-threading 3.14 new features, bugs and security fixes labels Dec 14, 2024
@ZeroIntensity ZeroIntensity self-assigned this Dec 14, 2024
@ZeroIntensity ZeroIntensity added the type-crash A hard crash of the interpreter, possibly with a core dump label Dec 14, 2024
@ZeroIntensity
Copy link
Member Author

PR ready, but waiting on #127950.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes 3.14 new features, bugs and security fixes extension-modules C modules in the Modules dir topic-ctypes topic-free-threading type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

No branches or pull requests

1 participant