[Mono-bugs] [Bug 700838] New: Race condition with File.Open and FileShare.None

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Jun 19 15:34:48 EDT 2011


https://bugzilla.novell.com/show_bug.cgi?id=700838

https://bugzilla.novell.com/show_bug.cgi?id=700838#c0


           Summary: Race condition with File.Open and FileShare.None
    Classification: Mono
           Product: Mono: Class Libraries
           Version: SVN
          Platform: i686
        OS/Version: Other
            Status: NEW
          Severity: Critical
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: armin at replicator.org
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.30
(KHTML, like Gecko) Chrome/12.0.742.100 Safari/534.30

Using File.Open() with "FileShare.None" on the same file from multiple threads
causes a reproducible race condition.

See the attachements for an executable test.



Reproducible: Always

Steps to Reproduce:
1. Compile and run Program.cs
Actual Results:  
Stacktrace:


Native stacktrace:

    mono [0x4957a9]
    mono [0x4e853d]
    mono [0x415136]
    /lib64/libpthread.so.0 [0x35c300eb10]
    /lib64/libc.so.6 [0x35c2872b3d]
    /lib64/libc.so.6(__libc_calloc+0xcd) [0x35c2874aad]
    mono [0x5c9bba]
    mono [0x5b89df]
    mono [0x5adf6a]
    mono [0x5ae52e]
    mono [0x5e7d1d]
    [0x4086c699]

Debug info from gdb:

Mono support loaded.
warning: no loadable sections found in added symbol-file system-supplied DSO at
0x7fff59ae6000
[Thread debugging using libthread_db enabled]
[New Thread 0x40842940 (LWP 19171)]
[New Thread 0x423c6940 (LWP 19170)]
[New Thread 0x421c5940 (LWP 19169)]
[New Thread 0x41fc4940 (LWP 19168)]
[New Thread 0x40641940 (LWP 19167)]
[New Thread 0x41db0940 (LWP 19166)]
0x00000035c300e1c1 in nanosleep () from /lib64/libpthread.so.0
  7 Thread 0x41db0940 (LWP 19166)  0x00000035c300aee9 in
pthread_cond_wait@@GLIBC_2.3.2 ()
   from /lib64/libpthread.so.0
  6 Thread 0x40641940 (LWP 19167)  0x00000035c300cd01 in sem_wait ()
   from /lib64/libpthread.so.0
  5 Thread 0x41fc4940 (LWP 19168)  0x00000035c300d4c4 in __lll_lock_wait ()
   from /lib64/libpthread.so.0
  4 Thread 0x421c5940 (LWP 19169)  0x00000035c300d91b in read ()
   from /lib64/libpthread.so.0
  3 Thread 0x423c6940 (LWP 19170)  0x00000035c300d4c4 in __lll_lock_wait ()
   from /lib64/libpthread.so.0
  2 Thread 0x40842940 (LWP 19171)  0x00000035c300d4c4 in __lll_lock_wait ()
   from /lib64/libpthread.so.0
* 1 Thread 0x2aeb46103d40 (LWP 19165)  0x00000035c300e1c1 in nanosleep ()
   from /lib64/libpthread.so.0

Thread 7 (Thread 0x41db0940 (LWP 19166)):
#0  0x00000035c300aee9 in pthread_cond_wait@@GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1  0x00000000005d8792 in GC_wait_marker () at pthread_support.c:1863
#2  0x00000000005d526e in GC_help_marker (my_mark_no=1200) at mark.c:1116
#3  0x00000000005d7599 in GC_mark_thread (id=0x0) at pthread_support.c:552
#4  0x00000035c300673d in start_thread () from /lib64/libpthread.so.0
#5  0x00000035c28d44bd in clone () from /lib64/libc.so.6

Thread 6 (Thread 0x40641940 (LWP 19167)):
#0  0x00000035c300cd01 in sem_wait () from /lib64/libpthread.so.0
#1  0x00000000005c0d88 in mono_sem_wait (sem=0x8ef5a0, alertable=1) at
mono-semaphore.c:113
#2  0x000000000053d91b in finalizer_thread (unused=<value optimized out>) at
gc.c:1072
#3  0x000000000058eb02 in start_wrapper_internal (data=<value optimized out>)
    at threads.c:567
