From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Robert Marlow Newsgroups: gmane.lisp.guile.bugs Subject: Thread + Socket + Pipes Bug? Date: 07 Aug 2003 15:58:10 +0800 Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Message-ID: <1060243090.29489.46.camel@helicon> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-H3LFFP028yIsdYpctBUs" X-Trace: main.gmane.org 1060243209 2290 80.91.224.253 (7 Aug 2003 08:00:09 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 7 Aug 2003 08:00:09 +0000 (UTC) Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Thu Aug 07 10:00:31 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19kfhH-00053C-00 for ; Thu, 07 Aug 2003 10:00:31 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19kffp-00076S-SQ for guile-bugs@m.gmane.org; Thu, 07 Aug 2003 03:59:01 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19kffi-00073u-JM for bug-guile@gnu.org; Thu, 07 Aug 2003 03:58:54 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19kffC-0006am-Lt for bug-guile@gnu.org; Thu, 07 Aug 2003 03:58:53 -0400 Original-Received: from [130.95.128.56] (helo=asclepius.uwa.edu.au) by monty-python.gnu.org with esmtp (Exim 4.20) id 19kffB-0006Wa-RO for bug-guile@gnu.org; Thu, 07 Aug 2003 03:58:22 -0400 Original-Received: from 127.0.0.1 (localhost [127.0.0.1]) by dummy.domain.name (Postfix) with SMTP id 8C3E7366A5E for ; Thu, 7 Aug 2003 15:58:10 +0800 (WST) Original-Received: from localhost.localdomain (helicon.ucs.uwa.edu.au [130.95.86.66]) by asclepius.uwa.edu.au (Postfix) with ESMTP id 555F7366D77 for ; Thu, 7 Aug 2003 15:58:10 +0800 (WST) Original-To: bug-guile@gnu.org X-Mailer: Ximian Evolution 1.0.5 X-BeenThere: bug-guile@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Bug reports for GUILE, GNU's Ubiquitous Extension Language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.bugs:877 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.bugs:877 --=-H3LFFP028yIsdYpctBUs Content-Type: text/plain Content-Transfer-Encoding: 7bit Hi I've been spending ages on this bug and can't figure it out. I'm pretty sure it's not a bug in something I've done so I'm submitting it here as a possible guile bug. If it's not a bug in guile, many apologies but please let me know what's gone wrong. I've attached two trimmed-down scripts which reproduce the bug. If you place them in the same directory and run buggy.scm then you should be able to connect to tcp port 6008 and start dumping data. The bug occurs when you do this, crashing with an error as follows: ERROR: In procedure select: ERROR: Bad file descriptor In my playing around I seem to have narrowed it down to being caused by select working on one thread and a pipe being written to on another thread. I couldn't determine much more than that. I do know the bug occurs on both Solaris and GNU/Linux. I hate to be whiney but my progress here at work is pretty well at a standstill until either this bug is resolved or I dump guile and settle for something like perl (which I really, really don't want to do). So please help. -- Regards, Robert Marlow --=-H3LFFP028yIsdYpctBUs Content-Disposition: attachment; filename=buggy.scm Content-Transfer-Encoding: quoted-printable Content-Type: text/x-scheme; name=buggy.scm; charset=ANSI_X3.4-1968 #!/usr/bin/guile \ -e main -s !# (use-modules (ice-9 threads) (ice-9 popen)) (define mutex (make-mutex)) (define message-ready (make-condition-variable)) (define message "") (define (main args) (begin-thread (thread)) (begin-thread (thread)) (begin-thread (thread)) (begin-thread (thread)) (begin-thread (thread)) (let ((sock #f) (fileno #f)) (lock-mutex mutex) (set! sock (socket AF_INET SOCK_STREAM 0)) (unlock-mutex mutex) (bind sock AF_INET INADDR_ANY 6008) (listen sock 5) (while #t (let* ((client-connection (accept/no-block sock)) (client-details (cdr client-connection)) (client (car client-connection))) (lock-mutex mutex) (do ((line (read-line client) (read-line client))) ((eof-object? line) (shutdown client 2)) (set! message (string-append message line "\n"))) (signal-condition-variable message-ready) (unlock-mutex mutex))))) (define (thread) (while #t =20 (lock-mutex mutex) (if (not (> (string-length message) 0)) (wait-condition-variable message-ready mutex) (let ((outgoing message)) (set! message "") (unlock-mutex mutex) (piper outgoing))) (unlock-mutex mutex))) (define (piper message) (lock-mutex mutex) (let ((pipe (open-output-pipe "./buggy-companion.scm"))) (display message pipe) (close-port pipe)) (unlock-mutex mutex)) =20 (define (accept/no-block s) (if (null? (car (select (vector s) '() '()))) ; This select complains (accept/no-block s) (let ((client #f)) (lock-mutex mutex) (set! client (accept s)) (unlock-mutex mutex) client))) --=-H3LFFP028yIsdYpctBUs Content-Disposition: attachment; filename=buggy-companion.scm Content-Transfer-Encoding: quoted-printable Content-Type: text/x-scheme; name=buggy-companion.scm; charset=ANSI_X3.4-1968 #!/usr/bin/guile \ -e main -s !# (define (main args) (let ((str "")) (do ((line (read-line) (read-line))) ((eof-object? line)) (set! str (string-append str line "\n"))) (sleep 10) (display str))) =20 =20 --=-H3LFFP028yIsdYpctBUs Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Bug-guile mailing list Bug-guile@gnu.org http://mail.gnu.org/mailman/listinfo/bug-guile --=-H3LFFP028yIsdYpctBUs--