Skip to content

Missing tsan interceptor for _longjmp on Mac #161443

@rmacnak-google

Description

@rmacnak-google

There is an interceptor for _setjmp but not _longjmp. The causes _longjmp to fail to restore the __tsan_func_entry/__tsan_func_exit stack to its position at _setjmp and can eventually result in overflow and internal TSAN crashes.

Discovered when addressing dart-lang/sdk#61536.

#include <setjmp.h>

__attribute__((noinline))
void foo(jmp_buf* buf) {
  _longjmp(*buf, 1);
}

int main() {
  jmp_buf buf;
  for (int i = 0; i < 10000000; i++) {
    if (_setjmp(buf) == 0) {
      foo(&buf);
    }
  }
}

This small example crashes with _setjmp/_longjmp, but works with setjmp/longjmp.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions