New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SIGSEGV when calling assembly.Write(path) on PCL from Android #266
Comments
Hm! If anything, that's a bug in Mono for Android that is triggered by us. As far as Cecil is concerned, it's simply writing a binary file. Can you file a bug with Xamarin and let us know the results? |
When creating a simple repro project with the bug for Xamarin, I realised the Using this crossplatform IO library, reading an assembly is fine but I don't see how I can get the modified assembly as a stream in a crossplatform way to write/save it back. Is there (another :-P) thing I've been missing regarding your PCL API? Thanks! |
@Martz94 can't you pass a stream you control to Write? Could be a MemoryStream if you want to stay in memory. |
This throws a |
In that case, s is a Read only stream (you pass FileAccess.Read). Cecil needs write and seek access. If you pass FileAccess.ReadWrite, your code should work. If you want to write in memory you can simply write: var stream = new MemoryStream(); |
Great, it works indeed. Thanks! I'll figure it out eventually though. Thanks so much for your help! Cheers. |
My code is roughly this:
var assembly = AssemblyDefinition.ReadAssembly(path);
// modify types within assembly
assembly.Write(path);
Crashes on the call to
Write(path)
04-07 19:31:21.984 E/mono-rt ( 4322):
04-07 19:31:21.984 E/mono-rt ( 4322): Attempting native Android stacktrace:
04-07 19:31:21.984 E/mono-rt ( 4322):
04-07 19:31:21.986 E/mono-rt ( 4322): at mono_metadata_type_hash+298 [0xa44d833a]
04-07 19:31:21.986 E/mono-rt ( 4322): at +298 [0xa44d83b4]
04-07 19:31:21.986 E/mono-rt ( 4322): at +298 [0xa44d8416]
04-07 19:31:21.986 E/mono-rt ( 4322): at +298 [0xa44d8463]
04-07 19:31:21.986 E/mono-rt ( 4322): at +298 [0xa459c096]
04-07 19:31:21.986 E/mono-rt ( 4322): at +298 [0xa459c177]
04-07 19:31:21.986 E/mono-rt ( 4322): at +298 [0xa44dd519]
04-07 19:31:21.986 E/mono-rt ( 4322): at +298 [0xa4486300]
04-07 19:31:21.986 E/mono-rt ( 4322): at +298 [0xa4486617]
04-07 19:31:21.986 E/mono-rt ( 4322): at +298 [0xa4419385]
04-07 19:31:21.986 E/mono-rt ( 4322): at +298 [0xa441af9b]
04-07 19:31:21.987 E/mono-rt ( 4322): at +298 [0xa441b69c]
04-07 19:31:21.987 E/mono-rt ( 4322): at +298 [0xa443b3dd]
04-07 19:31:21.987 E/mono-rt ( 4322): at +298 [0xa444c446]
04-07 19:31:21.987 E/mono-rt ( 4322): at +298 [0xa4596fd4]
04-07 19:31:21.987 E/mono-rt ( 4322): at _ZL15__pthread_startPv+56 [0xb73cc7e1]
04-07 19:31:21.987 E/mono-rt ( 4322): at __start_thread+25 [0xb736d586]
04-07 19:31:21.987 E/mono-rt ( 4322): at __bionic_clone+70 [0xb7363116]
04-07 19:31:21.987 E/mono-rt ( 4322):
04-07 19:31:21.987 E/mono-rt ( 4322): =================================================================
04-07 19:31:21.987 E/mono-rt ( 4322): Got a SIGSEGV while executing native code. This usually indicates
04-07 19:31:21.987 E/mono-rt ( 4322): a fatal error in the mono runtime or one of the native libraries
04-07 19:31:21.987 E/mono-rt ( 4322): used by your application.
04-07 19:31:21.987 E/mono-rt ( 4322): =================================================================
04-07 19:31:21.987 E/mono-rt ( 4322):
04-07 19:31:21.987 F/libc ( 4322): Fatal signal 7 (SIGBUS), code 2, fault addr 0xaf2c5ad0 in tid 4339 (Thread-336)
04-07 19:31:22.101 F/DEBUG ( 68): # 15 pc 000807e1 /system/l04-07 19:31:22.089 F/DEBUG ( 68): *** *** *** *** *** *** *** *** *** *** *** *** *** *** ** ***
04-07 19:31:22.101 F/DEBUG ( 68): # 04 pc 0023d096 /data/app/Mono.Android.DebugRuntime-1/lib/x86/libmonosgen-32bit-2.0.so
04-07 19:31:22.101 F/DEBUG ( 68): # 05 pc 0023d177 /data/app/Mono.Android.DebugRuntime-1/lib/x86/libmonosgen-32bit-2.0.so
04-07 19:31:22.101 F/DEBUG ( 68): # 06 pc 0017e519 /data/app/Mono.Android.DebugRuntime-1/lib/x86/libmonosgen-32bit-2.0.so
04-07 19:31:22.101 F/DEBUG ( 68): # 07 pc 00127300 /data/app/Mono.Android.DebugRuntime-1/lib/x86/libmonosgen-32bit-2.0.so
04-07 19:31:22.101 F/DEBUG ( 68): # 08 pc 00127617 /data/app/Mono.Android.DebugRuntime-1/lib/x86/libmonosgen-32bit-2.0.so
04-07 19:31:22.101 F/DEBUG ( 68): # 09 pc 000ba385 /data/app/Mono.Android.DebugRuntime-1/lib/x86/libmonosgen-32bit-2.0.so
04-07 19:31:22.101 F/DEBUG ( 68): # 10 pc 000bbf9b /data/app/Mono.Android.DebugRuntime-1/lib/x86/libmonosgen-32bit-2.0.so
04-07 19:31:22.101 F/DEBUG ( 68): # 11 pc 000bc69c /data/app/Mono.Android.DebugRuntime-1/lib/x86/libmonosgen-32bit-2.0.so
04-07 19:31:22.101 F/DEBUG ( 68): # 12 pc 000dc3dd /data/app/Mono.Android.DebugRuntime-1/lib/x86/libmonosgen-32bit-2.0.so
04-07 19:31:22.101 F/DEBUG ( 68): # 13 pc 000ed446 /data/app/Mono.Android.DebugRuntime-1/lib/x86/libmonosgen-32bit-2.0.so
04-07 19:31:22.101 F/DEBUG ( 68): # 14 pc 00237fd4 /data/app/Mono.Android.DebugRuntime-1/lib/x86/libmonosgen-32bit-2.0.so
04-07 19:31:22.101 F/DEBUG ( 68): # 15 pc 000807e1 /system/lib/libc.so (__pthread_start(void)+56)
04-07 19:31:22.101 F/DEBUG ( 68): # 16 pc 00021586 /system/lib/libc.so (__start_thread+25)
04-07 19:31:22.101 F/DEBUG ( 68): # 17 pc 00017116 /system/lib/libc.so (__bionic_clone+70)
04-07 19:31:22.207 F/DEBUG ( 68):
04-07 19:31:22.207 F/DEBUG ( 68): Tombstone written to: /data/tombstones/tombstone_08
04-07 19:31:22.207 E/DEBUG ( 68): AM write failed: Broken pipe
Mono.Cecil.dll built from latest master branch (which I've read in #262 should support PCLs).
Tried using PCL profiles 111 and 259, to no avail.
Is there something I'm doing wrong or is it a legit bug?
The text was updated successfully, but these errors were encountered: