-
Notifications
You must be signed in to change notification settings - Fork 270
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
Added initial version of thread.c #239
Conversation
Compiles with
|
So just to be clear: this defeats all your TSAN warnings, right? I will comb through this tomorrow but given we don't have load/acquire and store/release memory fences on non-x64/86 platforms, I feel this is only just the beginning... |
lib/Remotery.c
Outdated
#if __STDC_VERSION__ >= 201112L || __cplusplus >= 199711L | ||
#if !defined(__STDC_NO_ATOMICS__) | ||
#if !defined(RMT_USE_C_ATOMICS) // Check if the user already specified it | ||
#define RMT_USE_C_ATOMICS | ||
#endif | ||
#endif | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want a way to explicitly choose not to use the C atomics?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we do because we want to have an explicit test case that ensures that path always compiles.
On linux, I still get this TSAN warning, when using the C11 atomics:
And, I'm not sure what's going on with the Windows "dump.exe". I need to look into that as well. |
Your line numbers are different to the version I have so I'm not sure what it's referencing. At a guess I'd say it's the The side effects are:
Options:
|
@@ -5333,7 +5359,7 @@ static rmtU32 ThreadProfiler_GetNameHash(ThreadProfiler* thread_profiler, rmtMes | |||
if (hash_cache != NULL) | |||
{ | |||
// Calculate the hash first time round only | |||
name_hash = *hash_cache; | |||
name_hash = AtomicLoadU32((rmtAtomicU32*)hash_cache); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried some variants but so far, this was the one that worked and wasn't too intrusive.
I think it's all coming together now. However, I haven't figured out why the windows test stopped working. |
lib/Remotery.c
Outdated
@@ -167,6 +167,28 @@ static rmtBool g_SettingsInitialized = RMT_FALSE; | |||
#include <cuda.h> | |||
#endif | |||
|
|||
#if RMT_USE_LEGACY_ATOMICS==0 | |||
#if !defined(RMT_PLATFORM_WINDOWS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully can enable this once the windows tests start working again.
@@ -55,6 +55,7 @@ cl.exe %CL_OPTS% -Ilib -DRMT_USE_INTERNAL_HASH_FUNCTION=1 sample/sample.c lib/Re | |||
echo "Samples" | |||
cl.exe %CL_OPTS% -Ilib sample/sample.c lib/Remotery.c /link /out:build\sample.exe || goto :error | |||
cl.exe %CL_OPTS% -Ilib sample/dump.c lib/Remotery.c /link /out:build\dump.exe || goto :error | |||
cl.exe %CL_OPTS% -TP /MTd /O1 /fsanitize=address /Zi -Ilib sample/thread.c lib/Remotery.c /link /DEBUG /out:build\thread_asan.exe || goto :error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying out address sanitizer for windows
Is this ready to go? What is the status of running ASAN/UBSAN/TSAN after this change? |
I think it's good to go. |
Awesome work, thanks! |
No description provided.