public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/13431] New: jit code registration cleanup
@ 2011-11-22 21:31 sphink at gmail dot com
  2011-12-16 19:56 ` [Bug gdb/13431] " sphink at gmail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: sphink at gmail dot com @ 2011-11-22 21:31 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13431

             Bug #: 13431
           Summary: jit code registration cleanup
           Product: gdb
           Version: unknown
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
        AssignedTo: unassigned@sourceware.org
        ReportedBy: sphink@gmail.com
    Classification: Unclassified


When using the JIT CFI registration API, I very commonly run into

  Unsupported JIT protocol version in descriptor!

Or, when I'm unlucky, extremely bizarre behavior: the inferior starts jumping
to invalid locations. I generally notice it when it lands between two
instructions and I get a SIGILL, though I have noticed at least one case where
it just silently executed the wrong code.

I haven't seen the latter failure mode for a while.

I believe the problem is triggered when I am debugging a binary, and then I
recompile it in a way that changes the location of __jit_debug_descriptor. It
seems to reload the object file, then use the old location to unregister the
old JIT code. Or something.

The exact series of events goes something like:

  1. (gdb) run
  2. ...stop at a breakpoint...
  3. recompile
  4. (gdb) run
Unsupported JIT protocol version in descriptor!
  5. (gdb) run
`/home/sfink/src/MI-jitprofiler/obj/dist/bin/js' has changed; re-reading
symbols.
Unsupported JIT protocol version in descriptor!
  6. (gdb) run
Warning:
Cannot insert breakpoint -14865.
Error accessing memory address 0x378d805b60: Input/output error.
Cannot insert breakpoint -14866.
Error accessing memory address 0x378d805b70: Input/output error.
  7. (gdb) run
Now it runs, but all CFI information is completely mangled. Stack traces have
bogus return addresses.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug gdb/13431] jit code registration cleanup
  2011-11-22 21:31 [Bug gdb/13431] New: jit code registration cleanup sphink at gmail dot com
@ 2011-12-16 19:56 ` sphink at gmail dot com
  2011-12-16 20:01 ` sphink at gmail dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: sphink at gmail dot com @ 2011-12-16 19:56 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13431

--- Comment #1 from Steve Fink <sphink at gmail dot com> 2011-12-16 19:56:28 UTC ---
Created attachment 6115
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6115
Test case for __jit_debug_descriptor

Exact steps to reproduce:

1. Save the attached file to /tmp/jitrereg.c
2. gcc -o jitrereg /tmp/jitrereg.c
3. gdb ./jitrereg
4. gdb> run
5. Edit /tmp/jitrereg.c. Uncomment the line 'int spacer = 4'
6. From another shell (ie, without exiting gdb), redo step 2
7. From the same gdb as was running before, enter 'run' again

Observed:

(gdb) run
Unsupported JIT protocol version in descriptor!

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug gdb/13431] jit code registration cleanup
  2011-11-22 21:31 [Bug gdb/13431] New: jit code registration cleanup sphink at gmail dot com
  2011-12-16 19:56 ` [Bug gdb/13431] " sphink at gmail dot com
@ 2011-12-16 20:01 ` sphink at gmail dot com
  2012-02-01 17:45 ` tromey at redhat dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: sphink at gmail dot com @ 2011-12-16 20:01 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13431

--- Comment #2 from Steve Fink <sphink at gmail dot com> 2011-12-16 20:01:06 UTC ---
Note that I've found this to be a serious usability issue. I control whether
the JIT code registration does anything with an environment variable, but that
doesn't help with this bug -- as long as __jit_debug_descriptor is defined in
any linked object file, you'll occasionally get this problem. In my experience,
it isn't even necessary to modify the file containing the
__jit_debug_descriptor definition (or its headers) in order for it to be moved
around. (Probably the linker is putting the object file at a different address
or something.) And yet, you'll sometimes get lucky and recompile with major
modifications without seeing this issue.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug gdb/13431] jit code registration cleanup
  2011-11-22 21:31 [Bug gdb/13431] New: jit code registration cleanup sphink at gmail dot com
  2011-12-16 19:56 ` [Bug gdb/13431] " sphink at gmail dot com
  2011-12-16 20:01 ` sphink at gmail dot com
@ 2012-02-01 17:45 ` tromey at redhat dot com
  2012-02-01 20:22 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: tromey at redhat dot com @ 2012-02-01 17:45 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13431

Tom Tromey <tromey at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at redhat dot com
         AssignedTo|unassigned at sourceware    |tromey at redhat dot com
                   |dot org                     |

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug gdb/13431] jit code registration cleanup
  2011-11-22 21:31 [Bug gdb/13431] New: jit code registration cleanup sphink at gmail dot com
                   ` (2 preceding siblings ...)
  2012-02-01 17:45 ` tromey at redhat dot com
@ 2012-02-01 20:22 ` cvs-commit at gcc dot gnu.org
  2012-02-01 20:23 ` tromey at redhat dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2012-02-01 20:22 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13431

--- Comment #3 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> 2012-02-01 20:21:31 UTC ---
CVSROOT:    /cvs/src
Module name:    src
Changes by:    tromey@sourceware.org    2012-02-01 20:21:22

Modified files:
    gdb            : ChangeLog jit.c 
    gdb/testsuite  : ChangeLog 
Added files:
    gdb/testsuite/gdb.base: jit-simple.c jit-simple.exp 

Log message:
    PR gdb/13431:
    * jit.c (struct jit_inferior_data): Rewrite.
    (struct jit_objfile_data): New.
    (get_jit_objfile_data): New function.
    (add_objfile_entry): Update.
    (jit_read_descriptor): Return int.  Replace descriptor_addr
    argument with inf_data.  Update.  Don't call error.
    (jit_breakpoint_re_set_internal): Reorder logic.  Update.  Look up
    descriptor here.
    (jit_inferior_init): Don't look up descriptor.  Don't call error.
    (jit_reset_inferior_data_and_breakpoints)
    (jit_inferior_created_observer): Remove.
    (jit_inferior_exit_hook): Update.
    (jit_executable_changed_observer): Remove.
    (jit_event_handler): Update.
    (free_objfile_data): Reset inferior data if needed.
    (_initialize_jit): Update.
    gdb/testsuite
    * gdb.base/jit-simple.exp: New file.
    * gdb.base/jit-simple.c: New file.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.13799&r2=1.13800
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/jit.c.diff?cvsroot=src&r1=1.26&r2=1.27
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.3053&r2=1.3054
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.base/jit-simple.c.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.base/jit-simple.exp.diff?cvsroot=src&r1=NONE&r2=1.1

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug gdb/13431] jit code registration cleanup
  2011-11-22 21:31 [Bug gdb/13431] New: jit code registration cleanup sphink at gmail dot com
                   ` (3 preceding siblings ...)
  2012-02-01 20:22 ` cvs-commit at gcc dot gnu.org
@ 2012-02-01 20:23 ` tromey at redhat dot com
  2012-02-09 20:24 ` sphink at gmail dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: tromey at redhat dot com @ 2012-02-01 20:23 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13431

Tom Tromey <tromey at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |7.5

--- Comment #4 from Tom Tromey <tromey at redhat dot com> 2012-02-01 20:22:16 UTC ---
I think this is fixed.
I'd appreciate it if you gave it a try.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug gdb/13431] jit code registration cleanup
  2011-11-22 21:31 [Bug gdb/13431] New: jit code registration cleanup sphink at gmail dot com
                   ` (4 preceding siblings ...)
  2012-02-01 20:23 ` tromey at redhat dot com
@ 2012-02-09 20:24 ` sphink at gmail dot com
  2012-02-16  0:56 ` sphink at gmail dot com
  2012-02-16 18:17 ` tromey at redhat dot com
  7 siblings, 0 replies; 9+ messages in thread
From: sphink at gmail dot com @ 2012-02-09 20:24 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13431

--- Comment #5 from Steve Fink <sphink at gmail dot com> 2012-02-09 20:24:10 UTC ---
Yes, this seems to fix it for my actual code. Thanks!

(Sorry for the delay; I use git://sourceware.org/git/archer.git with a reverted
patch that I need for it to work, and it took me a while to find the source
tree where this patch was applied. I finally gave up and just used the CVS
tree.)

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug gdb/13431] jit code registration cleanup
  2011-11-22 21:31 [Bug gdb/13431] New: jit code registration cleanup sphink at gmail dot com
                   ` (5 preceding siblings ...)
  2012-02-09 20:24 ` sphink at gmail dot com
@ 2012-02-16  0:56 ` sphink at gmail dot com
  2012-02-16 18:17 ` tromey at redhat dot com
  7 siblings, 0 replies; 9+ messages in thread
From: sphink at gmail dot com @ 2012-02-16  0:56 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13431

--- Comment #6 from Steve Fink <sphink at gmail dot com> 2012-02-16 00:54:13 UTC ---
I suspect this is a different issue, but it started happening recently, and one
major recent change is the switch to the CVS version of gdb. At least as
likely, though, is that I'm seeing this on optimized builds (of my app); I also
started doing that recently (normally I always run nonoptimized, debug builds.)

Any chance you could take a quick look and tell me if I should file it
separately?

(gdb) bt
#0  inlineFrames (this=<optimized out>) at
/home/sfink/src/MI-jitprofiler/js/src/methodjit/MethodJIT.cpp:1146
#1  callSites (this=<optimized out>) at
/home/sfink/src/MI-jitprofiler/js/src/methodjit/MethodJIT.cpp:1152
#2  commonSectionLimit (this=<optimized out>) at
/home/sfink/src/MI-jitprofiler/js/src/methodjit/MethodJIT.cpp:1158
#3  getGlobalNames (this=<optimized out>) at
/home/sfink/src/MI-jitprofiler/js/src/methodjit/MethodJIT.cpp:1165
#4  setGlobalNames (this=<optimized out>) at
/home/sfink/src/MI-jitprofiler/js/src/methodjit/MethodJIT.cpp:1171
#5  callICs (this=<optimized out>) at
/home/sfink/src/MI-jitprofiler/js/src/methodjit/MethodJIT.cpp:1178
#6  js::mjit::JITScript::nativeToPC (this=0x9251d0,
returnAddress=0x7ffff7fe0401, pinline=0x7fffffffd4c0) at
/home/sfink/src/MI-jitprofiler/js/src/methodjit/MethodJIT.cpp:1467
#7  0x0000000000540419 in GrabJSStack (reason=0x7fffffffd51c,
rt=0x7ffff1e94010, sample=0x7ffff0d0f760) at
/home/sfink/src/MI-jitprofiler/js/src/devtools/profiler/Backtrace.cpp:680
#8  js::profiler::CaptureStack (sample=0x7ffff0d0f760, rt=0x7ffff1e94010,
flags=<optimized out>, numJunkFrames=<optimized out>, reason=0x7fffffffd51c) at
/home/sfink/src/MI-jitprofiler/js/src/devtools/profiler/Backtrace.cpp:770
#9  0x0000000000572747 in ProfileSignalHandler (vucx=<optimized out>) at
/home/sfink/src/MI-jitprofiler/js/src/devtools/profiler/Profiler.cpp:706
#10 <signal handler called>
BFD: BFD (GNU Binutils) 2.22.52.20120215 internal error, aborting at reloc.c
line 6394 in bfd_generic_get_relocated_section_contents

BFD: Please report this bug.

Debugger exited abnormally with code 1

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug gdb/13431] jit code registration cleanup
  2011-11-22 21:31 [Bug gdb/13431] New: jit code registration cleanup sphink at gmail dot com
                   ` (6 preceding siblings ...)
  2012-02-16  0:56 ` sphink at gmail dot com
@ 2012-02-16 18:17 ` tromey at redhat dot com
  7 siblings, 0 replies; 9+ messages in thread
From: tromey at redhat dot com @ 2012-02-16 18:17 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13431

--- Comment #7 from Tom Tromey <tromey at redhat dot com> 2012-02-16 18:16:16 UTC ---
Yeah, I think a new bug would be good.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-02-16 18:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-22 21:31 [Bug gdb/13431] New: jit code registration cleanup sphink at gmail dot com
2011-12-16 19:56 ` [Bug gdb/13431] " sphink at gmail dot com
2011-12-16 20:01 ` sphink at gmail dot com
2012-02-01 17:45 ` tromey at redhat dot com
2012-02-01 20:22 ` cvs-commit at gcc dot gnu.org
2012-02-01 20:23 ` tromey at redhat dot com
2012-02-09 20:24 ` sphink at gmail dot com
2012-02-16  0:56 ` sphink at gmail dot com
2012-02-16 18:17 ` tromey at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).