#593 (posix:wait) race condition

lisp error
closed-fixed
Sam Steingold
clisp (525)
5
2011-03-27
2011-03-25
Bill Evans
No

My abject apologies if this is a feature, not a bug.

The response to artifact 3224360 was that I should avoid (linux:waitpid) and use (posix:wait) instead. This presents a race condition (to say the least) if the child process finishes before the parent can get around to waiting for it, as the following will demonstrate.

=== platform:
Linux tiger 2.6.26-2-686 #1 SMP Sat Dec 26 09:01:51 UTC 2009 i686 GNU/Linux
=== compiler version:
gcc (Debian 4.3.2-1.1) 4.3.2
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

=== glibc version:
/lib/libc-2.7.so
=== clisp version:
GNU CLISP 2.49 (2010-07-07) (built 3510043534) (memory 3510043839)
Software: GNU C 4.3.2
gcc -g -O2 -W -Wswitch -Wcomment -Wpointer-arith -Wimplicit -Wreturn-type -Wmissing-declarations -Wno-sign-compare -Wno-format-nonliteral -O2 -fexpensive-optimizations -falign-functions=4 -DENABLE_UNICODE -DDYNAMIC_FFI -DDYNAMIC_MODULES -I. -lreadline -lncurses -ldl -lavcall -lcallback -lsigsegv libgnu_cl.a
SAFETY=0 HEAPCODES LINUX_NOEXEC_HEAPCODES GENERATIONAL_GC SPVW_BLOCKS SPVW_MIXED TRIVIALMAP_MEMORY
libsigsegv 2.5
libreadline 5.2
Features:
(READLINE REGEXP SYSCALLS I18N LOOP COMPILER CLOS MOP CLISP ANSI-CL COMMON-LISP LISP=CL INTERPRETER SOCKETS
GENERIC-STREAMS LOGICAL-PATHNAMES SCREEN FFI GETTEXT UNICODE BASE-CHAR=CHARACTER PC386 UNIX)
C Modules: (clisp i18n syscalls regexp readline)
Installation directory: /u/wally/public_html/doc/lisp/bug3/sandbox/
User language: ENGLISH
Machine: I686 (I686) tiger.x441afea5.org [10.0.0.1]

I downloaded the currently released version of clisp today (25 Mar 2011) from http://ftp.gnu.org/pub/gnu/clisp/latest.

I built it the normal way, as shown in the attached script. That script downloads the source, builds and installs clisp, copies "full" so it sits next to "base" (I still don't understand why I had to do that), and runs the program.

Discussion

  • Bill Evans
    Bill Evans
    2011-03-25

    script which downloads clisp, builds it, and makes the bug happen

     
    Attachments
  • Sam Steingold
    Sam Steingold
    2011-03-25

    I think the right interface is to export begin-receive-sigchild and end-receive-sigchild and with-receive-sigchild from syscalls.

     
  • http://article.gmane.org/gmane.lisp.clisp.devel/20422
    Bruno is right - this seems to be the way to handle it.
    However with MT (and many thread issuing fork/wait) - still not sure how to prevent races. Generally it is adviced not to mix fork-ing and threads but we should have some sane and predictable behavior

     
  • Sam Steingold
    Sam Steingold
    2011-03-27

    thank you for your bug report.
    the bug has been fixed in the source tree (mercurial/hg).
    you can either wait for the next release (recommended)
    or check out the current mercurial tree (see http://clisp.org\)
    and build CLISP from the sources (be advised that between
    releases the source tree is very unstable and may not even build
    on your platform).

     
  • Sam Steingold
    Sam Steingold
    2011-03-27

    • assigned_to: haible --> sds
    • status: open --> closed-fixed