udalrich / jdibug

Automatically exported from code.google.com/p/jdibug
17 stars 4 forks source link

Race condition when multiple breakpoints are in one class #7

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Set two breakpoints in a class that runs early in the program but is not
loaded when the debugger connects.
2. Connect jdibug.  There will be an error message that the class was not found
3. M-x jdibug-resume

What is the expected output? What do you see instead?

When the class is loaded, jdi-handle-class-prepare is called.  At the end,
it calls jdi-resume, then jdi-set-breakpoint.  If the code reaches the
second breakpoint soon after the class is loaded, it may proceed past that
breakpoint before the breakpoint is set in the debugger.

This is probably also possible with a single breakpoint, but multiple
breakpoints increases the time window for the code to reach the unset
breakpoint.  A multi-core CPU is probably helpful in triggering this.

What version of the product are you using? On what operating system?
jdibug 0.2, cygwin on Windows NT, java 1.6

Please provide any additional information below.

The following code at the end of jdi-handle-class-prepare appears to
resolve the issue.

      (let (matched)
        (dolist (br (jdi-breakpoint-requests jdi))
          (when (equal (jdi-breakpoint-request-source-file br)
(jdi-class-signature-to-source jdi signature))
            (jdi-set-breakpoint jdi (jdi-breakpoint-request-source-file br)
(jdi-breakpoint-request-line-number br))
            (jdi-trace "Set %s" br)
            (funcall (jdi-breakpoint-resolved-handler jdi) jdi br)
            (setq matched t)))
        (if matched (jdi-resume jdi))))))

Original issue reported on code.google.com by udalrich.schermer on 4 Mar 2010 at 7:54

GoogleCodeExporter commented 9 years ago

Original comment by udalrich.schermer on 27 Mar 2010 at 9:13

GoogleCodeExporter commented 9 years ago

Original comment by udalrich.schermer on 12 Apr 2011 at 3:23