Re: [FFmpeg-devel] GCC 5.1 warning: -Warray-bounds

2015-10-11 Thread Ganesh Ajjanagadde
On Wed, Jul 22, 2015 at 10:56 PM, Ganesh Ajjanagadde  wrote:
> On Tue, Jul 21, 2015 at 10:46 PM, James Almer  wrote:
>> On 21/07/15 11:43 PM, Ganesh Ajjanagadde wrote:
>>> or try to work upstream with GCC to remove these spurious warnings.
>>
>> If it can be fixed upstream then that's certainly the best option.
>> For all we know new code we add in the future may trigger this bug
>> again.
>
> I have filed a new bugreport for the issue in libavcodec/dca_xll.c:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66974

Ticket above looks dead, and given their high bug volume, I doubt any
one will be investigating it soon. Since there are only 2 instances
remaining, both silencable with one line changes, I will submit
patches for them unless someone objects.

>
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] GCC 5.1 warning: -Warray-bounds

2015-07-22 Thread Ganesh Ajjanagadde
On Tue, Jul 21, 2015 at 10:46 PM, James Almer jamr...@gmail.com wrote:
 On 21/07/15 11:43 PM, Ganesh Ajjanagadde wrote:
 or try to work upstream with GCC to remove these spurious warnings.

 If it can be fixed upstream then that's certainly the best option.
 For all we know new code we add in the future may trigger this bug
 again.

I have filed a new bugreport for the issue in libavcodec/dca_xll.c:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66974

 ___
 ffmpeg-devel mailing list
 ffmpeg-devel@ffmpeg.org
 http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] GCC 5.1 warning: -Warray-bounds

2015-07-21 Thread Ronald S. Bultje
Hi,

On Tue, Jul 21, 2015 at 10:07 PM, Ganesh Ajjanagadde gajja...@mit.edu
wrote:

 On Tue, Jul 21, 2015 at 5:31 PM, Ganesh Ajjanagadde gajja...@mit.edu
 wrote:
  On Tue, Jul 21, 2015 at 5:14 PM, Michael Niedermayer
  mich...@niedermayer.cc wrote:
  On Thu, Jun 25, 2015 at 01:25:08AM -0300, James Almer wrote:
  On 04/06/15 6:55 PM, Ganesh Ajjanagadde wrote:
   I have created a small test case which gets at the heart of one of
   these spurious
   warnings, namely the one for libavfilter/vf_swapuv.c.
  
   Here is the ticket on the GCC Bugzilla:
  
   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66422
  
   Note that as of the moment, -Warray-bounds appears quite broken on
 GCC
   (especially on -O3), and the bugzilla is full of bug reports on this.
 
  For the record, these bogus warnings have been fixed on the gcc 5
 branch.
 
  do any warnings remain for ffmpeg ?
  are they real issues or false positives as well ?
 
  Most are gone, only two files trigger these, namely
  libavformat/dvenc.c and libavcodec/dca_x11.c.
  I have attached a logfile from the build and will investigate this to
  see whether they are real or false positives.

 So I checked the above, and it turns out both are false positives.
 However, in neither case was it trivial to see that access patterns
 are well defined,
 and both required analysis across the function boundary.
 Perhaps this is why GCC still struggles with this stuff.
 I will try creating a test case based on this and file a GCC ticket.
 By the way, both false positives can be easily silenced with one line
 changes,
 but of course we should not needlessly bend our code to satisfy the
 whims of GCC.


Well, that depends, right? So, the question is one of benefit vs. effort.
If all warnings are useless and gcc never provided us any new insights we
didn't already have (i.e. identify a real bug), it's probably not worth it.
However, if gcc turned out to help us find real bugs and the changes are
minor and clean, I see no problem silencing the noise a little. I believe
we've done that in the past to make valgrind happier.

Ronald
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] GCC 5.1 warning: -Warray-bounds

2015-07-21 Thread James Almer
On 21/07/15 11:43 PM, Ganesh Ajjanagadde wrote:
 or try to work upstream with GCC to remove these spurious warnings.

If it can be fixed upstream then that's certainly the best option.
For all we know new code we add in the future may trigger this bug
again.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] GCC 5.1 warning: -Warray-bounds

