From nobody@FreeBSD.org  Sun Mar 11 21:58:52 2001
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id D866437B718
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 11 Mar 2001 21:58:52 -0800 (PST)
	(envelope-from nobody@FreeBSD.org)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.1/8.11.1) id f2C5wqD36607;
	Sun, 11 Mar 2001 21:58:52 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200103120558.f2C5wqD36607@freefall.freebsd.org>
Date: Sun, 11 Mar 2001 21:58:52 -0800 (PST)
From: meconlen@obfuscated.net
To: freebsd-gnats-submit@FreeBSD.org
Subject: kernel builds on March 12th -stable fail
X-Send-Pr-Version: www-1.0

>Number:         25721
>Category:       kern
>Synopsis:       kernel builds on March 12th -stable fail
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Mar 11 22:00:04 PST 2001
>Closed-Date:    Mon Mar 12 05:44:26 PST 2001
>Last-Modified:  Mon Mar 12 05:44:46 PST 2001
>Originator:     Michael Conlen
>Release:        FreeBSD 4.2-STABLE i386
>Organization:
Obfuscated Networking
>Environment:
FreeBSD eno.obfuscated.net 4.2-STABLE FreeBSD 4.2-STABLE #7: Tue Feb 27 23:20:23 EST 2001     meconlen@eno.obfuscated.net:/usr/obj/usr/src/sys/ENO  i386

with a cvsup today, and a make buildworld performed

/usr/src/sys/i*/conf/ENO (my kernel conf) has

options         TCPDEBUG

This problem only happens when this is turned on.


>Description:
#make buildkernel KERNCONF=ENO
<snip>

/usr/src/sys/netinet/tcp_usrreq.c: In function `tcp_usr_accept':
/usr/src/sys/netinet/tcp_usrreq.c:424: syntax error before `int'
/usr/src/sys/netinet/tcp_usrreq.c:424: `ostate' undeclared (first use in this function)
/usr/src/sys/netinet/tcp_usrreq.c:424: (Each undeclared identifier is reported only once
/usr/src/sys/netinet/tcp_usrreq.c:424: for each function it appears in.)
/usr/src/sys/netinet/tcp_usrreq.c:418: warning: `tp' might be used uninitialized in this function
*** Error code 1

Stop in /usr/obj/usr/src/sys/ENO.
Investigation shows the following

tcp_usr_accept(struct socket *so, struct sockaddr **nam)
{
        int s = splnet();
        int error = 0;
        struct inpcb *inp = sotoinpcb(so);
        struct tcpcb *tp;

        if (so->so_state & SS_ISDISCONNECTED) {
                error = ECONNABORTED;
                goto out;
        }
        COMMON_START();
        in_setpeeraddr(so, nam);
        COMMON_END(PRU_ACCEPT);
}

Line 424 is COMMON_START();

which is

#define COMMON_START()  TCPDEBUG0; \
                        do { \
                                     if (inp == 0) { \
                                             splx(s); \
                                             return EINVAL; \
                                     } \
                                     tp = intotcpcb(inp); \
                                     TCPDEBUG1(); \
                     } while(0)

TCPDEBUG0 is defined with

#ifdef TCPDEBUG
#define TCPDEBUG0       int ostate
#define TCPDEBUG1()     ostate = tp ? tp->t_state : 0
#define TCPDEBUG2(req)  if (tp && (so->so_options & SO_DEBUG)) \
                                tcp_trace(TA_USER, ostate, tp, 0, 0, req)
#else
#define TCPDEBUG0
#define TCPDEBUG1()
#define TCPDEBUG2(req)
#endif

Here we can see why the option in the conf file matters, however, the
definition seems to be fine.

Now, tracking down if it might be some other macro I only found

# cd /usr/include/netinet
# grep SS_ISDISCONNECTED *h
# cd ../sys
# grep SS_ISDISCONNECTED *h
socketvar.h:#define     SS_ISDISCONNECTED       0x2000  /* socket
disconnected from peer */
# cd ../net
# grep SS_ISDISCONNECTED *h
#


>How-To-Repeat:

>Fix:
First fix is to turn off TCPDEBUG. 

the second fix (actually fixing the code) is a lot harder, because the TCPDEBUG2 code references the variable. That code is in COMMON_END, so you can't just wrap COMMON_START in {}... ...I'll let you guys sort it out... ...and what is goto doing in there? Looks like the code could use some work in general...

BTW: I submitted this to -stable before I remembered the pr database, so someone might  move it in here from there as well, it would be a dup.






>Release-Note:
>Audit-Trail:

From: "Michael Conlen" <meconlen@obfuscated.net>
To: <freebsd-gnats-submit@FreeBSD.org>,
	"Michael E Conlen" <meconlen@obfuscated.net>
Cc:  
Subject: Re: kern/25721: kernel builds on March 12th -stable fail
Date: Mon, 12 Mar 2001 01:06:51 -0500

 I forgot to mention...
 
 Normally I can track down these things, but this is just weird. The only
 thing I can think of is that the current gcc is not accepting variables
 defined anywhere but the top of the function and is treating the var
 definition as something weird.
 
 sure enough
 
 # cat a.c
 main() {
         printf("hello world\n");
         int a;
         a = 1;
         printf("hello world %d\n", a);
 }
 # cc a.c
 a.c: In function `main':
 a.c:3: syntax error before `int'
 a.c:4: `a' undeclared (first use in this function)
 a.c:4: (Each undeclared identifier is reported only once
 a.c:4: for each function it appears in.)
 
 # cat a.c
 main() {
         int a;
         printf("hello world\n");
         a = 1;
         printf("hello world %d\n", a);
 }
 # cc a.c
 
 This seems to be the problem!
 
 Gotta love copy and paste limits...
 
 --
 Groove On Dude
 Michael Conlen
 Obfuscated Networking
 meconlen@obfuscated.net
  
State-Changed-From-To: open->feedback 
State-Changed-By: roam 
State-Changed-When: Sun Mar 11 23:30:49 PST 2001 
State-Changed-Why:  
Is this a duplicate of PR kern/25651, which also contains a patch? 
Does the patch in http://www.FreeBSD.org/cgi/query-pr.cgi?pr=25651 
solve the problem? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=25721 
State-Changed-From-To: feedback->closed 
State-Changed-By: roam 
State-Changed-When: Mon Mar 12 05:44:26 PST 2001 
State-Changed-Why:  
Duplicate of kern/25651. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=25721 
>Unformatted:
