https://bugzilla.novell.com/show_bug.cgi?id=224818
------- Comment #20 from miguel@ximian.com 2006-11-30 15:39 MST -------
Ok, we found out what the problem was. It took a while, but we found it.
ZMD is broken for the following reasons:
The use of signal handlers is not supported in Mono, but we provided a way of
doing it for those that knew what they were doing, for details see:
(http://www.mono-project.com/FAQ:_Technical#Can_I_use_signal_handlers_with_Mo...)
ZMD does not follow the practice (which is extremely tricky) and instead
created their own.
The problem is that signal handlers can be invoked at any time, and they would
trigger a JIT compilation of the code, and this would break the locking
mechanism inside the JIT.
So our process documents how to get this going (and we still strongly encourage
people to not use signal handlers with their applications, because it is error
prone).
* ZMD went beyond the only supported practice, did not follow the advise, and
got clever with its use of signals, in particular, they created a "SigAction
structure" that they intended would map into the underlying sigaction structure
of the operating system (which is highly OS dependent, and their code has a
definition that they probably copied from somewhere, that somewhere is probably
not Linux though, we did not document that nor provide code similar to that).
The definition they are using is:
internal struct SigActionData {
public SignalHandler handler;
public UInt64 flags;
public SignalRestorer restorer;
public UInt64 mask; // The actual struct has one long[2] type here but
this works.
public UInt64 mask2;
}
(That is from rug's UnixSignal.cs file).
The above does not match the definition for sigaction on my SLED 10, I do not
know where they copied that from.
Then they call "sigaction", and hope that Mono will translate the structures,
which it does, but does structures do not match the OS, so garbage goes to the
OS, and garbage is copied back, likely overwriting internal structures back and
forth.
In fact, the structure on my machine is smaller, so there is guaranteed
corruption.
To explain this in C terms, this is like someone not using #include