This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ctypes catches BreakPoint error on windows 32
Type: behavior Stage:
Components: Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Sacha.Brants-Menard, amaury.forgeotdarc, ishimoto, kristjan.jonsson, meador.inge, pjlbyrne, python-dev, theller
Priority: normal Keywords: patch

Created on 2010-11-03 08:20 by kristjan.jonsson, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
ctypes.diff kristjan.jonsson, 2013-03-18 21:47
Messages (6)
msg120312 - (view) Author: Kristján Valur Jónsson (kristjan.jonsson) * (Python committer) Date: 2010-11-03 08:20
import ctypes
ctypes.windll.kernel32.DebugBreak()
This used to be a handy way to attach a debugger to a running program, by way of JIT debugging.  Now ctypes catches and handles this exception so a debugger is never invoked.  Bummer.
msg124683 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-12-26 23:00
With a release build of python, I have a similar behavior on both 2.5 and 2.7; the messages are different though:
2.5: WindowsError: [Error -2147483645] One or more arguments are invalid.
2.7: WindowsError: exception: breakpoint encountered

And with both versions, a debug build (python_d.exe) triggers the JIT debugger. What do you get exactly?
msg124700 - (view) Author: Kristján Valur Jónsson (kristjan.jonsson) * (Python committer) Date: 2010-12-27 02:42
I _think_ that in our old 2.5 python (which had a backported ctypes from 2.6 to support 64 bits) we always got the JIT debugger i.e. with _ctypes.pyd and _ctypes_d.pyd.

This api, "DebugBreak" always invokes the JIT debugger, however the program was compiled (_NDEBUG, DEBUG, or not).
This is done by raising the breakpoint exception and apparently _ctypes.pyd is catching that exception and handling it, but only in release mode, while I think it shouldn't do.
msg155450 - (view) Author: Pat Byrne (pjlbyrne) Date: 2012-03-12 13:38
This affects me too.
msg184533 - (view) Author: Kristján Valur Jónsson (kristjan.jonsson) * (Python committer) Date: 2013-03-18 21:47
Here is a suggested patch.  SEH will now not catch BREAKPOINT exceptions.
msg184700 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-03-19 23:00
New changeset b2e8392a8f77 by Kristján Valur Jónsson in branch '2.7':
Issue #10296 : Don't handle BreakPoint exceptions using
http://hg.python.org/cpython/rev/b2e8392a8f77

New changeset bc5778b488c1 by Kristján Valur Jónsson in branch '3.2':
Issue #10296 : Don't handle BreakPoint exceptions using
http://hg.python.org/cpython/rev/bc5778b488c1

New changeset 4c7eb717ea88 by Kristján Valur Jónsson in branch '3.3':
#10296: Merge to 3.3
http://hg.python.org/cpython/rev/4c7eb717ea88

New changeset 4f3fbdb4d748 by Kristján Valur Jónsson in branch 'default':
Issue #10296: Merge to default
http://hg.python.org/cpython/rev/4f3fbdb4d748
History
Date User Action Args
2022-04-11 14:57:08adminsetgithub: 54505
2013-03-20 03:05:05kristjan.jonssonsetstatus: open -> closed
resolution: fixed
2013-03-19 23:00:52python-devsetnosy: + python-dev
messages: + msg184700
2013-03-18 21:47:41kristjan.jonssonsetfiles: + ctypes.diff
keywords: + patch
messages: + msg184533
2012-07-26 14:51:58pitrousetnosy: + meador.inge
2012-07-26 14:26:13ishimotosetnosy: + ishimoto
2012-03-12 13:38:30pjlbyrnesetnosy: + pjlbyrne
messages: + msg155450
2011-12-22 12:02:37Sacha.Brants-Menardsetnosy: + Sacha.Brants-Menard
2010-12-27 02:42:37kristjan.jonssonsetnosy: theller, amaury.forgeotdarc, kristjan.jonsson
messages: + msg124700
2010-12-26 23:00:59amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg124683
2010-12-22 22:06:59terry.reedysetnosy: + theller
2010-11-03 08:20:30kristjan.jonssoncreate