RFR: JDK-8298448: UndefinedBehaviorSanitizer [v2]
David Holmes
dholmes at openjdk.org
Mon Dec 12 06:52:41 UTC 2022
On Mon, 12 Dec 2022 05:51:52 GMT, Justin King <jcking at openjdk.org> wrote:
>> src/java.base/share/native/launcher/main.c line 37:
>>
>>> 35: #include "jni.h"
>>> 36:
>>> 37: #ifdef UNDEFINED_BEHAVIOR_SANITIZER
>>
>> I really do not like having to make source code changes to accommodate these kinds of tools.
>
> Yeah, it is unfortunate. However there is no other way to actually set the defaults nicely. The other alternative is to use environment variables, but they are easy to forget when invoking the launcher manually.
Does the env-var override the src declaration, or the other way around?
>> src/java.base/share/native/launcher/main.c line 40:
>>
>>> 38: // Override weak symbol exposed by UBSan to override default options. This is called by UBSan
>>> 39: // extremely early during library loading, before main is called.
>>> 40: JNIEXPORT const char* __ubsan_default_options() {
>>
>> Why would this need `JNIEXPORT`? This is not a JNI function.
>
> Ugh, apparently resolving doesn't add the comment. I thought it did...
>
> So answering, JNIEXPORT is needed so that the symbol is exported and the linker doesn't remove it. It adds `__attribute__((visibility("default"))`.
Okay. The limited documentation on these `___xxx_default_options` functions didn't show the need for any export/visibility attributes.
-------------
PR: https://git.openjdk.org/jdk/pull/11604
More information about the core-libs-dev
mailing list