pythonnet: clr.AddReference crashes mono in Linux environment
Environment
- Pythonnet version: 2.5.1
- Python version: Python 3.6.12 :: Anaconda, Inc.
- Operating System: Linux (Ubuntu 18.04.5 LTS bionic)
- mono version : Mono JIT compiler version 6.12.0.90
Details
- I am trying to add reference of .Net standard library(Linux compatible) from the python code. import clr clr.AddReference(“xxxx.xx”)
The code throws the below exception and mono crashes after that
*** Assertion at assembly.c:1939, condition `is_ok (hook_error)' not met, function:mono_assembly_invoke_load_hook_internal, (null) assembly:/usr/lib/mono/4.5/mscorlib.dll type:ReflectionTypeLoadException member:(null)**
=================================================================
Native Crash Reporting
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
=================================================================
Native stacktrace:
=================================================================
0x7fec3a9382a9 - /usr/lib/libmonosgen-2.0.so.1 :
0x7fec3a938629 - /usr/lib/libmonosgen-2.0.so.1 :
0x7fec3a8c2c94 - /usr/lib/libmonosgen-2.0.so.1 :
0x7fec3a937842 - /usr/lib/libmonosgen-2.0.so.1 :
0x7fec59a97980 - /lib/x86_64-linux-gnu/libpthread.so.0 :
0x7fec596d2fb7 - /lib/x86_64-linux-gnu/libc.so.6 : gsignal
0x7fec596d4921 - /lib/x86_64-linux-gnu/libc.so.6 : abort
0x7fec3ab1d3a7 - /usr/lib/libmonosgen-2.0.so.1 :
0x7fec3ab02573 - /usr/lib/libmonosgen-2.0.so.1 :
0x7fec3ab1d328 - /usr/lib/libmonosgen-2.0.so.1 :
0x7fec3ab1d8e3 - /usr/lib/libmonosgen-2.0.so.1 : monoeg_assertion_message
0x7fec3a9a1b98 - /usr/lib/libmonosgen-2.0.so.1 :
0x7fec3a9a28e7 - /usr/lib/libmonosgen-2.0.so.1 :
0x7fec3a9a4c13 - /usr/lib/libmonosgen-2.0.so.1 :
0x7fec3a9a43e1 - /usr/lib/libmonosgen-2.0.so.1 :
0x7fec3a9a6351 - /usr/lib/libmonosgen-2.0.so.1 : mono_assembly_load_reference
0x7fec3a9ae3fb - /usr/lib/libmonosgen-2.0.so.1 : mono_class_from_typeref_checked
0x7fec3aa0430c - /usr/lib/libmonosgen-2.0.so.1 :
0x7fec3aa045f2 - /usr/lib/libmonosgen-2.0.so.1 :
0x7fec3aa9364f - /usr/lib/libmonosgen-2.0.so.1 :
0x7fec3aa942e8 - /usr/lib/libmonosgen-2.0.so.1 :
0x7fec3aa949e8 - /usr/lib/libmonosgen-2.0.so.1 :
0x7fec3a9e8dfe - /usr/lib/libmonosgen-2.0.so.1 :
0x41cb3773 - Unknown
import clr
clr.AddReference("LiveAI.SDK")
- If there was a crash, please include the traceback here.
print('TODO')
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (6 by maintainers)
Got the same error on centos7 with mono 6.12.0.107. My app is using .NET assemblies 4.0.0.0, which then reference to a nuget package which then reference System.Text.Json.dll 5.0.0.0. AddRefrence(“System.Text.Json.dll”) caused the crash. The same app works fine on Mono 6.10.0 and 6.8.0. pythonnet version is 3.0.0.post1 Reproduce steps:
Thanks @vnavkal for decrypting this for me. I got the same error while building the QuantConnect lean indicators into my python project.
@filmor I believe I’ve managed to reproduce this error as well. I posted a dockerfile in https://github.com/vnavkal/pythonnet-ex that compiles similar code to what @samuthrakumar posted and then attempts to import it via pythonnet. And when I run the image, I see a similar cryptic crash log.
It’s not clear to me whether the issue is with pythonnet or with mono. I’m happy to try further debugging steps to pin down the source of the issue further, just let me know.
Thanks in advance!