[Mono-bugs] [Bug 79116][Nor] New - SIGSEGV using win32 FormatMessage API

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sun Aug 20 05:01:23 EDT 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by gert.driesen at pandora.be.

http://bugzilla.ximian.com/show_bug.cgi?id=79116

--- shadow/79116	2006-08-20 05:01:23.000000000 -0400
+++ shadow/79116.tmp.757	2006-08-20 05:01:23.000000000 -0400
@@ -0,0 +1,202 @@
+Bug#: 79116
+Product: Mono: Runtime
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: interop
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: gert.driesen at pandora.be               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: SIGSEGV using win32 FormatMessage API
+
+I'm currently using the Win32 FormatMessage API to lookup messages from 
+unmanaged resource DLLs, however there appear to be some issues with this.
+
+First of all, the number of bytes returned by the FormatMessage API is 
+different when executed from Mono, and is not consistent.
+
+When executing the exact same call (see attached repro) numerous times I 
+get results ranging from 6 to 14 bytes, while MS.NET always returns 10 
+bytes.
+
+Also when running it on Mono, I occasionally get a 234 win32 error, which 
+means that more data is available. However, I'm explicitly letting the 
+FormatMessage API allocate the buffer, so we should never get a 234 (and 
+I actually don't get it when running on MS.NET).
+
+Eventually, I always get a SIGSEGV:
+
+To reproduce:
+
+1. Extract the attached zip file.
+2. Compile test.cs.
+3. Run test.exe on Windows (as it uses win32 API calls).
+
+The attached zip file contains:
+
+- test.cs: C# source for reproducing error
+- EventLogMessages.dll: unmanaged resource DLL.
+
+Note: I've only tested using the Mono 1.1.6 release, as I have problems 
+building Mono from SVN on Windows.
+
+Expected result:
+
+10
+10
+drieseng
+
+(1000 times, as I execute the FormatMessage API in a loop)
+
+The first number is the number of bytes read, while the second number is 
+the length of the message (after converting from ptr to string).
+
+Actual result:
+
+14
+8
+drieseng
+win32 error [234]: Some sort of w32 error occurred: 234
+
+6
+9
+drieseng
+
+18
+8
+drieseng
+6
+9
+drieseng
+
+win32 error [234]: Some sort of w32 error occurred: 234
+
+6
+9
+drieseng
+
+22
+8
+drieseng
+6
+9
+drieseng
+
+6
+9
+drieseng
+
+6
+9
+drieseng
+
+6
+9
+drieseng
+
+6
+9
+drieseng
+
+6
+9
+drieseng
+
+6
+9
+drieseng
+
+18
+8
+drieseng
+9
+8
+drieseng
+18
+8
+drieseng
+6
+9
+drieseng
+
+6
+9
+drieseng
+
+9
+8
+drieseng
+18
+8
+drieseng
+9
+8
+drieseng
+18
+8
+drieseng
+6
+9
+drieseng
+
+6
+9
+drieseng
+
+6
+9
+drieseng
+
+6
+9
+drieseng
+
+6
+9
+drieseng
+
+6
+9
+drieseng
+
+6
+9
+drieseng
+
+6
+9
+drieseng
+
+
+=================================================================
+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.
+=================================================================
+
+Stacktrace:
+
+  at (wrapper managed-to-native) 
+ConsoleApplication1.Program.FormatMessage 
+(ConsoleApplication1.Program/FormatMessageFlags,intptr,uint,int,intptr&,in
+t,intptr[]) <0x00004>
+  at (wrapper managed-to-native) 
+ConsoleApplication1.Program.FormatMessage 
+(ConsoleApplication1.Program/FormatMessageFlags,intptr,uint,int,intptr&,in
+t,intptr[]) <0xffffffff>
+  at ConsoleApplication1.Program.FormatMessage (string,uint,string[]) 
+<0x000d9>
+  at ConsoleApplication1.Program.Main (string[]) <0x00053>
+  at (wrapper runtime-invoke) System.Object.runtime_invoke_void_string[] 
+(object,intptr,intptr,intptr) <0xffffffff>
+
+This application has requested the Runtime to terminate it in an unusual 
+way.
+Please contact the application's support team for more information.


More information about the mono-bugs mailing list