Issue 24160: Pdb sometimes raises exception when trying to remove a breakpoint defined in a different debugger session
Created on 2015-05-10 16:30 by ppperry, last changed 2022-04-11 14:58 by admin. This issue is now closed.
Messages (12)
msg242861 - (view)
Author: (ppperry)
Date: 2015-05-10 16:30
Date: 2015-05-15 07:44
Date: 2020-08-28 18:39
Date: 2020-11-05 11:39
Date: 2021-04-02 16:15
Date: 2021-04-02 16:22
Date: 2021-04-04 12:39
Date: 2021-04-04 12:40
Date: 2021-04-04 12:46
Date: 2021-04-04 13:37
Date: 2021-04-04 15:04
Date: 2021-04-04 15:05
>>> import pdb, test3
>>> pdb.run("reload(test3)")
> <string>(1)<module>()
(Pdb) s
--Call--
> c:\documents and settings\perry\desktop\coding_projects\python\test3.py(1)<module>()
-> foo = 7789
(Pdb) b 2
Breakpoint 1 at c:\documents and settings\perry\desktop\coding_projects\python\test3.py:2
(Pdb) c
> c:\documents and settings\perry\desktop\coding_projects\python\test3.py(2)<module>()
-> bar = 7788
(Pdb) c
>>> pdb.run("reload(test3)")
> <string>(1)<module>()
(Pdb) s
--Call--
> c:\documents and settings\perry\desktop\coding_projects\python\test3.py(1)<module>()
-> foo = 7789
(Pdb) b 1
Breakpoint 2 at c:\documents and settings\perry\desktop\coding_projects\python\test3.py:1
(Pdb) cl 1
Traceback (most recent call last):
File "<pyshell#592>", line 1, in <module>
pdb.run("reload(test3)")
File "C:\Python27\lib\pdb.py", line 1238, in run
Pdb().run(statement, globals, locals)
File "C:\Python27\lib\bdb.py", line 400, in run
exec cmd in globals, locals
File "<string>", line 1, in <module>
File "test3.py", line 1, in <module>
foo = 7789
File "C:\Python27\lib\bdb.py", line 51, in trace_dispatch
return self.dispatch_call(frame, arg)
File "C:\Python27\lib\bdb.py", line 80, in dispatch_call
self.user_call(frame, arg)
File "C:\Python27\lib\pdb.py", line 148, in user_call
self.interaction(frame, None)
File "C:\Python27\lib\pdb.py", line 210, in interaction
self.cmdloop()
File "C:\Python27\lib\cmd.py", line 142, in cmdloop
stop = self.onecmd(line)
File "C:\Python27\lib\pdb.py", line 279, in onecmd
return cmd.Cmd.onecmd(self, line)
File "C:\Python27\lib\cmd.py", line 221, in onecmd
return func(arg)
File "C:\Python27\lib\pdb.py", line 622, in do_clear
err = self.clear_bpbynumber(i)
File "C:\Python27\lib\bdb.py", line 297, in clear_bpbynumber
self._prune_breaks(bp.file, bp.line)
File "C:\Python27\lib\bdb.py", line 268, in _prune_breaks
self.breaks[filename].remove(lineno)
ValueError: list.remove(x): x not in list
Running the same code without first defining a breakpoint (in the second debugger instance) raises KeyError: [path to test3.py] on the same lien
The contents of test3.py are irrelevant, as long as it is at least two lines long and syntactically correct.
msg243255 - (view)
Author: Xavier de Gaye (xdegaye) *
Date: 2015-05-15 07:44
I can reproduce the problem on python 3.5 with test3.py as:
def foo():
foo = 7789
bar = 7788
$ python
Python 3.5.0a4+ (default:8bac00eadfda, May 6 2015, 17:40:12)
[GCC 4.9.2 20150304 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pdb, test3
>>> pdb.run('test3.foo()')
> <string>(1)<module>()
(Pdb) step
--Call--
> /home/xavier/tmp/test3.py(1)foo()
-> def foo():
(Pdb) break 3
Breakpoint 1 at /home/xavier/tmp/test3.py:3
(Pdb) continue
> /home/xavier/tmp/test3.py(3)foo()
-> bar = 7788
(Pdb) continue
>>> pdb.run('test3.foo()')
> <string>(1)<module>()
(Pdb) step
--Call--
> /home/xavier/tmp/test3.py(1)foo()
-> def foo():
(Pdb) break # 'break' lists no breakpoints.
(Pdb) break 2
Breakpoint 2 at /home/xavier/tmp/test3.py:2
(Pdb) break # 'break' lists two breakpoints.
Num Type Disp Enb Where
1 breakpoint keep yes at /home/xavier/tmp/test3.py:3
breakpoint already hit 1 time
2 breakpoint keep yes at /home/xavier/tmp/test3.py:2
(Pdb)
On the second debugging session, the first 'break' command lists no
breakpoints, while the second 'break' command lists two breakpoints including
the one set in the first debugging session.
The problem is that the 'breaks' attribute of the Pdb instance is inconsistent
with the 'bplist' and 'bpbynumber' class attributes of the bdb.Breakpoint
class when the second debugging session is started.
msg376044 - (view)
Author: Irit Katriel (iritkatriel) *
Date: 2020-08-28 18:39
I've submitted a patch that I believe fixes this problem. It adds in Bdb's __init__ a call to a function that reads the Breakpoint's 'bplist' and 'bpbynumber' class attributes and populates the new instances' 'breaks' dict.msg380406 - (view) Author: Tal Einat (taleinat) *
Date: 2020-11-05 11:39
Irit, I like the approach of your PR for an immediate fix, that we could consider backporting. In the long term, ISTM that we should refactor to store the breakpoints with only a single source of truth, and avoid the duplication between Breakpoint.bplist, Breakpoint.bpbynumber and Bdb.breaks.msg390077 - (view) Author: Guido van Rossum (gvanrossum) *
Date: 2021-04-02 16:15
New changeset ad442a674ca443feec43a88a2d3671784712e550 by Irit Katriel in branch 'master': bpo-24160: Fix breakpoints persistence across multiple pdb sessions (GH-21989) https://github.com/python/cpython/commit/ad442a674ca443feec43a88a2d3671784712e550msg390079 - (view) Author: Irit Katriel (iritkatriel) *
Date: 2021-04-02 16:22
Thanks!msg390186 - (view) Author: Pablo Galindo Salgado (pablogsal) *
Date: 2021-04-04 12:39
Unfortunately PR21989 has breaking the refleaks buildbots. Example: https://buildbot.python.org/all/#/builders/320/builds/226/steps/5/logs/stdio To reproduce: ❯ ./python -m test test_pdb -R 3:3 0:00:00 load avg: 1.40 Run tests sequentially 0:00:00 load avg: 1.40 [1/1] test_pdb beginning 6 repetitions 123456 .test test_pdb failed -- Traceback (most recent call last): File "/home/pablogsal/github/cpython/Lib/doctest.py", line 2205, in runTest raise self.failureException(self.format_failure(new.getvalue())) AssertionError: Failed doctest test for test.test_pdb.test_pdb_breakpoints_preserved_across_interactive_sessions File "/home/pablogsal/github/cpython/Lib/test/test_pdb.py", line 326, in test_pdb_breakpoints_preserved_across_interactive_sessions ---------------------------------------------------------------------- File "/home/pablogsal/github/cpython/Lib/test/test_pdb.py", line 330, in test.test_pdb.test_pdb_breakpoints_preserved_across_interactive_sessions Failed example: with PdbTestInput([ # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE 'import test.test_pdb', 'break test.test_pdb.do_something', 'break test.test_pdb.do_nothing', 'break', 'continue', ]): pdb.run('print()') Expected: > <string>(1)<module>() (Pdb) import test.test_pdb (Pdb) break test.test_pdb.do_something Breakpoint 1 at ...test_pdb.py:... (Pdb) break test.test_pdb.do_nothing Breakpoint 2 at ...test_pdb.py:... (Pdb) break Num Type Disp Enb Where 1 breakpoint keep yes at ...test_pdb.py:... 2 breakpoint keep yes at ...test_pdb.py:... (Pdb) continue Got: > <string>(1)<module>()->None (Pdb) import test.test_pdb (Pdb) break test.test_pdb.do_something Breakpoint 1 at /home/pablogsal/github/cpython/Lib/test/test_pdb.py:396 (Pdb) break test.test_pdb.do_nothing Breakpoint 2 at /home/pablogsal/github/cpython/Lib/test/test_pdb.py:393 (Pdb) break Num Type Disp Enb Where 1 breakpoint keep yes at /home/pablogsal/github/cpython/Lib/test/test_pdb.py:396 2 breakpoint keep yes at /home/pablogsal/github/cpython/Lib/test/test_pdb.py:393 (Pdb) continue <BLANKLINE> ---------------------------------------------------------------------- File "/home/pablogsal/github/cpython/Lib/test/test_pdb.py", line 350, in test.test_pdb.test_pdb_breakpoints_preserved_across_interactive_sessions Failed example: with PdbTestInput([ # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE 'break', 'break pdb.find_function', 'break', 'clear 1', 'continue', ]): pdb.run('print()') Expected: > <string>(1)<module>() (Pdb) break Num Type Disp Enb Where 2 breakpoint keep yes at ...test_pdb.py:... 3 breakpoint keep yes at ...pdb.py:... (Pdb) clear 2 Deleted breakpoint 2 at ...test_pdb.py:... (Pdb) clear 3 Deleted breakpoint 3 at ...pdb.py:... (Pdb) continue Got: > <string>(1)<module>()->None (Pdb) break Num Type Disp Enb Where 2 breakpoint keep yes at /home/pablogsal/github/cpython/Lib/test/test_pdb.py:393 3 breakpoint keep yes at /home/pablogsal/github/cpython/Lib/pdb.py:94 (Pdb) clear 2 Deleted breakpoint 2 at /home/pablogsal/github/cpython/Lib/test/test_pdb.py:393 (Pdb) clear 3 Deleted breakpoint 3 at /home/pablogsal/github/cpython/Lib/pdb.py:94 (Pdb) continue <BLANKLINE> test_pdb failed == Tests result: FAILURE == 1 test failed: test_pdb Total duration: 2.8 sec Tests result: FAILUREmsg390187 - (view) Author: Pablo Galindo Salgado (pablogsal) *
Date: 2021-04-04 12:40
Per our buildbot policy (https://discuss.python.org/t/policy-to-revert-commits-on-buildbot-failure/404) we will need to revert this in 24 hours if is not fixed to avoid masking future errors.msg390188 - (view) Author: Irit Katriel (iritkatriel) *
Date: 2021-04-04 12:46
Thanks, I'm looking.msg390189 - (view) Author: Irit Katriel (iritkatriel) *
Date: 2021-04-04 13:37
With the patch: PS C:\Users\User\src\cpython-dev> ./python -m test test_pdb -R 3:3 Running Debug|x64 interpreter... 0:00:00 Run tests sequentially 0:00:00 [1/1] test_pdb beginning 6 repetitions 123456 ...... == Tests result: SUCCESS == 1 test OK. Total duration: 34.2 sec Tests result: SUCCESSmsg390192 - (view) Author: Pablo Galindo Salgado (pablogsal) *
Date: 2021-04-04 15:04
New changeset aadd4e10fda87b64ea527667238503da326a06e7 by Irit Katriel in branch 'master': bpo-24160: Fix test_pdb refleaks failure (GH-25182) https://github.com/python/cpython/commit/aadd4e10fda87b64ea527667238503da326a06e7msg390193 - (view) Author: Pablo Galindo Salgado (pablogsal) *
Date: 2021-04-04 15:05
PR 25182 fixes the issue, so I am closing this again. Thanks for the quick fix, Irit!
History
Date
User
Action
Args
2022-04-11 14:58:16adminsetgithub: 68348
2021-04-04 15:05:35pablogsalsetstatus: open -> closed
resolution: fixed
messages: + msg390193
pull_requests: + pull_request23924 2021-04-04 12:46:04iritkatrielsetmessages: + msg390188 2021-04-04 12:40:04pablogsalsetmessages: + msg390187 2021-04-04 12:39:07pablogsalsetstatus: closed -> open
resolution: fixed
messages: + msg390079
messages: + msg390077
2020-11-05 11:39:24taleinatsetnosy: + taleinat
messages: + msg380406
2020-09-19 19:01:40georg.brandlsetnosy: - georg.brandl
2020-08-28 23:03:23iritkatrielsetversions: + Python 3.10, - Python 2.7, Python 3.5
title: Pdb sometimes crashes when trying to remove a breakpoint defined in a different debugger sessoon -> Pdb sometimes raises exception when trying to remove a breakpoint defined in a different debugger session 2020-08-28 18:40:00iritkatrielsetmessages: + msg376044 2020-08-28 18:34:02iritkatrielsetkeywords: + patch
nosy: + iritkatriel
2015-05-15 07:44:29xdegayesetnosy: + xdegaye
resolution: fixed
messages: + msg390193
stage: patch review -> resolved
2021-04-04 15:04:59pablogsalsetmessages: + msg390192 2021-04-04 13:37:18iritkatrielsetmessages: + msg390189 2021-04-04 13:35:58iritkatrielsetstage: resolved -> patch reviewpull_requests: + pull_request23924 2021-04-04 12:46:04iritkatrielsetmessages: + msg390188 2021-04-04 12:40:04pablogsalsetmessages: + msg390187 2021-04-04 12:39:07pablogsalsetstatus: closed -> open
nosy:
+ pablogsal
messages:
+ msg390186
resolution: fixed -> (no value)
2021-04-02 16:22:47iritkatriellinkissue33757 superseder 2021-04-02 16:22:06iritkatrielsetstatus: open -> closedresolution: fixed
messages: + msg390079
stage: patch review -> resolved
2021-04-02 16:15:36gvanrossumsetnosy: + gvanrossummessages: + msg390077
2020-11-05 11:39:24taleinatsetnosy: + taleinat
messages: + msg380406
2020-09-19 19:01:40georg.brandlsetnosy: - georg.brandl
2020-08-28 23:03:23iritkatrielsetversions: + Python 3.10, - Python 2.7, Python 3.5
title: Pdb sometimes crashes when trying to remove a breakpoint defined in a different debugger sessoon -> Pdb sometimes raises exception when trying to remove a breakpoint defined in a different debugger session 2020-08-28 18:40:00iritkatrielsetmessages: + msg376044 2020-08-28 18:34:02iritkatrielsetkeywords: + patch
nosy: + iritkatriel
pull_requests:
+ pull_request21098
stage: patch review
2015-05-15 07:44:29xdegayesetnosy: + xdegaye
messages:
+ msg243255
versions:
+ Python 3.5