Re: RFR: 8283059: Uninitialized warning in check_code.c with GCC 11.2 [v2]
On Fri, 18 Mar 2022 02:39:23 GMT, Mikael Vidstedt wrote: >> Note: this PR replaces the one I messed up earlier. >> >> Background, from JBS: >> >> src/java.base/share/native/libverify/check_code.c: In function >> 'read_all_code': >> src/java.base/share/native/libverify/check_code.c:942:5: error: 'lengths' >> may be used uninitialized [-Werror=maybe-uninitialized] >> 942 | check_and_push(context, lengths, VM_MALLOC_BLK); >> | ^~~ >> src/java.base/share/native/libverify/check_code.c:4145:13: note: by argument >> 2 of type 'const void *' to 'check_and_push' declared here >> 4145 | static void check_and_push(context_type *context, const void *ptr, >> int kind) >> | ^~ >> >> Because the second argument of check_and_push is "const void*" GCC assumes >> that the malloc:ed data, which has not yet been initialized, will not be/can >> not be modified later which in turn suggests it may be used without ever >> being initialized. >> >> The same general issue was addressed in JDK-8266168, presumably for GCC 11.1. >> >> Details: >> >> Instead of sprinkling more calloc calls around or using pragmas/gcc >> attributes I chose to change the check_and_push function to take a >> (non-const) void* argument, and provide a new wrapper function >> check_and_push_const which handles the const argument case. For the >> (non-const) VM_MALLOC_BKP that means the pointer never needs to go through a >> const conversion. >> >> To avoid having multiple ways of solving the same problem I also chose to >> revert the change made in JDK-8266168, reverting the calloc back to a malloc >> call. >> >> Testing: >> >> tier1 + builds-tier{2,3,4,5} > > Mikael Vidstedt has updated the pull request incrementally with one > additional commit since the last revision: > > Use const char for check_and_push_string_utf Looks good! - Marked as reviewed by dholmes (Reviewer). PR: https://git.openjdk.java.net/jdk/pull/7859
Re: RFR: 8283059: Uninitialized warning in check_code.c with GCC 11.2 [v2]
On Fri, 18 Mar 2022 02:10:32 GMT, David Holmes wrote: >> Mikael Vidstedt has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Use const char for check_and_push_string_utf > > src/java.base/share/native/libverify/check_code.c line 472: > >> 470: >> 471: static void check_and_push_malloc_block(context_type *context, void >> *ptr); >> 472: static void check_and_push_string_utf(context_type *context, const void >> *ptr); > > Can't this be: > > `static void check_and_push_string_utf(context_type *context, const char* > str);` Indeed it can. Fixed. - PR: https://git.openjdk.java.net/jdk/pull/7859
Re: RFR: 8283059: Uninitialized warning in check_code.c with GCC 11.2 [v2]
> Note: this PR replaces the one I messed up earlier. > > Background, from JBS: > > src/java.base/share/native/libverify/check_code.c: In function > 'read_all_code': > src/java.base/share/native/libverify/check_code.c:942:5: error: 'lengths' may > be used uninitialized [-Werror=maybe-uninitialized] > 942 | check_and_push(context, lengths, VM_MALLOC_BLK); > | ^~~ > src/java.base/share/native/libverify/check_code.c:4145:13: note: by argument > 2 of type 'const void *' to 'check_and_push' declared here > 4145 | static void check_and_push(context_type *context, const void *ptr, int > kind) > | ^~ > > Because the second argument of check_and_push is "const void*" GCC assumes > that the malloc:ed data, which has not yet been initialized, will not be/can > not be modified later which in turn suggests it may be used without ever > being initialized. > > The same general issue was addressed in JDK-8266168, presumably for GCC 11.1. > > Details: > > Instead of sprinkling more calloc calls around or using pragmas/gcc > attributes I chose to change the check_and_push function to take a > (non-const) void* argument, and provide a new wrapper function > check_and_push_const which handles the const argument case. For the > (non-const) VM_MALLOC_BKP that means the pointer never needs to go through a > const conversion. > > To avoid having multiple ways of solving the same problem I also chose to > revert the change made in JDK-8266168, reverting the calloc back to a malloc > call. > > Testing: > > tier1 + builds-tier{2,3,4,5} Mikael Vidstedt has updated the pull request incrementally with one additional commit since the last revision: Use const char for check_and_push_string_utf - Changes: - all: https://git.openjdk.java.net/jdk/pull/7859/files - new: https://git.openjdk.java.net/jdk/pull/7859/files/c5c60cb2..9f412d0b Webrevs: - full: https://webrevs.openjdk.java.net/?repo=jdk=7859=01 - incr: https://webrevs.openjdk.java.net/?repo=jdk=7859=00-01 Stats: 3 lines in 1 file changed: 0 ins; 0 del; 3 mod Patch: https://git.openjdk.java.net/jdk/pull/7859.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/7859/head:pull/7859 PR: https://git.openjdk.java.net/jdk/pull/7859
Re: RFR: 8283059: Uninitialized warning in check_code.c with GCC 11.2 [v2]
On Thu, 17 Mar 2022 20:36:31 GMT, Mikael Vidstedt wrote: >> Background, from JBS: >> >> src/java.base/share/native/libverify/check_code.c: In function >> 'read_all_code': >> src/java.base/share/native/libverify/check_code.c:942:5: error: 'lengths' >> may be used uninitialized [-Werror=maybe-uninitialized] >> 942 | check_and_push(context, lengths, VM_MALLOC_BLK); >> | ^~~ >> src/java.base/share/native/libverify/check_code.c:4145:13: note: by argument >> 2 of type 'const void *' to 'check_and_push' declared here >> 4145 | static void check_and_push(context_type *context, const void *ptr, >> int kind) >> | ^~ >> >> >> Because the second argument of check_and_push is "const void*" GCC assumes >> that the malloc:ed data, which has not yet been initialized, will not be/can >> not be modified later which in turn suggests it may be used without ever >> being initialized. >> >> The same general issue was addressed in >> [JDK-8266168](https://bugs.openjdk.java.net/browse/JDK-8266168), presumably >> for GCC 11.1. >> >> >> Details: >> >> Instead of sprinkling more calloc calls around or using pragmas/gcc >> attributes I chose to change the check_and_push function to take a >> (non-const) void* argument, and provide a new wrapper function >> `check_and_push_const` which handles the const argument case. For the >> (non-const) VM_MALLOC_BKP that means the pointer never needs to go through a >> const conversion. >> >> To avoid having multiple ways of solving the same problem I also chose to >> revert the change made in JDK-8266168, reverting the calloc back to a malloc >> call. >> >> Testing: >> >> tier1 + builds-tier{2,3,4,5} > > Mikael Vidstedt has updated the pull request incrementally with 50 additional > commits since the last revision: > > - Spell out check_and_push_malloc_block > - Fix code > - 8282773: Refactor parsing of integer VM options > >Reviewed-by: dholmes, kbarrett > - 8283274: Improve @jvms usage in java.base > >Reviewed-by: iris > - 8283188: Build time regression caused by JDK-8278917 > >Reviewed-by: kbarrett, tschatzl > - 8283320: Error message for Windows libraries always points to > --with-msvcr-dll no matter the actual file name > >Reviewed-by: erikj, ihse > - 8283056: show abstract machine code in hs-err for all VM crashes > >Reviewed-by: thartmann, dholmes > - 8282727: Parallel: Remove PSPromotionManager::_totally_drain > >Reviewed-by: tschatzl, kbarrett > - 8281146: Replace StringCoding.hasNegatives with countPositives > >Co-authored-by: Lutz Schmidt >Co-authored-by: Martin Doerr >Reviewed-by: kvn, lucy, rriggs > - 8282602: Refactor awt classes javadoc to use @throws instead of @exception > >Reviewed-by: aivanov, prr > - ... and 40 more: > https://git.openjdk.java.net/jdk/compare/baf72097...eb04d78a Um.. I think I managed to mess up this PR when I brought in latest master *and* tried it both with the current and new version of gcc. Sorry about that. I'll withdraw this one and open a new PR - PR: https://git.openjdk.java.net/jdk/pull/7794
Re: RFR: 8283059: Uninitialized warning in check_code.c with GCC 11.2 [v2]
> Background, from JBS: > > src/java.base/share/native/libverify/check_code.c: In function > 'read_all_code': > src/java.base/share/native/libverify/check_code.c:942:5: error: 'lengths' may > be used uninitialized [-Werror=maybe-uninitialized] > 942 | check_and_push(context, lengths, VM_MALLOC_BLK); > | ^~~ > src/java.base/share/native/libverify/check_code.c:4145:13: note: by argument > 2 of type 'const void *' to 'check_and_push' declared here > 4145 | static void check_and_push(context_type *context, const void *ptr, > int kind) > | ^~ > > > Because the second argument of check_and_push is "const void*" GCC assumes > that the malloc:ed data, which has not yet been initialized, will not be/can > not be modified later which in turn suggests it may be used without ever > being initialized. > > The same general issue was addressed in > [JDK-8266168](https://bugs.openjdk.java.net/browse/JDK-8266168), presumably > for GCC 11.1. > > > Details: > > Instead of sprinkling more calloc calls around or using pragmas/gcc > attributes I chose to change the check_and_push function to take a > (non-const) void* argument, and provide a new wrapper function > `check_and_push_const` which handles the const argument case. For the > (non-const) VM_MALLOC_BKP that means the pointer never needs to go through a > const conversion. > > To avoid having multiple ways of solving the same problem I also chose to > revert the change made in JDK-8266168, reverting the calloc back to a malloc > call. > > Testing: > > tier1 + builds-tier{2,3,4,5} Mikael Vidstedt has updated the pull request incrementally with 50 additional commits since the last revision: - Spell out check_and_push_malloc_block - Fix code - 8282773: Refactor parsing of integer VM options Reviewed-by: dholmes, kbarrett - 8283274: Improve @jvms usage in java.base Reviewed-by: iris - 8283188: Build time regression caused by JDK-8278917 Reviewed-by: kbarrett, tschatzl - 8283320: Error message for Windows libraries always points to --with-msvcr-dll no matter the actual file name Reviewed-by: erikj, ihse - 8283056: show abstract machine code in hs-err for all VM crashes Reviewed-by: thartmann, dholmes - 8282727: Parallel: Remove PSPromotionManager::_totally_drain Reviewed-by: tschatzl, kbarrett - 8281146: Replace StringCoding.hasNegatives with countPositives Co-authored-by: Lutz Schmidt Co-authored-by: Martin Doerr Reviewed-by: kvn, lucy, rriggs - 8282602: Refactor awt classes javadoc to use @throws instead of @exception Reviewed-by: aivanov, prr - ... and 40 more: https://git.openjdk.java.net/jdk/compare/baf72097...eb04d78a - Changes: - all: https://git.openjdk.java.net/jdk/pull/7794/files - new: https://git.openjdk.java.net/jdk/pull/7794/files/baf72097..eb04d78a Webrevs: - full: https://webrevs.openjdk.java.net/?repo=jdk=7794=01 - incr: https://webrevs.openjdk.java.net/?repo=jdk=7794=00-01 Stats: 5146 lines in 353 files changed: 2567 ins; 553 del; 2026 mod Patch: https://git.openjdk.java.net/jdk/pull/7794.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/7794/head:pull/7794 PR: https://git.openjdk.java.net/jdk/pull/7794