Bug 9365 - Breakpoints hit but no execution frame/callstack (Soft debugging/embedded Mono)
Summary: Breakpoints hit but no execution frame/callstack (Soft debugging/embedded Mono)
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: Debugger ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Zoltan Varga
URL:
Depends on:
Blocks:
 
Reported: 2013-01-07 22:01 UTC by Jeff Slutter
Modified: 2017-07-14 23:45 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Collection of source code files to reproduce (2.62 KB, application/gzip)
2013-01-07 22:01 UTC, Jeff Slutter
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Jeff Slutter 2013-01-07 22:01:05 UTC
Created attachment 3176 [details]
Collection of source code files to reproduce

I've recently updated our Mono from 2.10.9 to 3.0.2 via the Windows installer downloads available on the website. I now notice that in some places breakpoints that I use in MonoDevelop 3.06 (via soft debugging) hit, but show no execution frame or callstack (I can't do much except continue). I can not rule out that this happens in 2.10.9, as it is a very dodgy case that manifests itself differently, and can be resolved differently. I have done my best to try to track down exactly what causes the issue, but can hide the symptoms by making small changes that should not change anything. This happens in our internal code base, but I have created a reproduction case that also exhibits the bug - at least on my machine.

The following steps reproduce the issue on my machine. I have attached Host.tar.gz which contains the various source code and files. I am on a Windows 7 x64 machine, building using Visual Studio 2008 (for C++ code), Mono 3.0.2, and MonoDevelop 3.06.

1) Download and install Mono 3.0.2 and MonoDevelop 3.0.6 (I used the default install folders for both)
2) Create mono.lib from mono-2.0.dll via "lib /nologo /def:mono.def /out:mono.lib /machine:x86"
3) Unzip Host.tar.gz and put mono.lib and mono-2.0.dll in with the unzipped files. The C++ project is a Visual Studio 2008 project, configured to build with Mono installed to: "C:\Program Files (x86)\Mono-3.0.2\" (Adjust include directories as needed)
4) Open Host.sln into VS2008 and build. Debug and Release configurations exhibit the bug for me, but I am able to get a callstack sometimes in Debug, not in Release.
5) With Mono's bin folder in your path, run the Build.bat to compile the BuildAsm.dll assembly
6) Open BuildAsm.sln into MonoDevelop, with the environment variable "MONODEVELOP_SDB_TEST=1" to enable the 'secret' Soft Debugger in MonoDevelop - this bug happens with it, and my own Soft Debugger plugin for MonoDevelop.
7) Within MonoDevelop, with the BaseAsm.sln opened, open TestApplication.cs from the project list and put a breakpoint on line 9 (the one with Console.WriteLine).
8) In MonoDevelop, Run -> Run With -> Custom Command Mono Soft Debugger. Leaving the settings as-is click the Listen button.
9) Double-click the Host.exe in Explorer, built in step #4
10) The Host.exe is configured to call StaticMain() three times. What I experience is that the breakpoint will always get hit and the process will stop in MonoDevelop. However, most of the time I do not get a callstack or can do much other than continue. In a debug build of Host.exe the second call to StaticMain will hit and have a callstack for me. In a release build of Host.exe I can't get it to give me a callstack.
11) Playing around in C++ I can sometimes get it to hit, but it isn't consistent across my different projects. Playing around in C# I can sometimes get it to hit, but it isn't consistent.
12) It appears to not happen with Mono 2.10.9.
13) Another thing I noticed is that when you hit a breakpoint, without a callstack, if you do: "Run -> Show Current Execution Line" MonoDevelop will report the following

System.NullReferenceException: Object reference not set to an instance of an object.
   at MonoDevelop.Debugger.DebuggingService.ShowCurrentExecutionLine()
   at MonoDevelop.Debugger.ShowCurrentExecutionLineCommand.Run()
   at MonoDevelop.Components.Commands.CommandHandler.Run(Object dataItem)
   at MonoDevelop.Components.Commands.CommandHandler.InternalRun(Object dataItem)
   at MonoDevelop.Components.Commands.CommandManager.DefaultDispatchCommand(ActionCommand cmd, CommandInfo info, Object dataItem, Object target, CommandSource source)
   at MonoDevelop.Components.Commands.CommandManager.DispatchCommand(Object commandId, Object dataItem, Object initialTarget, CommandSource source)

14) I can reproduce this many different ways with different forms of C++ code embedding Mono. This is the the simplest form of the code.

In my experimentation I have suppressed the bug in various ways, none of which make any sense. For example, in C++, just moving the C++ code to be within a function kept the bug from happening (this is exhibited in the Debug build of the attached source code of this bug report). In one of my projects, I was able to get a callstack by having the C# function call to another C# function - that one I would be able to put breakpoints in. But in another project, such a 'fix' did not do anything.
Comment 1 bfhben 2013-04-02 09:56:13 UTC
I am getting this same behavior in my embedded mono instance, a breakpoint will be hit, but I am never getting a call stack. I also do not get any indication of which breakpoint was hit, or any locals or watches displayed. My case is a little more complex, I'm compiling in Visual Studio, generating mdbs and also modifying the P/Invoke entry points with Mono.Cecil and then attempting to debug with Xamarin Studio with the soft debugger. I am fairly certain that my debug symbols are fine as I get a valid call stack in exceptions.
Comment 2 bfhben 2013-04-06 09:29:00 UTC
This has been fixed for me by https://github.com/mono/mono/commit/66acbc75aaaf8874a82980ad1f8ea011557d1317
Comment 3 Rodrigo Kumpera 2017-07-14 23:45:14 UTC
Marking as fixed per reporter.