[WBEL-users] WBEL LINKING BUG ?

Kirby C. Bohling kbohling@birddog.com
Thu, 13 Jan 2005 18:03:55 -0600


On Thu, Jan 13, 2005 at 04:09:36PM -0500, Omar Turriate - Hacksoft wrote:
> Good morning,
> my name is Omar Turriate.
> I downloaded "White Box Enterprise Linux 3.0". I am programming a simple
> server application but when I run it, obtain an error out of logic. I think
> about a posible linking error from gcc package or some patch that I dont
> have.
> 
> I'm sending my example source code which listen on any address on port 
> 9000.
> When I comment (//) the lines 137 and 138, the application run ok, otherwise
> fail in the instruction accept.
> 
> The step that I make are:
> gcc -o server server.c
> ./server
> 
> On other console:
> telnet localhost 9000
> a + b
> 
> and on server happen accept error: invalid argument.
> 
> Please, I hope you help me with this problem and your soon answer.

Omar,

	Wow, I didn't expect I'd ever be asked to debug network code on
this list.  There are probably any number of forums that would be
much more directly useful.  Don't take that as an critisim, I'm
happy to answer the question.

	The problem is that you failed to initialize "addrlen".  If you
look at the C code, you'll find that addrlen is used while it's not
initialized.  According the man page, you should need to do
something like:

addrlen = sizeof( sin );

	You need to pass in the total amount of memory reserved at the
address.  It will give back to you the total length it actually used
if I am reading the man page correctly.  (Note: I didn't compile the
code, or do anything else with it this is my debugging via reading
the code and the man page).  I don't know you, and I'm at work.  I
don't compile random code sent to me via e-mail from people I don't
know.  

	I would assume that the commenting out the print statements is a
red herring.  It's just changing the stack alignment.  When the code
is commented out, addrlen just happens to have contents that
accept() deals with.  When the code is uncommented, the addrlen is
somewhere on the stack that has something that accept doesn't like,
and it errors out.

	Thanks,
		Kirby