Closed Bug 564351 Opened 14 years ago Closed 14 years ago

e10s: Figure out if XMLHttpRequests can be supported in xpcshell

Categories

(Core :: DOM: Core & HTML, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jduell.mcbugs, Assigned: jdm)

References

Details

Attachments

(1 file)

bz,

Jae-Seong Lee-Russo is running into the following error when trying e10s/necko with a simple XHR xpcshell test, and suspects some stubs you wrote:

test_xmlhttprequest_wrap.js aborts (test_xmlhttprequest.js works fine).  I
think bug 557605 is related to the assertion failure.

###!!! ASSERTION: wrong context on XPCJSContextStack!: 'cx == topJSContext',
file c:/mozilla-build/e10s/js/src/xpconnect/src/xpcquickstubs.cpp, line 1144

(http://mxr.mozilla.org/projects-central/source/electrolysis/js/src/xpconnect/src/xpcquickstubs.cpp#1144)

nsIXMLHttpRequest_SetOnreadystatechange in dom_quickstubs.cpp called
xpc_qsAssertContextOK.

Jae-Seong, I assume this test was working when we checked it in April 21st as part of bug 547051, right?  Bz added the stubs you suspect are breaking things on April 23rd as part of bug 557605.

P.S.  CORE|DOM appears to be where XHR bugs live?  Seems like it could use its own category.
I didn't write the stubs; they're autogenerated code.  See js/src/xpconnect/src/qsgen.py for the script that generates them.

It sounds like in this case you're failing the standard XPC_QS_ASSERT_CONTEXT_OK assert, which just asserts that the JSContext passed to the quickstub matches whatever is on the XPConnect per-thread JSContext stack at the time.

Can you point me to the test in question?

XHR bugs live in Core:DOM or Core:DOM:Mozilla Extensions.
test_xmlhttprequest_wrap.js is the test and was working on April 21.

See test_bug558801_wrap.js (the name is changed) in https://bug558801.bugzilla.mozilla.org/attachment.cgi?id=440136.
Hmm.  What can you tell me about the JSContext on the stack as compared to the cx passed in?
topJSContext is null.
I see.  Does xpcshell not push the jscontext it's running on onto the stack?

(I should note that in general using XHR, or any DOM object, from xpcshell is not exactly supported.)
What's the stack to the assertion? xpcshell *does* seem to push its stack onto the context stack.
(In reply to comment #6)
> What's the stack to the assertion? xpcshell *does* seem to push its stack onto
> the context stack.

(gdb) p cx
$1 = (JSContext *) 0x12968f0
(gdb) p topJSContext
$2 = (JSContext *) 0x0
(gdb) bt
#0  0x00002ac7e08daf51 in nanosleep () from /lib/libc.so.6
#1  0x00002ac7e08dada0 in __sleep (seconds=<value optimized out>) at ../sysdeps/unix/sysv/linux/sleep.c:138
#2  0x00002ac7dd267cdf in ah_crap_handler (signum=6) at /home/cjones/mozilla/electrolysis/toolkit/xre/nsSigHandlers.cpp:132
#3  0x00002ac7dd267d2a in child_ah_crap_handler (signum=6) at /home/cjones/mozilla/electrolysis/toolkit/xre/nsSigHandlers.cpp:145
#4  <signal handler called>
#5  0x00002ac7e086a4b5 in *__GI_raise (sig=<value optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#6  0x00002ac7e086df50 in *__GI_abort () at abort.c:92
#7  0x00002ac7dfc4a1d0 in PR_Abort () at /home/cjones/mozilla/electrolysis/nsprpub/pr/src/io/prlog.c:548
#8  0x00002ac7de7c05a8 in Abort (aMsg=0x7fffb03662d0 "###!!! ASSERTION: wrong context on XPCJSContextStack!: 'cx == topJSContext', file /home/cjones/mozilla/electrolysis/js/src/xpconnect/src/xpcquickstubs.cpp, line 1140") at /home/cjones/mozilla/electrolysis/xpcom/base/nsDebugImpl.cpp:387
#9  0x00002ac7de7c054d in NS_DebugBreak_P (aSeverity=1, aStr=0x2ac7ded25770 "wrong context on XPCJSContextStack!", aExpr=0x2ac7ded25757 "cx == topJSContext", aFile=0x2ac7ded25528 "/home/cjones/mozilla/electrolysis/js/src/xpconnect/src/xpcquickstubs.cpp", aLine=1140) at /home/cjones/mozilla/electrolysis/xpcom/base/nsDebugImpl.cpp:356
#10 0x00002ac7de06b177 in xpc_qsAssertContextOK (cx=0x12968f0) at /home/cjones/mozilla/electrolysis/js/src/xpconnect/src/xpcquickstubs.cpp:1140
#11 0x00002ac7de0ca11e in nsIXMLHttpRequest_SetOnreadystatechange (cx=0x12968f0, obj=0x2ac7e9535540, id=47038101324452, vp=0x7fffb0366cf8) at dom_quickstubs.cpp:21172
#12 0x00002ac7e0f7f4c2 in JSScopeProperty::set (this=0x13148c8, cx=0x12968f0, obj=0x2ac7e9535540, vp=0x7fffb0366cf8) at /home/cjones/mozilla/electrolysis/js/src/jsscope.h:1015
#13 0x00002ac7e0f79732 in js_SetPropertyHelper (cx=0x12968f0, obj=0x2ac7e9535540, id=47038101324452, defineHow=1, vp=0x7fffb0366cf8) at /home/cjones/mozilla/electrolysis/js/src/jsobj.cpp:4991
#14 0x00002ac7e0f46b3f in js_Interpret (cx=0x12968f0) at /home/cjones/mozilla/electrolysis/js/src/jsops.cpp:1821
#15 0x00002ac7e0f5dcf8 in js_Execute (cx=0x12968f0, chain=0x2ac7e95146c0, script=0x1236960, down=0x0, flags=0, result=0x7fffb03671c8) at /home/cjones/mozilla/electrolysis/js/src/jsinterp.cpp:1073
#16 0x00002ac7e0ece998 in JS_ExecuteScript (cx=0x12968f0, obj=0x2ac7e95146c0, script=0x1236960, rval=0x7fffb03671c8) at /home/cjones/mozilla/electrolysis/js/src/jsapi.cpp:4802
#17 0x00002ac7de71c85a in mozilla::ipc::XPCShellEnvironment::EvaluateString (this=0x1296890, aString=..., aResult=0x7fffb0367240) at /home/cjones/mozilla/electrolysis/ipc/testshell/XPCShellEnvironment.cpp:1236
#18 0x00002ac7de71896d in mozilla::ipc::TestShellChild::RecvPTestShellCommandConstructor (this=0x12a2380, aActor=0x11360c0, aCommand=...) at /home/cjones/mozilla/electrolysis/ipc/testshell/TestShellChild.cpp:85
#19 0x00002ac7de70eec5 in mozilla::ipc::PTestShellChild::OnMessageReceived (this=0x12a2380, msg=...) at PTestShellChild.cpp:235
#20 0x00002ac7de6cc18d in mozilla::dom::PContentProcessChild::OnMessageReceived (this=0x112bdd0, msg=...) at PContentProcessChild.cpp:206
#21 0x00002ac7de610bd3 in mozilla::ipc::AsyncChannel::OnDispatchMessage (this=0x112bde0, msg=...) at /home/cjones/mozilla/electrolysis/ipc/glue/AsyncChannel.cpp:262
#22 0x00002ac7de61978c in mozilla::ipc::RPCChannel::OnMaybeDequeueOne (this=0x112bde0) at /home/cjones/mozilla/electrolysis/ipc/glue/RPCChannel.cpp:415
#23 0x00002ac7de61f64e in DispatchToMethod<mozilla::ipc::RPCChannel, void (mozilla::ipc::RPCChannel::*)()> (obj=0x112bde0, method=0x2ac7de619500 <mozilla::ipc::RPCChannel::OnMaybeDequeueOne()>, arg=...) at /home/cjones/mozilla/electrolysis/ipc/chromium/src/base/tuple.h:383
#24 0x00002ac7de61f59e in RunnableMethod<mozilla::ipc::RPCChannel, void (mozilla::ipc::RPCChannel::*)(), Tuple0>::Run (this=0x1136ce0) at /home/cjones/mozilla/electrolysis/ipc/chromium/src/base/task.h:307
#25 0x00002ac7de61b121 in mozilla::ipc::RPCChannel::RefCountedTask::Run (this=0x1136d20) at ../../dist/include/mozilla/ipc/RPCChannel.h:435
#26 0x00002ac7de61b224 in mozilla::ipc::RPCChannel::DequeueTask::Run (this=0x11360f0) at ../../dist/include/mozilla/ipc/RPCChannel.h:460
#27 0x00002ac7de82a816 in MessageLoop::RunTask (this=0x7fffb0368ab0, task=0x11360f0) at /home/cjones/mozilla/electrolysis/ipc/chromium/src/base/message_loop.cc:336
#28 0x00002ac7de82a886 in MessageLoop::DeferOrRunPendingTask (this=0x7fffb0368ab0, pending_task=...) at /home/cjones/mozilla/electrolysis/ipc/chromium/src/base/message_loop.cc:344
#29 0x00002ac7de82ac84 in MessageLoop::DoWork (this=0x7fffb0368ab0) at /home/cjones/mozilla/electrolysis/ipc/chromium/src/base/message_loop.cc:444
#30 0x00002ac7de616d06 in mozilla::ipc::MessagePump::Run (this=0x11291c0, aDelegate=0x7fffb0368ab0) at /home/cjones/mozilla/electrolysis/ipc/glue/MessagePump.cpp:122
#31 0x00002ac7de6171fb in mozilla::ipc::MessagePumpForChildProcess::Run (this=0x11291c0, aDelegate=0x7fffb0368ab0) at /home/cjones/mozilla/electrolysis/ipc/glue/MessagePump.cpp:232
#32 0x00002ac7de82a321 in MessageLoop::RunInternal (this=0x7fffb0368ab0) at /home/cjones/mozilla/electrolysis/ipc/chromium/src/base/message_loop.cc:216
#33 0x00002ac7de82a2a6 in MessageLoop::RunHandler (this=0x7fffb0368ab0) at /home/cjones/mozilla/electrolysis/ipc/chromium/src/base/message_loop.cc:199
#34 0x00002ac7de82a237 in MessageLoop::Run (this=0x7fffb0368ab0) at /home/cjones/mozilla/electrolysis/ipc/chromium/src/base/message_loop.cc:173
#35 0x00002ac7de4a0287 in nsBaseAppShell::Run (this=0x12a2570) at /home/cjones/mozilla/electrolysis/widget/src/xpwidgets/nsBaseAppShell.cpp:175
#36 0x00002ac7dd269147 in XRE_RunAppShell () at /home/cjones/mozilla/electrolysis/toolkit/xre/nsEmbedFunctions.cpp:516
#37 0x00002ac7de617136 in mozilla::ipc::MessagePumpForChildProcess::Run (this=0x11291c0, aDelegate=0x7fffb0368ab0) at /home/cjones/mozilla/electrolysis/ipc/glue/MessagePump.cpp:218
#38 0x00002ac7de82a321 in MessageLoop::RunInternal (this=0x7fffb0368ab0) at /home/cjones/mozilla/electrolysis/ipc/chromium/src/base/message_loop.cc:216
#39 0x00002ac7de82a2a6 in MessageLoop::RunHandler (this=0x7fffb0368ab0) at /home/cjones/mozilla/electrolysis/ipc/chromium/src/base/message_loop.cc:199
#40 0x00002ac7de82a237 in MessageLoop::Run (this=0x7fffb0368ab0) at /home/cjones/mozilla/electrolysis/ipc/chromium/src/base/message_loop.cc:173
#41 0x00002ac7dd268af9 in XRE_InitChildProcess (aArgc=1, aArgv=0x7fffb0368e18, aProcess=GeckoProcessType_Content) at /home/cjones/mozilla/electrolysis/toolkit/xre/nsEmbedFunctions.cpp:397
#42 0x0000000000400980 in main (argc=3, argv=0x7fffb0368e18) at /home/cjones/mozilla/electrolysis/ipc/app/MozillaRuntimeMain.cpp:87
Temporarily disabled this test to stop perma-crash on e10s tinderbox

http://hg.mozilla.org/projects/electrolysis/rev/5c5c9309dfab
Unless we can (fairly easily) get XHR working in xpcshell (the jscontext issue, and whatever else pops up), we should just remove the XHR test and close this bug.

Blake/bz:  does the stack trace that Jae-Seong supplied give you any hints?  Is this worth pursuing?
Summary: e10s: XMLHttpRequests: XHR QuickStubs break XHR on e10s? → e10s: Figure out if XMLHttpRequests can be supported in xpcshell
> does the stack trace that Jae-Seong supplied give you any hints?

You mean the one Chris supplied?

If so, yes.  XPCShellEnvironment::EvaluateString is buggy.  It needs to push the context it's using onto the context stack, like the normal xpcshell does.  Probably using that AutoContextPusher thingie it's got hanging around?
Getting XHR xpcshell tests to work is not a blocker for fennec.  Mochitest coverage will do.

Would be nice to figure out the context stack issue, so we can either fix or abandon this.
Blocks: e10s-necko
No longer blocks: 558801
Looks like it should be a simple fix.  I'm on it.
Assignee: nobody → josh
Attached patch PatchSplinter Review
test_xmlhttprequest_wrap.js passes with this patch.
Attachment #461782 - Flags: review?(bent.mozilla)
Attachment #461782 - Flags: review?(bent.mozilla) → review+
Blocks: 584604
Blocks: 536321
http://hg.mozilla.org/projects/electrolysis/rev/14342400e38b

landed in e10s, will be merge to m-c today
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: