[Mono-bugs] [Bug 648894] DateTime.Now occasionally throws NullReferenceException
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Thu Jan 6 18:58:48 EST 2011
https://bugzilla.novell.com/show_bug.cgi?id=648894
https://bugzilla.novell.com/show_bug.cgi?id=648894#c1
John Costella <john.costella at petermac.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |john.costella at petermac.org
--- Comment #1 from John Costella <john.costella at petermac.org> 2011-01-06 23:58:47 UTC ---
I confirm this bug.
I believe the problem is that Mono's implementation of System.DateTime.Now is
not thread-safe, whereas MSDN specifies that all members of System.DateTime are
thread-safe.
Sample output 2 below reproduces your experience.
=== Sample code: ===
using System;
using System.Threading.Tasks;
class MainClass
{
public static void Main (string[] args)
{
Parallel.For(0, 4, i => Console.WriteLine(DateTime.Now));
}
}
=== Sample output 1: ===
Stacktrace:
at System.Threading.Tasks.Parallel/<For>c__AnonStorey44.<>m__47
(int,System.Threading.Tasks.ParallelLoopState) <0xffffffff>
at System.Threading.Tasks.Parallel/<For>c__AnonStorey44.<>m__47
(int,System.Threading.Tasks.ParallelLoopState) <0x0001e>
at System.Threading.Tasks.Parallel/<For>c__AnonStorey45.<>m__48
(int,System.Threading.Tasks.ParallelLoopState,object) <0x00028>
at System.Threading.Tasks.Parallel/<For>c__AnonStorey46`1.<>m__4B ()
<0x00204>
at System.Threading.Tasks.TaskFactory/<StartNew>c__AnonStorey13.<>m__B
(object) <0x00014>
at System.Threading.Tasks.Task.InnerInvoke () <0x00021>
at System.Threading.Tasks.Task.ThreadStart () <0x000e8>
at System.Threading.Tasks.Task.Execute
(System.Action`1<System.Threading.Tasks.Task>) <0x00051>
at System.Threading.Tasks.ThreadWorker.WorkerMethod
(System.Func`1<bool>,System.Collections.Concurrent.IProducerConsumerCollection`1<System.Threading.Tasks.Task>,System.Threading.Tasks.ThreadWorker[])
<0x000a7>
at System.Threading.Tasks.Scheduler.ParticipateUntil (System.Func`1<bool>)
<0x00021>
at System.Threading.Tasks.Scheduler.ParticipateUntil
(System.Threading.Tasks.Task) <0x00077>
at System.Threading.Tasks.Task.Wait () <0x0002e>
at System.Threading.Tasks.Task.WaitAll (System.Threading.Tasks.Task[])
<0x0005a>
at System.Threading.Tasks.Parallel.For<TLocal>
(int,int,System.Threading.Tasks.ParallelOptions,System.Func`1<TLocal>,System.Func`4<int,
System.Threading.Tasks.ParallelLoopState, TLocal,
TLocal>,System.Action`1<TLocal>) <0x00302>
at System.Threading.Tasks.Parallel.For
(int,int,System.Threading.Tasks.ParallelOptions,System.Action`2<int,
System.Threading.Tasks.ParallelLoopState>) <0x0008a>
at System.Threading.Tasks.Parallel.For
(int,int,System.Threading.Tasks.ParallelOptions,System.Action`1<int>) <0x0007c>
at System.Threading.Tasks.Parallel.For (int,int,System.Action`1<int>)
<0x00031>
at MainClass.Main (string[]) <0x00082>
at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object
(object,intptr,intptr,intptr) <0x0007b>
Native stacktrace:
mono() [0x489a0b]
mono() [0x4dd35f]
/lib/libpthread.so.0(+0xfb40) [0x7fe0804c3b40]
mono() [0x4b9cb7]
mono() [0x4ca780]
mono() [0x417b5d]
mono() [0x41af7d]
mono() [0x41c46c]
mono() [0x41cc0d]
mono() [0x48e074]
[0x4086e0ca]
Debug info from gdb:
7/01/2011 10:48:41 AM
7/01/2011 10:48:41 AM
7/01/2011 10:48:41 AM
Could not attach to process. If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user. For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Operation not permitted.
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
=== Sample output 2: ===
7/01/2011 10:53:18 AM
Unhandled Exception: Exception(s) occurred : .
[ Exception(s) occurred : .
[ System.NullReferenceException: Object reference not set to an instance of an
object
at System.DateTime.get_Now () [0x00000] in <filename unknown>:0
at MainClass.<Main>m__0 (Int32 i) [0x00000] in <filename unknown>:0
at System.Threading.Tasks.Parallel+<For>c__AnonStorey44.<>m__47 (Int32 index,
System.Threading.Tasks.ParallelLoopState state) [0x00000] in <filename
unknown>:0
at System.Threading.Tasks.Parallel+<For>c__AnonStorey45.<>m__48 (Int32 i,
System.Threading.Tasks.ParallelLoopState s, System.Object l) [0x00000] in
<filename unknown>:0
at
System.Threading.Tasks.Parallel+<For>c__AnonStorey46`1[System.Object].<>m__4B
() [0x00000] in <filename unknown>:0
at System.Threading.Tasks.TaskFactory+<StartNew>c__AnonStorey13.<>m__B
(System.Object o) [0x00000] in <filename unknown>:0
at System.Threading.Tasks.Task.InnerInvoke () [0x00000] in <filename
unknown>:0
at System.Threading.Tasks.Task.ThreadStart () [0x00000] in <filename
unknown>:0 ]
]
[ Exception(s) occurred : .
[ System.NullReferenceException: Object reference not set to an instance of an
object
at System.DateTime.get_Now () [0x00000] in <filename unknown>:0
at MainClass.<Main>m__0 (Int32 i) [0x00000] in <filename unknown>:0
at System.Threading.Tasks.Parallel+<For>c__AnonStorey44.<>m__47 (Int32 index,
System.Threading.Tasks.ParallelLoopState state) [0x00000] in <filename
unknown>:0
at System.Threading.Tasks.Parallel+<For>c__AnonStorey45.<>m__48 (Int32 i,
System.Threading.Tasks.ParallelLoopState s, System.Object l) [0x00000] in
<filename unknown>:0
at
System.Threading.Tasks.Parallel+<For>c__AnonStorey46`1[System.Object].<>m__4B
() [0x00000] in <filename unknown>:0
at System.Threading.Tasks.TaskFactory+<StartNew>c__AnonStorey13.<>m__B
(System.Object o) [0x00000] in <filename unknown>:0
at System.Threading.Tasks.Task.InnerInvoke () [0x00000] in <filename
unknown>:0
at System.Threading.Tasks.Task.ThreadStart () [0x00000] in <filename
unknown>:0 ]
]
[ Exception(s) occurred : .
[ System.NullReferenceException: Object reference not set to an instance of an
object
at System.DateTime.get_Now () [0x00000] in <filename unknown>:0
at MainClass.<Main>m__0 (Int32 i) [0x00000] in <filename unknown>:0
at System.Threading.Tasks.Parallel+<For>c__AnonStorey44.<>m__47 (Int32 index,
System.Threading.Tasks.ParallelLoopState state) [0x00000] in <filename
unknown>:0
at System.Threading.Tasks.Parallel+<For>c__AnonStorey45.<>m__48 (Int32 i,
System.Threading.Tasks.ParallelLoopState s, System.Object l) [0x00000] in
<filename unknown>:0
at
System.Threading.Tasks.Parallel+<For>c__AnonStorey46`1[System.Object].<>m__4B
() [0x00000] in <filename unknown>:0
at System.Threading.Tasks.TaskFactory+<StartNew>c__AnonStorey13.<>m__B
(System.Object o) [0x00000] in <filename unknown>:0
at System.Threading.Tasks.Task.InnerInvoke () [0x00000] in <filename
unknown>:0
at System.Threading.Tasks.Task.ThreadStart () [0x00000] in <filename
unknown>:0 ]
]
=== Sample output 3: ===
4431 Segmentation fault
=== Sample output 4: ===
Stacktrace:
Native stacktrace:
mono() [0x489a0b]
mono() [0x4dd35f]
/lib/libpthread.so.0(+0xfb40) [0x7f904f162b40]
mono() [0x4b9cb7]
mono() [0x4ca780]
mono() [0x417b5d]
mono() [0x41af7d]
mono() [0x41c46c]
mono() [0x41cc0d]
mono() [0x48e074]
[0x412820ca]
Debug info from gdb:
7/01/2011 10:55:40 AM
7/01/2011 10:55:40 AM
7/01/2011 10:55:40 AM
Could not attach to process. If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user. For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Operation not permitted.
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
(Plus a dozen or more runs where it worked fine.)
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list