#4  start_wrapper (data=<value optimized out>) at threads.c:615
#5  0x00000000005a8383 in thread_start_routine (args=0x147de080) at
wthreads.c:289
#6  0x00000000005c2d0c in inner_start_thread (arg=<value optimized out>)
    at mono-threads-posix.c:44
#7  0x00000000005d842f in GC_start_routine (arg=0x2aaaab62afc0) at
pthread_support.c:1468
#8  0x00000035c300673d in start_thread () from /lib64/libpthread.so.0
#9  0x00000035c28d44bd in clone () from /lib64/libc.so.6

Thread 5 (Thread 0x41fc4940 (LWP 19168)):
#0  0x00000035c300d4c4 in __lll_lock_wait () from /lib64/libpthread.so.0
#1  0x00000035c3008e1a in _L_lock_1034 () from /lib64/libpthread.so.0
#2  0x00000035c3008cdc in pthread_mutex_lock () from /lib64/libpthread.so.0
#3  0x00000000005b67ff in noshm_sem_lock (sem=<value optimized out>) at
shared.c:67
#4  _wapi_shm_sem_lock (sem=<value optimized out>) at shared.c:861
#5  0x00000000005b873e in _wapi_handle_lock_shared_handles (device=64768,
inode=29895859, 
    new_sharemode=0, new_access=1073741824, old_sharemode=0x41fc39bc,
old_access=
    0x41fc39b8, share_info=0x41fc3a88) at
./../mono/io-layer/handles-private.h:336
#6  _wapi_handle_get_or_set_share (device=64768, inode=29895859,
new_sharemode=0, 
    new_access=1073741824, old_sharemode=0x41fc39bc, old_access=0x41fc39b8,
share_info=
    0x41fc3a88) at handles.c:1701
#7  0x00000000005adf6a in share_allows_open (statbuf=<value optimized out>,
sharemode=0, 
    fileaccess=4294967295, share_info=0x41fc3a88) at io.c:1407
#8  0x00000000005ae503 in share_check (name=<value optimized out>,
fileaccess=1073741824, 
    sharemode=0, security=<value optimized out>, createmode=<value optimized
out>, attrs=
    128, template=0x0) at io.c:1465
#9  CreateFile (name=<value optimized out>, fileaccess=1073741824, sharemode=0, 
    security=<value optimized out>, createmode=<value optimized out>,
attrs=128, template=
    0x0) at io.c:1627
#10 0x00000000005e7d1d in ves_icall_System_IO_MonoIO_Open (filename=<value
optimized out>, 
    mode=<value optimized out>, access_mode=2, share=0, options=<value
optimized out>, 
    error=0x41fc3bd4) at file-io.c:792
#11 0x000000004086c699 in ?? ()
#12 0x000000001482a5c0 in ?? ()
#13 0x00002aaaab6ef240 in ?? ()
#14 0x00002aaaab6ef240 in ?? ()
#15 0x00002aaaaaece0b5 in System.IO.MonoIO:ExistsDirectory (path=null,
error=1107049472)
    at /root/mono/mcs/class/corlib/System.IO/MonoIO.cs:252
#16 0x0000000000000000 in ?? ()

Thread 4 (Thread 0x421c5940 (LWP 19169)):
#0  0x00000035c300d91b in read () from /lib64/libpthread.so.0
#1  0x00000000004958a6 in mono_handle_native_sigsegv (signal=<value optimized
out>, 
    ctx=<value optimized out>) at mini-exceptions.c:2254
#2  0x00000000004e853d in mono_arch_handle_altstack_exception
(sigctx=0x2aaaab40dc40, 
    fault_addr=<value optimized out>, stack_ovf=0) at exceptions-amd64.c:951
#3  0x0000000000415136 in mono_sigsegv_signal_handler (_dummy=11,
info=0x2aaaab40dd70, 
    context=0x2aaaab40dc40) at mini.c:5870
