Skip to content

Our current mechanism for accessing the C raise() function is broken on Windows if using the debug CRT #816

Description

@njsmith

We need to be able to deliver signals to the current process, both for testing, and to handle an obscure race condition in open_signal_receiver. On POSIX we just use os.kill, but on Windows we use the C raise function (since the kill syscall doesn't exist, and os.kill wrapper does something very different). We get access to it via cffi, loading the api-ms-win-crt-runtime-l1-1-0.dll.

But, it turns out that this is not always the correct DLL to use. In particular, if the Python interpreter is built against the debug version of the CRT, you have to use ucrtbased.dll instead.

Fortunately, this does not affect many people, because people rarely use debug interpreters. But, as far as I know there is no way to figure out which DLL is correct, so right now Trio just can't support debug interpreters on Windows :-(.

Relevant discussion:

Possible solutions:

  • Figure out a way to autodetect which CRT the interpreter is using?
  • As suggested in bpo-35568, get the stdlib to add a wrapper for raise so that we don't have to go grovelling around in DLLs by hand?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions