[Home]

Summary:ASTERISK-27580: [patch] lpc10: Array may be uninitialized.
Reporter:Alexander Traud (traud)Labels:patch
Date Opened:2018-01-12 07:14:53.000-0600Date Closed:
Priority:MinorRegression?
Status:Open/NewComponents:Codecs/codec_lpc10
Versions:16.10.0 17.4.0 Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) lpc10_array_init.patch
Description:{{./configure && make}} and Ubuntu 14.04 LTS (GCC 4.8.2), Ubuntu 16.04 LTS (GCC 5.4.0), Ubuntu 18.04 LTS (GCC 7.5.0) report:{code}irc2pc.c:145:12: warning: 'temp[9]' may be used uninitialized in this function [-Wmaybe-uninitialized]
     pc[j] = temp[j - 1];
     ~~~~~~^~~~~~~~~~~~~
irc2pc.c:145:12: warning: 'temp[8]' may be used uninitialized in this function [-Wmaybe-uninitialized]
irc2pc.c:145:12: warning: 'temp[7]' may be used uninitialized in this function [-Wmaybe-uninitialized]{code}This does not happen, when optimization is level 2 or lower, like off. This does not happen in the alternative compiler _clang_. It is just GCC with (Asterisk’s default of) -O3 or -Ofast.
Comments:By: Kevin Harwell (kharwell) 2018-01-12 10:17:55.772-0600

[~traud], I'm assuming you'll push this patch up to gerrit, so assigning to you for now. If that turns out to not be correct just un-assign yourself.

By: Alexander Traud (traud) 2018-01-12 13:27:47.444-0600

I am not happy with the patch. Perhaps one day, I find the time to investigate what GCC is doing exactly. Especially because that happens only at -O3 and higher. -O2 and lower, everything is fine. However, I wonder why nobody reported that before. This seems to be an issue since GCC 4.8.

By: Alexander Traud (traud) 2020-05-28 08:13:03.077-0500

Not sure what to do with this.

GCC 9, the default compiler in Ubuntu 20.04 LTS does not exhibit this anymore. GCC 8 does not exhibit this either. Furthermore, I was not able to determine which optimization is triggering this exactly. In Ubuntu 18.04 LTS with its default compiler GCC 7, I went for {{./configure --enable-dev-mode=noisy}}, copied the GCC invocation, and tried that with {{-O2}} plus the [additional flags|https://github.com/gcc-mirror/gcc/blob/releases/gcc-7/gcc/opts.c#L527] from {{-O3}}. Then, I am not facing that warning. Only if I go for {{-O3}}, I get that warning. Go figure! Additionally, to be honest, I do not see the code path which might give an uninitialized state. The next step would be to live-debugging GCC itself. However, all still supported GCC releases do not emit this warning anymore = GCC 7 is not an supported release already.

Therefore, I am not sure what do with this. Ubuntu 18.04 LTS is still going to be around for three years. Finally, the Asterisk Developer Mode activates {{-Werror}} normally. However, [not with|https://github.com/asterisk/asterisk/commit/8d6d166b14b5c3cb569670a8501cfb808ab19b57#diff-da3571cce673e671b995201bd3e6700b] the codec module LPC10. Consequently, is this printed warning just cosmetic?