Closed Bug 1021180 Opened 6 years ago Closed 6 years ago

[NFC] marionette web-api tests which use MozNDEFRecord failing on emulator-jb

Categories

(Firefox OS Graveyard :: NFC, defect)

x86
macOS
defect
Not set

Tracking

(tracking-b2g:backlog)

RESOLVED DUPLICATE of bug 1020034
tracking-b2g backlog

People

(Reporter: tauzen, Assigned: tauzen)

References

Details

Attachments

(5 files)

Attached file tests-failing.logcat
On latest gecko NFC marionette webapi test are failing with the following errors:

TEST-UNEXPECTED-FAIL | test_ndef.js | IOError: Connection to Marionette server is lost. Check gecko.log (desktop firefox) or logcat (b2g) for errors.

Reverting to earlier gecko solves the problem (tested on f297dd29f28bb736dfcfd374dfc62c02ed4f871c). Not sure if it's not a general problem .
Attached file marionette log
Attached file qemu.log
Summary: All NFC marionette test failing on latest gecko → All NFC marionette test failing on emulator-jb with latest gecko
From marionette.log, I saw some errors from BT

06-05 18:31:53.875 I/GeckoBluetooth(  547): EnsureBluetoothHalLoad: Error: Unknown error -2
06-05 18:31:53.875 I/GeckoBluetooth(  547): BluetoothServiceBluedroid: Error! Failed to load bluedroid library.

