Last Comment Bug 695985 - CFI for JaegerMonkey assembly code should apply one instruction *before* entry point
: CFI for JaegerMonkey assembly code should apply one instruction *before* entr...
Status: RESOLVED FIXED
[inbound]
:
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: unspecified
: x86_64 Linux
: -- normal (vote)
: mozilla10
Assigned To: general
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-10-19 22:49 PDT by Jim Blandy :jimb
Modified: 2011-10-28 04:30 PDT (History)
2 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Provide CFI for the code address GDB checks when a return address points at JaegerThrowpoline's or JaegerInterpoline's entry point. (10.75 KB, patch)
2011-10-19 22:49 PDT, Jim Blandy :jimb
sphink: review+
Details | Diff | Splinter Review

Description Jim Blandy :jimb 2011-10-19 22:49:59 PDT
Created attachment 568315 [details] [diff] [review]
Provide CFI for the code address GDB checks when a return address points at JaegerThrowpoline's or JaegerInterpoline's entry point.

Here's the explanation from the comments in the patch:

+ * Special rules for JaegerThrowpoline and friends:
+ *
+ * In ordinary code, return addresses always point directly after a call
+ * instruction. When GDB looks up the CFI for a return address it got from the
+ * stack (as opposed to the current PC), it uses the CFI just before the return
+ * address --- the CFI associated with the call instruction --- to do the
+ * unwinding. However, JaegerMonkey uses hacks that edit return addresses to
+ * point directly at the first instruction of JaegerThrowpoline,
+ * JaegerInterpoline, and their ilk, so GDB ends up trying to use the CFI
+ * associated with whatever instruction lies immediately *before* the given
+ * entry point.
+ *
+ * We make sure our CFI covers the code address GDB will actually use, by
+ * placing a 'nop' *before* the entry point --- it is never executed --- and
+ * having our CFI apply starting at that nop.
Comment 1 Steve Fink [:sfink] [:s:] 2011-10-24 16:39:36 PDT
Comment on attachment 568315 [details] [diff] [review]
Provide CFI for the code address GDB checks when a return address points at JaegerThrowpoline's or JaegerInterpoline's entry point.

Review of attachment 568315 [details] [diff] [review]:
-----------------------------------------------------------------

Wow. Very nice. Uh... I'm glad you caught this, because I'd have gone bonkers if I ever noticed it happening and tried to debug it.

Great comment too. I should've done that in the first place, I guess.
Comment 3 Ed Morley [:emorley] 2011-10-28 04:30:55 PDT
https://hg.mozilla.org/mozilla-central/rev/74a92a761da1

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