nulastudio / HostFXRPatcher

patched libhostfxr and patcher for fixing the relative additional probing path issue. See https://github.com/dotnet/runtime/issues/3708
1 stars 1 forks source link

Linux - patched libhostfxr.so does not work on "older" distributions #1

Closed jurijr closed 4 years ago

jurijr commented 4 years ago

Running with patched libhostfxr on CentOS 7 (which is still listed under .net core 3.1 supported os versions) yields following error: Failed to load �r�, error: /lib64/libstdc++.so.6: version GLIBCXX_3.4.20' not found (required by PATH/libhostfxr.so) The library libhostfxr.so was found, but loading it from PATH/libhostfxr.so failed

strings /usr/lib64/libstdc++.so.6 | grep GLIB yields

GLIBCXX_3.4 GLIBCXX_3.4.1 GLIBCXX_3.4.2 GLIBCXX_3.4.3 GLIBCXX_3.4.4 GLIBCXX_3.4.5 GLIBCXX_3.4.6 GLIBCXX_3.4.7 GLIBCXX_3.4.8 GLIBCXX_3.4.9 GLIBCXX_3.4.10 GLIBCXX_3.4.11 GLIBCXX_3.4.12 GLIBCXX_3.4.13 GLIBCXX_3.4.14 GLIBCXX_3.4.15 GLIBCXX_3.4.16 GLIBCXX_3.4.17 GLIBCXX_3.4.18 GLIBCXX_3.4.19 GLIBC_2.3 GLIBC_2.2.5 GLIBC_2.14 GLIBC_2.4 GLIBC_2.3.2 GLIBCXX_DEBUG_MESSAGE_LENGTH

liesauer commented 4 years ago

are you using patched libhostfxr with NetCoreBeauty? if so, what is your specific rid?

liesauer commented 4 years ago

it is pretty normal on my centos 7, it is a fresh system. image btw, i don't have GLIBCXX_3.4.20 either, but it is still runnable. image you can try renaming libhostfxr.so to libhostfxr.so.bak2 and restoring libhostfxr.so.bak back to libhostfxr.so and then run the app by cd /path/to/app_base && ./app, libhostfxr.so.bak is the original one that produced by dotnet publish, if it is still unrunnable, it may not a hostfxr problem. update the system and dependencies to lastest may help.

if the problem still or gone, plz let me know.

jurijr commented 4 years ago

No, we do not use NetCoreBeauty, but we have done similar lib folder sharing between multiple projects. To migitate the APP_BASE bug we use patched libhostfxr.so from artifacts folder in this repository and overwrite the original one.

My steps to reproduce: I have redownloaded and installed the latest CentOS 7 version (7.7.1908 - workstation install). Ran sudo yum update (just to be sure everything is up-to-date) On different machine I have published new console project (hello world) with 3.1.101 sdk dotnet publish -r linux-x64. Copied publish folder onto the fresh CentOS machine. Successfully ran it. Overwrite the libhostfxr.so with the one downloaded from https://github.com/nulastudio/HostFXRPatcher/raw/master/artifacts/v3.1.1/linux-x64.Release/libhostfxr.so Ran it again, but with errors.

[jurijr@localhost publish]$ ./ConsoleApp
Hello World!
[jurijr@localhost publish]$ ./ConsoleApp
Failed to load (�|, error: /lib64/libstdc++.so.6: version GLIBCXX_3.4.20 not found (required by /home/jurijr/demo/publish/libhostfxr.so)
The library libhostfxr.so was found, but loading it from /home/jurijr/demo/publish/libhostfxr.so failed
  - Installing .NET Core prerequisites might help resolve this problem.
     https://go.microsoft.com/fwlink/?linkid=2063370

Have I missed anything? It appears to run fine on my other test VMs. Thank you for assistance.

liesauer commented 4 years ago

that is weird. everything was the same but two differences. i used 3.1.100 sdk to build the project and used NetCoreBeauty to organize it, just it. but this shouldn't break the app. could you please upload your project including published app? i will do more tests tonight.

jurijr commented 4 years ago

Used dotnet publish -c Release -r linux-x64. Once again with 3.1.101 sdk. Publish folder still contains original hostfxr.so, so for a test you still need to overwrite it.

I suppose it shouldn't matter, but just in case, my building machine is running Ubuntu 19.10.

sln: HelloWorld.zip publish: https://drive.google.com/file/d/1x0YYc0E9Jj1Lg2U9TVSxQ9luBAP97YJV/view?usp=sharing

liesauer commented 4 years ago

the patched libhostfxr that i built is using gcc7. but unfortunately the latest gcc on centos 7 is 4.8. and install the latest libstdc++.so.6 won't work because GLIBCXX >= 3.4.20 only available on centos 8. install gcc4.9 won't work either because it contains static lib only.

so three optional solutions for you:

  1. upgrade to centos 8.
  2. build gcc>=4.9 from sources and recreate the symbol link.
  3. download the higher pre-build libstdc++.so.6 from internet(plz be sure from a trusty website) and recreate the symbol link.

for me:

  1. however, i still need to re-compile all artifacts using older gcc like 4.8 for better compatibility. re-compiled patched libhostfxr will be available within 1-2 days. then you don't need to do anything.
liesauer commented 4 years ago

already uploaded all recompiled artifacts and test working properly. if problem still, reopen this issue plz.

liesauer commented 4 years ago

NOTE: used locale.h instead xlocale.h when building v2.0.x. because xlocale has been removed in glibc 2.26. and xlocale.h is threadsafe version of locale.h

liesauer commented 4 years ago

NOTE: some useful links: ABI Policy and Guidelines CENTOS下GLIBCXX_3.4.20的问题