Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 May 2005 21:45:16 -0500
From:      Dan Nelson <dnelson@allantgroup.com>
To:        Xu Qiang <Qiang.Xu@fujixerox.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: The availability of socketbits.h?
Message-ID:  <20050518024516.GA4756@dan.emsphone.com>
In-Reply-To: <20050518015322.7F0F11D93F@imss.sgp.fujixerox.com>
References:  <20050518015322.7F0F11D93F@imss.sgp.fujixerox.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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<command_count; i++) {

, since command_count should already be set to COUNTOF(command_list) by
a previous call to command_init().

-- 
	Dan Nelson
	dnelson@allantgroup.com



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050518024516.GA4756>