corert
corert copied to clipboard
[SharedLibrary] SIGSEGV on unload
on exit process Program received signal SIGSEGV, Segmentation fault.
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff6770d58 in CloseHandle (handle=0x60d0c0) at /root/corert_3253263/src/Native/Runtime/unix/PalRedhawkUnix.cpp:583
583 /root/corert_3253263/src/Native/Runtime/unix/PalRedhawkUnix.cpp: No such file or directory.
(gdb) bt
#0 0x00007ffff6770d58 in CloseHandle (handle=0x60d0c0) at /root/corert_3253263/src/Native/Runtime/unix/PalRedhawkUnix.cpp:583
#1 0x00007ffff672fd25 in PalCloseHandle (arg1=0x60d0c0) at /root/corert_3253263/src/Native/Runtime/Full/../PalRedhawkFunctions.h:14
#2 Thread::Destroy (this=0x6046d0) at /root/corert_3253263/src/Native/Runtime/thread.cpp:375
#3 0x00007ffff6730e23 in ThreadStore::DetachCurrentThread () at /root/corert_3253263/src/Native/Runtime/threadstore.cpp:181
#4 0x00007ffff677196e in TlsDestructionMonitor::~TlsDestructionMonitor (this=<optimized out>) at /root/corert_3253263/src/Native/Runtime/unix/PalRedhawkUnix.cpp:468
#5 0x00007ffff792cb19 in (anonymous namespace)::run (p=<optimized out>) at ../../../../libstdc++-v3/libsupc++/atexit_thread.cc:64
#6 0x00007ffff7024b69 in __run_exit_handlers (status=0, listp=0x7ffff73b16c8 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true) at exit.c:77
#7 0x00007ffff7024bb7 in __GI_exit (status=<optimized out>) at exit.c:99
#8 0x00007ffff700d3dc in __libc_start_main (main=0x400abd <main>, argc=1, argv=0x7fffffffe528, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>,
stack_end=0x7fffffffe518) at ../csu/libc-start.c:300
#9 0x00000000004009f9 in _start ()
shared library
using System;
using System.Runtime.InteropServices;
namespace SharedLibrary
{
public class Class1
{
[NativeCallable(EntryPoint = "add", CallingConvention = CallingConvention.StdCall)]
public static int Add(int a, int b)
{
return a + b;
}
}
}
sample(c++) code
#include <stdio.h>
#include <dlfcn.h>
typedef int(*f_add)(int, int);
int main(int argc, char* argv[]) {
void* handle = dlopen ("SharedLibrary.so", RTLD_LAZY);
f_add add = (f_add)dlsym(handle, "add");
printf("%d\r\n", add(5, 10));
dlclose(handle);
return 0;
}
CoreRT libraries are not unloadable. There are number of problems that would need to be fixed to make them unload cleanly. https://github.com/dotnet/corert/pull/7011#issuecomment-519403322 lists some of the issues.
Should I ignore it using a signal handler? Is there any other way?
CoreRT libraries are not unloadable. There are number of problems that would need to be fixed to make them unload cleanly. #7011 (comment) lists some of the issues.
Preventing the library from unloading is the only reliable way.
On Ubuntu WSL dlclose is working now.