This is an archive of the discontinued LLVM Phabricator instance.

[tsan] Fix ScopedInterceptor's handling of !thr->is_inited
AbandonedPublic

Authored by kubamracek on Jan 15 2016, 1:57 AM.

Details

Summary

The commit r257866 (https://github.com/llvm-mirror/compiler-rt/commit/b78f9c1f623e5faa4cca68227ab536ae80f9fc16, differential revision http://reviews.llvm.org/D15301, which is slightly different than the commit) introduced a test failure in Darwin/ignored-interceptors.mm. When ignore_interceptors_accesses=1, we only check !thr_->is_inited in the constructor of ScopedInterceptor, which then skips ThreadIgnoreBegin, but the destructor still calls ThreadIgnoreEnd:

ScopedInterceptor::ScopedInterceptor(...) {
  Initialize(thr);
  if (!thr_->is_inited)
    return;
  ...
  if (flags()->ignore_interceptors_accesses) ThreadIgnoreBegin(thr_, pc_);
}
ScopedInterceptor::~ScopedInterceptor() {
  if (flags()->ignore_interceptors_accesses) ThreadIgnoreEnd(thr_, pc_);
  ...
}

Diff Detail

Event Timeline

kubamracek updated this revision to Diff 44968.Jan 15 2016, 1:57 AM
kubamracek retitled this revision from to [tsan] Fix ScopedInterceptor's handling of !thr->is_inited.
kubamracek updated this object.
kubamracek added subscribers: llvm-commits, zaks.anna.
yabinc edited edge metadata.Jan 15 2016, 11:54 AM

Sorry, I missed two lines when committing http://reviews.llvm.org/D15301. I uploaded the fix in http://reviews.llvm.org/D15301.
I think if !thr->is_inited, it means __tsan_thread_start_func()->ThreadStart() is not called, and I think we shouldn't access
fields in ThreadState as it is not inited. Please let me know if my understanding is wrong.

kubamracek abandoned this revision.Apr 11 2016, 2:46 AM