Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugger error "RuntimeError: release unlocked lock" #65

Closed
DonJayamanne opened this issue Nov 13, 2017 · 34 comments
Closed

Debugger error "RuntimeError: release unlocked lock" #65

DonJayamanne opened this issue Nov 13, 2017 · 34 comments
Labels
area-debugging bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster

Comments

@DonJayamanne
Copy link

From @DonJayamanne on September 9, 2016 23:40

Reported on reddit:
https://www.reddit.com/r/programming/comments/51t7no/visual_studio_code_august_2016_15/d7f31jv

I occasionally get "RuntimeError: release unlocked lock" when debugging Python.

Copied from original issue: DonJayamanne/pythonVSCode#298

@DonJayamanne
Copy link
Author

DonJayamanne commented Nov 13, 2017

From @peringz on September 10, 2016 0:6

This is what I see in the console.

File "/Users/<user>/.vscode/extensions/donjayamanne.python-0.3.22/pythonFiles/PythonTools/visualstudio_py_debugger.py", line 1246, in run_on_thread
  self.schedule_work(lambda : self.run_locally(text, cur_frame, execution_id, frame_kind, repr_kind))
File "/Users/<user>/.vscode/extensions/donjayamanne.python-0.3.22/pythonFiles/PythonTools/visualstudio_py_debugger.py", line 1238, in schedule_work
  self.unblock()
File "/Users/<user>/.vscode/extensions/donjayamanne.python-0.3.22/pythonFiles/PythonTools/visualstudio_py_debugger.py", line 1234, in unblock
  self._block_lock.release()
RuntimeError: release unlocked lock

@DonJayamanne
Copy link
Author

@peringz, thanks for the immediate feedback.

  • Please could you ensure you have updated the python extension to the latest version 0.3.22 (released yesterday)
  • What is your OS?
  • Please could you provide a sample program (or instructions) for me to replicate this at my end?
  • What version of Python are you using?

Thanks

@DonJayamanne
Copy link
Author

From @peringz on September 10, 2016 0:37

@DonJayamanne I'm using extension version 0.3.22 on OS X and using Python 3.5.2 (tried 2.7.10 and got the same results)

A simple program like the one below will often throw this exception at a random interval. An error is thrown only when the first line of code or a breakpoint is hit.

def next_id(arr):
    nextid = 0
    while nextid in arr:
        nextid += 1
    return nextid

print(next_id([0, 1, 2, 3, 4, 12, 11, 8, 9]))

My launch configuration looks like this

"configurations": [
    {
        "name": "Python",
        "type": "python",
        "request": "launch",
        "stopOnEntry": true,
        "program": "${file}",
        "pythonPath": "/usr/local/bin/python3",
        "debugOptions": [
            "WaitOnAbnormalExit",
            "WaitOnNormalExit",
            "RedirectOutput"
        ]
    },

To replicate, put a breakpoint in line number 4, go to debug and click the Run button selecting Python configuration. Keep pressing F5 to iterate through the loop until Extension throws the error. You may want to repeat this debugging few times to see the error.

@DonJayamanne
Copy link
Author

@peringz, one last question. Do you have any watch variables? Thanks

@DonJayamanne
Copy link
Author

From @peringz on September 10, 2016 1:32

@DonJayamanne I had three, removed them and did some quick testing. Not able to reproduce the error any longer.

@DonJayamanne
Copy link
Author

@peringz
Oh no, do you remember what variables you had. Please could you add them back. And try again.

@DonJayamanne
Copy link
Author

From @peringz on September 10, 2016 2:31

@DonJayamanne I don't know the variable names. But I was able to replicate the problem by adding two invalid watch variables (foo and bar)
vscode_python

@DonJayamanne
Copy link
Author

Great thanks, will check this out tonight.

@DonJayamanne
Copy link
Author

@peringz , i'm unable o replicate this issue at my end. Will keep trying.
However there's a ray of hope, I have fixed an issue that may be related to this (#292). Will release a build soon.

@DonJayamanne
Copy link
Author

@peringz , will close this as the fix for #292 should have resolve this issue. If not , please re-open the issue.

@DonJayamanne
Copy link
Author

From @staffann on January 30, 2017 13:4

I get the same problem with version 0.5.6:
Traceback (most recent call last):
File "/home/sni1lud/.vscode/extensions/donjayamanne.python-0.5.6/pythonFiles/PythonTools/visualstudio_py_debugger.py", line 1725, in loop
cmd()
File "/home/sni1lud/.vscode/extensions/donjayamanne.python-0.5.6/pythonFiles/PythonTools/visualstudio_py_debugger.py", line 2022, in command_enum_children
thread.enum_child_on_thread(text, cur_frame, eid, frame_kind)
File "/home/sni1lud/.vscode/extensions/donjayamanne.python-0.5.6/pythonFiles/PythonTools/visualstudio_py_debugger.py", line 1345, in enum_child_on_thread
self.schedule_work(lambda : self.enum_child_locally(text, cur_frame, execution_id, frame_kind))
File "/home/sni1lud/.vscode/extensions/donjayamanne.python-0.5.6/pythonFiles/PythonTools/visualstudio_py_debugger.py", line 1316, in schedule_work
self.unblock()
File "/home/sni1lud/.vscode/extensions/donjayamanne.python-0.5.6/pythonFiles/PythonTools/visualstudio_py_debugger.py", line 1312, in unblock
self._block_lock.release()
RuntimeError: release unlocked lock

Using python 3. Have some different watch variables. The problem occurs when I step inside the code.

@DonJayamanne
Copy link
Author

From @ngawangtrinley on February 6, 2017 5:13

I'm on Linux and I get the same problem when I "step into" the code in a fast sequence. If I wait half a second or a second between each time I hit F11 I don't have the problem. I didn't have the problem in Windows.

@DonJayamanne
Copy link
Author

From @guiambros on February 12, 2017 6:8

Likewise; I can now reproduce in a very consistent manner. If I wait 0.2s before I press F10/F11, it works well. If I hold the F10 key pressed, it will execute for 3-4 iterations and then cause the error and lock up the session. I have to then stop debugger and start again.

Not a huge issue, but a bit annoying when you want to advance a long for-loop without stepping out or setting a breakpoint.

Version 0.5.8 (3 February 2017)

@DonJayamanne
Copy link
Author

From @mostafaeweda on June 15, 2017 22:21

I keep hitting this issue - I'm willing to help fix it, but need guidance where to start.

@brettcannon brettcannon added awaiting 2-PR area-debugging bug Issue identified by VS Code Team member as probable bug labels Nov 14, 2017
@brunetton
Copy link

I've the feeling that it happens when I hit "F10" too fast. Like if the thread that displays debug spied variables have no time to compute display outputs and don't like to get interrupted during that job.
(I'm totally aware my contribution is far from being scientific ;) but it's a path to explore)

@dinglioutlook
Copy link

I agree with @brunetton . It's quite random, in debug mode, if i choose to run till some code, then it sometimes deadlock, but if i slowly step by step to the breakpoint, nothing happened.

@avilay
Copy link

avilay commented Dec 28, 2017

Consistently happens when I am watching a variable (in my case a dict) that is being updated. I am on

  • Ubuntu 16.04
  • VS Code 1.19.1
  • Python Extension 0.9.1

Doesn't seem to be related to speed. I tried hitting F5/F10 really fast when there were no watch variables and there was no repro.

@mmyoungman
Copy link

mmyoungman commented Jan 14, 2018

I'm getting the same problem.

VS Code details:
Version 1.19.1
Commit 0759f77bb8d86658bc935a10a64f6182c5a1eeba
Date 2017-12-19T09:41:01.414Z
Shell 1.7.9
Renderer 58.0.3029.110
Node 7.9.0
Architecture x64

(Edit: I just upgraded to 1.91.2, and I get the exact same problem)

  • Manjaro
  • Ms-python.python 0.9.1

While debugging, I don't have any problem until I add some expressions to watch variables. With a few expressions added, if I step through quickly, the debugger crashes:
Traceback (most recent call last): File "/home/mark/.vscode/extensions/ms-python.python-0.9.1/pythonFiles/PythonTools/visualstudio_py_debugger.py", line 1729, in loop cmd() File "/home/mark/.vscode/extensions/ms-python.python-0.9.1/pythonFiles/PythonTools/visualstudio_py_debugger.py", line 1747, in command_step_into self.command_resume_all() File "/home/mark/.vscode/extensions/ms-python.python-0.9.1/pythonFiles/PythonTools/visualstudio_py_debugger.py", line 1908, in command_resume_all thread.unblock() File "/home/mark/.vscode/extensions/ms-python.python-0.9.1/pythonFiles/PythonTools/visualstudio_py_debugger.py", line 1315, in unblock self._block_lock.release() RuntimeError: release unlocked lock

@thesilican
Copy link

thesilican commented Feb 3, 2018

I have the same issue, I'm using

  • VS Code
    • Version 1.19.3
    • Commit 7c4205b5c6e52a53b81c69d2b2dc8a627abaa0ba
    • Date 2018-01-25T10:36:34.867Z
    • Shell 1.7.9
    • Renderer 58.0.3029.110
    • Node 7.9.0
    • Architecture x64
  • Windows 10 Home
  • ms-python.python 2018.1
  File "C:\Users\Bryan C\.vscode\extensions\ms-python.python-2018.1.0\pythonFiles\PythonTools\visualstudio_py_debugger.py", line 2026, in command_enum_children
    thread.enum_child_on_thread(text, cur_frame, eid, frame_kind)
  File "C:\Users\Bryan C\.vscode\extensions\ms-python.python-2018.1.0\pythonFiles\PythonTools\visualstudio_py_debugger.py", line 1348, in enum_child_on_thread
    self.schedule_work(lambda : self.enum_child_locally(text, cur_frame, execution_id, frame_kind))
  File "C:\Users\Bryan C\.vscode\extensions\ms-python.python-2018.1.0\pythonFiles\PythonTools\visualstudio_py_debugger.py", line 1319, in schedule_work
    self.unblock()
  File "C:\Users\Bryan C\.vscode\extensions\ms-python.python-2018.1.0\pythonFiles\PythonTools\visualstudio_py_debugger.py", line 1315, in unblock
    self._block_lock.release()
RuntimeError: release unlocked lock

EDIT: I'm getting another error by spamming F10 and F11 keys at the same time

Traceback (most recent call last):
  File "C:\Users\Bryan C\.vscode\extensions\ms-python.python-2018.1.0\pythonFiles\PythonTools\visualstudio_py_debugger.py", line 1729, in loop
    cmd()
  File "C:\Users\Bryan C\.vscode\extensions\ms-python.python-2018.1.0\pythonFiles\PythonTools\visualstudio_py_debugger.py", line 1762, in command_step_over
    assert thread._is_blocked
AssertionError

Try running any python code, and mash both F10 and F11 at the same time

@Kongsea
Copy link

Kongsea commented Mar 29, 2018

Has this debug been resolved?
I still encounter it sometimes when I press F10 quickly to debug my program.

@brettcannon
Copy link
Member

Does this happen for people when using our experimental debugger?

@brettcannon brettcannon added info-needed Issue requires more information from poster and removed needs PR labels Mar 29, 2018
@Kongsea
Copy link

Kongsea commented Mar 30, 2018

I use VSCode 1.21.1 and ms-python.python extension 2018.3.1 version.
I did not use the experimental debuger.
I encountered the error just when I just debug a program and I didn't watch any variables.

@valleygtc
Copy link

valleygtc commented Mar 30, 2018

I encontered this problem too.
It happened sometimes. I don't kown why. It frustrates me.
Can somebody help to fix it.

@brettcannon
Copy link
Member

The debugger team is focusing on the new experimental debugger, so verifying if this issue shows up there would be helpful.

@fab35
Copy link

fab35 commented Apr 19, 2018

The problems occurs (including in the latest versions) as soon as you debug hitting "FX" (where FX can be F5, F10...) keyboard too fast (or keeping the F10 down...). Annoying for debug...

@brettcannon brettcannon added needs upstream fix and removed info-needed Issue requires more information from poster labels May 7, 2018
@adocampo
Copy link

I did suffered this as well, removing evaluation expression that I wasn't evaluating at that moment solved the issue.

@osvalban
Copy link

osvalban commented Jun 4, 2018

I am running into this problem when I 'Step Over' quickly and have watched variables set in the debugger. It's kind of annoying because variables in the 'Variables' window get collapsed after they're modified by the code, hence why I started using the 'Watch' window. Is there a work-around to keep variables expanded under 'Variables'?

Environment:

  • Ubuntu 18.04 LTS
  • VS Code Version 1.23.1 @ Commit d0182c3417d225529c6d5ad24b7572815d0de9ac
  • Python VS Code extension version 2018.4.0 (2 May 2018)

@DonJayamanne
Copy link
Author

@fab35 @adocampo @osvalban
As suggested in a previous comment, have you managed to test this issue out with the new experimental Python debugger?

  • Go into .vscode/launch.json file in your project/workspace folder
  • Change the setting "type":"python" to "type":"pythonExperimental"

@osvalban
Copy link

osvalban commented Jun 4, 2018

@DonJayamanne the exception "RuntimeError: release unlocked lock" is gone, but now I see this stack trace thrown sporadically when hitting F10 repeatedly:

Traceback (most recent call last): File "/home/osvaldo/.vscode/extensions/ms-python.python-2018.4.0/pythonFiles/experimental/ptvsd/ptvsd/wrapper.py", line 796, in done fut.result() File "/home/osvaldo/.vscode/extensions/ms-python.python-2018.4.0/pythonFiles/experimental/ptvsd/ptvsd/futures.py", line 40, in result reraise(self._exc_info) File "/home/osvaldo/.vscode/extensions/ms-python.python-2018.4.0/pythonFiles/experimental/ptvsd/ptvsd/reraise3.py", line 8, in reraise raise exc_info[1].with_traceback(exc_info[2]) File "/home/osvaldo/.vscode/extensions/ms-python.python-2018.4.0/pythonFiles/experimental/ptvsd/ptvsd/futures.py", line 149, in callback x = next(it) File "/home/osvaldo/.vscode/extensions/ms-python.python-2018.4.0/pythonFiles/experimental/ptvsd/ptvsd/wrapper.py", line 1386, in on_evaluate pyd_tid, pyd_fid = self.frame_map.to_pydevd(vsc_fid) File "/home/osvaldo/.vscode/extensions/ms-python.python-2018.4.0/pythonFiles/experimental/ptvsd/ptvsd/wrapper.py", line 215, in to_pydevd return self._vscode_to_pydevd[vscode_id] KeyError: 1177

@hyphenrf
Copy link

hyphenrf commented Jun 5, 2018

Seconding @osvalban

I followed this thread to see if the issue was acknowledged or if it was just a problem on my side of things. So hitting F10 repeatedly did return the runtime error on the python debugger, but not the experimental. The experimental complained without kicking me out:

Traceback (most recent call last): File "/home/user/.vscode/extensions/ms-python.python-2018.4.0/pythonFiles/experimental/ptvsd/ptvsd/wrapper.py", line 796, in done fut.result() File "/home/user/.vscode/extensions/ms-python.python-2018.4.0/pythonFiles/experimental/ptvsd/ptvsd/futures.py", line 40, in result reraise(self._exc_info) File "/home/user/.vscode/extensions/ms-python.python-2018.4.0/pythonFiles/experimental/ptvsd/ptvsd/reraise3.py", line8, in reraise raise exc_info[1].with_traceback(exc_info[2]) File "/home/user/.vscode/extensions/ms-python.python-2018.4.0/pythonFiles/experimental/ptvsd/ptvsd/futures.py", line 149, in callback x = next(it) File "/home/user/.vscode/extensions/ms-python.python-2018.4.0/pythonFiles/experimental/ptvsd/ptvsd/wrapper.py", line 1386, in on_evaluate pyd_tid, pyd_fid = self.frame_map.to_pydevd(vsc_fid) File "/home/user/.vscode/extensions/ms-python.python-2018.4.0/pythonFiles/experimental/ptvsd/ptvsd/wrapper.py", line 215, in to_pydevd return self._vscode_to_pydevd[vscode_id] KeyError: 426

Info about my system:

  • OS: Debian 9(testing)
  • CPU: Intel Pentium N3540 (4) @ 2.665GHz
  • Memory: 3830MiB
  • VSCode:
    • Version 1.23.1
    • Commit d0182c3417d225529c6d5ad24b7572815d0de9ac
    • Date 2018-05-10T16:04:33.747Z
    • Shell 1.7.12
    • Renderer 58.0.3029.110
    • Node 7.9.0
    • Architecture x64
  • VSCode was installed using dpkg v1.19.0.5(amd64)

I will attach the code that produced the issue and all the relevant files in the next comment

here's a scrot
2018-06-05-162516_1314x315_scrot

@hyphenrf
Copy link

hyphenrf commented Jun 5, 2018

The script:

fil = open('rofi/mytheme.rasi','a+')

fil.seek(0)
lines=set(fil.readlines())
badlines=set()
for line in lines:
	if 'rgba' not in line:
		badlines.add(line)
lines=lines.difference(badlines)
newset=set()
for line in lines:
	percentage=line[line.rfind(',')+1:line.rfind('%')].strip()
	newpercentage=str(eval(percentage)/100)
	line=line.strip().replace(' ','').replace('%','')
	line=line.replace(percentage,newpercentage)
	newset.add(line)

fil.seek(0)
newbuffer=""
for line in fil:
	lineprop = line[:line.find(':')].strip()
	if 'rgba' in line:
		for item in newset:
			prop = item[:item.find(':')]
			print(prop)
			if prop == lineprop:
				line= "{} --> {}".format(line,item)
	newbuffer+=line

print(prop)
print(newbuffer)
fil.close()

and the file sample (the whole thing is a bit too large):

* {
    selected-normal-foreground:  rgba ( 129, 147, 150, 100 % );
    foreground:                  rgba ( 129, 147, 150, 100 % );
    normal-foreground:           @foreground;
    alternate-normal-background: rgba ( 0, 43, 55, 100 % );
    red:                         rgba ( 220, 50, 47, 100 % );
    selected-urgent-foreground:  rgba ( 218, 66, 129, 100 % );
    blue:                        rgba ( 38, 139, 210, 100 % );
    selected-normal-background:  rgba ( 0, 54, 66, 100 % );
    border-color:                @foreground;
    spacing:                     2;
}
#window {
    background-color: @background;
    border:           0;
    padding:          5;
}
textbox-prompt-colon {
    expand:     false;
    str:        ":";
    margin:     0px 0.3em 0em 0em ;
    text-color: @normal-foreground;
}

@DonJayamanne
Copy link
Author

@osvalban @ZyptosKid

  • Please could you download the latest development build of the Python extension and try this out once again. Thanks. The development build contains a number of fixes related to the debugger (to be released this week).
  • I've tested this at my end and it works as expected.

@DonJayamanne DonJayamanne added info-needed Issue requires more information from poster and removed needs verification labels Jun 5, 2018
@no-response no-response bot closed this as completed Jul 3, 2018
@no-response
Copy link

no-response bot commented Jul 3, 2018

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

@brettcannon brettcannon reopened this Jul 9, 2018
@DonJayamanne
Copy link
Author

@brettcannon any reason why this was reopened?

@lock lock bot locked as resolved and limited conversation to collaborators Aug 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-debugging bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests