caml_leave_blocking section and errno corruption #5982
Original bug ID: 5982
This is a widespread idiom for writing C stubs:
Here [uerror] uses the global variable [errno]. The problem is that [leave_blocking_section] can run arbitrary code and so modify [errno]. It can run signal handlers for instance. Attached is an example of program where the call to select is expected to fail with EINTR but instead fails with EROFS.
Obviously bindings should be written this way:
But since this is very common I propose that [leave_blocking_section] saves and restores [errno].
let () =
ignore (Unix.alarm 1);
The text was updated successfully, but these errors were encountered: