[Mono-dev] [PATCH]: Fix lexical block reading when UNALIGNED or big-endian

David S. Miller davem at davemloft.net
Sat Mar 25 23:08:20 EST 2006

minfo->lexical_blocks is a raw pointer into the symbol table metadata
information of a *.dll file.  Therefore it may be aligned arbitrarily,
and it's in little-endian format.

Therefore the entry members must be accessed using the read*()

I guess "--debug" is untested on both UNALIGNED and big-endian
platforms, because any attempt fails immediately with a SIGBUS
or reading corrupt lexical block information due to this bug.

I bet with some clever C type games, we could prevent direct
dereferences of these values that must be accessed via the read*()

BTW, is there any chance to parallelize the bootstrap build of the CLI
when building the mono tree?  31 of my Niagara cpus sit idle while
these 120MB mono processes linearly build the code.  :) If anything,
it should be possible to parallelize the NET_1_1 and NET_2_0 passes.

I think the test case run should be parallelizable too.


2006-03-26  David S. Miller  <davem at sunset.davemloft.net>

	* mono-debug.c (mono_debug_add_method): Access minfo->lexical_blocks[]
	entry elements using read32().

--- mono/metadata/mono-debug.c.~1~	2006-02-02 02:38:34.000000000 -0800
+++ mono/metadata/mono-debug.c	2006-03-26 03:54:52.000000000 -0800
@@ -505,10 +505,10 @@
 	for (i = 0; i < jit->num_lexical_blocks; i ++) {
 		MonoDebugLexicalBlockEntry *jit_lbe = &jit->lexical_blocks [i];
 		MonoSymbolFileLexicalBlockEntry *minfo_lbe = &minfo->lexical_blocks [i];
-		jit_lbe->il_start_offset = minfo_lbe->_start_offset;
+		jit_lbe->il_start_offset = read32(&(minfo_lbe->_start_offset));
 		jit_lbe->native_start_offset = _mono_debug_address_from_il_offset (jit, jit_lbe->il_start_offset);
-		jit_lbe->il_end_offset = minfo_lbe->_end_offset;
+		jit_lbe->il_end_offset = read32(&(minfo_lbe->_end_offset));
 		jit_lbe->native_end_offset = _mono_debug_address_from_il_offset (jit, jit_lbe->il_end_offset);

More information about the Mono-devel-list mailing list