Skip to content

Crash on GetElementType #221

@0x410c

Description

@0x410c
LLVMContextRef context = LLVMContextRef.Create();
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 opcodeNewarr = LLVM.GetNamedFunction(_helperModule, (sbyte*)Marshal.StringToHGlobalAnsi("a"));
 var to1 = LLVM.TypeOf(opcodeNewarr);
var to1e = LLVM.GetElementType(to1);

ir:

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define i32 @a(){
  ret i32 1
}

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions