[WIP] bpo-30703: More reentrant signal handler#2408
Conversation
Modify the signal handler to not call Py_AddPendingCall() function since this function uses a lock and a list, and so is unlikely to be reentrant. Add a new _PyEval_SignalReceived() function which only writes into an atomic variable and so is reentrant.
|
What about the part without WITH_THREAD? :-) |
Sorry, something went wrong.
|
Ok, I think there is a problem with this patch. What if a C signal is received just after |
Sorry, something went wrong.
|
This is why, by the way, |
Sorry, something went wrong.
|
A possible solution should be to call UNSIGNAL_PENDING_CALLS() before calling PyErr_CheckSignals(), and remove the UNSIGNAL_PENDING_CALLS() call from the Py_MakePendingCalls() loop. Also, perhaps change the bit that calls Py_MakePendingCalls() in the eval loop to: (i.e. change the |
Sorry, something went wrong.
|
It's difficult to reproduce the race condition described above but here is a script that may work: |
Sorry, something went wrong.
|
This patch applied to your PR should make things better: |
Sorry, something went wrong.
Please push directly into my branch, you are allowed to do that ;-) See maybe https://docs.python.org/devguide/gitbootcamp.html#editing-a-pull-request-prior-to-merging |
Sorry, something went wrong.
|
I added [WIP] to the title, since I didn't test my change. I was more to discuss a practical solution to the problem. It seems like you spotted bugs in my implementation, thanks ;-) |
Sorry, something went wrong.
|
That doesn't work. I get: |
Sorry, something went wrong.
|
I'll create another PR instead of dealing with git cruft. |
Sorry, something went wrong.
It seems like you used the HTTPS URL. I suggest you to use the SSH URL. Moreover, when I try to push to a different repository, I try to only push a single branch. For example, to push the to BRANCH branch of REMOTE remote, you can type: HEAD uses the current branch, ":BRANCH" means that you push to REMOTE:BRANCH. Non obvious syntax, but I like it. |
Sorry, something went wrong.
It is what I tried before (see above) :-)
I'm almost sure I'll have forgotten that the next time I'll need it :-/ |
Sorry, something went wrong.
Modify the signal handler to not call Py_AddPendingCall() function
since this function uses a lock and a list, and so is unlikely to be
reentrant. Add a new _PyEval_SignalReceived() function which only
writes into an atomic variable and so is reentrant.