RFR: 8298006: Build failure by maybe-uninitialized error on Linux s390x GCC8
Ichiroh Takiguchi
itakiguchi at openjdk.org
Wed Dec 7 05:26:09 UTC 2022
On Tue, 6 Dec 2022 18:24:17 GMT, Phil Race <prr at openjdk.org> wrote:
>>> src/java.desktop/share/native/libawt/awt/medialib/awt_ImagingLib.c: In function 'allocateRasterArray':
>>> src/java.desktop/share/native/libawt/awt/medialib/awt_ImagingLib.c:2944:73: error: 'roff[3]' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>>> (((*inP&rasterP->sppsm.maskArray[c]) >> roff[c])
>>
>> That's weird. allocateRasterArray is at lines 2360-2575 .. so why are you seeing it at line 2944 ????
>
>> Thanks @prrace .
>>
>> > That's weird. allocateRasterArray is at lines 2360-2575 .. so why are you seeing it at line 2944 ????
>>
>> Ummm, I could not determine the reason...
>>
>> I assume AddressSanitizer detected memory errors because of following 2 codes:
>>
>> https://github.com/openjdk/jdk/blob/1e468320dc6e495343dbdf392cbcbda79672c7ad/src/java.desktop/share/native/libawt/awt/medialib/awt_ImagingLib.c#L2937
>>
>>
>> https://github.com/openjdk/jdk/blob/1e468320dc6e495343dbdf392cbcbda79672c7ad/src/java.desktop/share/native/libawt/awt/medialib/awt_ImagingLib.c#L3118
>>
>> So I'd like to put `memset()` on these parts.
>>
>> But I checked `if` and `else` blocks on above part. These are exactly the same.
>>
>> https://github.com/openjdk/jdk/blob/1e468320dc6e495343dbdf392cbcbda79672c7ad/src/java.desktop/share/native/libawt/awt/medialib/awt_ImagingLib.c#L2937-L2965
>>
>>
>> https://github.com/openjdk/jdk/blob/1e468320dc6e495343dbdf392cbcbda79672c7ad/src/java.desktop/share/native/libawt/awt/medialib/awt_ImagingLib.c#L3118-L3153
>>
>> I tried to modify from `if .. else` block to flat. AddressSanitizer did not detect memory error.
>>
>> Could you give me any advice ?
>
> Oh you are running a tool to find these issues ? I thought it was supposed to be a build failure ?
> Or are you running the tool to try to understand the build failure.
> Tools are not always right in my experience.
> I think there's just as much chance as both being false positives as both being correct.
> I think at some point the tools arm-wave that this could be a problem but it is not provable.
> As Magnus pointed out "newer" compilers aren't complaining here.
>
> I don't know what kind of advice you are seeking. If you are asking me to somehow do better than the tools .. well I'd say its a whole lot easier to just memset these to zero. Zero may not be the correct offset either .. but it should be safer.
Hello @prrace .
I applied minimum changes which is reported by SLES12's GCC8.
-------------
PR: https://git.openjdk.org/jdk/pull/11475
More information about the client-libs-dev
mailing list