#4  <signal handler called>
#5  0x00000035c2872b3d in _int_malloc () from /lib64/libc.so.6
#6  0x00000035c2874aad in calloc () from /lib64/libc.so.6
#7  0x00000000005c9bba in monoeg_malloc0 (x=40) at gmem.c:84
#8  0x00000000005b89df in _wapi_handle_get_or_set_share (device=64768,
inode=29895859, 
    new_sharemode=0, new_access=1073741824, old_sharemode=0x421c49bc,
old_access=
    0x421c49b8, share_info=0x421c4a88) at handles.c:1735
#9  0x00000000005adf6a in share_allows_open (statbuf=<value optimized out>,
sharemode=0, 
    fileaccess=2885681352, share_info=0x421c4a88) at io.c:1407
#10 0x00000000005ae52e in share_check (name=<value optimized out>,
fileaccess=1073741824, 
    sharemode=0, security=<value optimized out>, createmode=<value optimized
out>, attrs=
    128, template=0x0) at io.c:1479
#11 CreateFile (name=<value optimized out>, fileaccess=1073741824, sharemode=0, 
    security=<value optimized out>, createmode=<value optimized out>,
attrs=128, template=
    0x0) at io.c:1627
#12 0x00000000005e7d1d in ves_icall_System_IO_MonoIO_Open (filename=<value
optimized out>, 
    mode=<value optimized out>, access_mode=2, share=0, options=<value
optimized out>, 
    error=0x421c4bd4) at file-io.c:792
#13 0x000000004086c699 in ?? ()
#14 0x0000000014827c30 in ?? ()
#15 0x00002aaaab78cae0 in ?? ()
#16 0x00002aaaab78cae0 in ?? ()
#17 0x00002aaaaaece0b5 in System.IO.MonoIO:ExistsDirectory (path=null,
error=1109150720)
    at /root/mono/mcs/class/corlib/System.IO/MonoIO.cs:252
#18 0x0000000000000000 in ?? ()

Thread 3 (Thread 0x423c6940 (LWP 19170)):
#0  0x00000035c300d4c4 in __lll_lock_wait () from /lib64/libpthread.so.0
#1  0x00000035c3008e1a in _L_lock_1034 () from /lib64/libpthread.so.0
#2  0x00000035c3008cdc in pthread_mutex_lock () from /lib64/libpthread.so.0
#3  0x00000000005b67ff in noshm_sem_lock (sem=<value optimized out>) at
shared.c:67
#4  _wapi_shm_sem_lock (sem=<value optimized out>) at shared.c:861
#5  0x00000000005b873e in _wapi_handle_lock_shared_handles (device=64768,
inode=29895859, 
    new_sharemode=0, new_access=1073741824, old_sharemode=0x423c59bc,
old_access=
    0x423c59b8, share_info=0x423c5a88) at
./../mono/io-layer/handles-private.h:336
#6  _wapi_handle_get_or_set_share (device=64768, inode=29895859,
new_sharemode=0, 
    new_access=1073741824, old_sharemode=0x423c59bc, old_access=0x423c59b8,
share_info=
    0x423c5a88) at handles.c:1701
#7  0x00000000005adf6a in share_allows_open (statbuf=<value optimized out>,
sharemode=0, 
    fileaccess=4294967295, share_info=0x423c5a88) at io.c:1407
#8  0x00000000005ae54e in share_check (name=<value optimized out>,
fileaccess=1073741824, 
    sharemode=0, security=<value optimized out>, createmode=<value optimized
out>, attrs=
    128, template=0x0) at io.c:1492
#9  CreateFile (name=<value optimized out>, fileaccess=1073741824, sharemode=0, 
    security=<value optimized out>, createmode=<value optimized out>,
attrs=128, template=
    0x0) at io.c:1627
#10 0x00000000005e7d1d in ves_icall_System_IO_MonoIO_Open (filename=<value
optimized out>, 
    mode=<value optimized out>, access_mode=2, share=0, options=<value
optimized out>, 
    error=0x423c5bd4) at file-io.c:792
#11 0x000000004086c699 in ?? ()
#12 0x0000000014833950 in ?? ()
#13 0x00002aaaab70ccf0 in ?? ()
#14 0x00002aaaab70ccf0 in ?? ()
#15 0x00002aaaaaece0b5 in System.IO.MonoIO:ExistsDirectory (path=null,
error=1111251968)
    at /root/mono/mcs/class/corlib/System.IO/MonoIO.cs:252
#16 0x0000000000000000 in ?? ()

Thread 2 (Thread 0x40842940 (LWP 19171)):
#0  0x00000035c300d4c4 in __lll_lock_wait () from /lib64/libpthread.so.0
#1  0x00000035c3008e1a in _L_lock_1034 () from /lib64/libpthread.so.0
#2  0x00000035c3008cdc in pthread_mutex_lock () from /lib64/libpthread.so.0
#3  0x00000000005b67ff in noshm_sem_lock (sem=<value optimized out>) at
shared.c:67
#4  _wapi_shm_sem_lock (sem=<value optimized out>) at shared.c:861
#5  0x00000000005b873e in _wapi_handle_lock_shared_handles (device=64768,
inode=29895859, 
    new_sharemode=0, new_access=1073741824, old_sharemode=0x408419bc,
old_access=
    0x408419b8, share_info=0x40841a88) at
./../mono/io-layer/handles-private.h:336
#6  _wapi_handle_get_or_set_share (device=64768, inode=29895859,
new_sharemode=0, 
    new_access=1073741824, old_sharemode=0x408419bc, old_access=0x408419b8,
share_info=
    0x40841a88) at handles.c:1701
#7  0x00000000005adf6a in share_allows_open (statbuf=<value optimized out>,
sharemode=0, 
    fileaccess=4294967295, share_info=0x40841a88) at io.c:1407
#8  0x00000000005ae503 in share_check (name=<value optimized out>,
fileaccess=1073741824, 
    sharemode=0, security=<value optimized out>, createmode=<value optimized
out>, attrs=
    128, template=0x0) at io.c:1465
#9  CreateFile (name=<value optimized out>, fileaccess=1073741824, sharemode=0, 
    security=<value optimized out>, createmode=<value optimized out>,
attrs=128, template=
    0x0) at io.c:1627
#10 0x00000000005e7d1d in ves_icall_System_IO_MonoIO_Open (filename=<value
optimized out>, 
    mode=<value optimized out>, access_mode=2, share=0, options=<value
optimized out>, 
    error=0x40841bd4) at file-io.c:792
#11 0x000000004086c699 in ?? ()
#12 0x00000000148347e0 in ?? ()
#13 0x00002aaaab735ea0 in ?? ()
#14 0x00002aaaab735ea0 in ?? ()
#15 0x00002aaaaaece0b5 in System.IO.MonoIO:ExistsDirectory (path=null,
error=1082399744)
    at /root/mono/mcs/class/corlib/System.IO/MonoIO.cs:252
#16 0x0000000000000000 in ?? ()

Thread 1 (Thread 0x2aeb46103d40 (LWP 19165)):
#0  0x00000035c300e1c1 in nanosleep () from /lib64/libpthread.so.0
#1  0x00000000005a6c98 in SleepEx (ms=0, alertable=1) at wthreads.c:1030
#2  0x0000000000590aee in ves_icall_System_Threading_Thread_Sleep_internal
(ms=60000)
    at threads.c:1111
#3  0x000000004086c80a in ?? ()
#4  0x000000001478e9a0 in ?? ()
#5  0x0000000000000004 in ?? ()
#6  0x0000000000000000 in ?? ()

=================================================================
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.
=================================================================


Expected Results:  
The program should terminate after 60 seconds without error.


The problem can be reproduced with Mono 2.6, 2.8.2 and 2.10 and the current
version from the github repository. 

And sometimes the following diagnostic message appears:

===
*** glibc detected *** mono: malloc(): smallbin double linked list corrupted:
0x0000000009ca5b50 ***
===

System:
Linux 2.6.18-238.12.1.el5 #1 SMP x86_64 GNU/Linux

-- 
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