[Mono-bugs] [Bug 77651][Cos] New - Runtime crashes if the .exe being run is recompiled

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon Feb 27 06:31:00 EST 2006

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by pawel.sakowski at mind-breeze.com.


--- shadow/77651	2006-02-27 06:31:00.000000000 -0500
+++ shadow/77651.tmp.31945	2006-02-27 06:31:00.000000000 -0500
@@ -0,0 +1,81 @@
+Bug#: 77651
+Product: Mono: Compilers
+Version: 1.1
+OS: GNU/Linux [Other]
+OS Details: 
+Status: NEW   
+Priority: Cosmetic
+Component: C#
+AssignedTo: rharinath at novell.com                            
+ReportedBy: pawel.sakowski at mind-breeze.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+Summary: Runtime crashes if the .exe being run is recompiled
+Description of Problem:
+When gmcs compiles a previously compiled source, it overwrites the original
+.exe file's contents. If that file is being executed, the unexpected file
+modification makes mono crash (except some trivial cases where there's no
+further code to be executed from the file).
+There's no straightforward way to avoid it in the runtime (the .exe would
+have to be locked or held all in the memory). However, this can be easily
+avoided that gmcs triggers the issue. gcc on a compilation first issues an
+unlink(2) on the target file. This way, the target file content's change is
+invisible to the processes that already hold the file open (another inode
+is written to).
+I believe Mono should also unlink the target .exe file before writing the
+compilation output.
+Steps to reproduce the problem:
+A quick sample of how the issue can be triggered:
+1. Prepare x1.cs with the contents:
+using System;
+using System.Threading;
+class X {
+static void Main() {
+static void B() {
+2. Prepare x2.cs with the contents:
+using System;
+using System.Threading;
+class X {
+static void Main() {
+static void B(int i) {
+3. Issue the command sequence:
+cp x1.cs x.cs
+gmcs x.cs
+mono x.exe&
+cp x2.cs x.cs
+gmcs x.cs
+4. Wait until the Sleep runs out.
+Actual Results:
+** ERROR ** : file loader.c: line 1667 (mono_method_get_header): assertion
+failed: (loc)
+Expected Results:
+"5" on the console
+How often does this happen? 
+The crash itself is not very deterministic. It depends on various factors,
+with different code samples I saw various assertion failures triggered, in
+some cases the execution proceeded without obstruction. The file overwrite
+happens 100%.

More information about the mono-bugs mailing list