Last Comment Bug 760347 - nsDeviceSensor.cpp ASSERTs in debug builds for light sensors
: nsDeviceSensor.cpp ASSERTs in debug builds for light sensors
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: DOM: Device Interfaces (show other bugs)
: unspecified
: ARM Gonk (Firefox OS)
: -- normal (vote)
: mozilla16
Assigned To: Dave Hylands [:dhylands]
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-05-31 20:19 PDT by Dave Hylands [:dhylands]
Modified: 2012-06-06 08:26 PDT (History)
3 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
One way of resolving the problem. (1.11 KB, patch)
2012-05-31 20:36 PDT, Dave Hylands [:dhylands]
no flags Details | Diff | Splinter Review
Proposed patch for bug 760347 v2 (1.10 KB, patch)
2012-05-31 21:01 PDT, Dave Hylands [:dhylands]
doug.turner: review+
Details | Diff | Splinter Review

Description Dave Hylands [:dhylands] 2012-05-31 20:19:11 PDT
I'm hitting the following assert in B2G on debug builds:
Assertion failure: i < Length() (invalid array index), at ../../dist/include/nsTArray.h:535

This appears to be occuring with light sensors which only have a single value. The nsDeviceSensors::Notify function blindly pulls 3 values which causes the assert.
Comment 1 Dave Hylands [:dhylands] 2012-05-31 20:36:55 PDT
Created attachment 629033 [details] [diff] [review]
One way of resolving the problem.
Comment 2 Chris Jones [:cjones] inactive; ni?/f?/r? if you need me 2012-05-31 20:43:42 PDT
I would do

 const InfallibleTArray<float>& values = aSensorData.values();
 size_t len = values.Length();
 double x = len > 0 ? values[0] : 0.0;
 double y = len > 1 ? values[1] : 0.0;
 //...
Comment 3 Dave Hylands [:dhylands] 2012-05-31 21:01:50 PDT
Created attachment 629041 [details] [diff] [review]
Proposed patch for bug 760347 v2

Bah. Humbug.

OK - I like the looks of your version better.
Comment 5 Ed Morley [:emorley] 2012-06-06 08:26:52 PDT
https://hg.mozilla.org/mozilla-central/rev/3524b3fe9492

Note You need to log in before you can comment on or make changes to this bug.