Closed ramosian-glider closed 9 years ago
fixed in llvm r160853.
eugenis@, do we need to do something special with the Android copy of asan?
Reported by konstantin.s.serebryany
on 2012-07-27 07:13:06
Fixed
Thanks.
Nick can now update and commit his Android patch.
Reported by eugenis@google.com
on 2012-07-27 08:58:07
I reviewed asan patch 160853, and I think there's a slight bug in it.
In "strcmp", we check the variable "asan_inited". That differs from "strncmp" where
we check the variable "asan_init_is_running".
The ENSURE_ASAN_INITED call in "strcmp" will never be executed because of the asan_inited
check immediately above. Or, another way, if you expand the macro in strcmp, you get
the following code where __asan_init() is unreachable.
INTERCEPTOR(int, strcmp, const char *s1, const char *s2) {
if (!asan_inited) {
return internal_strcmp(s1, s2);
}
do {
CHECK(!asan_init_is_running);
if (!asan_inited) {
__asan_init(); // UNREACHABLE
}
} while (0);
[deleted]
For reference, here's patch 160852:
$ svn diff -r 160852
Index: asan_interceptors.cc
===================================================================
--- asan_interceptors.cc (revision 160852)
+++ asan_interceptors.cc (working copy)
@@ -423,6 +423,7 @@
if (!asan_inited) {
return internal_strcmp(s1, s2);
}
+ ENSURE_ASAN_INITED();
unsigned char c1, c2;
uptr i;
for (i = 0; ; i++) {
@@ -494,6 +495,7 @@
if (asan_init_is_running) {
return REAL(strncmp)(s1, s2, size);
}
+ ENSURE_ASAN_INITED();
unsigned char c1 = 0, c2 = 0;
uptr i;
for (i = 0; i < size; i++) {
Reported by nnk@google.com
on 2012-07-27 16:15:56
>> The ENSURE_ASAN_INITED call in "strcmp" will never be executed because of the asan_inited
check immediately above.
Well, someone else will eventually call __asan_init.
So, effectively the call to ENSURE_ASAN_INITED is a no-op, but a harmless one.
No?
Alexey, could you please review the current situation?
Reported by konstantin.s.serebryany
on 2012-07-27 16:43:45
New
Agreed. The code as currently written is a harmless no-op.
Reported by nnk@google.com
on 2012-07-27 16:46:25
I changed
if (!asan_inited) return internal_strcmp(s1, s2);
to
if (asan_init_is_running) return REAL(strcmp)(s1, s2);
for consistency with other interceptors. I think the code should be ok now (r161109)
Reported by samsonov@google.com
on 2012-08-01 13:01:22
Fixed
thanks!
Reported by nnk@google.com
on 2012-08-01 20:28:21
Adding Project:AddressSanitizer as part of GitHub migration.
Reported by ramosian.glider
on 2015-07-30 09:12:59
Originally reported on Google Code with ID 94
Reported by
nnk@google.com
on 2012-07-26 19:51:43