зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1281581 - save and restore errno in the profiler's signal handler; r=BenWa
The profiler's signal handler clobbers errno, via its calls to sem_post, or via other functions that it transitively calls. TSan complains about this, as a sample arriving at the wrong time could make it look like a function that failed actually succeeded, or vice versa. Ensure that the signal handler preserves the state of the world by saving and restoring errno around its operation.
This commit is contained in:
Родитель
206dc72425
Коммит
b4dc060490
|
@ -231,8 +231,12 @@ static void SetSampleContext(TickSample* sample, void* context)
|
|||
namespace {
|
||||
|
||||
void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) {
|
||||
// Avoid TSan warning about clobbering errno.
|
||||
int savedErrno = errno;
|
||||
|
||||
if (!Sampler::GetActiveSampler()) {
|
||||
sem_post(&sSignalHandlingDone);
|
||||
errno = savedErrno;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -253,6 +257,7 @@ void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) {
|
|||
|
||||
sCurrentThreadProfile = NULL;
|
||||
sem_post(&sSignalHandlingDone);
|
||||
errno = savedErrno;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
Загрузка…
Ссылка в новой задаче