-
Notifications
You must be signed in to change notification settings - Fork 1.6k
work around _FORTIFY_SOURCE false positive #250
Conversation
|
I prefer to leave this alone, since the warning does not indicate an exercisable issue, and the solution adds cpp noise. The |
|
The error / warning is produced by This doesn't happen with glibc because they don't check for buffer read overflows, only writes, and they use |
|
Other operating systems will probably be checking for read overflows too, so that was my motivation for submitting it here rather than just for Android's jemalloc tree. FreeBSD is getting a https://wiki.freebsd.org/SummerOfCode2015/FreeBSDLibcSecurityExtensions |
|
Oh, I have an idea. The This would result in the function body being optimized out in release builds too, without adding the overhead of a branch anywhere as |
|
(just need a |
|
Cool, I'm all for a |
|
This works well, and reduces the size of the shared object from 403k -> 367k. |
|
This is awesome. I have some thoughts and questions though.
|
|
Hmm, |
Clang actually has nice built-ins for dealing with this without autoconf now ( http://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros It sets
It would make sense, but it's only a small code size win for dead code. I'm not sure if it's worth doing. I don't really like the idea of an incorrect assert like The
It would make sense to use |
|
Ah, |
|
@jasone: It actually optimizes out properly with just |
In builds with profiling disabled (default), the opt_prof_prefix array has a one byte length as a micro-optimization. This will cause the usage of write in the unused profiling code to be statically detected as a buffer overflow by Bionic's _FORTIFY_SOURCE implementation as it tries to detect read overflows in addition to write overflows. This works around the problem by informing the compiler that not_reached() means code in unreachable in release builds.
|
This change makes me really happy. Thanks again! |
In builds with profiling disabled (default), the opt_prof_prefix array
has a one byte length as a micro-optimization. This will cause the usage
of write in the unused profiling code to be statically detected as a
buffer overflow by Bionic's _FORTIFY_SOURCE implementation as it tries
to detect read overflows in addition to write overflows.