Re: Reentrant call to malloc/free

2006-07-07 Thread YAMAMOTO Mitsuharu
 On Thu, 06 Jul 2006 09:53:57 +0900, YAMAMOTO Mitsuharu [EMAIL 
 PROTECTED] said:

 I've once posted a (not complete) list of Darwin library functions
 that may call malloc-related functions but are not protected by
 BLOCK_INPUT:

localtime, gmtime, ctime, opendir, getc, getaddrinfo, fwrite,
 mkstemp fclose, closedir, freeaddrinfo, mktime (not used as of
 2004-09)

 (http://lists.gnu.org/archive/html/emacs-devel/2004-09/msg00074.html)

 I cannot detect `getgrgid' as such a function, but I guess this is
 due to the difference in name service backends (NIS, LDAP, ...).

Sorry, I could.  So it has nothing to do with the type of backends.
Also, I found that getpwuid/getpwnam/getgrgid in both glibc and
FreeBSD libc called malloc-related functions.  So I think it's
reasonable to put BLOCK_INPUTs around them.  Objections?

 YAMAMOTO Mitsuharu
[EMAIL PROTECTED]

Index: src/Makefile.in
===
RCS file: /cvsroot/emacs/emacs/src/Makefile.in,v
retrieving revision 1.327
diff -c -p -r1.327 Makefile.in
*** src/Makefile.in 18 May 2006 17:05:36 -  1.327
--- src/Makefile.in 8 Jul 2006 05:30:06 -
*** pre-crt0.o: pre-crt0.c
*** 1108,1114 
  ecrt0.o: ecrt0.c $(config_h)
CRT0_COMPILE ${srcdir}/ecrt0.c
  dired.o: dired.c commands.h buffer.h $(config_h) charset.h coding.h regex.h \
!systime.h
  dispnew.o: dispnew.c  systty.h systime.h commands.h process.h frame.h \
 window.h buffer.h dispextern.h termchar.h termopts.h termhooks.h cm.h \
 disptab.h indent.h intervals.h \
--- 1108,1114 
  ecrt0.o: ecrt0.c $(config_h)
CRT0_COMPILE ${srcdir}/ecrt0.c
  dired.o: dired.c commands.h buffer.h $(config_h) charset.h coding.h regex.h \
!systime.h blockinput.h
  dispnew.o: dispnew.c  systty.h systime.h commands.h process.h frame.h \
 window.h buffer.h dispextern.h termchar.h termopts.h termhooks.h cm.h \
 disptab.h indent.h intervals.h \
*** doprnt.o: doprnt.c charset.h $(config_h)
*** 1119,1130 
  dosfns.o: buffer.h termchar.h termhooks.h frame.h blockinput.h window.h \
 msdos.h dosfns.h dispextern.h charset.h coding.h $(config_h)
  editfns.o: editfns.c window.h buffer.h systime.h $(INTERVAL_SRC) charset.h \
!coding.h dispextern.h frame.h $(config_h)
  emacs.o: emacs.c commands.h systty.h syssignal.h blockinput.h process.h \
 termhooks.h buffer.h atimer.h systime.h $(INTERVAL_SRC) $(config_h) \
 window.h dispextern.h keyboard.h keymap.h
  fileio.o: fileio.c window.h buffer.h systime.h $(INTERVAL_SRC) charset.h \
!coding.h msdos.h dispextern.h $(config_h)
  filelock.o: filelock.c buffer.h charset.h coding.h systime.h epaths.h 
$(config_h)
  filemode.o: filemode.c  $(config_h)
  frame.o: frame.c xterm.h window.h frame.h termhooks.h commands.h keyboard.h \
--- 1119,1130 
  dosfns.o: buffer.h termchar.h termhooks.h frame.h blockinput.h window.h \
 msdos.h dosfns.h dispextern.h charset.h coding.h $(config_h)
  editfns.o: editfns.c window.h buffer.h systime.h $(INTERVAL_SRC) charset.h \
!coding.h dispextern.h frame.h blockinput.h $(config_h)
  emacs.o: emacs.c commands.h systty.h syssignal.h blockinput.h process.h \
 termhooks.h buffer.h atimer.h systime.h $(INTERVAL_SRC) $(config_h) \
 window.h dispextern.h keyboard.h keymap.h
  fileio.o: fileio.c window.h buffer.h systime.h $(INTERVAL_SRC) charset.h \
!coding.h msdos.h dispextern.h blockinput.h $(config_h)
  filelock.o: filelock.c buffer.h charset.h coding.h systime.h epaths.h 
$(config_h)
  filemode.o: filemode.c  $(config_h)
  frame.o: frame.c xterm.h window.h frame.h termhooks.h commands.h keyboard.h \
Index: src/dired.c
===
RCS file: /cvsroot/emacs/emacs/src/dired.c,v
retrieving revision 1.123
diff -c -p -r1.123 dired.c
*** src/dired.c 24 Jun 2006 07:24:42 -  1.123
--- src/dired.c 8 Jul 2006 05:30:06 -
*** extern struct direct *readdir ();
*** 99,104 
--- 99,105 
  #include charset.h
  #include coding.h
  #include regex.h
+ #include blockinput.h
  
  /* Returns a search buffer, with a fastmap allocated and ready to go.  */
  extern struct re_pattern_buffer *compile_pattern ();
*** Elements of the attribute list are:
*** 951,960 
--- 952,963 
  }
else
  {
+   BLOCK_INPUT;
pw = (struct passwd *) getpwuid (s.st_uid);
values[2] = (pw ? build_string (pw-pw_name) : make_number (s.st_uid));
gr = (struct group *) getgrgid (s.st_gid);
values[3] = (gr ? build_string (gr-gr_name) : make_number (s.st_gid));
+   UNBLOCK_INPUT;
  }
values[4] = make_time (s.st_atime);
values[5] = make_time (s.st_mtime);
Index: src/editfns.c
===
RCS file: /cvsroot/emacs/emacs/src/editfns.c,v
retrieving revision 

Re: Reentrant call to malloc/free

2006-07-05 Thread YAMAMOTO Mitsuharu
 On Wed, 05 Jul 2006 13:25:12 +0200, [EMAIL PROTECTED] (Dr. Carsten 
 Bormann) said:

 While typing input (apparently often related to file/process
 operations, such as minibuffer completions of file names), emacs
 occasionally (say, once a day in heavy usage) hangs and uses high
 CPU (most of which is system time).  Attaching GDB says:

 #11 0x000e0850 in poll_for_input ()
 #12 0x00213930 in alarm_signal_handler ()
 #13 signal handler called
 #14 0x90006a8c in szone_free ()
 #15 0x0320 in ?? ()
 #16 0x9005d7dc in getgr_internal ()
 #17 0x9005d070 in getgr ()
 #18 0x0013ed6c in Ffile_attributes ()

I've once posted a (not complete) list of Darwin library functions
that may call malloc-related functions but are not protected by
BLOCK_INPUT:

   localtime, gmtime, ctime, opendir, getc, getaddrinfo, fwrite, mkstemp
   fclose, closedir, freeaddrinfo,
   mktime (not used as of 2004-09)

(http://lists.gnu.org/archive/html/emacs-devel/2004-09/msg00074.html)

I cannot detect `getgrgid' as such a function, but I guess this is due
to the difference in name service backends (NIS, LDAP, ...).

We can put BLOCK_INPUTs around every getpw* and getgr* call, but if
the problem only occurs on Darwin, creating wrapper functions is an
alternative way.  Does anyone know the situation on other systems?

 YAMAMOTO Mitsuharu
[EMAIL PROTECTED]


___
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug