This is an archive of the discontinued LLVM Phabricator instance.

[Support] Avoid concurrency hazard in signal handler registration
ClosedPublic

Authored by bruno on Mar 24 2017, 2:53 PM.

Details

Reviewers
beanz
Summary

Several static functions from the signal API can be invoked simultaneously; RemoveFileOnSignal for instance can be called indirectly by multiple parallel loadModule() invocations, which might lead to the assertion:

Assertion failed: (NumRegisteredSignals < array_lengthof(RegisteredSignalInfo) && "Out of space for signal handlers!"),

function RegisterHandler, file /llvm/lib/Support/Unix/Signals.inc, line 105.

RemoveFileOnSignal calls RegisterHandlers(), which isn't currently mutex protected, leading to the behavior above. Since there are a few potentially affected static functions, this patch fix RegisterHandlers to use a mutex.

Diff Detail

Event Timeline

bruno created this revision.Mar 24 2017, 2:53 PM
beanz accepted this revision.Mar 24 2017, 4:38 PM

LGTM.

This revision is now accepted and ready to land.Mar 24 2017, 4:38 PM
bruno closed this revision.Mar 27 2017, 2:21 PM

Committed r298871