2015-07-21 Thread Ganesh Ajjanagadde
On Tue, Jul 21, 2015 at 5:31 PM, Ganesh Ajjanagadde gajja...@mit.edu wrote:
 On Tue, Jul 21, 2015 at 5:14 PM, Michael Niedermayer
 mich...@niedermayer.cc wrote:
 On Thu, Jun 25, 2015 at 01:25:08AM -0300, James Almer wrote:
 On 04/06/15 6:55 PM, Ganesh Ajjanagadde wrote:
  I have created a small test case which gets at the heart of one of
  these spurious
  warnings, namely the one for libavfilter/vf_swapuv.c.
 
  Here is the ticket on the GCC Bugzilla:
 
  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66422
 
  Note that as of the moment, -Warray-bounds appears quite broken on GCC
  (especially on -O3), and the bugzilla is full of bug reports on this.

 For the record, these bogus warnings have been fixed on the gcc 5 branch.

 do any warnings remain for ffmpeg ?
 are they real issues or false positives as well ?

 Most are gone, only two files trigger these, namely
 libavformat/dvenc.c and libavcodec/dca_x11.c.
 I have attached a logfile from the build and will investigate this to
 see whether they are real or false positives.

So I checked the above, and it turns out both are false positives.
However, in neither case was it trivial to see that access patterns
are well defined,
and both required analysis across the function boundary.
Perhaps this is why GCC still struggles with this stuff.
I will try creating a test case based on this and file a GCC ticket.
By the way, both false positives can be easily silenced with one line changes,
but of course we should not needlessly bend our code to satisfy the
whims of GCC.



 [...]
 --
 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

 I am the wisest man alive, for I know one thing, and that is that I know
 nothing. -- Socrates

 ___
 ffmpeg-devel mailing list
 ffmpeg-devel@ffmpeg.org
 http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] GCC 5.1 warning: -Warray-bounds

2015-07-21 Thread Ganesh Ajjanagadde
On Tue, Jul 21, 2015 at 5:14 PM, Michael Niedermayer
mich...@niedermayer.cc wrote:
 On Thu, Jun 25, 2015 at 01:25:08AM -0300, James Almer wrote:
 On 04/06/15 6:55 PM, Ganesh Ajjanagadde wrote:
  I have created a small test case which gets at the heart of one of
  these spurious
  warnings, namely the one for libavfilter/vf_swapuv.c.
 
  Here is the ticket on the GCC Bugzilla:
 
  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66422
 
  Note that as of the moment, -Warray-bounds appears quite broken on GCC
  (especially on -O3), and the bugzilla is full of bug reports on this.

 For the record, these bogus warnings have been fixed on the gcc 5 branch.

 do any warnings remain for ffmpeg ?
 are they real issues or false positives as well ?

Most are gone, only two files trigger these, namely
libavformat/dvenc.c and libavcodec/dca_x11.c.
I have attached a logfile from the build and will investigate this to
see whether they are real or false positives.


 [...]
 --
 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

 I am the wisest man alive, for I know one thing, and that is that I know
 nothing. -- Socrates

 ___
 ffmpeg-devel mailing list
 ffmpeg-devel@ffmpeg.org
 http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

