[Mono-dev] Crash running C code built on OS X El Capitan in Xcode 7

Martin Potter Martin.Potter at faithlife.com
Mon Nov 2 22:24:15 UTC 2015


We ran into a similar problem with running Mono embedded in our
application. I would guess that this is an issue with the version of
pthread_getspecific that gets used when running from Xcode with LLDB
attached when launching on 10.11. We have been running a custom version of
Mono with a patch that allows us to run with LLDB attached at launch, but
I submitted a pull request earlier today that was pulled into master so it
should be fixed at some point in the future.

‹ Martin

On 11/2/15, 6:37 AM, "mono-devel-list-bounces at lists.ximian.com on behalf
of Jonathan Mitchell" <mono-devel-list-bounces at lists.ximian.com on behalf
of jonathan at mugginsoft.com> wrote:

>The following C test code calls the current Mono 4.2.1-91 framework.
>It builds and runs fine within Xcode 6.4 on 10.10.
>
>It fails if I build and run it on OS X 10.11 using Xcode 7.1 -
>EXC_BAD_ACCESS in mono_jit_runtime_invoke() when calling
>AssemblyName:GetName()
>However the built binary runs fine outside of the Xcode environment.
>
>This obviously makes life difficult.
>It seems logical to infer that the Xcode IDE is the issue here and I have
>posted to the Xcode list.
>
>However, maybe there is more to this than I can detect.
>Perhaps the code below is somehow suspect.
>Any comments would be appreciated.
>
>Jonathan
>
>// Link against both Mono and CoreFoundation.
>// Header search path set to
>/Library/Frameworks/Mono.framework/Headers/Mono-2.0
>// Architecture i386.
>#include <stdio.h>
>#import <mono/jit/jit.h>
>#import <mono/metadata/metadata.h>
>#import <mono/metadata/debug-helpers.h>
>
>MonoObject *invokeName(MonoObject *object, char *name);
>
>int main(int argc, const char * argv[]) {
>
>   // init
>   MonoDomain *domain = mono_jit_init_version("Dubrovnik", "v4.0.30319");
>   MonoAssembly *assembly = mono_domain_assembly_open(domain, "mscorlib");
>
>   // returns System.Reflection.Assembly
>   MonoReflectionAssembly *assemblyObject =
>mono_assembly_get_object(domain, assembly);
>
>   // returns System.Reflection.AssemblyName
>   MonoObject *assemblyNameObject = invokeName((MonoObject
>*)assemblyObject, ":GetName()");
>
>   // returns System.Version
>   MonoObject *versionObject = invokeName(assemblyNameObject,
>":get_Version()");
>
>   // Returns System.String
>   MonoObject *stringObject = invokeName(versionObject, ":ToString()");
>   printf("Version : %s\n", mono_string_to_utf8((MonoString
>*)stringObject));
>
>   return 0;
>}
>
>MonoObject *invokeName(MonoObject *object, char *name)
>{
>   MonoClass *klass = mono_object_get_class(object);
>
>   MonoMethodDesc *methodDesc = mono_method_desc_new(name, 1);
>   MonoMethod *meth = NULL;
>   while (klass != NULL) {
>       meth = mono_method_desc_search_in_class(methodDesc, klass);
>       if(meth != NULL) {
>           meth = mono_object_get_virtual_method(object, meth);
>           break;
>       }
>       klass = mono_class_get_parent(klass);
>   }
>   MonoObject *monoException = NULL;
>   MonoObject *resultObject = mono_runtime_invoke(meth, object, NULL,
>&monoException);
>
>   klass = mono_object_get_class(resultObject);
>   printf("invokeName returned : %s\n", mono_class_get_name(klass));
>
>   return resultObject;
>}
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>_______________________________________________
>Do not post admin requests to the list. They will be ignored.
>Xcode-users mailing list      (Xcode-users at lists.apple.com)
>Help/Unsubscribe/Update your Subscription:
>https://lists.apple.com/mailman/options/xcode-users/jonathan%40mugginsoft.
>com
>
>This email sent to jonathan at mugginsoft.com
>_______________________________________________
>Mono-devel-list mailing list
>Mono-devel-list at lists.ximian.com
>http://lists.ximian.com/mailman/listinfo/mono-devel-list



More information about the Mono-devel-list mailing list