RFR: JDK-8327986: ASAN reports use-after-free in DirectivesParserTest.empty_object_vm

Thomas Stuefe stuefe at openjdk.org
Wed Mar 13 07:25:20 UTC 2024


ASAN reports a use-after-free, because we feed the string we got from `setlocale` back to `setlocale`, but the libc owns this string, and the libc decided to free it in the meantime.

According to POSIX, it should be valid to pass into setlocale output from setlocale.

However, glibc seems to delete the old string when calling setlocale again:

https://codebrowser.dev/glibc/glibc/locale/setlocale.c.html#198

Best to make a copy, and pass in the copy to setlocale.

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

Commit messages:
 - JDK-8327986-ASAN-reports-use-after-free-in-DirectivesParserTest-empty_object_vm

Changes: https://git.openjdk.org/jdk/pull/18235/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=18235&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8327986
  Stats: 3 lines in 1 file changed: 1 ins; 0 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/18235.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/18235/head:pull/18235

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


More information about the hotspot-compiler-dev mailing list