CC	libavdevice/alldevices.o
CC	libavdevice/alsa.o
CC	libavdevice/alsa_dec.o
CC	libavdevice/alsa_enc.o
CC	libavdevice/fbdev_common.o
CC	libavdevice/avdevice.o
CC	libavdevice/fbdev_dec.o
CC	libavdevice/dv1394.o
CC	libavdevice/fbdev_enc.o
CC	libavdevice/lavfi.o
CC	libavdevice/oss.o
CC	libavdevice/oss_dec.o
CC	libavdevice/pulse_audio_common.o
CC	libavdevice/oss_enc.o
CC	libavdevice/pulse_audio_dec.o
CC	libavdevice/pulse_audio_enc.o
CC	libavdevice/sdl.o
CC	libavdevice/timefilter.o
CC	libavdevice/utils.o
CC	libavdevice/v4l2-common.o
CC	libavdevice/v4l2.o
CC	libavdevice/v4l2enc.o
CC	libavdevice/xcbgrab.o
CC	libavdevice/xv.o
CC	libavfilter/aeval.o
CC	libavfilter/af_adelay.o
CC	libavfilter/af_aecho.o
CC	libavfilter/af_afade.o
CC	libavfilter/af_aformat.o
CC	libavfilter/af_amerge.o
CC	libavfilter/af_amix.o
CC	libavfilter/af_anull.o
CC	libavfilter/af_apad.o
CC	libavfilter/af_aphaser.o
CC	libavfilter/af_aresample.o
CC	libavfilter/af_asetnsamples.o
CC	libavfilter/af_asetrate.o
CC	libavfilter/af_ashowinfo.o
CC	libavfilter/af_astats.o
CC	libavfilter/af_astreamsync.o
CC	libavfilter/af_asyncts.o
CC	libavfilter/af_atempo.o
CC	libavfilter/af_biquads.o
CC	libavfilter/af_channelmap.o
CC	libavfilter/af_channelsplit.o
CC	libavfilter/af_chorus.o
CC	libavfilter/af_compand.o
CC	libavfilter/af_dcshift.o
CC	libavfilter/af_dynaudnorm.o
CC	libavfilter/af_earwax.o
CC	libavfilter/af_flanger.o
CC	libavfilter/af_join.o
CC	libavfilter/af_pan.o
CC	libavfilter/af_replaygain.o
CC	libavfilter/af_resample.o
CC	libavfilter/af_silencedetect.o
CC	libavfilter/af_silenceremove.o
CC	libavfilter/af_volume.o
CC	libavfilter/af_volumedetect.o
CC	libavfilter/allfilters.o
CC	libavfilter/asink_anullsink.o
CC	libavfilter/asrc_anullsrc.o
CC	libavfilter/asrc_sine.o
CC	libavfilter/audio.o
CC	libavfilter/avcodec.o
CC	libavfilter/avf_avectorscope.o
CC	libavfilter/avf_showcqt.o
CC	libavfilter/avf_concat.o
CC	libavfilter/avf_showspectrum.o
CC	libavfilter/avf_showvolume.o
CC	libavfilter/avf_showwaves.o
libavfilter/avcodec.c: In function ‘avfilter_get_video_buffer_ref_from_frame’:
libavfilter/avcodec.c:36:9: warning: ‘avfilter_get_video_buffer_ref_from_arrays’ is deprecated [-Wdeprecated-declarations]
 avfilter_get_video_buffer_ref_from_arrays(frame-data, frame-linesize, perms,
 ^
In file included from libavfilter/avcodec.h:31:0,
 from libavfilter/avcodec.c:26:
libavfilter/avfilter.h:914:1: note: declared here
 avfilter_get_video_buffer_ref_from_arrays(uint8_t * const data[4], const int linesize[4], int perms,
 ^
libavfilter/avcodec.c:41:5: warning: ‘avfilter_copy_frame_props’ is deprecated [-Wdeprecated-declarations]
 if (avfilter_copy_frame_props(picref, frame)  0) {
 ^
In file included from libavfilter/avcodec.h:31:0,
 from libavfilter/avcodec.c:26:
libavfilter/avfilter.h:1117:5: note: declared here
 int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src);
 ^
libavfilter/avcodec.c:43:9: warning: ‘avfilter_unref_bufferp’ is deprecated [-Wdeprecated-declarations]
 avfilter_unref_bufferp(picref);
 ^
In file included from libavfilter/avcodec.h:31:0,
 from libavfilter/avcodec.c:26:
libavfilter/avfilter.h:236:6: note: declared here
 void avfilter_unref_bufferp(AVFilterBufferRef **ref);
  ^
libavfilter/avcodec.c: In function ‘avfilter_get_audio_buffer_ref_from_frame’:
libavfilter/avcodec.c:60:5: warning: ‘avfilter_get_audio_buffer_ref_from_arrays_channels’ is deprecated [-Wdeprecated-declarations]
 samplesref = avfilter_get_audio_buffer_ref_from_arrays_channels(
 ^
In file included from libavfilter/avcodec.h:31:0,
 from libavfilter/avcodec.c:26:

Re: [FFmpeg-devel] GCC 5.1 warning: -Warray-bounds

2015-07-21 Thread Michael Niedermayer
On Thu, Jun 25, 2015 at 01:25:08AM -0300, James Almer wrote:
 On 04/06/15 6:55 PM, Ganesh Ajjanagadde wrote:
  I have created a small test case which gets at the heart of one of
  these spurious
  warnings, namely the one for libavfilter/vf_swapuv.c.
  
  Here is the ticket on the GCC Bugzilla:
  
  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66422
  
  Note that as of the moment, -Warray-bounds appears quite broken on GCC
  (especially on -O3), and the bugzilla is full of bug reports on this.
 
 For the record, these bogus warnings have been fixed on the gcc 5 branch.

do any warnings remain for ffmpeg ?
are they real issues or false positives as well ?

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I am the wisest man alive, for I know one thing, and that is that I know
nothing. -- Socrates


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] GCC 5.1 warning: -Warray-bounds

2015-07-21 Thread Ganesh Ajjanagadde
On Tue, Jul 21, 2015 at 10:28 PM, Ronald S. Bultje rsbul...@gmail.com wrote:
 Hi,

 On Tue, Jul 21, 2015 at 10:07 PM, Ganesh Ajjanagadde gajja...@mit.edu
 wrote:

 On Tue, Jul 21, 2015 at 5:31 PM, Ganesh Ajjanagadde gajja...@mit.edu
 wrote:
  On Tue, Jul 21, 2015 at 5:14 PM, Michael Niedermayer
  mich...@niedermayer.cc wrote:
  On Thu, Jun 25, 2015 at 01:25:08AM -0300, James Almer wrote:
  On 04/06/15 6:55 PM, Ganesh Ajjanagadde wrote:
   I have created a small test case which gets at the heart of one of
   these spurious
   warnings, namely the one for libavfilter/vf_swapuv.c.
  
   Here is the ticket on the GCC Bugzilla:
  
   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66422
  
   Note that as of the moment, -Warray-bounds appears quite broken on
   GCC
   (especially on -O3), and the bugzilla is full of bug reports on
   this.
 
  For the record, these bogus warnings have been fixed on the gcc 5
  branch.
 
  do any warnings remain for ffmpeg ?
  are they real issues or false positives as well ?
 
  Most are gone, only two files trigger these, namely
  libavformat/dvenc.c and libavcodec/dca_x11.c.
  I have attached a logfile from the build and will investigate this to
  see whether they are real or false positives.

 So I checked the above, and it turns out both are false positives.
 However, in neither case was it trivial to see that access patterns
 are well defined,
 and both required analysis across the function boundary.
 Perhaps this is why GCC still struggles with this stuff.
 I will try creating a test case based on this and file a GCC ticket.
 By the way, both false positives can be easily silenced with one line
 changes,
 but of course we should not needlessly bend our code to satisfy the
 whims of GCC.


 Well, that depends, right? So, the question is one of benefit vs. effort. If
 all warnings are useless and gcc never provided us any new insights we
 didn't already have (i.e. identify a real bug), it's probably not worth it.
 However, if gcc turned out to help us find real bugs and the changes are
 minor and clean, I see no problem silencing the noise a little. I believe
 we've done that in the past to make valgrind happier.

That's essentially the issue of -Warray-bounds.
Warray-bounds is a great concept, and to me on first glance should be super
useful to a project like ffmpeg, given the number of loops, array
manipulations/indexing, etc
that are performed.
Moreover, it is very easy to screw up the indexing and make off by one
mistakes, etc
which could lead to segfaults/corruption of buffers, and the like.
Thus, I would have hoped this was more useful to ffmpeg.
It seems like instead it can only catch simple cases,
and in complex situations (like most cases in ffmpeg) it either does
nothing or gives false positives.

On a positive note, as above thread indicates, most spurious stuff has
been silenced,
and in ffmpeg, only two instances remain.
I am happy to provide simple patches to silence these two cases,
or try to work upstream with GCC to remove these spurious warnings.


 Ronald
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] GCC 5.1 warning: -Warray-bounds

2015-06-24 Thread James Almer
On 04/06/15 6:55 PM, Ganesh Ajjanagadde wrote:
 I have created a small test case which gets at the heart of one of
 these spurious
 warnings, namely the one for libavfilter/vf_swapuv.c.
 
 Here is the ticket on the GCC Bugzilla:
 
 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66422
 
 Note that as of the moment, -Warray-bounds appears quite broken on GCC
 (especially on -O3), and the bugzilla is full of bug reports on this.

For the record, these bogus warnings have been fixed on the gcc 5 branch.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] GCC 5.1 warning: -Warray-bounds

2015-06-04 Thread Ganesh Ajjanagadde
I have created a small test case which gets at the heart of one of
these spurious
warnings, namely the one for libavfilter/vf_swapuv.c.

Here is the ticket on the GCC Bugzilla:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66422

Note that as of the moment, -Warray-bounds appears quite broken on GCC
(especially on -O3), and the bugzilla is full of bug reports on this.

On Thu, Jun 4, 2015 at 12:16 PM, James Almer jamr...@gmail.com wrote:
 On 04/06/15 10:08 AM, Ganesh Ajjanagadde wrote:
 On Thu, Jun 4, 2015 at 7:00 AM, Michael Niedermayer michae...@gmx.at wrote:
 On Wed, Jun 03, 2015 at 10:05:54PM -0400, Ganesh Ajjanagadde wrote:
 While compiling ffmpeg, I noticed a bunch of -Warray-bounds warnings.
 I think it would be great if ffmpeg could be built warning-free, and
 -Warray-bounds seems to be one of the biggest culprits. Nevertheless,

 -Warray-bounds is quite useful in most cases.

 how many of the warnings shown are real and how many are false
 positives (in some version not neccessarily the latest of FFmpeg)
 ?

 So I checked out n2.5 release. There are too many warnings to quickly
 audit all of them.
 Nevertheless, I went through about 6 instances (randomly selected),
 and found all of them to be false positives.
 Basically, there is a basic pattern to all of these warnings:
 struct foo {
 int bar[MAX_BAR];
 int num_bar;
 }; // could have other declarations as well

 // in usage
 int set_foo(foo* my_foo) {
 my_foo-num_bar = get_num_bar();
 if (num_bar  MAX_BAR)
 return -1;
 }

 int loop_over(const foo* my_foo) {
 int i;
 for(i = 0; i  foo-num_bar; i++) {
 // do something with foo-bar[i]
 // this triggers the warning: GCC tries to do a constant
 propagation to verify array in bounds, since it knows MAX_BAR, i.e
 foo-bar is an array.
 // However, it can't do deep enough analysis to verify that in
 set_foo, num_bar is sanitized to ensure proper in bounds access.
}
 }

 Could you make a bug report about this on https://gcc.gnu.org/bugzilla/?
 ___
 ffmpeg-devel mailing list
 ffmpeg-devel@ffmpeg.org
 http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] GCC 5.1 warning: -Warray-bounds

