Skip to content

Need to ensure Path.GetTempPath() / other APIs work as expected on cross-plat coreclr fwk #4027

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

Closed
MattGal opened this issue Mar 9, 2015 · 13 comments
Assignees

Comments

@MattGal
Copy link
Member

MattGal commented Mar 9, 2015

See this thread:

aspnet/HttpAbstractions#168

... basically the expectation is that Path.GetTempPath() may fail on Unix or MacOS systems when switching to the cross-plat coreclr implementation. From reading the current implementation, it still depends on the API in Kernel32.

@stephentoub
Copy link
Member

@MattGal, have you seen a problem at run time, or is this just based on code inspection? P/Invokes to kernel32.dll in mscorlib get redirected by the runtime to its PAL layer, so a call to GetTempPath on Unix doesn't actually try to load kernel32.dll, but instead uses the native implementation from libcoreclr. Today I believe it only goes to /tmp/, but it could certainly be extended to first check an environment variable, and that is indeed the plan for when Path is instead exposed in a standalone System.Runtime.Extensions library implemented in managed code over on https://github.com/dotnet/corefx.

@felipepaixao
Copy link

Same issue here.

@stephentoub
Copy link
Member

@felipepaixao, can you elaborate on the issue you're seeing? How is it failing?

@felipepaixao
Copy link

Hi, @stephentoub
I'm having an issue when my application, which is hosted in a Linux vm, tries to access the default temporary location.
Here's the detailed exception error:

[EDIT]

It happens when I try to Sign in asynchronouslly in (SignInManager.PasswordSignInAsync). So i don't have any control over the temporary targeted path.

An unhandled exception occurred while processing the request.

DirectoryNotFoundException: Exception of type 'System.IO.DirectoryNotFoundException' was thrown.
Microsoft.AspNet.Http.Core.BufferingHelper.get_TempDirectory () [0x00000] in , line 0

@stephentoub
Copy link
Member

Thanks. This is using the ASP.NET BufferingHelper, which is a wrapper around Path.GetTempPath(), but only as a fallback:
https://github.com/aspnet/HttpAbstractions/blob/dev/src/Microsoft.AspNet.Http.Core/BufferingHelper.cs
What's the value of the "ASPNET_TEMP" environment variable it's checking first? Are you sure it's falling back to GetTempPath?

@felipepaixao
Copy link

Hey!
Here's the detailed error:
I Also tried to check the first value of "ASPNET_TEMP" but every time i try to check, i got an exception error. The same exception as described below. When i try to run in a Windows machine, it works fine.

