2 / 4
Mar 7

Hello!

I have an issue where the mongo driver causes a segfault. Its being ran inside a mono environment which might cause an issue(?) but the segmentation fault doesn’t always happen, something like a 50% chance it happens.

Obtained 43 stack frames. #0 0x007fad399b7140 in funlockfile #1 0x007fad39929e30 in __nss_database_lookup #2 0x007facfd19c2a3 in mono_assembly_names_equal #3 0x007facfd1948ab in mono_runtime_init #4 0x007facfd19da60 in mono_assembly_invoke_search_hook #5 0x007facfd19d463 in mono_assembly_load_reference #6 0x007facfd1a3e6e in mono_class_from_typeref_checked #7 0x007facfd1a73e9 in mono_class_get_checked #8 0x007facfd1f204e in mono_metadata_cleanup #9 0x007facfd1f4786 in mono_metadata_get_inflated_signature #10 0x007facfd1f216a in mono_metadata_cleanup #11 0x007facfd1a9ea2 in mono_field_get_type #12 0x007facfd1abeb8 in mono_class_is_valid_enum #13 0x007facfd1ac27b in mono_class_is_valid_enum #14 0x007facfd0891e5 in mono_set_break_policy #15 0x007facfd074981 in mono_set_break_policy #16 0x007facfd09a85e in mono_set_break_policy #17 0x007facfd074981 in mono_set_break_policy #18 0x007facfd093c74 in mono_set_break_policy #19 0x007facfd067680 in _init #20 0x007facfd0698b6 in _init #21 0x007facfd06d548 in mono_jit_set_domain #22 0x007facfd0eb603 in mono_install_ftnptr_eh_callback #23 0x007facfd0eb06c in mono_install_ftnptr_eh_callback #24 0x00000041c05396 in (Unknown) #25 0x000000421473c4 in MongoDB.Driver.MongoUrl:.ctor (string)

Has anyone encountered this before?

Had another type of crash,

#0 0x007f515c728140 in funlockfile #1 0x007f51506b6cee in mono_stringify_assembly_name #2 0x007f51506e16d5 in mono_install_unhandled_exception_hook #3 0x007f51506ed0c1 in mono_lookup_icall_symbol #4 0x00000040dc8dea in (wrapper managed-to-native) System.Reflection.RuntimeAssembly:get_fullname (System.Reflection.Assembly) #5 0x00000040b3a998 in System.Linq.Enumerable:FirstOrDefault<TSource_REF> (System.Collections.Generic.IEnumerable`1<TSource_REF>,System.Func`2<TSource_REF, bool>) #6 0x00000040d3f0b8 in System.AppDomain:DoAssemblyResolve (string,System.Reflection.Assembly,bool) #7 0x00000040d3f260 in (wrapper runtime-invoke) <Module>:runtime_invoke_object__this___object_object_byte (object,intptr,intptr,intptr) #8 0x007f515058b1e8 in mono_get_runtime_build_info #9 0x007f515072a136 in (Unknown) #10 0x007f51506b10e9 in mono_domain_owns_vtable_slot #11 0x007f51506b0f05 in mono_domain_owns_vtable_slot #12 0x007f51506ae9b7 in mono_runtime_init #13 0x007f51506b7a60 in mono_assembly_invoke_search_hook #14 0x007f51506ba525 in mono_assembly_open_full #15 0x007f51506d9fd9 in mono_install_unhandled_exception_hook #16 0x007f51506f1a0b in mono_lookup_icall_symbol #17 0x00000040c15dc2 in (wrapper managed-to-native) System.RuntimeTypeHandle:internal_from_name (string,System.Threading.StackCrawlMark&,System.Reflection.Assembly,bool,bool,bool) #18 0x00000040c15a08 in System.RuntimeType:GetType (string,bool,bool,bool,System.Threading.StackCrawlMark&) #19 0x00000040f10240 in MongoDB.Driver.Core.Connections.ClientDocumentHelper:CreateDriverDocument (string) #20 0x00000040f0f87c in System.Lazy`1<T_REF>:ExecutionAndPublication (System.LazyHelper,bool) #21 0x00000040f0f5d4 in System.Lazy`1<T_REF>:CreateValue () /entrypoint.sh: line 50: 38 Segmentation fault (core dumped) ${MODIFIED_STARTUP}

Its different than the last one, both of them happen on startup; for more info this is a vault plugin for a unity game (serverside).

17 days later

Hi @RBMK_Blaze ,

First, as a quick disclaimer, the C# driver does not officially support Unity at this time. Based on the stack trace you provided, this appears to be a Mono issue rather than the driver itself. Both stack traces seem to point to something involving assembly_name at the top.

To help isolate the issue, I recommend testing whether the problem occurs with a minimal example. For instance, try running the following line to see if it crashes:

typeof(IMongoClient).GetTypeInfo().Assembly;

Let me know how it goes!

Hey, I ended up fixing it by initing the mongo client when server finishes startup (assets, plugins, level loaded) and it fixed it. Thanks for your response thought.