How can I debug an internal error in the .NET Runtime?

后端 未结 5 459
滥情空心
滥情空心 2021-01-30 01:05

I am trying to debug some work that processes large files. The code itself works, but there are sporadic errors reported from the .NET Runtime itself. For context, the

5条回答
  •  無奈伤痛
    2021-01-30 01:36

    I usually invesitgate memory related problems with Valgrind and gdb.

    If you run your things on Windows, there are plenty of good alternatives such as verysleepy for callgrind as suggested here:
    Is there a good Valgrind substitute for Windows?

    If you really want to debug internal errors of the .NET runtime, you have the problem that there is no source for neither the class libraries nor the VM.

    Since you can't debug what you don't have, I suggest that (apart from decompiling the .NET framework libraries in question with ILSpy, and adding them to your project, which still doesn't cover the vm) you could use the mono runtime.
    There you have both the source of the class libraries as well as of the VM.
    Maybe your program works fine with mono, then your problem would be solved, at least as long as it's only a one-time-processing task.

    If not, there is an extensive FAQ on debugging, including GDB support
    http://www.mono-project.com/Debugging

    Miguel also has this post regarding valgrind support:
    http://tirania.org/blog/archive/2007/Jun-29.html

    In addition to that, if you let it run on Linux, you can also use strace, to see what's going on in the syscalls. If you don't have extensive winforms usage or WinAPI calls, .NET programs usually work fine on Linux (for problems regarding file system case-sensitivity, you can loopmount a case-insensitive file system and/or use MONO_IOMAP).

    If you're Windows centric person, this post says the closest thing Windows has is WinDbg's Logger.exe, but ltrace information is not as extensive.

    Mono sourcecode is available here:
    http://download.mono-project.com/sources/

    You are probably interested in the sources of the latest mono version
    http://download.mono-project.com/sources/mono/mono-3.0.3.tar.bz2

    If you need framework 4.5, you'll need mono 3, you can find precompiled packages here
    https://www.meebey.net/posts/mono_3.0_preview_debian_ubuntu_packages/

    If you want to make changes to the sourcecode, this is how to compile it:
    http://ubuntuforums.org/showthread.php?t=1591370

提交回复
热议问题