Closed Bug 104089 Opened 23 years ago Closed 22 years ago

Cannot reattach context to its thread because of the bug in Context class

Categories

(Rhino Graveyard :: Core, defect)

x86
Windows NT
defect
Not set
normal

Tracking

(Not tracked)

VERIFIED WORKSFORME

People

(Reporter: vstroutchkov, Assigned: norrisboyd)

Details

From Bugzilla Helper: User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0) BuildID: The following code: // reattach cx to its thread Context current; if((current = Context.enter(cx)) != cx) { System.out.println("debugger error: cx = " + cx + " current = " + current); } from function org.mozilla.javascript.tools.debugger.Main.interrupted(Context cx) doesn't work because of the problem in Context.enter(Context cx) function: else if (cx != null) { synchronized (cx) { if (cx.currentThread == null) { cx.currentThread = t; threadContexts.put(t, cx); cx.enterCount++; } } current = cx; } When cx.currentThread != null it's not replaced by the current thread as attempted. The fragment above should be replaced with something like that: else if (cx != null) { synchronized (cx) { if (cx.currentThread == null || cx.currentThread != t) { if (cx.currentThread != null) { threadContexts.remove(cx.currentThread); cx.enterCount--; } cx.currentThread = t; threadContexts.put(t, cx); cx.enterCount++; } } current = cx; } Reproducible: Always Steps to Reproduce: 1.Start debugger without parameters. 2.Using browser, run a script containing Context.getCurrentContext() call. 3.The call returns null Actual Results: My script cannot find the right context because it still "attached" to another thread.
Rhino bug -> Rhino product
Assignee: rginda → nboyd
Component: JavaScript Debugger → Core
Product: Browser → Rhino
QA Contact: rginda → pschwartau
Status: UNCONFIRMED → NEW
Ever confirmed: true
The bug description is not applicable any more due to changes in Context.enter/Context.exit, but as the test case works fine now, I suggest to close this as fixed.
Resolving as WORKSFORME -
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → WORKSFORME
Marking Verified. Vitaly, if there is a problem that still exists, please reopen - thanks.
Status: RESOLVED → VERIFIED
Targeting as resolved against 1.5R4
Target Milestone: --- → 1.5R4
You need to log in before you can comment on or make changes to this bug.