I'm now trying to fill missing BLOCK_INPUTs for Mac OS X. I suspect occasional hang of Carbon Emacs is due to the heap corruption caused by interrupted malloc/free mentioned in blockinput.h. Two patches are attached. The first one is for adding missing BLOCK_INPUTs that I tracked down (mainly for window operations). The second one is for a helper that assists us to detect malloc/calloc/valloc/realloc/free that is not protected by BLOCK_INPUT. It hooks a check function to each internal memory allocation routine. To use this, compile with "CFLAGS=-g -DDEBUG_BLOCK_INPUT" after applying both patches, and set a break point to `debug_block_input'. It works only on Carbon build. I have some questions about this issue. 1. The check function that is executed in every malloc call is as follows: int check_block_input () { sigset_t mask; if (poll_suppress_count == 0 && interrupt_input_blocked == 0) { sigprocmask (0, NULL, &mask); if (!sigismember (&mask, SIGALRM)) { debug_block_input (); return -1; } } return 0; } Is this correct? Or does it produce a false alarm? (Carbon Emacs uses polling by SIGALRM, because window events don't come from sockets and we can't use SIGIO.) 2. The following library functions are detected as those that may call malloc and so on without BLOCK_INPUT. localtime, gmtime, ctime, opendir, getc, getaddrinfo, fwrite, mkstemp fclose, closedir, freeaddrinfo If the check function in the previous item is correct, should we make a wrapper function for each of them? Or add BLOCK_INPUTs to caller functions? YAMAMOTO Mitsuharu mituharu@math.s.chiba-u.ac.jp