After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 729067 - goom filter: left shift of 24 places cannot be represented in type 'int'
goom filter: left shift of 24 places cannot be represented in type 'int'
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other All
: Normal minor
: 1.3.1
Assigned To: Luis de Bethencourt
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-04-27 18:02 UTC by Luis de Bethencourt
Modified: 2014-05-01 20:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fix (961 bytes, patch)
2014-04-27 18:07 UTC, Luis de Bethencourt
committed Details | Review
change precalCoef[][] to uint. (4.53 KB, patch)
2014-04-27 22:08 UTC, Luis de Bethencourt
none Details | Review

Description Luis de Bethencourt 2014-04-27 18:02:24 UTC
In gst/goom/filters.c there is a left shift of 24 places to an integer. This can cause a problem for values over 128.

For example:
runtime error: left shift of 134 by 24 places cannot be represented in type 'int'.
Comment 1 Luis de Bethencourt 2014-04-27 18:07:00 UTC
Created attachment 275272 [details] [review]
fix
Comment 2 Tim-Philipp Müller 2014-04-27 18:40:58 UTC
Looks fine I guess, but you're fixing a compiler warning, so don't talk about run-time errors in the commit message unless you have actually seen any errors caused by this in the output :) (And then the result is put into an int array and ints are used everywhere else as well..)
Comment 3 Luis de Bethencourt 2014-04-27 22:02:39 UTC
I saw the pasted error when I run `make check` after building with -fsanitize=undefined. I can remove the reference to a run-time error in the commit message if you like though. Does testing input count?
Comment 4 Luis de Bethencourt 2014-04-27 22:08:14 UTC
Created attachment 275282 [details] [review]
change precalCoef[][] to uint.

The result of the first patch was put into an int array, so it was merely protecting for sign flipping due to an overflow.

This patch changes the array to allocate unsigned integers. The change is a bit more intrusive, but would behave better with an overflow.

Let me know which one you prefer better.

Thanks for the review! :)
Comment 5 Tim-Philipp Müller 2014-04-27 22:16:58 UTC
The runtime error bit is still confusing, since it's caused by the special '-fsanitize' option which you don't mention there. IMHO just say that you're fixing undefined behaviour, like "don't left-shift into the sign bit, the result is undefined" or somesuch.

I would stick to the minimal patch required to fix this, unless you actually understand how the code affected by your changes works, or you're sure it doesn't have undesired side-effects (or it generates further warnings).
Comment 6 Luis de Bethencourt 2014-04-27 22:21:10 UTC
Sure!

Will change the message of the first commit and push.

I have read the affected code thoroughly and tested my changes, but I am not going to pretend I have a deep understanding of everything related.

Half of the comments are in French! :P
Also there is a big function that is just commented out. Should it remain there?

I offer to translate and remove that function, if you would like me to. I know it falls into "style" changes, which is why I ask before submitting something to bugzilla.
Comment 7 Luis de Bethencourt 2014-04-29 14:18:02 UTC
Tim.

Thanks for fixing this s/uint/Uint :)