From owner-freebsd-hackers Mon Jun 16 06:50:57 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id GAA06044 for hackers-outgoing; Mon, 16 Jun 1997 06:50:57 -0700 (PDT) Received: from dg-rtp.dg.com (dg-rtp.rtp.dg.com [128.222.1.2]) by hub.freebsd.org (8.8.5/8.8.5) with SMTP id GAA06032 for ; Mon, 16 Jun 1997 06:50:52 -0700 (PDT) Received: by dg-rtp.dg.com (5.4R3.10/dg-rtp-v02) id AA07204; Mon, 16 Jun 1997 09:50:11 -0400 Received: from ponds by dg-rtp.dg.com.rtp.dg.com; Mon, 16 Jun 1997 09:50 EDT Received: from lakes.water.net (lakes [10.0.0.3]) by ponds.water.net (8.8.5/8.7.3) with ESMTP id OAA23833; Sun, 15 Jun 1997 14:48:01 -0400 (EDT) Received: (from rivers@localhost) by lakes.water.net (8.8.5/8.6.9) id OAA10921; Sun, 15 Jun 1997 14:56:04 -0400 (EDT) Date: Sun, 15 Jun 1997 14:56:04 -0400 (EDT) From: Thomas David Rivers Message-Id: <199706151856.OAA10921@lakes.water.net> To: ponds!hq.icb.chel.su!babkin, ponds!time.cdrom.com!jkh Subject: Re: C optimizer bug ? Cc: ponds!FreeBSD.ORG!hackers Content-Type: text Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > > > > > I tried everything and finally decided to build the kernel > > > without the optimization. Everything started working fine! > > > So the C optimizer seems like having a bug. > > > > Without trying to reduce this down to something others can actually > > reproduce, however, this basically goes into the same category as > > UFO sightings and alien abductions. There's strong evidence that > > it _might_ happen, but with no concrete proof we can only continue > > to speculate as to whether or not they're real. :-) > > Okay, here is the description: The function scsi_done() must check > whether xs->bp is zero and then depending on it call biodone() > or wakeup(xs). Sometimes it confuses these cases and does the > wrong thing, in this case the process hangs on tsleep(...,"scsicmd") > or waiting for biodone() (I can't remember the argument of > tsleep() for biodone exactly). The probability of hangup on missing > wakeup(xs) is about 1/4. The hangups on missing biodone() are > rare. > > In case of any delays caused by printf() or tcpdump or > using a loopback Ethernet card simulator > the SCSI simulator is able to finish the operation before the > scsi_scsi_cmd() function gets control back from the SCSI > card driver and in this case it just does not sleep. The hangups > on missing biodone() still occur even with delays. > > I don't know how to reproduce this bug without all those > simulators but I think it should be possible. Hey!!! This sounds an awful lot like my "daily panic" problem - when I put printf()s around scsi_done, etc... the problem goes away. [Although, my problem isn't limited to SCSI...] Since I've demonstrated this with older and newer versions of FreeBSD, which used at least two different GCC compilers - I tend to think it's not a compiler problem... I'll bet you'll discover something else is trashing some memory. Likely overwriting memory that's in a different location when you don't optimize. That also why adding printf()s "helps" the problem; as the printf()s change the size of the stack... - Dave Rivers - > > -SB >