Bug 28872 - System.NullReferenceException: in System.Threading.Monitor:FastMonitorEnterV4
Summary: System.NullReferenceException: in System.Threading.Monitor:FastMonitorEnterV4
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: 3.12.0
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: marcos.henrich
URL:
Depends on:
Blocks:
 
Reported: 2015-04-07 19:00 UTC by Jake Scott
Modified: 2015-06-30 16:40 UTC (History)
3 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description Jake Scott 2015-04-07 19:00:46 UTC
I have the following Dockerfile

FROM microsoft/aspnet
COPY project.json /app/
WORKDIR /app
RUN ["kpm", "restore"]
COPY . /app
EXPOSE 5004
ENTRYPOINT ["k", "kestrel"]

# In this folder:
# sudo docker build -t myapp .
# sudo docker run -t -d -p 80:5004 myapp /port=5004

I get the following error when I run the command sudo docker build -t myapp .

root@rustbox:/home/jakescott/vnext/hello-web# sudo docker build -t myapp .
Sending build context to Docker daemon 105.5 kB
Sending build context to Docker daemon 
Step 0 : FROM microsoft/aspnet
 ---> 98b0320569c3
Step 1 : COPY project.json /app/
 ---> f6c9eaaee015
Removing intermediate container d323ec72e0c8
Step 2 : WORKDIR /app
 ---> Running in 99e801881f10
 ---> 49da217d991e
Removing intermediate container 99e801881f10
Step 3 : RUN kpm restore
 ---> Running in 78306a175ad1
Restoring packages for /app/project.json
  GET https://www.nuget.org/api/v2/FindPackagesById()?Id='Kestrel'.
  GET https://www.nuget.org/api/v2/FindPackagesById()?Id='Microsoft.AspNet.Diagnostics'.
  GET https://www.nuget.org/api/v2/FindPackagesById()?Id='Microsoft.AspNet.Hosting'.
  GET https://www.nuget.org/api/v2/FindPackagesById()?Id='Microsoft.AspNet.Server.WebListener'.
  GET https://www.nuget.org/api/v2/FindPackagesById()?Id='Microsoft.AspNet.StaticFiles'.
  OK https://www.nuget.org/api/v2/FindPackagesById()?Id='Kestrel' 2313ms
  OK https://www.nuget.org/api/v2/FindPackagesById()?Id='Microsoft.AspNet.Server.WebListener' 2254ms
  GET https://www.nuget.org/api/v2/package/Kestrel/1.0.0-beta3.
  GET https://www.nuget.org/api/v2/package/Microsoft.AspNet.Server.WebListener/1.0.0-beta3.
  OK https://www.nuget.org/api/v2/FindPackagesById()?Id='Microsoft.AspNet.StaticFiles' 2330ms
  GET https://www.nuget.org/api/v2/package/Microsoft.AspNet.StaticFiles/1.0.0-beta3.
  OK https://www.nuget.org/api/v2/FindPackagesById()?Id='Microsoft.AspNet.Hosting' 2400ms
  GET https://www.nuget.org/api/v2/package/Microsoft.AspNet.Hosting/1.0.0-beta3.
  OK https://www.nuget.org/api/v2/FindPackagesById()?Id='Microsoft.AspNet.Diagnostics' 2454ms
  GET https://www.nuget.org/api/v2/package/Microsoft.AspNet.Diagnostics/1.0.0-beta3.
ERROR building certificate chain: System.NullReferenceException: Object reference not set to an instance of an object
  at System.Security.Cryptography.X509Certificates.X509Certificate2Collection.AddRange (System.Security.Cryptography.X509Certificates.X509Certificate2Collection certificates) [0x00000] in <filename unknown>:0 
  at System.Security.Cryptography.X509Certificates.X509Chain.get_CertificateCollection () [0x00000] in <filename unknown>:0 
  at System.Security.Cryptography.X509Certificates.X509Chain.FindParent (System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) [0x00000] in <filename unknown>:0 
  at System.Security.Cryptography.X509Certificates.X509Chain.BuildChainFrom (System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) [0x00000] in <filename unknown>:0 
  at System.Security.Cryptography.X509Certificates.X509Chain.Build (System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) [0x00000] in <filename unknown>:0 
  at System.Net.ServicePointManager+ChainValidationHelper.ValidateChain (Mono.Security.X509.X509CertificateCollection certs) [0x00000] in <filename unknown>:0 
Please, report this problem to the Mono team
ERROR processing certificate: System.NullReferenceException: Object reference not set to an instance of an object
  at System.Collections.CollectionBase.get_Count () [0x00000] in <filename unknown>:0 
  at System.Security.Cryptography.X509Certificates.X509ExtensionCollection..ctor (Mono.Security.X509.X509Certificate cert) [0x00000] in <filename unknown>:0 
  at System.Security.Cryptography.X509Certificates.X509Certificate2.get_Extensions () [0x00000] in <filename unknown>:0 
  at System.Net.ServicePointManager+ChainValidationHelper.CheckCertificateUsage (System.Security.Cryptography.X509Certificates.X509Certificate2 cert) [0x00000] in <filename unknown>:0 
Please, report this problem to the Mono team

Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
  at (wrapper unknown) System.Threading.Monitor:FastMonitorEnterV4 (object,bool&)
  at Mono.Security.Protocol.Tls.RecordProtocol+ReceiveRecordAsyncResult.SetComplete (System.Exception ex, System.Byte[] resultingBuffer) [0x00000] in <filename unknown>:0 
  at Mono.Security.Protocol.Tls.RecordProtocol+ReceiveRecordAsyncResult.SetComplete (System.Exception ex) [0x00000] in <filename unknown>:0 
  at Mono.Security.Protocol.Tls.RecordProtocol.InternalReceiveRecordCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
INFO[0004] The command [kpm restore] returned a non-zero code: 255 
root@rustbox:/home/jakescott/vnext/hello-web#
Comment 1 Jake Scott 2015-04-07 19:01:18 UTC
I also reported the bug here: https://github.com/aspnet/aspnet-docker/issues/46
Comment 2 xamarin 2015-04-29 05:00:10 UTC
I've had this crash happen in Mono 4.0.1 too:

[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
  at (wrapper unknown) System.Threading.Monitor:FastMonitorEnterV4 (object,bool&)
  at System.Threading.Timer+Scheduler.SchedulerThread () [0x00000] in <filename unknown>:0
  at System.Threading.Thread.StartInternal () [0x00000] in <filename unknown>:0
Comment 3 xamarin 2015-04-29 05:18:59 UTC
Also had a different crash related to Timers just now:

[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
  at System.Threading.EventWaitHandle.Reset () [0x00000] in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) System.Threading.EventWaitHandle:Reset ()
  at System.Threading.Timer+Scheduler.SchedulerThread () [0x00000] in <filename unknown>:0
  at System.Threading.Thread.StartInternal () [0x00000] in <filename unknown>:0
Comment 4 Rodrigo Kumpera 2015-06-30 16:40:49 UTC
Hi Marcos,

Could you take a look and try to repro this one?

Note You need to log in before you can comment on or make changes to this bug.