2015-06-04 Thread James Almer
On 04/06/15 10:08 AM, Ganesh Ajjanagadde wrote:
 On Thu, Jun 4, 2015 at 7:00 AM, Michael Niedermayer michae...@gmx.at wrote:
 On Wed, Jun 03, 2015 at 10:05:54PM -0400, Ganesh Ajjanagadde wrote:
 While compiling ffmpeg, I noticed a bunch of -Warray-bounds warnings.
 I think it would be great if ffmpeg could be built warning-free, and
 -Warray-bounds seems to be one of the biggest culprits. Nevertheless,

 -Warray-bounds is quite useful in most cases.

 how many of the warnings shown are real and how many are false
 positives (in some version not neccessarily the latest of FFmpeg)
 ?
 
 So I checked out n2.5 release. There are too many warnings to quickly
 audit all of them.
 Nevertheless, I went through about 6 instances (randomly selected),
 and found all of them to be false positives.
 Basically, there is a basic pattern to all of these warnings:
 struct foo {
 int bar[MAX_BAR];
 int num_bar;
 }; // could have other declarations as well
 
 // in usage
 int set_foo(foo* my_foo) {
 my_foo-num_bar = get_num_bar();
 if (num_bar  MAX_BAR)
 return -1;
 }
 
 int loop_over(const foo* my_foo) {
 int i;
 for(i = 0; i  foo-num_bar; i++) {
 // do something with foo-bar[i]
 // this triggers the warning: GCC tries to do a constant
 propagation to verify array in bounds, since it knows MAX_BAR, i.e
 foo-bar is an array.
 // However, it can't do deep enough analysis to verify that in
 set_foo, num_bar is sanitized to ensure proper in bounds access.
}
 }

Could you make a bug report about this on https://gcc.gnu.org/bugzilla/?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] GCC 5.1 warning: -Warray-bounds

2015-06-04 Thread Hendrik Leppkes
On Thu, Jun 4, 2015 at 4:05 AM, Ganesh Ajjanagadde gajja...@mit.edu wrote:
 While compiling ffmpeg, I noticed a bunch of -Warray-bounds warnings.
 I think it would be great if ffmpeg could be built warning-free, and
 -Warray-bounds seems to be one of the biggest culprits. Nevertheless,
 -Warray-bounds is quite useful in most cases.
 I currently see 2 possible improvements:
 1. using av_assert0() to ensure that array access remains in bounds in
 these few cases. This could lead to performance hit.
 2. creating a macro to disable this warning locally in the few places
 to suppress this. This could be done on lines of AV_NOWARN_DEPRECATED
 in libavutil/attributes.h. This is perhaps uglier.

 Which option do the devs here prefer?

3. Fix the compiler to stop false-positives, and don't litter the code
with workarounds.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] GCC 5.1 warning: -Warray-bounds

