c# - 错误 : SIGSEGV when running application on Mono

标签 c# mono debian segmentation-fault raspberry-pi

经过几个小时的尝试,我决定是时候发帖了。

我有一个非常基础的 C# Windows 窗体应用程序,我可以在 Windows 上编译和运行它。不过,整个项目都是为在 Pi 上工作而设计的,所以我将项目移到了 Pi 上并进行了编译。经过几个小时的最终编译(发现我必须引用 MySql.Data.dll 文件),它编译没有错误!

然后我跑了

Mono Administration.exe

我遇到了这个巨大的错误,我在网上找不到什么:

pi@raspberrypi /media/WAYNEIO/pi/ProjectNibiru/ProjectNibiru $ mono Administration.exe
Stacktrace:

  at System.Drawing.Font.CreateFont (string,single,System.Drawing.FontStyle,System.Drawing.GraphicsUnit,byte,bool) <0x00143>
  at System.Drawing.Font..ctor (string,single,System.Drawing.FontStyle,System.Drawing.GraphicsUnit,byte,bool) <0x0007f>
  at System.Drawing.Font..ctor (string,single,string) <0x00057>
  at (wrapper remoting-invoke-with-check) System.Drawing.Font..ctor (string,single,string) <0xffffffff>
  at System.Drawing.SystemFonts.get_DefaultFont () <0x00073>
  at System.Windows.Forms.Theme..ctor () <0x0002f>
  at System.Windows.Forms.ThemeWin32Classic..ctor () <0x00013>
  at System.Windows.Forms.ThemeVisualStyles..ctor () <0x00013>
  at System.Windows.Forms.ThemeEngine..cctor () <0x0007f>
  at (wrapper runtime-invoke) object.runtime_invoke_void (object,intptr,intptr,intptr) <0xffffffff>
  at System.Windows.Forms.X11DesktopColors..cctor () <0x000bb>
  at (wrapper runtime-invoke) object.runtime_invoke_void (object,intptr,intptr,intptr) <0xffffffff>
  at System.Windows.Forms.XplatUIX11..ctor () <0x001af>
  at System.Windows.Forms.XplatUIX11.GetInstance () <0x00073>
  at System.Windows.Forms.XplatUI..cctor () <0x00157>
  at (wrapper runtime-invoke) object.runtime_invoke_void (object,intptr,intptr,intptr) <0xffffffff>
  at System.Windows.Forms.Application.EnableVisualStyles () <0x00023>
  at ProjectNibiru.Program.Main () <0x0000b>
  at (wrapper runtime-invoke) object.runtime_invoke_void (object,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:


Debug info from gdb:

Cannot access memory at address 0x0
Cannot access memory at address 0x0
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
[New Thread 0x4093b460 (LWP 2224)]
0x40085f30 in read () from /lib/arm-linux-gnueabihf/libpthread.so.0
  Id   Target Id         Frame
  2    Thread 0x4093b460 (LWP 2224) "mono" 0x40084d84 in sem_wait@@GLIBC_2.4 () from /lib/arm-linux-gnueabihf/libpthread.so.0
* 1    Thread 0x400cd000 (LWP 2223) "mono" 0x40085f30 in read () from /lib/arm-linux-gnueabihf/libpthread.so.0

Thread 2 (Thread 0x4093b460 (LWP 2224)):
#0  0x40084d84 in sem_wait@@GLIBC_2.4 () from /lib/arm-linux-gnueabihf/libpthread.so.0
#1  0x00195a40 in mono_sem_wait ()
#2  0x000ea384 in ?? ()
#3  0x000ea384 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 1 (Thread 0x400cd000 (LWP 2223)):
#0  0x40085f30 in read () from /lib/arm-linux-gnueabihf/libpthread.so.0
#1  0x40085770 in __pthread_enable_asynccancel () from /lib/arm-linux-gnueabihf/libpthread.so.0
#2  0x00000000 in ?? ()

=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================

Aborted

任何人都可以就为什么会出现这种情况以及如何解决问题提供建议吗?

注意事项;无论我是用“Xbuild”还是“dmcs”编译,或者它是在 Windows 中编译并复制,都会发生这种情况。编译一个基本的 hello world 脚本也能正常工作,所以它可能与 Windows.Forms 或 MySql.Data 有关。 PI 也在运行 Debian。

最佳答案

在更仔细地阅读您的问题后,我发现它是特定的段错误,说 无法访问地址 0x0 处的内存,所以它可能访问了由于错误而返回的指针。例如,程序请求类似给我字体 X 的句柄 并且函数出于某种原因返回空指针。您可以尝试一些可能的解决方案:

  • 从源代码编译单声道,在失败的函数附近打断点并在观察变量值的同时步进,也许他们会告诉你一些事情;
  • 如果您还没有安装mono-complete 包;
  • 尝试安装此应用程序使用的字体(尽管可以从堆栈跟踪中看出该应用程序正在寻找默认字体;))

您也可以查看源代码。有趣的部分可能是:

旧答案:

这里没有太多细节,但每当我遇到 Windows 窗体应用程序的段错误时,我的第一个猜测是某些 UI 控件是从不同的 UI 线程访问的。很多时候,相同的应用程序不会在 Windows 窗体的 MS 实现上崩溃,但是这种方法是不正确的。也许这是你的问题?

错误的其他可能原因列表包括 Mono 错误(给我们版本号)或第三方 native 库中的某种错误(如果使用)。对于后一种情况,确实值得使用 GDB(之前使用一些调试选项编译这些库,例如 g3)。为了不被垃圾收集器发送的信号打扰记得发出

handle SIGXCPU SIG33 SIG35 SIGPWR nostop noprint

在 GDB session 期间。

关于c# - 错误 : SIGSEGV when running application on Mono,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13540478/

相关文章:

c# - 如何让不同的解决方案引用一个 resx 文件?

mono - 在 CentOS7 或 RHEL 7.2 上安装特定的 Mono 版本

mono - 无效的 IL 代码 IL_0038 : newobj in MonoTouch

linux - 如何使用 dpkg 卸载最后安装的应用程序(最近安装的)?

linux - 如何检测我的网络摄像头支持哪种像素格式?

c# - 谷歌货币API(按日期显示的结果)

c# - 未经证实 确保结合接口(interface)引用另一个属性

c# - UserManager 错误 - 在上一个异步操作完成之前在此上下文中启动了第二个操作

.net - 构建发布时 MonoTouch 中的 WebClient 编码问题

linux - 为什么我的程序存储器写入速度比读取速度快?