-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
Description
Calling System.Diagnostics.Debugger.Break() should cause the debugger to stop by triggering a user breakpoint at the location where the function was called.
Reproduction Steps
Call Debugger.Break() in small C# console app
Expected behavior
Debugger should stop as if it hit a breakpoint when Debugger.Break() is called
Actual behavior
A System.Runtime.InteropServices.COMException is triggered
Regression?
This is a regression in .NET 9 main builds
Known Workarounds
N/A
Configuration
All OS's and Architectures
Other information
DebuggerUserBreakpoint::IsFrameInDebuggerNamespace is checking the Namespace and the Class by converting a UTF8 string into a Unicode string:
runtime/src/coreclr/debug/ee/controller.cpp
Lines 8332 to 8333 in bd84a96
| MAKE_WIDEPTR_FROMUTF8(wszNamespace, szNamespace); // throw | |
| MAKE_WIDEPTR_FROMUTF8(wszClassName, szClassName); |
The MAKE_WIDEPTR_FROMUTF8 macro uses ConvertUtf8_Unicode which was re-written in #96099. The original implementation seemed to accept zero-length strings, but the new one will now throw an exception. I am not sure if ConvertUtf8_Unicode intends to support zero length strings (if yes we should consider updating the function). We can work around this particular issue by avoiding converting zero-length strings in DebuggerUserBreakpoint::IsFrameInDebuggerNamespace.