Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark cs_* as thread local to avoid race condition in multithreads #1891

Merged
merged 1 commit into from
Jul 4, 2022

Conversation

wtdcode
Copy link
Contributor

@wtdcode wtdcode commented Jul 3, 2022

Per @trufae reported,

=================================================================
==251167==ERROR: AddressSanitizer: odr-violation (0x7f5cd9115f40):
  [1] size=8 'cs_vsnprintf' cs.c:299:16
  [2] size=8 'cs_vsnprintf' cs.c:299:16
These globals were registered at these points:
  [1]:
    #0 0x7f5ce2a20938 in __asan_register_globals ../../../../src/libsanitizer/asan/asan_globals.cpp:341
    #1 0x7f5cd5fbc712 in _sub_I_00099_1 (/usr/local/lib/libr_anal.so+0x3260712)
    #2 0x7f5ce3401b99 in call_init /build/glibc-SzIz7B/glibc-2.31/elf/dl-init.c:72

  [2]:
    #0 0x7f5ce2a20938 in __asan_register_globals ../../../../src/libsanitizer/asan/asan_globals.cpp:341
    #1 0x7f5cde789b44 in _sub_I_00099_1 (/usr/local/lib/libr_asm.so+0x103db44)
    #2 0x7f5ce3401b99 in call_init /build/glibc-SzIz7B/glibc-2.31/elf/dl-init.c:72

==251167==HINT: if you don't care about these errors you may set ASAN_OPTIONS=detect_odr_violation=0
SUMMARY: AddressSanitizer: odr-violation: global 'cs_vsnprintf' at cs.c:299:16
==251167==ABORTING

This PR marks cs_* variables as thread_local to avoid race access in multiple threads. For platforms that don't support thread_local, this PR does nothing.

@kabeor
Copy link
Member

kabeor commented Jul 4, 2022

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants