2012-11-24 44 views
3

经过数小时的努力,我决定是时候发布了。错误:在Mono上运行应用程序时出现SIGSEGV问题

我有一个很基本的C#Windows窗体应用程序,我可以在Windows上编译并运行它。整个项目的目的是为了在Pi上工作,所以我将项目移交给它并编译。几个小时后终于得到它编译(发现我不得不引用MySql.Data.dll文件)编译没有错误!

但后来我跑

Mono Administration.exe 

,我得到了这个巨大的错误,我能找到关于网上很少:

[email protected] /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 [email protected]@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 [email protected]@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。

+1

更好的问题可能是,我如何在Linux – Wayneio

+0

你可以用'单--trace'得到发生了什么更好的主意调试SIGSEGV以下发现

答案。对于大多数细节,您需要带有单声道支持的'gdb'和带有调试信息的单声道库。 – Jester

回答

1

答案是更新到单声道的最新版本,并确保它在soft-float debian上运行。此线程http://www.raspberrypi.org/phpBB3/viewtopic.php?f=66&t=11634

+0

几年前Raspberry Pi图像曾经是armel(软浮动),但现在看起来所有现成的Raspberry Pi图像都是armhf(硬件浮点) 。您是否知道仍在维护Raspberry Pi的良好软浮动图像,或者您是否听说过此SIGSEGV的其他任何解决方案? –

2

更仔细地阅读你的问题后,我可以看到它是特定的段错误说Cannot access memory at address 0x0,所以它可能访问由于错误返回的指针。例如程序要求类似的东西让我处理字体X和函数返回空指针出于某种原因。一些可能的解决方案,你可以尝试:从来源

  • 编译单声道,使出现故障的功能,并一步接近一个断点,同时观察变量值,也许他们会告诉你一些事情;
  • 安装mono-complete包如果你还没有;
  • 尝试安装此应用程序使用的字体(虽然可以从堆栈跟踪告诉应用程序正在寻找的默认字体;))

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

老答案:

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

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

handle SIGXCPU SIG33 SIG35 SIGPWR nostop noprint 

+0

谢谢,很好的回复。我如何确保所有的UI控件都运行在同一个线程上?至于第三方本地库,我也尝试过使用基本的Windows窗体应用程序,但仍然有错误。单声道版本是Mono JIT编译器版本2.10.8.1(Debian 2.10.8.1-5)。错误提及系统字体 – Wayneio

+0

@Wayneio:请参阅编辑答案。 –

+1

@Wayneio至于“如何从同一个线程运行所有的UI控件”:如果你想从另一个线程操纵UI,使用Control.Invoke()和适当的委托函数。这会将代表移交给拥有您试图影响的控件的线程,并在其上运行它:完全是您在寻找的内容。有点像他们为此类情况所做的:D – Mark

相关问题