Summary: | Tail call optimizations lead to crashes on ARM Thumb + Linux | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Zan Dobersek <zan> | ||||||||
Component: | JavaScriptCore | Assignee: | Zan Dobersek <zan> | ||||||||
Status: | RESOLVED FIXED | ||||||||||
Severity: | Normal | CC: | basile_clement, commit-queue, fpizlo, ggaren, keith_miller, mark.lam, msaboff, oliver, ossy, sbarati, ysuzuki | ||||||||
Priority: | P2 | ||||||||||
Version: | WebKit Nightly Build | ||||||||||
Hardware: | Unspecified | ||||||||||
OS: | Unspecified | ||||||||||
Bug Depends on: | |||||||||||
Bug Blocks: | 108645 | ||||||||||
Attachments: |
|
Description
Zan Dobersek
2015-10-13 00:21:11 PDT
Created attachment 262978 [details] JSC_showDisassembly=true output on google.com This is all the output of the disassembled code that's generated in the same instance that's inspected in comment #0. I assume what's supposed to be called is the JIT CTI native call at 0x719c90e0. In debug build, a probably relevant assert is hit: ASSERTION FAILED: !(reinterpret_cast<intptr_t>(to) & 1) ../Source/JavaScriptCore/assembler/ARMv7Assembler.h(2205) : static void JSC::ARMv7Assembler::relinkJump(void*, void*) 1 0x7408650e WTFCrash 2 0x729b6bd2 JSC::ARMv7Assembler::relinkJump(void*, void*) 3 0x729dbc32 JSC::AbstractMacroAssembler<JSC::ARMv7Assembler, JSC::MacroAssemblerARMv7>::repatchNearCall(JSC::CodeLocationNearCall, JSC::CodeLocationLabel) 4 0x729d773a JSC::linkFor(JSC::ExecState*, JSC::CallLinkInfo&, JSC::CodeBlock*, JSC::JSFunction*, JSC::MacroAssemblerCodePtr) 5 0x729bb8a8 Created attachment 269042 [details]
Naive fixes
At this point there are two issues in JSC code that affect tail calls on ARM Thumb, both revolving around tail call code location (data location vs executable address).
The first one is in AbstractMacroAssembler<>::repatchNearCall(), where the destination's data location, instead of executable address, should be passed in to relinkJump(). This was previously causing assertions in relinkJump() for the `to` value.
The second one is in linkPolymorphicCall(). When calling LinkBuffer::link() for a tail call, the data location of the destination should be passed in, since in that case MacroAssembler::linkCall() will be linking a jump instead of a call. This too was hitting an assertion later down the call stack, in ARMv7::linkJumpAbsolute().
The attached patch just shows the quick-fix I've done for the two problems, and some feedback would already be appreciated. The first fix looks straightforward, but the second one is a bit convoluted.
(In reply to comment #3) > Created attachment 269042 [details] > Naive fixes > > At this point there are two issues in JSC code that affect tail calls on ARM > Thumb, both revolving around tail call code location (data location vs > executable address). > > The first one is in AbstractMacroAssembler<>::repatchNearCall(), where the > destination's data location, instead of executable address, should be passed > in to relinkJump(). This was previously causing assertions in relinkJump() > for the `to` value. > > The second one is in linkPolymorphicCall(). When calling LinkBuffer::link() > for a tail call, the data location of the destination should be passed in, > since in that case MacroAssembler::linkCall() will be linking a jump instead > of a call. This too was hitting an assertion later down the call stack, in > ARMv7::linkJumpAbsolute(). > > The attached patch just shows the quick-fix I've done for the two problems, > and some feedback would already be appreciated. The first fix looks > straightforward, but the second one is a bit convoluted. I tried this patch and fixes bug155790 on Thumb2. It would be great if JSC experts can check if this fix is proper or not. Created attachment 275788 [details]
Patch
Now in reviewable form.
(In reply to comment #5) > Created attachment 275788 [details] > Patch > > Now in reviewable form. (In reply to comment #4) > I tried this patch and fixes bug155790 on Thumb2. It would be > great if JSC experts can check if this fix is proper or not. Ping? *** Bug 155790 has been marked as a duplicate of this bug. *** (In reply to comment #5) > Created attachment 275788 [details] > Patch > > Now in reviewable form. (In reply to comment #4) > I tried this patch and fixes bug155790 on Thumb2. It would be > great if JSC experts can check if this fix is proper or not. Ping? *** Bug 154857 has been marked as a duplicate of this bug. *** Comment on attachment 275788 [details] Patch It seems 3 months wasn't enough for JSC maintainers to check this serious bug, which is a 7 months old regression caused by http://trac.webkit.org/changeset/189884 . I tested it, checked the implementation and looks good to me, r=me, let's land it as is. But I'm not sure if it is the best way to fix this regression. Please let use know if you have better fix for it. Comment on attachment 275788 [details] Patch Clearing flags on attachment: 275788 Committed r199586: <http://trac.webkit.org/changeset/199586> All reviewed patches have been landed. Closing bug. summary: - GTK - before: 380 failures https://build.webkit.org/builders/GTK%20Linux%20ARM%20Release/builds/10880 - GTK - after: 4 failures https://build.webkit.org/builders/GTK%20Linux%20ARM%20Release/builds/10881 - JSCOnly - before: 635 failures https://build.webkit.org/builders/JSCOnly%20Linux%20ARMv7%20Thumb2%20Release/builds/261 - JSCOnly - after: 16 failures https://build.webkit.org/builders/JSCOnly%20Linux%20ARMv7%20Thumb2%20Release/builds/264 |