Hi Shawn, is this error message normal on Jelly-Bean Emulator?
Flags: needinfo?(shuang)
(In reply to Yoshi Huang[:allstars.chh] from comment #3)
> From marionette.log, I saw some errors from BT
> 
> 06-05 18:31:53.875 I/GeckoBluetooth(  547): EnsureBluetoothHalLoad: Error:
> Unknown error -2
> 06-05 18:31:53.875 I/GeckoBluetooth(  547): BluetoothServiceBluedroid:
> Error! Failed to load bluedroid library.
> 
> Hi Shawn, is this error message normal on Jelly-Bean Emulator?
Do you test this after Bluetooth Emulator fully enabled? See https://bugzilla.mozilla.org/show_bug.cgi?id=944299. Need to wait for all configuration and code been merged.

The log shows Bluedroid library was not been installed into emulator.
Flags: needinfo?(shuang)
(In reply to Shawn Huang [:shuang] [:shawnjohnjr] from comment #4)
> (In reply to Yoshi Huang[:allstars.chh] from comment #3)
> > From marionette.log, I saw some errors from BT
> > 
> > 06-05 18:31:53.875 I/GeckoBluetooth(  547): EnsureBluetoothHalLoad: Error:
> > Unknown error -2
> > 06-05 18:31:53.875 I/GeckoBluetooth(  547): BluetoothServiceBluedroid:
> > Error! Failed to load bluedroid library.
> > 
> > Hi Shawn, is this error message normal on Jelly-Bean Emulator?
> Do you test this after Bluetooth Emulator fully enabled? See
> https://bugzilla.mozilla.org/show_bug.cgi?id=944299. Need to wait for all
> configuration and code been merged.
> 
> The log shows Bluedroid library was not been installed into emulator.

Emulator JB BT just finished last week, are these test case related to bluetooth?
The test cases are NFC only, should not be related to bluetooth. I've just done ./repo sync -d and built the emulator. I did this once more 1h ago and I still get the same errors. 

Reverting to older Gecko (f297dd29f28bb736dfcfd374dfc62c02ed4f871c) and rebuilding emulator solves the problem. I assume that I need to retest this when Bug 944299 lands.
logcat after fresh build, tests still fail
marionette log, fresh build, test fail
I've done a fresh build (around 8AM CEST: $ cd b2g; $ git pull; $ ./repo sync -d; $ ./build.sh). Still all tests are failing, I don't see any problems with Bluedroid in the logs right now.
Blocks: 1019668
Assigning this to me, as I'm currently analysing this. Will reach out for help if this will be too complicated.
Assignee: nobody → kmioduszewski
Posting the stack trace that Krysztof provided:

Program received signal SIGSEGV, Segmentation fault.
congruent_aligned32 () at bionic/libc/arch-arm/generic/bionic/memcpy.S:149
149 ldrhi r3, [r12], #32 /* cheap ARM9 preload */
(gdb) bt
#0 congruent_aligned32 () at bionic/libc/arch-arm/generic/bionic/memcpy.S:149
#1 0x4148b670 in CreateCommon (data=0x64006e <Address 0x64006e out of bounds>, length=6357101, cx=<optimized out>)
at ../../dist/include/mozilla/dom/TypedArray.h:186
#2 mozilla::dom::TypedArray<unsigned char, &js::UnwrapUint8Array, &(JS_GetUint8ArrayData(JSObject*)), &js::GetUint8ArrayLengthAndData, &(JS_NewUint8Array(JSContext*, unsigned int))>::Create (cx=<optimized out>, creator=<optimized out>, length=6357101, data=0x64006e <Address 0x64006e out of bounds>)
at ../../dist/include/mozilla/dom/TypedArray.h:169
#3 0x4503216c in ?? ()
Cannot access memory at address 0x740063
#4 0x4503216c in ?? ()
Cannot access memory at address 0x740063
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
This is probably related to bug 1018068.

The |Create| in the stack trace is called from dom/nfc/MozNDEFRecord.cpp, near line 100. The passed data and length seem to be invalid (length ~= 6.5 MiB). These values are set in the typed array by a call to |js::GetUint8ArrayLengthAndData|. This function is created by the macro JS_DEFINE_DATA_AND_LENGTH_ACCESSOR in js/src/jsfriendapi.h, near line 1353 and below. It reads the data and length from the typed array's JS data structures.

Jeff, do you have an idea why the typed array contains invalid data? You can find the Uint8Array in the tests under dom/nfc/tests/marionette. It seems to happen in all related tests.
Flags: needinfo?(jwalden+bmo)
Just to give a bit more background about the conclusions which Thomas wrote in Comment 13. 
I've been looking at the logcat output in attachment 8437476 [details] and I've noticed that Marionette server is starting twice, as you can see that:

> Marionette	INFO	marionette-server.js loaded

is printed twice (line 118 and line 503) with different process number. Thomas took a look at the log and pointed out that there is a segmentation fault in Gecko which is causing b2g to restart. This is line 407 showing the segmentation fault:

> F/libc    (   45): Fatal signal 11 (SIGSEGV) at 0x48e00000 (code=2), thread 45 (b2g)

And this explains the error visible in marionette log (attachment 8437478 [details], line 35) 

> TEST-UNEXPECTED-FAIL | test_ndef.js | IOError: Connection to Marionette server is lost. Check gecko.log (desktop firefox) or logcat (b2g) for errors.

As advised by Thomas I've attached gdb to get the error stack trace. Unfortunately I didn't have the debug build. Debug trace is visible in Comment 12. After some additional test runs we came to the conclusion that MozNDEFRecord constructor is responsible for the seg fault. Tests which don't instantiate MozNDEFRecord are passing as expected. So the only tests which are failing are: test_ndef.js, test_nfc_peer_sendndef.js, test_nfc_error_messages.js. 

This also explains why patch for 1019668 was failing (https://bugzilla.mozilla.org/show_bug.cgi?id=1019668#c15). test_nfc_error_messages.js instantiates MozNDEFRecord before the actual check for MozNFC is done. So the test was failing instead of being skipped.
Summary: All NFC marionette test failing on emulator-jb with latest gecko → [NFC] marionette web-api tests which use MozNDEFRecord failing on emulator-jb
I'll try to post full stack trace tomorrow morning. I have a debug build now but the emulator does not seem to start properly. Will need to take a bit more look into it. 

Also many thanks to Thomas for helping me out with this on IRC.
I suspect you'll need the patch in bug 1020034 to get this working.  (And then yet another patch when the longer-term concern there is addressed, but that's more in the future.)
Flags: needinfo?(jwalden+bmo)
Hi Jeff

(In reply to Jeff Walden [:Waldo] (remove +bmo to email) from comment #16)
> I suspect you'll need the patch in bug 1020034 to get this working.  (And
> then yet another patch when the longer-term concern there is addressed, but
> that's more in the future.)

I'm not authorized to see bug 1020034. Could you please add Krysztof, dlee, and me to that bug? Thanks.
Flags: needinfo?(jwalden+bmo)
Not sure why, but the emulator just freezes on debug builds for me (with and without gdb attached). 

I've done two additional builds:
1. gecko 2aa12e1428b481432e009b18573024d3143213ae - Bug 1018068 landed, test are failing
2. gecko f2fa1b849759bec4d9c96d0bef69e5d4d0168b93 - one commit before point 1., tests are passing

So i guess the fix for Bug 1018068 fixed sharing on flame but is not well supported on emulator-jb. Dimi could you also take a look at this? Maybe you have some idea what is missing in emulator-jb?
Flags: needinfo?(dlee)
(In reply to Krzysztof Mioduszewski[:kmioduszewski][:tauzen] from comment #18)
> Not sure why, but the emulator just freezes on debug builds for me (with and
> without gdb attached). 

Maybe you're hitting bug 1000063 or 1014065.
(In reply to Thomas Zimmermann [:tzimmermann] [:tdz] from comment #17)
> Could you please add Krysztof, dlee,
> and me to that bug?

Done for #1 and #3, #2 is already there.  :-)  I'll land today if I get approval to do so.
Flags: needinfo?(jwalden+bmo)
blocking-b2g: --- → backlog
I use latest gecko with patch in bug 1020034, all nfc testcase passed.
let's wait the patch lands and check if this issue still occurs.
blocking-b2g: backlog → ---
Flags: needinfo?(dlee)
blocking-b2g: --- → backlog
Ok, same here. I did a clean build with repo sync and applied patch from Bug 1020034. All tests are passing now. Will retest once more after 1020034 lands.
Depends on: 1020034
Bug 1020034 has landed and I have re run all the tests. Everything is working fine form me.

As I didn't need to upload any patch for this I'm not sure what status should I set here. Yoshi can we mark this a Resolve Fixed?
Status: NEW → RESOLVED
Closed: 6 years ago
Flags: needinfo?(allstars.chh)
Resolution: --- → WORKSFORME
Flags: needinfo?(allstars.chh)
Resolution: WORKSFORME → DUPLICATE
Duplicate of bug: 1020034
blocking-b2g: backlog → ---
You need to log in before you can comment on or make changes to this bug.