Bug 43358 - Fix warning in JavaScriptCore/wtf/ByteArray.h
Summary: Fix warning in JavaScriptCore/wtf/ByteArray.h
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P3 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: 43191
  Show dependency treegraph
 
Reported: 2010-08-02 09:25 PDT by Csaba Osztrogonác
Modified: 2010-08-26 02:40 PDT (History)
5 users (show)

See Also:


Attachments
Fix the array subscript is above array bounds warning in ByteArray on ARM (2.21 KB, patch)
2010-08-10 09:41 PDT, Gabor Loki
no flags Details | Formatted Diff | Diff
Fix the array subscript is above array bounds warning in ByteArray on ARM. (1.76 KB, patch)
2010-08-11 00:21 PDT, Gabor Loki
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Csaba Osztrogonác 2010-08-02 09:25:28 PDT
../../../JavaScriptCore/wtf/ByteArray.h:66: warning: array subscript is above array bounds

unsigned char get(unsigned index) const
{
    ASSERT(index < m_size);
    return m_data[index];  < -- line 66
}
Comment 1 Gabor Loki 2010-08-10 09:41:44 PDT
Created attachment 64018 [details]
Fix the array subscript is above array bounds warning in ByteArray on ARM

The proposed patch replaces the m_data array to a zero-sized one, in order to skip the 'array subscript is above array bounds' warning check. I think the reason of this warning should be very similar to this GCC's bug: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37861

This fix works fine with GCC. I hope the other build-bots will be happy as well ;)
Comment 2 Geoffrey Garen 2010-08-10 10:51:48 PDT
Comment on attachment 64018 [details]
Fix the array subscript is above array bounds warning in ByteArray on ARM

r=me
Comment 3 WebKit Review Bot 2010-08-10 11:09:50 PDT
Attachment 64018 [details] did not build on win:
Build output: http://queues.webkit.org/results/3734035
Comment 4 Gabor Loki 2010-08-10 11:32:27 PDT
> Build output: http://queues.webkit.org/results/3734035

Well, not much to say about it. :D
Tomorrow I will get someone to test this patch on Win as well.
Comment 5 Csaba Osztrogonác 2010-08-10 13:18:49 PDT
Comment on attachment 64018 [details]
Fix the array subscript is above array bounds warning in ByteArray on ARM

cq- -ed not to break windows build

----  Comment #3 From  WebKit Review Bot   2010-08-10 11:09:50 PST   (-) [reply] -------
Attachment 64018 [details] did not build on win:
Build output: http://queues.webkit.org/results/3734035
Comment 6 Gabor Loki 2010-08-10 23:19:58 PDT
Comment on attachment 64018 [details]
Fix the array subscript is above array bounds warning in ByteArray on ARM

Unfortunately, the vc++ complains about the zero-sized array: http://msdn.microsoft.com/en-us/library/79wf64bc.aspx
Comment 7 Gabor Loki 2010-08-11 00:21:06 PDT
Created attachment 64081 [details]
Fix the array subscript is above array bounds warning in ByteArray on ARM.

This patch uses the offsetof method to compute the static size of the structure for creation.

It looks like if the creation of an array is in the same context where the usage of the same array is unrolled, the GCC will shoot this false positive warning. I would like to create a small example which demonstrates this warning for the GCC community.
Comment 8 Csaba Osztrogonác 2010-08-11 02:37:15 PDT
(In reply to comment #7)
> Created an attachment (id=64081) [details]
> Fix the array subscript is above array bounds warning in ByteArray on ARM.

It isn't an ARM related warning, but a general GCC related warning,
we can find it on all our bots. (x86-linux, x86-windows too)
Comment 9 Gabor Loki 2010-08-11 02:51:03 PDT
Comment on attachment 64081 [details]
Fix the array subscript is above array bounds warning in ByteArray on ARM.

> It isn't an ARM related warning, but a general GCC related warning,
> we can find it on all our bots. (x86-linux, x86-windows too)

Okay, I will remove the ARM keyword before landing (cq- is set).
Comment 10 Geoffrey Garen 2010-08-12 11:03:46 PDT
Comment on attachment 64081 [details]
Fix the array subscript is above array bounds warning in ByteArray on ARM.

r=me
Comment 11 WebKit Commit Bot 2010-08-12 11:23:00 PDT
Comment on attachment 64081 [details]
Fix the array subscript is above array bounds warning in ByteArray on ARM.

Clearing flags on attachment: 64081

Committed r65260: <http://trac.webkit.org/changeset/65260>
Comment 12 WebKit Commit Bot 2010-08-12 11:23:05 PDT
All reviewed patches have been landed.  Closing bug.
Comment 13 Csaba Osztrogonác 2010-08-12 11:49:49 PDT
It still fails on Qt Linux Release bot:

../../../JavaScriptCore/wtf/ByteArray.h: In member function ‘bool WebCore::FELighting::drawLighting(WebCore::CanvasPixelArray*, int, int)’:
../../../JavaScriptCore/wtf/ByteArray.h:66: warning: array subscript is above array bounds

Gabor, could you check it tomorrow?
Comment 14 Csaba Osztrogonác 2010-08-26 02:40:32 PDT
(In reply to comment #13)
> It still fails on Qt Linux Release bot:
> 
> ../../../JavaScriptCore/wtf/ByteArray.h: In member function ‘bool WebCore::FELighting::drawLighting(WebCore::CanvasPixelArray*, int, int)’:
> ../../../JavaScriptCore/wtf/ByteArray.h:66: warning: array subscript is above array bounds
> 
> Gabor, could you check it tomorrow?

Filed a new bug for it: https://bugs.webkit.org/show_bug.cgi?id=44672