The availability of socketbits.h?

Dan Nelson dnelson at allantgroup.com
Tue May 17 19:45:41 PDT 2005


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 at allantgroup.com


More information about the freebsd-questions mailing list