sagemath / cysignals

cysignals: interrupt and signal handling for Cython
GNU Lesser General Public License v3.0
44 stars 23 forks source link

Signal safety #163

Closed tornaria closed 9 months ago

tornaria commented 2 years ago

Follow up to #162.

The first commit gets rid of all usage of stdio in signal handlers (mostly, but not only, inside ENABLE_DEBUG_CYSIGNALS).

The second commit replaces use of gettimeofday() by clock_gettime(), the latter being safe according to signal-safety(7). It's also monotonic, unlike gettimeofday().

Other stuff that happens inside the signal handler:

mkoeppe commented 10 months ago

Rebased, to run the current tests

mkoeppe commented 9 months ago

@malb @dimpase should this be merged? It seems to pass all tests. @tornaria Are you using these fixes in production already?

tornaria commented 9 months ago

@malb @dimpase should this be merged? It seems to pass all tests. @tornaria Are you using these fixes in production already?

I'm only using #162 (see https://github.com/void-linux/void-packages/tree/master/srcpkgs/python3-cysignals/patches). This is the only issue that I know how to reproduce. This PR "fixes" potential issues of the same kind that I don't know how to reproduce.

Note that #162 is merged but never released. It would be nice to have a new release which fixes this issue and fully supports cython 3. The easy way to support cython 3 is to use legacy_implicit_noexcept but a proper fix is to actually add all the noexcept clauses so the code builds fine with cython 0.29 or cython 3.

dimpase commented 9 months ago

rebased over the latest main, to see how it goes with CI