|
Bugzilla – Full Text Bug Listing |
| Summary: | Marshal.StructureToPtr handles null pointers/delegates incorrectly | ||
|---|---|---|---|
| Product: | [Mono] Mono: Class Libraries | Reporter: | Christian Hoff <christian_hoff> |
| Component: | CORLIB | Assignee: | Mono Bugs <mono-bugs> |
| Status: | RESOLVED FIXED | QA Contact: | Mono Bugs <mono-bugs> |
| Severity: | Major | ||
| Priority: | P5 - None | CC: | forgotten_vxPDddArjq |
| Version: | SVN | ||
| Target Milestone: | --- | ||
| Hardware: | x86-64 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Found By: | Development | Services Priority: | |
| Business Priority: | Blocker: | --- | |
| Marketing QA Status: | --- | IT Deployment: | --- |
| Attachments: | test case | ||
That's the output of the test case(compile it with gmcs, not mcs):
Creating dummy
--- structure.test should be null ---
Stacktrace:
at (wrapper managed-to-native) object.wrapper_native_(nil) () <0x00042>
at (wrapper managed-to-native) object.wrapper_native_(nil) () <0xffffffff>
at TestStructToPtr.MainClass.Main (string[]) <0x0007a>
at (wrapper runtime-invoke) TestStructToPtr.MainClass.runtime_invoke_void_object (object,intptr,intptr,intptr) <0xffffffff>
Native stacktrace:
mono [0x4bd937]
mono [0x520a00]
mono [0x421c91]
/lib/libpthread.so.0 [0x7f2c33bb5a80]
Debug info from gdb:
=================================================================
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.
=================================================================
Created attachment 273712 [details]
test case
Fixed in SVN HEAD/2.4 branch: http://lists.ximian.com/pipermail/mono-patches/2009-February/142158.html |
When invoking StructureToPtr, delegates in the returned structure are never NULL. Suppose you have a class struct containing one delegate: struct TestStruct { TestDelegate test; } "test" is never set to null when it doesn't point to a C method. Invoking that method results in a segfault. See the attached test case for a minimal repro. The unmanaged code is already compiled to a static lib; if it doesn't work for you(probably only working on 64Bit machaines), recompile it using: gcc -c -fPIC ./main.c -o ./main.o gcc -shared -Wl,-soname,libptr_to_struct.so.1 -o libptr_to_struct.so ./main.o As this is a blocker for a Gtk# patch, it would be really nice if you could have a look at that bug soon :-)