[Mono-list] Nasty x86_magic_trampoline gremlin: ambiguous call sequences

Eric Kidd eric.kidd@pobox.com
24 Feb 2002 10:07:06 -0500


On Sun, 2002-02-24 at 08:04, Paolo Molaro wrote:
> Funnyly enough I found this bug this morning, too, while adding
> support for tracking a few statistics in the JIT. At the fifth counter
> I added, it started segfaulting...
> Your test program works for me after the fix (but it did work before
> that, too). My fix is in cvs now, let me know if it works for you.

-       if ((code [3] == 0xff) && ((code [4] & 0x18) == 0x10) && ((code [4] >> 6) == 1)) {
+       if ((code [1] != 0xe8) && (code [3] == 0xff) && ((code [4] & 0x18) == 0x10) && ((code [4] >> 6) == 1)) {

I'm not quite sure I understand this fix--does anything guarantee that
the preceding instruction could *never* contain an 0xe8?  This code
needs to work for 100% of legal instruction streams, not just 99.999%.

I understand why 'ff MR ** ** ** **' and '.. e8 ** ** ** **' are always
unambiguous, but I don't yet understand why a valid '.. .. .. ff MR **'
could never appear as '.. e8 .. ff MR **'.

Please help a poor novice JIT hacker find enlightenment. ;-)

Cheers,
Eric

P.S.  The patched version now segfaults in a different place for me. 
What's the recommended way for debugging JIT'd code?