-
Bug
-
Resolution: Fixed
-
P4
-
8, 21, 23
-
b21
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8332193 | 22.0.2 | Matthias Baesken | P4 | Resolved | Fixed | b06 |
JDK-8332295 | 21.0.4 | Matthias Baesken | P4 | Resolved | Fixed | b04 |
JDK-8334480 | 17.0.13 | Matthias Baesken | P4 | Resolved | Fixed | b01 |
For example in the java/util jtreg tests those are easily reproducable when compiling with -ftrapv (clang/gcc toolchains).
While those overflows never seem to cause crashes or similar errors, they are unwanted because
signed integer overflows in C cause undefined behavior.
See
https://www.gnu.org/software/c-intro-and-ref/manual/html_node/Signed-Overflow.html
>
> For signed integers, the result of overflow in C is in principle undefined, meaning that anything whatsoever could happen.
> Therefore, C compilers can do optimizations that treat the overflow case with total unconcern.
So we might still get unwanted results (maybe bad/strange hashing, depending on compiler and optimization level).
Compilation with -ftrapv causes/triggers this SIGILL on macOS showing the issue :
# Problematic frame:
# C [libzip.dylib+0x6362] hashN+0x32
#
Stack: [0x000070000c496000,0x000070000c596000], sp=0x000070000c5957e0, free space=1021k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [libzip.dylib+0x6362] hashN+0x32
C [libzip.dylib+0x5d5e] readCEN+0xd2e
C [libzip.dylib+0x4ee0] ZIP_Put_In_Cache0+0x160
V [libjvm.dylib+0x544b1e] ClassLoader::open_zip_file(char const*, char**, JavaThread*)+0x3e
V [libjvm.dylib+0x543fec] ClassLoader::create_class_path_entry(JavaThread*, char const*, stat const*, bool, bool)+0x6c
V [libjvm.dylib+0x543833] ClassLoader::setup_bootstrap_search_path_impl(JavaThread*, char const*)+0xf3
V [libjvm.dylib+0x54819b] classLoader_init1()+0x1b
V [libjvm.dylib+0x92602a] init_globals()+0x3a
V [libjvm.dylib+0x12b3b74] Threads::create_vm(JavaVMInitArgs*, bool*)+0x314
V [libjvm.dylib+0xa848f4] JNI_CreateJavaVM+0x64
C [libjli.dylib+0x4483] JavaMain+0x123
C [libjli.dylib+0x7529] ThreadJavaMain+0x9
C [libsystem_pthread.dylib+0x68fc] _pthread_start+0xe0
C [libsystem_pthread.dylib+0x2443] thread_start+0xf
- backported by
-
JDK-8332193 avoid signed integer overflows in zip_util.c readCen / hashN
- Resolved
-
JDK-8332295 avoid signed integer overflows in zip_util.c readCen / hashN
- Resolved
-
JDK-8334480 avoid signed integer overflows in zip_util.c readCen / hashN
- Resolved
- links to
-
Commit openjdk/jdk17u-dev/8751acea
-
Commit openjdk/jdk21u-dev/9b8f9887
-
Commit openjdk/jdk22u/5550682a
-
Commit openjdk/jdk/5af6b45e
-
Review openjdk/jdk17u-dev/2591
-
Review openjdk/jdk21u-dev/555
-
Review openjdk/jdk22u/186
-
Review openjdk/jdk/18908