On Fri, 10 Apr 2026 04:04:01 GMT, SendaoYan <[email protected]> wrote:
> Hi all, > > Function handleMessage in file > src/jdk.sctp/unix/native/libsctp/SctpChannelImpl.c declare 'struct > controlData cdata[1]' but do not initiali the struct variable. After the > declation, the cdata will write the related data through funciton call > 'getControlData(msg, cdata)', and the data will be readed through > '(*env)->NewObject'. During 'getControlData(msg, cdata)' call the cdate maybe > unchange and then return. > > In C/C++, read the variable which has not been uninitializaed is undefined > behavior. I think it's better to initial the cdata, this will avoid the > compiler use too aggressive optimilization. > > Before this PR, com/sun/nio/sctp/SctpChannel/ReceiveIntoDirect.java crash 'C > [libsctp.so+0x3b3e] handleMessage+0x4e' with clang23/llvm23 release build . > After this PR test run passed. > > --------- > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai). This pull request has now been integrated. Changeset: 66ae5508 Author: SendaoYan <[email protected]> URL: https://git.openjdk.org/jdk/commit/66ae5508998aeacde2848dcf934539f6b0fd72d6 Stats: 2 lines in 1 file changed: 0 ins; 0 del; 2 mod 8381851: handleMessage use uninitialized struct Reviewed-by: jpai ------------- PR: https://git.openjdk.org/jdk/pull/30664
