Next: Blocking the Current Thread
MzScheme's threads can break external C code under two circumstances:
- Pointers to stack-based values can be communicated between threads. For example, if thread A stores a pointer to a stack-based
variable in a global variable, if thread B uses the pointer in the
global variable, it may point to data that is not currently on the
- C functions that can invoke MzScheme (and also be invoked by MzScheme) depend on strict function-call nesting. For example,
suppose a function F uses an internal stack, pushing items on to the
stack on entry and popping the same items on exit. Suppose also that
F invokes MzScheme to evaluate an expression. If the evaluate on
this expression invoked F again in a new thread, but then returns to
the first thread before completeing the second F, then F's internal
stack will be corrupted.
If either of these circumstances occurs, MzScheme will probably crash.