2012-11-24 42 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

相關問題