From owner-freebsd-questions@FreeBSD.ORG Wed May 18 02:45:41 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BB7A316A4CE for ; Wed, 18 May 2005 02:45:41 +0000 (GMT) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3A2A843DAC for ; Wed, 18 May 2005 02:45:41 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.13.1/8.13.3) id j4I2jHMS072631; Tue, 17 May 2005 21:45:17 -0500 (CDT) (envelope-from dan) Date: Tue, 17 May 2005 21:45:16 -0500 From: Dan Nelson To: Xu Qiang Message-ID: <20050518024516.GA4756@dan.emsphone.com> References: <20050518015322.7F0F11D93F@imss.sgp.fujixerox.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050518015322.7F0F11D93F@imss.sgp.fujixerox.com> X-OS: FreeBSD 5.4-STABLE X-message-flag: Outlook Error User-Agent: Mutt/1.5.9i cc: Giorgos Keramidas cc: freebsd-questions@freebsd.org Subject: Re: The availability of socketbits.h? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 May 2005 02:45:41 -0000 In the last episode (May 18), Xu Qiang said: > Dan Nelson wrote: > > That's because after including the header that provides a declaration > > for random (stdlib.h), the author decided to include another of his > > own for some reason, but he used the wrong return type so gcc > > complained. Just remove like 22 of mink.c. > > Thank you again. It can roll forward when the declaration of the "random" function function is removed. It seems 1.1.16 version is full of bugs, like stated above. The 1.1.14 version is much better in compiling. > > However, both versions give me an error when I run the compiled application after gmake, gmake install. I go to bin directory and type "./nngssrv", it told me: > Bus error (core dumped) > > GDB trace is here: > (gdb) bt > #0 0x2818bbc5 in __vfprintf () from /lib/libc.so.5 > #1 0x2818a513 in vfprintf () from /lib/libc.so.5 > #2 0x28177352 in fprintf () from /lib/libc.so.5 > #3 0x0805f98c in commands_init () at command.c:1149 > #4 0x0805aeab in main (argc=1116382465, argv=0x807e702) at nngsmain.c:162 > ----------------------------------------------- > > What is a "Bus error"? It's usually caused by an incorrect pointer, or a stack overflow, where the program tries to read a memory address not available to it. In fact, I can see the problem right away. command_list is a statically-initilized array (defined at command_list.h:55). Note that there is no special "end-of-list" value at the end of the array. The loop at command.c:1149 loops until command_list[i].comm_name is NULL, but since there's no explicit NULL entry at the end, the loop falls off the end of the array, where it eventually hits an unmapped page of memory and gets a bus error. That for loop should really read: for(i=0; i