udhcpc segmentation fault

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

udhcpc segmentation fault

3,974 Views
SteveJoiner
Contributor I
I'm using ltib (20051213) on a 5474. I've configured it to use dhcp (udhcpc from busybox), but udhcpc is giving a segfault when it runs. Specifically:

-sh-2.05b# udhcpc -b -i eth0
udhcpc (v0.9.9-pre) started
Segmentation fault
-sh-2.05b#

Anyone know how to fix this?

Thanks,
Steve
Labels (1)
0 Kudos
3 Replies

687 Views
SteveJoiner
Contributor I
I did some digging and it seems to be segfaulting when it calls:

run_script(NULL, "deconfig");

I did a "find ./ -name deconfig" on my filesystem, but there's no deconfig to be found. Any thoughts?

-Steve
0 Kudos

687 Views
SteveJoiner
Contributor I
Digging in a little more, it looks like run_script() is failing when it calls vfork(). It appears that the segfault is happening in vfork(). In particular, the offending code in run_script() looks like this:

pid = vfork();
if (pid) {
waitpid(pid, NULL, 0);
for (curr = envp; *curr; curr++) free(*curr);
free(envp);
return;
} else if (pid == 0) {
/* close fd's? */

/* exec script */
execle(client_config.script, client_config.script,
name, NULL, envp);
LOG(LOG_ERR, "script %s failed: %m", client_config.script);
exit(1);
}

I have verified that the code is getting to the vfork() then segfaulting. Anyone know how to fix this?

-Steve
0 Kudos

687 Views
SteveJoiner
Contributor I
I fixed it.

For anyone else who runs into this problem (and for the ltib maintainer), I fixed this by replacing the vfork() call with a fork() call. I don't know why that fixed it, but it did.

After the segfault was fixed, I found that udhcpc was unable to get a lease when my system booted. This seemed to be cased by the ethernet interface not being initialized, so I added "ifconfig $INTERFACE 0.0.0.0" in my /etc/rc.d/init.d/network script right before the udhcpc call. That seems to have fixed that problem.

If you're fixing this in ltib, it may be helpful to know that /etc/rc.c/init.d/network is in the skell package. While you're in there, you may want to fix another little bug that I noticed: most of the init scripts in /etc/rc.c/init.d/ have a line that looks like this:

if [ "$1 = "stop" -o "$1 = "restart" ]

It should be changed to this:

if [ "$1" = "stop" -o "$1" = "restart" ]

-Steve
0 Kudos