martinpitt / umockdev

Mock hardware devices for creating unit tests and bug reporting
https://launchpad.net/umockdev
GNU Lesser General Public License v2.1
308 stars 55 forks source link

preload: fix sigmask block and restore race #253

Closed barathrm closed 1 month ago

barathrm commented 1 month ago

Related to and discussed more at https://github.com/martinpitt/umockdev/issues/252


To avoid clobbering a threads signal mask with that of another thread, take locks before storing a thread's signal mask in case another thread has already stored its own signal mask in the trap_path_sig_restore variable, but has not yet restored it.

Without this change, the following could happen:

If umockdev-run is used to run a process which spawns multiple threads, and each of those threads writes to a file, and has specific signal mask requirements, the following may happen

martinpitt commented 1 month ago

Hello @barathrm ! Oh dear, you clearly win my "bug report and analysis of the year" trophy! :trophy: Thanks so much for tracking this down!

The fix is straightforward, as usual in these cases (where there's a ton of work in debugging and understanding the problem).

Unfortunately meson is making a boo-boo in Debian testing. That has nothing to do with your fix, it just broke independently. I'll investigate this, and then rebase/queue your PR after that fix.

Cheers!