2015-06-04 Thread Nicolas George
Le quintidi 15 prairial, an CCXXIII, Ganesh Ajjanagadde a écrit :
 1. using av_assert0() to ensure that array access remains in bounds in
 these few cases. This could lead to performance hit.

Using av_assert1() or av_assert2() will yield a performance hit, but only
when enabled in development builds.

But I agree with Hendrik, it should only be done when the correctness of the
code is not obvious for a reasonably smart human reader. If the compiler is
not smart enough to see it, then it only means it is too early to enable
that warning.

Regards,

-- 
  Nicolas George


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] GCC 5.1 warning: -Warray-bounds

2015-06-04 Thread Carl Eugen Hoyos
Ganesh Ajjanagadde gajjanag at mit.edu writes:

 I think it would be great if ffmpeg could be 
 built warning-free

I am sure nobody here is against compiling FFmpeg 
without warnings but I wonder if it is possible 
and if it is worth the effort.

 Which option do the devs here prefer?

Not related to your actual issue:
It has shown more success in the past to send 
actual patches instead of asking for opinions 
beforehand.

I suspect that asserts in not speed-relevant 
code where it is very difficult to understand 
if an array access gets out-of-bound or not 
would be acceptable (but that may only be me).

Carl Eugen

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] GCC 5.1 warning: -Warray-bounds

2015-06-04 Thread Michael Niedermayer
On Wed, Jun 03, 2015 at 10:05:54PM -0400, Ganesh Ajjanagadde wrote:
 While compiling ffmpeg, I noticed a bunch of -Warray-bounds warnings.
 I think it would be great if ffmpeg could be built warning-free, and
 -Warray-bounds seems to be one of the biggest culprits. Nevertheless,

 -Warray-bounds is quite useful in most cases.

how many of the warnings shown are real and how many are false
positives (in some version not neccessarily the latest of FFmpeg)
?


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] GCC 5.1 warning: -Warray-bounds

2015-06-04 Thread Ganesh Ajjanagadde
On Thu, Jun 4, 2015 at 7:00 AM, Michael Niedermayer michae...@gmx.at wrote:
 On Wed, Jun 03, 2015 at 10:05:54PM -0400, Ganesh Ajjanagadde wrote:
 While compiling ffmpeg, I noticed a bunch of -Warray-bounds warnings.
 I think it would be great if ffmpeg could be built warning-free, and
 -Warray-bounds seems to be one of the biggest culprits. Nevertheless,

 -Warray-bounds is quite useful in most cases.

 how many of the warnings shown are real and how many are false
 positives (in some version not neccessarily the latest of FFmpeg)
 ?

So I checked out n2.5 release. There are too many warnings to quickly
audit all of them.
Nevertheless, I went through about 6 instances (randomly selected),
and found all of them to be false positives.
Basically, there is a basic pattern to all of these warnings:
struct foo {
int bar[MAX_BAR];
int num_bar;
}; // could have other declarations as well

// in usage
int set_foo(foo* my_foo) {
my_foo-num_bar = get_num_bar();
if (num_bar  MAX_BAR)
return -1;
}

int loop_over(const foo* my_foo) {
int i;
for(i = 0; i  foo-num_bar; i++) {
// do something with foo-bar[i]
// this triggers the warning: GCC tries to do a constant
propagation to verify array in bounds, since it knows MAX_BAR, i.e
foo-bar is an array.
// However, it can't do deep enough analysis to verify that in
set_foo, num_bar is sanitized to ensure proper in bounds access.
   }
}



 [...]

 --
 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

 He who knows, does not speak. He who speaks, does not know. -- Lao Tsu

 ___
 ffmpeg-devel mailing list
 ffmpeg-devel@ffmpeg.org
 http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] GCC 5.1 warning: -Warray-bounds

2015-06-03 Thread Ganesh Ajjanagadde
While compiling ffmpeg, I noticed a bunch of -Warray-bounds warnings.
I think it would be great if ffmpeg could be built warning-free, and
-Warray-bounds seems to be one of the biggest culprits. Nevertheless,
-Warray-bounds is quite useful in most cases.
I currently see 2 possible improvements:
1. using av_assert0() to ensure that array access remains in bounds in
these few cases. This could lead to performance hit.
2. creating a macro to disable this warning locally in the few places
to suppress this. This could be done on lines of AV_NOWARN_DEPRECATED
in libavutil/attributes.h. This is perhaps uglier.

Which option do the devs here prefer?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel