Skip to content

System.Diagnostics.Debugger.Break() causes System.Runtime.InteropServices.COMException #97261

Closed

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:

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions