This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug python/19927] Python unwinder API should be resilient to recursion and frame cache reinitialization


https://sourceware.org/bugzilla/show_bug.cgi?id=19927

Andrew Dinn <adinn at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |adinn at redhat dot com

--- Comment #1 from Andrew Dinn <adinn at redhat dot com> ---
Here are instructions to recreate the original problems by tweaking the current
OpenJDK unwinder

(assumes you have a recent OpenJDK8 installed on your machine)

Obtain the unwinder code from here

  http://icedtea.classpath.org/people/adinn/unwinder/

(you only need to obtain a zip of the latest repo)

Edit the code of method OpenJDKUnwinder.__call__ in file dbg8.py so that it
does not attempt to test or update the association list self.invocations. The
result should look like the snippet below (comments have been added at lines
775, 776, 778, 781, 784 and 789). n.b. all this does is remove the logic used
to ensure that recursive entries to the unwinder in any given thread are forced
to back out and return None.


   769         # sometimes when we call into python gdb routines
   770         # the call tries to re-establish the frame and ends
   771         # up calling the frame sniffer recursively
   772         #
   773         # so use a list keyed by thread to avoid recursive calls
   774         # t("OpenJDKUnwinder.__call__")
   775         #thread = gdb.selected_thread()
   776         #if self.invocations.get(thread) != None:
   777             # debug_write("!!! blocked %s !!!\n" % str(thread))
   778             #return None
   779         try:
   780             # debug_write("!!! blocking %s !!!\n" % str(thread))
   781             #self.invocations[thread] = thread
   782             result = self.call_sub(pending_frame)
   783             # debug_write("!!! unblocking %s !!!\n" % str(thread)) 
   784             #self.invocations[thread] = None
   785             return result
   786         except Exception, arg:
   787             gdb.write("!!! oops %s !!!\n" % arg)
   788             # debug_write("!!! unblocking %s !!!\n" % str(thread))
   789             #self.invocations[thread] = None
   790             return None
   791 

Having doctored the code now install it into your java deployment by following
the instructions in the README. Then run up java in gdb and watch it crash when
you type run! If you want to be sure the unwinder is loaded uncomment the top
level printout at line 46

    45 
    46 # debug_write("dbg.py\n")

You might also want to uncomment some or all of the calls to t() [which traces
execution of individual python source lines] and debug_write() [which prints
info about unwinder python code state].

Also, it might be wise to place a break on the pyuw_sniffer function and on the
frame reinit function. That will let you see i) the recursive sniffer calls and
2) the outer frame being junked when you are inside the sniffer (enable the
frame reinit break when you hit the first break on the sniffer)

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]