-
Notifications
You must be signed in to change notification settings - Fork 99
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
Crash on GetElementType #221
Comments
Not an expert but I investigated a bit your issue and I think it may be related with opaque pointers (https://releases.llvm.org/16.0.0/docs/OpaquePointers.html). Even if it's not, the migration instructions contains some suggestions that can be applied to your case. The type your are getting in the line var to1 = LLVM.TypeOf(opcodeNewarr); is a
Since the function defined in the ir is a global function and there is a LLVMContextRef context = LLVMContextRef.Create();
LLVMModuleRef _helperModule;
string ir = File.ReadAllText("helper_module.ir");
nint mem = Marshal.StringToHGlobalAnsi(ir);
var memBuf = LLVM.CreateMemoryBufferWithMemoryRangeCopy((sbyte*)mem, (nuint)ir.Length, (sbyte*)Marshal.StringToHGlobalAnsi("helper_module"));
context.TryParseIR(memBuf, out _helperModule, out string msg);
_helperModule.TryVerify(LLVMVerifierFailureAction.LLVMPrintMessageAction, out string message);
var func = LLVM.GetNamedFunction(_helperModule, (sbyte*)Marshal.StringToHGlobalAnsi("a"));
var funcType = LLVM.GlobalGetValueType(func);
var returnType = LLVM.GetReturnType(funcType);
var funcTypeKind = LLVM.GetTypeKind(funcType);
var returnTypeKind = LLVM.GetTypeKind(returnType); This code is not failing anymore. |
wont be able to confirm, dropped llvm usage in the project 😅 |
It's fine, it was an exercise for me to check the issue. Hopefully someone else might find it useful. Should the issue be closed? |
ir:
i am trying to get return type of the function, but getting on
var to1e = LLVM.GetElementType(to1);
System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'
i am using version 16 of llvmsharp
The text was updated successfully, but these errors were encountered: