[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


From: YAMAMOTO Mitsuharu
Subject: BLOCK_INPUT on Mac OS X
Date: Fri, 03 Sep 2004 21:41:47 +0900
User-agent: Wanderlust/2.10.1 (Watching The Wheels) SEMI/1.14.5 (Awara-Onsen) FLIM/1.14.5 (Demachiyanagi) APEL/10.6 Emacs/21.3.50 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI)

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

    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

Attachment: diff-blockinput.gz
Description: Binary data

Attachment: diff-blockinput-debug.gz
Description: Binary data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]