.net core docker container exited with error code 139 in production because of Null Exception

Viewed 3309

I have a docker container with .net core web app on it. The docker has been exited with error code 139. Docker inspect has no oom indication
When I looked at the logs I saw this, and no more hints:

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at Services.Web.Services.ProductClient.RunCient.<>c__DisplayClass5_0.<<ScrapeProfileInfo>b__0>d.MoveNext() in /src/Services.Web/Services/Clients/ProductClient.cs:line 30
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__139_1(Object state)
   at System.Threading.QueueUserWorkItemCallback.<>c.<.cctor>b__6_0(QueueUserWorkItemCallback quwi)
   at System.Threading.ExecutionContext.RunForThreadPoolUnsafe[TState](ExecutionContext executionContext, Action`1 callback, TState& state)
   at System.Threading.QueueUserWorkItemCallback.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()

In ProductClient.cs: line 30 there is no potential risk of null exception... if (txt == string.Empty) return;

  1. What may cause this exception, this line has no risk at all?
  2. Docker does not suppose to exist just because of one exception, does it hint to what may happened?

I'm hosted on the Google cloud platform. the docker is on a ubuntu server under compute engine... (docker-compose)

Update
The build is a docker build
RUN dotnet build "TestServices.Web.csproj" -c Release -o /app/build
Not using c# nullable feature

Thanks

1 Answers

I don't think the problem is in docker, more likely it's in c#

Things you could try:

  1. Change build mode to debug: -c Debug. C# compiler during optimization can inline some functions and the NPE might come from different line than exception states (see https://developer.azurewebsites.net/2015/11/net-c-build-release-mode-with-full-stack-trace-and-line-numbers/)
  2. Use nullables. It helps a lot with tracking potential NPE issues.
  3. try checking for null before. add a test clause if (txt is null) and see if you're sure that txt there is not null.
Related