-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to initialize CoreCLR, HRESULT: 0x80004005 when deploying on sandstorm #2534
Comments
CC @schellap |
@pgrm can you please provide the trace generated when run with export COREHOST_TRACE=1. |
@pgrm can you check if https://github.com/dotnet/coreclr/issues/9014#issuecomment-290677198 solves your issue |
Closing the issue due to lack of details. Please reopen if the issue persists with the latest runtime. |
I have gotten back to this issue on modern .NET Core 3.1, and would love some help troubleshooting. Creating a hack for /dev similar to as @ramarag mentioned did not help me.
|
@gkhanna79 Can we reopen this for troubleshooting? I've got a .NET developer who would be interested in being able to play with .NET Core inside a Sandstorm sandbox. |
This is the log with COREHOST_TRACE=1: |
New test repo is here: https://github.com/ocdtrekkie/vagrant-spk-dotnet-test1 |
@ocdtrekkie neither @gkhanna79 nor @ramarag are on the .NET Core team anymore. |
How would be the best way to generate that for you? (I'm a bit if a beginner in the Linux space as much as I am new to .NET Core.) I was wondering if they were still around as I did notice a sparse GitHub contribution history, and it's been a few years. |
To get the strace log, you can execute it as follows:
The log will get generated into the strace.log file. |
As a Gist: https://gist.github.com/ocdtrekkie/324b26993aa20479de6b967b9e522cd1 Also attached: |
@ocdtrekkie I can see the code is looking for several proc file system files that do not exist exist based on the log close to the failure:
Only the /proc/self/maps and /proc/{PID}/stat is something that our runtime explicitly tries to open and we fail if we don't find it. |
I basically have to figure out how to fake things in /proc, so let me see what I can manage there. I think we have an open issue to add /dev/shm too. Thanks! This lets me know what I need to accomplish. |
Spoofing |
the /proc/{PID}/stat is used to get a start time of a process and the /proc/self/maps to get a list of shared libraries and executable in the current process. |
Does .NET care about the address ranges in I think with Ideally .NET would just not have hard dependencies on stuff in proc though. Unfortunately just providing procfs in sandstorm isn't something I'm open to; its absence has protected us from LPE vulnerabilities in the past, and I don't think any other runtime has given us much trouble. We bind mount specifically I wonder how much of .NET's use of |
@zenhack I am sorry, I've missed your last question and discovered it today. Wherever we can use non- /proc based approach, I'd be more than happy to use it. However, I am not aware of ones that we could easily replace. |
Getting rid of Those are mostly running in some kind of chroot or similar reduced environments where access to |
I tried updating @ocdtrekkie's scripts to use the latest .NET 5 preview: https://github.com/ocdtrekkie/vagrant-spk-dotnet-test1/pull/1/files It doesn't appear to have fixed the
But if I keep the workaround for that, then I get the same error as before; full log: So the situation seems unchanged with .NET 5. A couple thoughts:
|
We are using /proc/self/exe only if getauxval(AT_EXECFN) returns NULL. Is it possible that it happens in your environment? Regarding the proc/{PID}/stat, we use it for other processes too for diagnostics interprocess communication. We use the time obtained from it for process id disambiguation (see GetProcessIdDisambiguationKey). The point is that a process id can get recycled during the lifetime of a .NET app. |
And (getauxval returning null seems plausible, and it's a secondary concern anyway). |
/proc/{PID}/maps is used to get a list of currently loaded shared libraries for a given process for debugger interface purposes and to create a crash dump when .NET app crashes and creating crashdump is enabled. I don't see /proc/self/maps being used in our sources now. |
Hm, both of those things seem like they could be non-fatal errors; how invasive a change would it be to just disable the relevant functionality if /proc isn't available, rather that aborting? Not being able to launch a debugger doesn't seem like it should prevent an app from running at all. |
The /proc/{PID}/maps is actually not opened at startup, only the /proc/{PID}/stat is. But that one can be disabled by setting env var |
No dice. Did an
Adding the full log as an attachment. (I think this is the same as what we observed with @ocdtrekkie's earlier attempt) |
Ah, I have realized that I was not testing it with the dotnet host, but rather the corerun that is a simple host that predates dotnet and we use it for running coreclr tests. With that one, executing a dotnet app didn't touch anything in the /proc file system, according to my strace log. Looking at the dotnet host, it really uses /proc/self/maps and /proc/self/exe (it doesn't try to use getauxval(AT_EXECFN)). We can easily fix the /proc/self/exe. The /proc/self/maps is used to find whether a library is already loaded or not if dlopen fails with just the library name. The comment says that it was found that on some systems, dlopen finds that a library was loaded only if given absolute path. I'm not sure how dlopen behaves on your system. |
The exact rules for resolution on linux are documented in the man page: https://linux.die.net/man/3/dlopen It looks like it was previously failing to find libnuma and libttng-ust. Through a combination of adding a couple directories to |
@zenhack so it turned out the code that opens
|
The man page suggests that this can happen if you call it on the main thread:
Peeking at the implementation confirms this: So I guess that gets us back to: what is this information needed for, and can we work around it? |
(I had a look at the musl libc implementation and it looks like it doesn't have this problem -- so maybe I'll try it out on alpine) |
We use the
|
I tried getting this working with the alpine/musl build (using docker-spk, since vagrant-spk is tied to debian) and can confirm that we don't hit the I asked in Avoiding
I don't know how hard (1) would be. you can get the total size of the stack with |
A small update: the musl maintainer expressed interest in getting realpath() working without /proc, so that's another possible way forward. |
Ok, I swapped in a working realpath() implementation and got a bit further, but it's getting a NullReferenceException on startup. s |
Unfortunately this NullReferenceException is in an area I know nothing about. Dumping the exception here from the log for better visibility for others:
However, I've just found a github issue in the sdk repo that mentions exactly the same exception: |
It is likely that It is an example of situation where #40862 would help. |
Hm, it looks like the issue in that case was that public Muxer()
{
_muxerPath = Process.GetCurrentProcess().MainModule.FileName;
}
It seems reasonable to believe that this is due to procfs being absent, though I'm not exactly sure what part of procfs it's trying to access. |
|
So I realized I'm probably making this harder than I need to by doing |
I was just about to suggest trying self contained publish, so I am glad it worked. |
I was going to close this issue, but I have found that |
Moved from github.com/dotnet/cli/issues/4111 on behalf of @pgrm
Steps to reproduce
Install vagrant-spk
clone the sample repository pgrm/sandstorm-asp-net-core-test
inside the repository run
open the browser and go to http://local.sandstorm.io:6080/
sign in with sample developer account (I always use alice)
go to http://local.sandstorm.io:6080/apps and click on example app
create a new instance
open the debug log (in the top an icon which looks like a terminal - it's located between the trash bin and download arrow icons)
Expected behavior
At least it would be great if I could see the current dotnet version. Actually the yeoman generator default website should show up, but at least in the debug log, I should be able to see the dotnet version
Actual behavior
Environment data
dotnet --info
output:However, this
dotnet --info
was executed inside the.sandstorm/build.sh
script where dotnet works just fine, and not inside.sandstorm/launcher.sh
script where the problems show up.I think the problem is, because sandstorm containers don't have access to
/proc/self/exe
which was introduced with https://github.com/dotnet/coreclr/issues/1774. I tried to fake that file as discussed in sandstorm-io/sandstorm#1582. I've set the link to point to/usr/local/bin/dotnet
as well as/opt/dotnet/dotnet
but in both cases I'm getting the same error.Maybe I'm pointing it to the wrong file, or there is something more missing to make it work. Unfortunately the error message is hard to understand so some help would really be appreciated. Thx
The text was updated successfully, but these errors were encountered: