RFR: 8308975: Fix signed integer overflow in compiler code, part 2

Dean Long dlong at openjdk.org
Tue May 30 17:26:00 UTC 2023


On Tue, 30 May 2023 11:54:31 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> This is a followup from part 1.  I had to use java_add/subtract/multiply/negate in a few more places.
>> cpu_loads_process had an overflow on BSD when the first snapshot is relative to the epoch in 1970.
>> Use unsigned for C2 Type hash functions.
>
> src/hotspot/os/bsd/os_perf_bsd.cpp line 173:
> 
>> 171:     result = OS_ERR;
>> 172:   } else {
>> 173:     long delta_nanos = active_processor_count * (total_cpu_nanos - _total_cpu_nanos);
> 
> We shouldn't use 'long' in the source code even though long is always 64 bits on bsd and this is specific to that, we often scan for this as a potential error since it's 32 bits on Windows.  int64_t is preferable.  Can you use that?

Sure, I'll use uint64_t for the nanos, but I don't want to clean up this whole file in this PR.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14188#discussion_r1210591426


More information about the hotspot-dev mailing list