Page MenuHomePhabricator

C#: Fix class registration when running with dotnet core
Closed, ResolvedPublic


Current function registration code uses dlsym(RTLD_DEFAULT, ...). While it works on Mono (which dlopen's with RTLD_GLOBAL), it fails in dotnet core which uses RTLD_LOCAL (dlopen's default).

We should change the registration code to use the library handles when dlsym'ing the function pointers.

lauromoura triaged this task as High priority.
woohyun added a subscriber: woohyun.Dec 6 2018, 6:29 PM


Could you share the progress of this work ?


ping ? Could you check above question ?


So, the problem is a bit worse. It seems using RTLD_GLOBAL is not stable and gives all kinds of problems (as per dotnet github issue
Also, one other problem is that Mono and Visual Studio .NET allows for DllMaps to map library names to actual library files. This will be implemented in a completely different way in dotnet, however and will only be available in dotnet 3.0.0 version (which is still a preview).

So, the workaround for this to work in dotnet is to create code that imperatively calls LoadLibrary/dlopen and GetProcAddress/dlsym and save those as delegates. Just as CoreFX does it self.
This means a considerable (but localized) amount of changes to the generator.

We need to consider its priority in consideration to other bugs (such as inheritance, constructors, etc).