[plt-scheme] Re, Windows crash on mouse movement?

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Fri Nov 26 17:07:26 EST 2004

At Tue, 23 Nov 2004 23:30:51 +0100, Toon Verwaest wrote:
> again I ask if maybe anyone of you knows how to solve
> my problem in windows? (DrScheme crashing when you move
> the mouse during pico-evaluation)

It looks like the problem is related to setjmp() and longjmp().

Setjmp() and longjmp() in Windows (or it is MSVC?) get confused by the
games that MzScheme plays with the C stack.

So MzScheme avoids usual setjmp() and longjmp() under Windows, and
instead uses its own scheme_setjmp() and scheme_longjmp() (which are
implemented in assembly).

It looks like setjmp() and longjmp() get confused even when used on a
portion of the stack that MzScheme isn't manipulating, such as the C
stack used by the Pico interpreter. Presumably, setjmp() or longjmp()
is looking for something at the stack base, and it isn't there, because
MzScheme has overwritten it.

Replacing setjmp() and longjmp() in the Pico code with scheme_setjmp()
and scheme_longjmp() does solve the problem. (Technically,
scheme_setjmp() wants a mz_pre_jmp_buf instead of a jmp_buf, but the
latter is reliably at least as large as the former.) Probably you don't
want to pollute the Pico code with something MzScheme-specific, but
something like that may work for you.

Another solution would be to run the Pico interpreter in a different
Windows thread, (i.e., a thread with a stack that is safe from
MzScheme's games).


Posted on the users mailing list.