Microsoft.AspNet.Http.Core.BufferingHelper.get_TempDirectory () [0x00000] in
Microsoft.AspNet.Http.Core.BufferingHelper.EnableRewind (Microsoft.AspNet.Http.HttpRequest request, Int32 bufferThreshold) [0x00000] in
Microsoft.AspNet.Http.Core.FormFeature+d__12.MoveNext () [0x00000] in
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in
System.Runtime.CompilerServices.TaskAwaiter1[Microsoft.AspNet.Http.IFormCollection].GetResult () [0x00000] in <filename unknown> Microsoft.AspNet.Mvc.AntiForgeryTokenStore+<GetFormTokenAsync>d__4.MoveNext () [0x00000] in <filename unknown> --- End of stack trace from previous location where exception was thrown --- System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown> System.Runtime.CompilerServices.TaskAwaiter1[Microsoft.AspNet.Mvc.AntiForgeryToken].GetResult () [0x00000] in
Microsoft.AspNet.Mvc.AntiForgeryWorker+d__15.MoveNext () [0x00000] in
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in
System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in
Microsoft.AspNet.Mvc.AntiForgery+d__5.MoveNext () [0x00000] in
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in
System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in
Microsoft.AspNet.Mvc.ValidateAntiForgeryTokenAuthorizationFilter+d__2.MoveNext () [0x00000] in
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in
System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in
Microsoft.AspNet.Mvc.FilterActionInvoker+d__35.MoveNext () [0x00000] in
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in
System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in
Microsoft.AspNet.Mvc.FilterActionInvoker+d__35.MoveNext () [0x00000] in
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in
System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in
Microsoft.AspNet.Mvc.FilterActionInvoker+d__34.MoveNext () [0x00000] in
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in
System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in
Microsoft.AspNet.Mvc.FilterActionInvoker+d__32.MoveNext () [0x00000] in
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in
System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in
Microsoft.AspNet.Mvc.MvcRouteHandler+d__3.MoveNext () [0x00000] in
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in
System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in
Microsoft.AspNet.Mvc.MvcRouteHandler+d__2.MoveNext () [0x00000] in
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in
System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in
Microsoft.AspNet.Routing.Template.TemplateRoute+d__25.MoveNext () [0x00000] in
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in
System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in
Microsoft.AspNet.Routing.RouteCollection+d__9.MoveNext () [0x00000] in
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in
System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in
Microsoft.AspNet.Builder.RouterMiddleware+d__5.MoveNext () [0x00000] in
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in
System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in
Microsoft.AspNet.Security.Infrastructure.AuthenticationMiddleware1+<Invoke>d__11[Microsoft.AspNet.Security.Cookies.CookieAuthenticationOptions].MoveNext () [0x00000] in <filename unknown> --- End of stack trace from previous location where exception was thrown --- System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown> Microsoft.AspNet.Security.Infrastructure.AuthenticationMiddleware1+d__11[Microsoft.AspNet.Security.Cookies.CookieAuthenticationOptions].MoveNext () [0x00000] in
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in
System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in
Microsoft.AspNet.Security.Infrastructure.AuthenticationMiddleware1+<Invoke>d__11[Microsoft.AspNet.Security.Cookies.CookieAuthenticationOptions].MoveNext () [0x00000] in <filename unknown> --- End of stack trace from previous location where exception was thrown --- System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown> Microsoft.AspNet.Security.Infrastructure.AuthenticationMiddleware1+d__11[Microsoft.AspNet.Security.Cookies.CookieAuthenticationOptions].MoveNext () [0x00000] in
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in
System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in
Microsoft.AspNet.Security.Infrastructure.AuthenticationMiddleware1+<Invoke>d__11[Microsoft.AspNet.Security.Cookies.CookieAuthenticationOptions].MoveNext () [0x00000] in <filename unknown> --- End of stack trace from previous location where exception was thrown --- System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown> Microsoft.AspNet.Security.Infrastructure.AuthenticationMiddleware1+d__11[Microsoft.AspNet.Security.Cookies.CookieAuthenticationOptions].MoveNext () [0x00000] in
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in
System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in
Microsoft.AspNet.Security.Infrastructure.AuthenticationMiddleware1+<Invoke>d__11[Microsoft.AspNet.Security.Cookies.CookieAuthenticationOptions].MoveNext () [0x00000] in <filename unknown> --- End of stack trace from previous location where exception was thrown --- System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown> Microsoft.AspNet.Security.Infrastructure.AuthenticationMiddleware1+d__11[Microsoft.AspNet.Security.Cookies.CookieAuthenticationOptions].MoveNext () [0x00000] in
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in
System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in
System.Threading.Tasks.TaskExtensions+CultureAwaiter.GetResult () [0x00000] in
Microsoft.AspNet.Diagnostics.Entity.MigrationsEndPointMiddleware+d__5.MoveNext () [0x00000] in
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in
System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in
System.Threading.Tasks.TaskExtensions+CultureAwaiter.GetResult () [0x00000] in
Microsoft.AspNet.Diagnostics.Entity.DatabaseErrorPageMiddleware+d__6.MoveNext () [0x00000] in
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in
Microsoft.AspNet.Diagnostics.Entity.DatabaseErrorPageMiddleware+d__6.MoveNext () [0x00000] in
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in
System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in
Microsoft.AspNet.Diagnostics.ErrorPageMiddleware+d__4.MoveNext () [0x00000] in

@stephentoub
Copy link
Member

@felipepaixao, thanks. I was curious about the configuration of your machine. A few questions:

  1. What distro of Linux are you running on?
  2. Are you running on Mono or on CoreCLR?
  3. Do you have a /tmp directory on your machine?
  4. What's the value of the ASPNET_TEMP environment variable? Try "printenv ASPNET_TEMP" from the terminal.
  5. If you set the ASPNET_TEMP environment variable to some temporary directory of your choosing (e.g. "export ASPNET_TEMP=/home/yourusername/tmpdirectoryyoucreate/") , does that make the error go away?

@felipepaixao
Copy link

Hi, @stephentoub
Thanks for your reply.
I Will check everything and I will give you a feedback.
And thanks again for your attention and for your advices.

@stephentoub
Copy link
Member

Excellent, thanks.

@davidfowl
Copy link
Member

I can chime in here. We added ASPNET_TEMP because IIS usually runs without a user profile under a service account. In those cases without carefully choosing a temp path, it ends up in a bizzare folder (system32 something). When we run in IIS, Helios (the IIS native module) sets ASPNET_TEMP to something appropriate.

When running self hosted however, the intent was to fall back to the regular temp path.

@davidfowl
Copy link
Member

@stephentoub This is also likely a mono stacktrace as nobody has built core clr dnx besides @ellismg and I 😄

@stephentoub
Copy link
Member

Thanks, David. Regarding Mono, that's what I was assuming, but, well, we all know what happens when people assume 😄 Hence the questions.

@stephentoub stephentoub self-assigned this Apr 17, 2015
@stephentoub
Copy link
Member

There doesn't actually appear to be a CoreCLR problem here, and with dotnet/coreclr@43e2851 we now also check TMPDIR prior to just returning /tmp/, so I'm closing this. If an issue is discovered here subsequently, we can reopen or open a new issue.

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 30, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Jan 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants