RFR: JDK-8298448: UndefinedBehaviorSanitizer

Justin King jcking at openjdk.org
Fri Dec 9 13:50:02 UTC 2022


On Fri, 9 Dec 2022 06:53:31 GMT, Justin King <jcking at openjdk.org> wrote:

> Allow building OpenJDK with UBSan. Currently the build fails when optimizing the image due to lots of undefined behavior (it invokes the built JVM). Follow up PRs will either replace the undefined behavior with well defined behavior or suppress errors which are intentional. The goal is to make OpenJDK more well defined and thus more portable across compilers and architectures.

What version of GCC are you using? I'm on 12.2 which is the most recent. It
might be that I'm on a newer build with more UBSan coverage.

__ubsan_default_options is called extremely early before main, during
static initializers. IIRC the launcher uses dynamic loading to get
libjvm.so, so that won't work. But maybe I'm misremembering, I'll double
check.

On Fri, Dec 9, 2022, 6:56 PM Robbin Ehn ***@***.***> wrote:

> Two questions, this works fine for me:
> UBSAN_CFLAGS="-fsanitize=undefined -fsanitize=float-divide-by-zero
> -Wno-stringop-truncation -Wno-format-overflow -fno-omit-frame-pointer" ;
> UBSAN_LDFLAGS="-fsanitize=undefined -fsanitize=float-divide-by-zero" ; sh
> configure --with-conf-name=udf --with-debug-level=fastdebug
> --with-native-debug-symbols=internal -with-version-opt=releaserobbin
> --with-gtest=/home/rehn/source/gtest181/ --disable-precompiled-headers
> --enable-dtrace --with-extra-cflags="$UBSAN_CFLAGS"
> --with-extra-cxxflags="$UBSAN_CFLAGS" --with-extra-ldflags="$UBSAN_LDFLAGS"
> && make images CONF=udf
> I.e.build works ?
>
> Secondly, the method __ubsan_default_options is in the java launcher.
> libjvm.so is a "standalone product" that can be used by different
> launchers.
> So I'm not sure it should be in launcher if it was needed.
>
>> Reply to this email directly, view it on GitHub
> <https://github.com/openjdk/jdk/pull/11604#issuecomment-1344309622>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAHTURS2GYPXYGIN5D2CVZ3WMMXRFANCNFSM6AAAAAASY75DP4>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>

-------------

PR: https://git.openjdk.org/jdk/pull/11604


More information about the core-libs-dev mailing list