hpyproject/hpy

Debug context: check that HPy API is accessed only from Python threads

steve-s opened this issue · 0 comments

Possible implementation: store thread ID in the debug context just before calling extension function, and check it on every API call.

Caveats:

  • is there some portable way to get something like thread ID in C. First implementation could be just for Unix/Linux. We can have some abstraction like we have for stack traces.
  • play nicely with debug context reuse (turn the check off when we run out of contexts?)
  • should have happy and bad case tests that actually spin multiple Python threads (context from one Python thread must not be used in other Python thread too), and a bad case test that spins unrelated C threads and tries to call HPy API in them