core icon indicating copy to clipboard operation
core copied to clipboard

watch : Exited with error code 139 watch : Waiting for a file to change before restarting dotnet...

Open Kwofie-mex opened this issue 3 years ago • 19 comments

Problem encountered on https://dotnet.microsoft.com/en-us/learn/aspnet/blazor-tutorial/run Operating System: linux

Provide details about the problem you're experiencing. Include your operating system version, exact error message, code sample, and anything else that is relevant.

Kwofie-mex avatar Jan 13 '22 15:01 Kwofie-mex

@danroth27 can you assist with this?

mairaw avatar Jan 13 '22 17:01 mairaw

Hmm...not sure. @pranavkm ?

danroth27 avatar Jan 13 '22 22:01 danroth27

139 usually means access violation. Is this error consistent? Do you get this running other dotnet commands?

pranavkm avatar Jan 13 '22 23:01 pranavkm

Yes! This is a little bit worrying. This happens when I want to run a small project in .NET 6 or .NET 5. This message is:

watch : Started

watch : Exited with error code 139
watch : Waiting for a file to change before restarting dotnet...

And that appears when I use the command dotnet watch run or dotnet run. Also when I try to run from the folder bin/Debug/My-project, another message appears: Violación de segmento ('core' generado), which translates to English (if I am not mistaken) as Core Dump (Segmentation fault). I don't know why this happens and I cannot use .NET in my machine.

Some info:

  • Operating system: Ubuntu 20.04 with kernel 5.13.0-28-generic.
  • This happens with dotnet version 6.0.101 and the last from .NET 5 (I think it is 5.0.404).
  • When I press Ctrl + C, it shows:
Long message
Unhandled exception. System.OperationCanceledException: The operation was canceled.
   at System.Threading.CancellationToken.ThrowOperationCanceledException()
   at System.Threading.CancellationToken.ThrowIfCancellationRequested()
   at Microsoft.CodeAnalysis.EditAndContinue.CommittedSolution.<>c__DisplayClass15_0.<<GetMatchingDocumentsAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.CodeAnalysis.EditAndContinue.CommittedSolution.GetMatchingDocumentsAsync(IEnumerable`1 documentsByProject, Func`2 compilationOutputsProvider, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.EditAndContinue.EditAndContinueWorkspaceService.StartDebuggingSessionAsync(Solution solution, IManagedHotReloadService debuggerService, ImmutableArray`1 captureMatchingDocuments, Boolean captureAllMatchingDocuments, Boolean reportDiagnostics, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.ExternalAccess.Watch.Api.WatchHotReloadService.StartSessionAsync(Solution solution, CancellationToken cancellationToken)
   at Microsoft.DotNet.Watcher.Tools.CompilationWorkspaceProvider.CreateProject(TaskCompletionSource`1 taskCompletionSource, Task`1 hotReloadCapabilitiesTask, String projectPath, IReporter reporter, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   at System.Threading.QueueUserWorkItemCallbackDefaultContext.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
   at System.Threading.Thread.StartCallback()

rosgori avatar Feb 07 '22 02:02 rosgori

Same problem with dotnet version 6.0.102.

rosgori avatar Feb 08 '22 20:02 rosgori

Is it possible you're building from/to a protected directory?

danroth27 avatar Feb 08 '22 21:02 danroth27

The solution is weird, I don't know why. I have installed dotnet through snap and it was working fine, no problem there. Suddenly on February when I tried to run some projects, it didn't work, it showed watch : Exited with error code 139. I tried two possible solutions: the first one, I downloaded the binaries from here and I used the executable (for the versions 5 and 6). Same error. The second solution was to install from apt (I am using Ubuntu) using this guide. It worked!. Again, I don't know why, but I can run any project using dotnet run or dotnet watch run. Although this does not answer the question: why did that kind of error show up?

rosgori avatar Feb 09 '22 02:02 rosgori

We were debugging an issue where our .NET containers (linux) sometimes exit with 139 errors and I later found that if the .NET app (which runs as the entrypoint to the container) throws an unhandled exception (same as in @rosgori's comment), then the container consistently has an exit code of 139. What is even more confusing is that if you shell into the same container and run the "dotnet my-app.dll" manually you get an exit code of 134 (Abort) when an unhandled exception is thrown. You can simulate this with any .NET app (from 3.1 to 6.0) where you simply throw an exception in the Main method.

mot256 avatar Mar 02 '22 10:03 mot256

https://github.com/dotnet/core/issues/7112#issuecomment-1033292899 thanks your solutions works

bijeaylimbu avatar Oct 17 '22 11:10 bijeaylimbu

We are trying to fix our docs to warn people about snap being mostly broken for dotnet tools: https://github.com/dotnet/docs/pull/31045

omajid avatar Oct 17 '22 13:10 omajid

The solution is weird, I don't know why. I have installed dotnet through snap and it was working fine, no problem there. Suddenly on February when I tried to run some projects, it didn't work, it showed watch : Exited with error code 139. I tried two possible solutions: the first one, I downloaded the binaries from here and I used the executable (for the versions 5 and 6). Same error. The second solution was to install from apt (I am using Ubuntu) using this guide. It worked!. Again, I don't know why, but I can run any project using dotnet run or dotnet watch run. Although this does not answer the question: why did that kind of error show up?

Thank you so much! The 2nd solution did helped me.

Sidjay00 avatar Feb 11 '23 14:02 Sidjay00

I'm getting the same issue on archlinux, I'm using dotnet 6.0 I had no clue why this happen, I already try install manually, by script dotnet-install.sh and also from aur package dotnet-sdk-6.0

dotnet watch ❌ Exited with error code 139
dotnet watch ⏳ Waiting for a file to change before restarting dotnet...```

nandafirmans avatar Dec 01 '23 18:12 nandafirmans

@nandafirmans I don't do much on Linux, but it doesn't look like archlinux is currently on the supported distro list for .NET 8: https://github.com/dotnet/core/blob/main/release-notes/8.0/supported-os.md.

@richlander Do you know if there are known issues running .NET on archlinux?

danroth27 avatar Dec 02 '23 02:12 danroth27

Does anyone have updates regarding this issue? We are currently using .NET Core SDK 7 (mcr.microsoft.com/dotnet/sdk:7.0) on Amazon Elastic Container Service (ECS). For several weeks now, we have been encountering these errors where the container is abruptly terminated with exit code 139. Unfortunately, there is no additional information provided to help us comprehend the root cause of the error.

diegodfsd avatar Dec 06 '23 22:12 diegodfsd

Facing the same issue as @diegodfsd above. Tried Ubuntu amd64 and Alpine amd64 docker image. Same issue. Host OS is Ubuntu. Nothing in logs. Seems more easily triggered on Ubuntu vs Alpine, which takes longer. Tried debugging it for weeks now.

arhue avatar Jan 13 '24 09:01 arhue

@arhue / @diegodfsd Do you have fix to this issue yet? It's being a bottle neck for one of my service with similar setup on ECS

huzaynbolt avatar Aug 02 '24 19:08 huzaynbolt