Crash running C code built on OS X El Capitan in Xcode 7
Crash running C code built on OS X El Capitan in Xcode 7
- Subject: Crash running C code built on OS X El Capitan in Xcode 7
- From: Jonathan Mitchell <email@hidden>
- Date: Mon, 02 Nov 2015 14:27:27 +0000
- X_v_e_cd: 7c08bcff6dc7d7bdf1c43e9ab2fbb3fe
- X_v_r_cd: 7a17b574967d63fe2acb15cda3026a20
The following C test code calls the current Mono 4.2.1-91 framework.
It builds and runs fine on 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.
Any ideas or suggestions as to why this is occurring?
Is there anyway to mitigate it?
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 (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden