Bug 1295819 - jit reader get_frame_id and unwind_frame callbacks do not get called
jit reader get_frame_id and unwind_frame callbacks do not get called
Product: Fedora
Classification: Fedora
Component: gdb (Show other bugs)
All Linux
unspecified Severity unspecified
: ---
: ---
Assigned To: Jan Kratochvil
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2016-01-05 09:38 EST by Andrew Dinn
Modified: 2016-12-20 12:38 EST (History)
7 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2016-12-20 12:38:24 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Andrew Dinn 2016-01-05 09:38:45 EST
Description of the problem:

I have developed a prototype jit reader shared library for OpenJDK. It's purpose is to enable symbolic names for compiled Java methods be registered with gdb.

gdb recognises and invokes the hook function gdb_init_reader provided by my shared library. It also correctly invokes the read and destroy callbacks registered by gdb_init_reader. However, it never calls the get_frame_id and unwind_frame callbacks.

I debugged gdb (using gdb :-) and it turns out that the inferior process fails to install the required unwinder (jit_unwinder). This is supposed to be registered by function jit_inferior_created_hook.The only call to that function occurs in follow_exec (infrun.c) but follow_exec does not appear to be called when the JVM process is started.

I modified function post_create_inferior (infcmd.c) so that it calls jit_inferior_created_hook (I inserted the call at the end after the call to observer_notify_inferior_created) and this causes the relevant unwinder to be registered. With this patch the jit reader get_frame_id and unwind_frame callbacks are subsequently invoked and my prototype jit reader is able to list Java method and stub function names in backtraces.

Thgis was tested (and patched) on Fedora 21 with gdb 7.9.1. However, the same problem occurs with gdb 7.10.1 on Fedora 23.

How reproducible:

My JIT reader is fairly small and simple to build/use. However, it is not easy to reproduce the problem using this code because exercising the JIT reader requires building an OpenJDK release tweaked to generate info for JITted methods. I won't burden anyone with the details of how to achieve *that* unless it becomes absolutely necessary.

However, the bug does not need a working JIT reader (never mind the accompanying JIT compiler) to manifest the problem. A simple dummy JIT reader can be used to identify that the get_frame_id and unwind functions are not being called. You just need to implement the former to return an invalid frame (ip = 0x0, sp = 0x0) and the latter to return GDB_FAIL. You might add also add print statements to show whether they are being called or not. Alternatively, you can use gdb to debug the jit reader runnign in an inferior gdb and place breakpoints on the jit reader callbacks. I recommend placing the breakpoints on the unwinder function, jit_frame_sniffer.

Either method will also serve to show that my proposed patch does ensure the callbacks are invoked.

Steps to Reproduce:
1. implement adummy JIT reader
2. run gdb with gdb as target
3. from the outer gdb break jit_frame_sniffer
4. start the inner gdb from the outer gdb
5. register the dummy jit reader in the inferior gdb
4. start /any/ app from the inner gdb
5. hit Ctrl-C to break the app
6. type bt to exercise stack unwinding

Actual results:

jit_frame_sniffer will not get called.

Expected results:

jit_frame_sniffer should get called and should itself call the unwind callback.

Additional info:

The patch to fix this 7.9.1 is

$ diff -r gdb-7.9.1/gdb/infcmd.c tmp/gdb-7.9.1/gdb/infcmd.c
<   // make sure we set up the jit reader
<   jit_inferior_created_hook ();

The patch to fix this 7.10.1 is

$ diff -r gdb-7.10.1/gdb/infcmd.c tmp/gdb-7.10.1/gdb/infcmd.c
<   // make sure we set up the jit reader
<   jit_inferior_created_hook ();

I have several other issues with the way the jit reader works which I will report in separate bugzillas.
Comment 1 Jan Kratochvil 2016-01-08 16:32:23 EST
I may get to it but if I forget again there may be more suitable to post it to:
Comment 2 Fedora End Of Life 2016-11-24 09:43:47 EST
This message is a reminder that Fedora 23 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 23. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '23'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 23 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.
Comment 3 Fedora End Of Life 2016-12-20 12:38:24 EST
Fedora 23 changed to end-of-life (EOL) status on 2016-12-20. Fedora 23 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this

Thank you for reporting this bug and we are sorry it could not be fixed.

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