Open ramosian-glider opened 9 years ago
I'd like to try to implement this when I get time. Any hints, e.g., where to start
looking.
Reported by mohamed.omar.bana
on 2012-07-06 10:02:17
First, you need a small program that spawns a thread, sets its name (GDB can help to
check whether it actually happens) and crashes because of an ASan error. We'll need
to put it into the test suite later.
Next, you'll need to wrap prctl() on Linux and pthread_setname_np() on Mac and store
the name somewhere. Mac-specific wrappers reside in asan_mac.cc, you'll need to introduce
something similar for Linux as well (maybe rename them to InitializePlatformInterceptors?)
The thread name should be stored in AsanThreadSummary, as we may want to print them
after the thread has been deleted.
After all, you'll need to replace all the code printing "T%d" with calls to an AsanThreadSummary
method that returns the thread number together with thread name (if it's available).
Keep in mind this may affect the output tests.
For the record, name-your-threads.html is down, but is available from Google cache:
http://webcache.googleusercontent.com/search?sugexp=chrome,mod=10&sourceid=chrome&ie=UTF-8&q=cache%3A0pointer.de%2Fblog%2Fprojects%2Fname-your-threads.html
Reported by ramosian.glider
on 2012-07-06 10:41:28
http://llvm.org/viewvc/llvm-project?rev=169598&view=rev implements part of what's needed.
Alex, Tiumur, what's the analog to prctl(PR_SET_NAME) on Mac/Windows.
Also, how do we couple this with tsan's AnnotateThreadName?
Should we route AnnotateThreadName to prctl? Unfortunately, names in prctl are limited
with 15 bytes, so that may degrade our functionality...
Perhaps like this?
SanitizerSetThreadName calls prctl and also remembers the full name in a thread-local
variable. (not all platforms have TLS)
SanitizerGetThreadName checks if we have our own thread-local variable set.
If yes, it returns it, otherwise it returns what's in prctl
Thoughts?
Reported by konstantin.s.serebryany
on 2012-12-07 11:35:26
Reported by konstantin.s.serebryany
on 2012-12-07 11:41:59
I can't help with the other parts, but prctl(PR_SET_NAME,X,0,0,0) is also the right
way to set thread names on Mac.
Reported by lee@leecbaker.com
on 2012-12-07 13:53:17
http://llvm.org/viewvc/llvm-project?rev=169601&view=rev implements
reporting thread names in the actual reports:
% AsanTest --gtest_filter=*DISABLED_DemoThreadedTest --gtest_also_run_disabled_tests
2>&1 | grep hread
...
WRITE of size 4 at 0x7fbb5ab95040 thread T3 (UseThr)
freed by thread T2 (FreeThr) here:
previously allocated by thread T1 (AllocThr) here:
Thread T3 (UseThr) created by T0 here:
Thread T2 (FreeThr) created by T0 here:
Thread T1 (AllocThr) created by T0 here:
Reported by konstantin.s.serebryany
on 2012-12-07 15:18:50
> what's the analog to prctl(PR_SET_NAME) on Windows
http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx
You could have looked it up in the Chromium sources, base/threading/platform_thread_win.cc
Reported by timurrrr@google.com
on 2012-12-08 09:26:23
FTR:
automagically, the current asan implementation on linux works for pthread_setname_np,
because this function calls prctl(PR_SET_NAME)
Reported by konstantin.s.serebryany
on 2013-01-17 11:50:33
FTR, this is only true if pthread_setname_np() is being called for the current thread.
Not sure if the other case is used wide enough.
Reported by ramosian.glider
on 2013-01-17 12:02:25
Reported by konstantin.s.serebryany
on 2013-02-15 14:31:32
Reported by ramosian.glider
on 2015-07-30 09:05:30
Adding Project:AddressSanitizer as part of GitHub migration.
Reported by ramosian.glider
on 2015-07-30 09:06:54
Originally reported on Google Code with ID 79
Reported by
ramosian.glider
on 2012-06-14 16:03:44