sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Self-contained applications in Linux are not truly portable

Open hglkrijger opened this issue 10 years ago • 9 comments

Steps to reproduce

  1. create self-contained application (Ubuntu runtime)
  2. dotnet restore
  3. dotnet publish
  4. ldd -v
  5. for each dynamic dependency, copy and link locally (in the publish folder), e.g.: cp /usr/lib/x86_64-linux-gnu/libunwind.so.8.0.1 . ln -s libunwind.so.8.0.1 libunwind.so.8 cp /usr/lib/x86_64-linux-gnu/libunwind-x86_64.so.8 .
  6. find the loader listed in the ldd output, and copy locally (in the publish folder), e.g.: ll /lib64/ld-linux-x86-64.so.2 cp /lib/x86_64-linux-gnu/ld-2.19.so .
  7. create a tarball with the output of publish + dependencies as above
  8. copy this tarball to another distro
  9. execute using: LD_LIBRARY_PATH=. e.g.: D_LIBRARY_PATH=. ./ld-2.19.so ./myapp ./myapp.dll

Expected behavior

Since Linux guarantees kernel api compatibility across versions, it should be possible to package all userspace dependencies and libraries, and package them in this way to create a portable application. The executable should run successfully using the original loader.

Actual behavior

Failed to initialize CoreCLR, HRESULT: 0x80131500

Trace shows that the process name is taken from the loader and used to determine the name of the assembly to load, which does not exist:

Own DLL path=[/.../ld-2.19.so.dll]

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-rc2-002678)

Product Information: Version: 1.0.0-rc2-002678 Commit Sha: 3b2ea9d14b

Runtime Environment: OS Name: ubuntu OS Version: 14.04 OS Platform: Linux RID: ubuntu.14.04-x64

Dotnet version: 1.0.0-rc2-002678 Built against kernel: 3.19.0-58-generic

Target kernels tested for execution:

Centos6 [2.6.32-573.18.1.el6.x86_64] Centos7 [3.10.0-327.10.1.el7.x86_64] SLES11 [3.0.101-71-default]

hglkrijger avatar May 18 '16 23:05 hglkrijger

Please assign to @schellap

hglkrijger avatar May 18 '16 23:05 hglkrijger

/cc @schellap

thesmithee avatar May 19 '16 17:05 thesmithee

@blackdwarf, this is a topic for discussion. What are we promising with respect to app portability? @hglkrijger is trying to take a published standalone app to another distro (another rid) and manually copying over the other dynamic dependencies (what we mark as pre-requisites) of the app.

This is at best unsupported because it breaks the invariant of:

  • Using the published executable as the activator -- instead the dynamic linker (ld-linux.so*) is used to load the executable like:

./ld-linux.so* app* <managed-args> # this breaks our notion of the process name because the process is not dotnet* or app* but ld-linux.so*

  • Also, standalone apps are designed to be executed on the same or compatible rid that the app is being published for. Note that the conformance is at the NuGet "rid" level.
    • Can "rid" compatibility be equated to kernel compatibility? I doubt that because, AFAIK, we don't guarantee ubuntu 14.04 to ubuntu 16.04 compatibility.

If an user wants to migrate to different platforms, I would consider using the Shared Framework and make their application a portable application by retaining the "type": "platform" in the project.json

Cc @piotrpMSFT @davidfowl @gkhanna79

I'm moving this out of preview-2.

schellap avatar May 23 '16 22:05 schellap

@schellap let's chat tomorrow, I need to understand some more what is happening here. The loading logic...is it like that because the host is not built for all distros that this is supposed to run on?

RID compat is not kernel compat, that is, it doesn't imply that.

thesmithee avatar May 24 '16 05:05 thesmithee

Any updates on this?

hglkrijger avatar Jun 09 '16 16:06 hglkrijger

Hey guys, is there any work done with regards to this?

@hglkrijger @blackdwarf @gkhanna79 @krwq @schellap

I'm really looking forward to create some applications using dotNET core, it'd be great help if you could provide some insights.

abhi18av avatar Jan 09 '17 13:01 abhi18av

@abhi18av what is the insight you are looking for? This issue describes a very special approach to having a self-contained deployment that also carries with it .NET Core's native dependencies. Is this what you had in mind or something else?

thesmithee avatar Jan 09 '17 16:01 thesmithee

I just wanted to probe the idea whether I'd able to create xwt or gtk# applications based on dotNET core. The article you pointed me to, was helpful but I'd like to know your opinion about it.

abhi18av avatar Jan 10 '17 10:01 abhi18av

The runtime has done considerable work to change how they reference native dependencies. This should be addressed now.

livarcocc avatar May 10 '19 18:05 livarcocc