# DHCPCD sigsegv with systemd and renaming interfaces

## theit8514

I'm not entirely sure this is related to systemd renaming interfaces, but it's the only thing I could think that is crashing it.

Every time my new system boots, dhcpcd sigsegvs and I have to log into the console and run systemctl start dhcpcd.

Log from journalctl:

 *Quote:*   

> Jun 27 18:07:54 localhost dhcpcd[4475]: version 6.4.0 starting
> 
> Jun 27 18:07:54 localhost dhcpcd[4475]: dev: loaded udev
> 
> Jun 27 18:07:54 localhost dhcpcd[4475]: eth0: adding address fe80::xxxx
> ...

 

So, having not installed Gentoo in probably about 3-4 years, how do I:

A. Prevent systemd from renaming my interface. I do not want to type eno16777736 every time. Sheesh.

B. Stop dhcpcd from crashing (maybe fixed by A?). I did try to follow some directions I saw on here from earlier this month and install dhcpcd 6.4 but the problem still persists.

Thanks!

----------

## UberLord

Well, the udev plugin loaded and udev must have told dhcpcd that eth0 was stable which it obviously wasn't

Still, it should not have segfaulted.

Can you built with debugging enabled and provide a backtrace from a dhcpcd core dump please?

----------

## theit8514

Haha, I think I finally figured this out. I set up kernel with CONFIG_COREDUMP, added the * soft core unlimited to limits.conf, updated the systemd service with LimitCORE=infinity, and set the sysctl settings for dumping the core of suid. Whew.

And just to double check, this is the proper debug config for building the package, right?

```
# cat /etc/portage/env/debug.conf 

CFLAGS="${CFLAGS} -ggdb"

CXXFLAGS="${CXXFLAGS} -ggdb"

FEATURES="noclean nostrip splitdebug"

# cat /etc/portage/package.env

net-misc/dhcpcd debug.conf
```

And tada, I have a core dump. Only took me 2 hours   :Embarassed: 

```
# gdb_get_backtrace `which dhcpcd` core.dump.1403951241.4491 

[New LWP 4491]

warning: Could not load shared library symbols for linux-vdso.so.1.

Do you need "set solib-search-path" or "set sysroot"?

[Thread debugging using libthread_db enabled]

Using host libthread_db library "/lib64/libthread_db.so.1".

Core was generated by `/sbin/dhcpcd -q --nobackground'.

Program terminated with signal 11, Segmentation fault.

#0  0x0000000000416091 in dhcp_start1 (arg=0x636830) at dhcp.c:2915

2915            if (ifp->ctx->udp_fd == -1 && dhcp_openudp(ifp->ctx, NULL) != -1)

Thread 1 (Thread 0x7f6c06921700 (LWP 4491)):

#0  0x0000000000416091 in dhcp_start1 (arg=0x636830) at dhcp.c:2915

        ifp = 0x636830

        ifo = 0x654630

        state = <optimized out>

        st = {st_dev = 1, st_ino = 4258656, st_nlink = 140736987641488, st_mode = 1137, st_uid = 0, st_gid = 0, __pad0 = 0, st_rdev = 0, st_size = 1, st_blksize = 4258157, st_blocks = 140736987641152, st_atim = {tv_sec = 6601440, tv_nsec = 25769803776}, st_mtim = {tv_sec = 420906795072, tv_nsec = 6513360}, st_ctim = {tv_sec = 140736987640944, tv_nsec = 140736989141068}, __unused = {140736987640976, 1, 140736987641008}}

        now = {tv_sec = 1137, tv_usec = 1137}

        l = <optimized out>

        nolease = <optimized out>

#1  0x0000000000407a13 in eloop_start (dctx=dctx@entry=0x7fffe227b690) at eloop.c:357

        ctx = 0x63e430

        now = {tv_sec = 11, tv_usec = 535167}

        n = 6515840

        e = <optimized out>

        t = 0x636790

        tv = <optimized out>

        ts = {tv_sec = 0, tv_nsec = 348779000}

        tsp = <optimized out>

        t0 = <optimized out>

#2  0x0000000000403809 in main (argc=<optimized out>, argv=<optimized out>) at dhcpcd.c:1598

        ctx = {sigset = {__val = {0 <repeats 16 times>}}, cffile = 0x427bd4 "/etc/dhcpcd.conf", options = 1830040538848265, argc = 3, argv = 0x7fffe227b9b8, ifac = 0, ifav = 0x0, ifdc = 0, ifdv = 0x0, ifc = 0, ifv = 0x7fffe227b9d0, duid = 0x64c250 "", duid_len = 14, pid_fd = 3, link_fd = 6, ifaces = 0x64dee0, eloop = 0x63e430, control_fd = 4, control_fds = 0x0, control_sock = "/run/dhcpcd.sock", '\000' <repeats 20 times>, control_group = 0, vivso = 0x0, vivso_len = 0, dhcp_opts = 0x63c5e0, dhcp_opts_len = 121, ipv4_routes = 0x64df60, udp_fd = -1, packet = 0x0, opt_buffer = 0x0, secret = '\000' <repeats 63 times>, secret_len = 0, dhcp6_opts = 0x643810, dhcp6_opts_len = 69, ipv6 = 0x64b360, ra_restore = 0x64df20, ra_restore_len = 2, dev_load = 0x0, dev_fd = 8, dev = 0x64da80, dev_handle = 0x64c990}

        pidfile = "/run/dhcpcd.pid\000 +\223\006l\177\000\000ô'q\006l\177\000\000po\027\006l\177"

        ifo = 0x0

        ifp = 0x0

        family = <optimized out>

        opt = 0

        oi = 25

        i = <optimized out>

        t = <optimized out>

        len = <optimized out>

        pid = <optimized out>

        sig = <optimized out>

        siga = <optimized out>

        ts = {tv_sec = 140101935394384, tv_nsec = 140101941311835}

        __func__ = "main"
```

----------

## UberLord

Hmmmm, it shouldn't really be crashing there.

Can you add debug on a line by itself in /etc/dhcpcd.conf and provide another log snippet please so I can get more context?

----------

## theit8514

```
Jun 28 08:00:20 localhost dhcpcd[4513]: version 6.4.0 starting

Jun 28 08:00:20 localhost dhcpcd[4513]: udev: starting

Jun 28 08:00:20 localhost dhcpcd[4513]: dev: loaded udev

Jun 28 08:00:20 localhost dhcpcd[4513]: eno16777736: disabling kernel IPv6 RA support

Jun 28 08:00:20 localhost dhcpcd[4513]: eno16777736: adding address fe80::xxxx

Jun 28 08:00:20 localhost dhcpcd[4513]: eno16777736: vltime infinity, pltime infinity

Jun 28 08:00:20 localhost dhcpcd[4513]: eno16777736: executing `/lib/dhcpcd/dhcpcd-run-hooks' PREINIT

Jun 28 08:00:20 localhost dhcpcd[4513]: eno16777736: executing `/lib/dhcpcd/dhcpcd-run-hooks' NOCARRIER

Jun 28 08:00:20 localhost dhcpcd[4513]: no interfaces have a carrier

Jun 28 08:00:20 localhost dhcpcd[4513]: eno16777736: waiting for carrier

Jun 28 08:00:20 localhost dhcpcd[4513]: eno16777736: carrier acquired

Jun 28 08:00:20 localhost dhcpcd[4513]: eno16777736: executing `/lib/dhcpcd/dhcpcd-run-hooks' CARRIER

Jun 28 08:00:20 localhost dhcpcd[4513]: DUID {duid}

Jun 28 08:00:20 localhost dhcpcd[4513]: eno16777736: IAID 29:0c:64:ca

Jun 28 08:00:20 localhost dhcpcd[4513]: eno16777736: delaying IPv6 router solictation for 0.5 seconds

Jun 28 08:00:20 localhost dhcpcd[4513]: eno16777736: delaying DHCP for 0.9 seconds

Jun 28 08:00:20 localhost dhcpcd[4513]: eno16777736: libudev: add

Jun 28 08:00:20 localhost dhcpcd[4513]: eno16777736: executing `/lib/dhcpcd/dhcpcd-run-hooks' PREINIT

Jun 28 08:00:20 localhost dhcpcd[4513]: eno16777736: executing `/lib/dhcpcd/dhcpcd-run-hooks' CARRIER

Jun 28 08:00:20 localhost dhcpcd[4513]: eno16777736: IAID 29:0c:64:ca

Jun 28 08:00:20 localhost dhcpcd[4513]: eno16777736: IAID conflicts with one assigned to eno16777736

Jun 28 08:00:20 localhost dhcpcd[4513]: eno16777736: delaying IPv6 router solictation for 0.4 seconds

Jun 28 08:00:20 localhost dhcpcd[4513]: eno16777736: delaying DHCP for 0.8 seconds

Jun 28 08:00:20 localhost dhcpcd[4513]: eno16777736: libudev: move

Jun 28 08:00:20 localhost dhcpcd[4513]: eno16777736: executing `/lib/dhcpcd/dhcpcd-run-hooks' PREINIT

Jun 28 08:00:20 localhost dhcpcd[4513]: eno16777736: executing `/lib/dhcpcd/dhcpcd-run-hooks' CARRIER

Jun 28 08:00:20 localhost dhcpcd[4513]: eno16777736: IAID 29:0c:64:ca

Jun 28 08:00:20 localhost dhcpcd[4513]: eno16777736: IAID conflicts with one assigned to eno16777736

Jun 28 08:00:20 localhost dhcpcd[4513]: eno16777736: delaying IPv6 router solictation for 0.2 seconds

Jun 28 08:00:20 localhost dhcpcd[4513]: eno16777736: delaying DHCP for 0.4 seconds

Jun 28 08:00:21 localhost dhcpcd[4513]: eno16777736: soliciting an IPv6 router

Jun 28 08:00:21 localhost dhcpcd[4513]: eno16777736: delaying Router Solicitation for LL address

Jun 28 08:00:21 localhost dhcpcd[4513]: [30B blob data]

Jun 28 08:00:21 localhost systemd[1]: dhcpcd.service: main process exited, code=dumped, status=11/SEGV

Jun 28 08:00:21 localhost systemd[1]: Unit dhcpcd.service entered failed state.

Jun 28 08:00:21 localhost systemd-udevd[4107]: renamed network interface eth0 to eno16777736

Jun 28 08:00:21 localhost kernel: dhcpcd[4513]: segfault at 770 ip 000000000041e480 sp 00007fff0b73d4d0 error 4

Jun 28 08:00:21 localhost kernel:  in dhcpcd[400000+35000]

Jun 28 08:00:21 localhost systemd[1]: dhcpcd.service: main process exited, code=dumped, status=11/SEGV

Jun 28 08:00:21 localhost systemd[1]: Unit dhcpcd.service entered failed state.

Jun 28 08:00:21 localhost kernel: dhcpcd[4513]: segfault at 770 ip 000000000041e480 sp 00007fff0b73d4d0 error 4

Jun 28 08:00:21 localhost kernel:  in dhcpcd[400000+35000]
```

----------

## UberLord

Interesting.

So it looks like that udev lied that the device was ready and it issued an add and move call - only one should have been issued.

So I think it's caused by a udev bug.

However, dhcpcd still shouldn't segfault but I can't see what I'm doing wrong. I'll keep poking at it, but for the time being file a bug at bugs.gentoo.org

----------

## UberLord

Can you test this patch please?

http://roy.marples.name/~roy/dhcpcd-ifdebug.diff

If it fails, some more dhcpcd debug output would be nice so I can see the new messages.

----------

## UberLord

Or you can try the dhcpcd-9999 ebuild as I have committed a similar patch upstream.

----------

## theit8514

So maybe the error is not tied to the renaming of the interface. Patch applied and still crashing. I'm doing an emerge @world right now to see if maybe something else is messed up.

Two new logs:

```
Jun 30 06:49:06 localhost systemd-udevd[4411]: renamed network interface eth0 to eno16777736

Jun 30 06:49:06 localhost dhcpcd[4557]: version 6.4.0 starting

Jun 30 06:49:06 localhost dhcpcd[4557]: udev: starting

Jun 30 06:49:06 localhost dhcpcd[4557]: dev: loaded udev

Jun 30 06:49:06 localhost dhcpcd[4557]: eno16777736: disabling kernel IPv6 RA support

Jun 30 06:49:06 localhost dhcpcd[4557]: eno16777736: adding address fe80::xxxx

Jun 30 06:49:06 localhost dhcpcd[4557]: eno16777736: vltime infinity, pltime infinity

Jun 30 06:49:06 localhost dhcpcd[4557]: eno16777736: executing `/lib/dhcpcd/dhcpcd-run-hooks' PREINIT

Jun 30 06:49:06 localhost dhcpcd[4557]: eno16777736: executing `/lib/dhcpcd/dhcpcd-run-hooks' NOCARRIER

Jun 30 06:49:06 localhost dhcpcd[4557]: no interfaces have a carrier

Jun 30 06:49:06 localhost kernel: IPv6: ADDRCONF(NETDEV_UP): eno16777736: link is not ready

Jun 30 06:49:06 localhost dhcpcd[4557]: eno16777736: waiting for carrier

Jun 30 06:49:06 localhost dhcpcd[4557]: eno16777736: libudev: add

Jun 30 06:49:06 localhost dhcpcd[4557]: eno16777736: interface updated

Jun 30 06:49:06 localhost systemd[1]: dhcpcd.service: main process exited, code=killed, status=11/SEGV

Jun 30 06:49:06 localhost systemd[1]: Unit dhcpcd.service entered failed state.

Jun 30 06:49:06 localhost kernel: dhcpcd[4557]: segfault at 60a0 ip 0000000000405c75 sp 00007fff84365230 error 4 in dhcpcd[400000+35000]

Jun 30 06:49:06 localhost kernel: e1000: eno16777736 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None

Jun 30 06:49:06 localhost kernel: IPv6: ADDRCONF(NETDEV_CHANGE): eno16777736: link becomes ready
```

```
Jun 30 06:58:41 localhost dhcpcd[4444]: version 6.4.0 starting

Jun 30 06:58:41 localhost dhcpcd[4444]: udev: starting

Jun 30 06:58:41 localhost dhcpcd[4444]: dev: loaded udev

Jun 30 06:58:41 localhost dhcpcd[4444]: eno16777736: disabling kernel IPv6 RA support

Jun 30 06:58:41 localhost dhcpcd[4444]: eno16777736: adding address fe80::xxxx

Jun 30 06:58:41 localhost dhcpcd[4444]: eno16777736: vltime infinity, pltime infinity

Jun 30 06:58:41 localhost dhcpcd[4444]: eno16777736: executing `/lib/dhcpcd/dhcpcd-run-hooks' PREINIT

Jun 30 06:58:41 localhost systemd-udevd[4415]: renamed network interface eth0 to eno16777736

Jun 30 06:58:41 localhost dhcpcd[4444]: eno16777736: executing `/lib/dhcpcd/dhcpcd-run-hooks' NOCARRIER

Jun 30 06:58:41 localhost dhcpcd[4444]: no interfaces have a carrier

Jun 30 06:58:41 localhost dhcpcd[4444]: lo: libudev: add

Jun 30 06:58:41 localhost dhcpcd[4444]: lo: unsupported interface type 00, falling back to ethernet

Jun 30 06:58:41 localhost dhcpcd[4444]: lo: interface added

Jun 30 06:58:41 localhost dhcpcd[4444]: lo: disabling kernel IPv6 RA support

Jun 30 06:58:41 localhost dhcpcd[4444]: lo: adding address fe80::xxxx

Jun 30 06:58:41 localhost dhcpcd[4444]: if_addaddress6: No such device

Jun 30 06:58:41 localhost dhcpcd[4444]: lo: executing `/lib/dhcpcd/dhcpcd-run-hooks' PREINIT

Jun 30 06:58:41 localhost dhcpcd[4444]: lo: executing `/lib/dhcpcd/dhcpcd-run-hooks' CARRIER

Jun 30 06:58:41 localhost dhcpcd[4444]: DUID 00:01:00:01:1b:40:73:45:xxxx

Jun 30 06:58:41 localhost dhcpcd[4444]: lo: IAID 00:00:01:00

Jun 30 06:58:41 localhost dhcpcd[4444]: lo: delaying IPv6 router solictation for 0.6 seconds

Jun 30 06:58:41 localhost dhcpcd[4444]: lo: delaying DHCP for 0.4 seconds

Jun 30 06:58:41 localhost dhcpcd[4444]: eno16777736: waiting for carrier

Jun 30 06:58:41 localhost dhcpcd[4444]: eno16777736: libudev: add

Jun 30 06:58:41 localhost dhcpcd[4444]: eno16777736: interface updated

Jun 30 06:58:41 localhost systemd[1]: dhcpcd.service: main process exited, code=dumped, status=11/SEGV

Jun 30 06:58:41 localhost systemd[1]: Unit dhcpcd.service entered failed state.

Jun 30 06:58:41 localhost kernel: e1000: eno16777736 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None

Jun 30 06:58:41 localhost kernel: IPv6: ADDRCONF(NETDEV_UP): eno16777736: link is not ready

Jun 30 06:58:41 localhost kernel: IPv6: ADDRCONF(NETDEV_CHANGE): eno16777736: link becomes ready

Jun 30 06:58:41 localhost kernel: dhcpcd[4444]: segfault at 60a0 ip 0000000000405c75 sp 00007fff604c0e40 error 4 in dhcpcd[400000+35000]
```

The IPv6 is new, and I have this new backtrace which happens in dhcpcd_startinterface (IPv6)

```
# gdb_get_backtrace `which dhcpcd` core.dump.1404125921.4444 

[New LWP 4444]

warning: Could not load shared library symbols for linux-vdso.so.1.

Do you need "set solib-search-path" or "set sysroot"?

[Thread debugging using libthread_db enabled]

Using host libthread_db library "/lib64/libthread_db.so.1".

Core was generated by `/sbin/dhcpcd -q --nobackground'.

Program terminated with signal 11, Segmentation fault.

#0  dhcpcd_startinterface (arg=arg@entry=0x64e680) at dhcpcd.c:576

576             if (ifo->options & DHCPCD_IPV6 && ipv6_start(ifp) == -1) {

Thread 1 (Thread 0x7fb8613ab700 (LWP 4444)):

#0  dhcpcd_startinterface (arg=arg@entry=0x64e680) at dhcpcd.c:576

        ifp = 0x64e680

        ifo = 0x0

        i = <optimized out>

        buf = "\020\017L`ÿ\177\000\000P\016L`ÿ\177\000\000\200\021L`ÿ\177\000\000\070õd\000\000\000\000\000\200æd\000\000\000\000\000\210ßd", '\000' <repeats 29 times>, "bgÍ`¸\177\000\000\003\020\000\000\000\000\000\000\001\000\000\000\060\000\000\000\230æd\000\000\000\000\000 \017L`ÿ\177\000\000`Id\000\000\000\000\000`ñd\000\000\000\000\000\200\021L`ÿ\177"

#1  0x0000000000406480 in dhcpcd_handleinterface (arg=0x7fff604c1180, action=1, ifname=0x64c4b0 "eno16777736") at dhcpcd.c:786

        ctx = 0x7fff604c1180

        ifs = 0x64f030

        ifp = 0x64e680

        ifn = 0x0

        ifl = 0x64df70

        argv = {0x64c4b0 "eno16777736"}

        i = 0

#2  0x00007fb8609eb029 in udev_handle_device (ctx=0x7fff604c1180) at udev.c:95

        device = 0x64af30

        subsystem = 0x64e260 "net"

        ifname = 0x64c4b0 "eno16777736"

        action = <optimized out>

#3  0x0000000000407af6 in eloop_start (dctx=dctx@entry=0x7fff604c1180) at eloop.c:399

        ctx = 0x63e430

        now = {tv_sec = 10, tv_usec = 613775}

        n = 6610850

        e = <optimized out>

        t = 0x64e0a0

        tv = <optimized out>

        ts = {tv_sec = 0, tv_nsec = 403839000}

        tsp = <optimized out>

        t0 = <optimized out>

#4  0x0000000000403809 in main (argc=<optimized out>, argv=<optimized out>) at dhcpcd.c:1603

        ctx = {sigset = {__val = {0 <repeats 16 times>}}, cffile = 0x427c55 "/etc/dhcpcd.conf", options = 1830040538848297, argc = 3, argv = 0x7fff604c14a8, ifac = 0, ifav = 0x0, ifdc = 0, ifdv = 0x0, ifc = 0, ifv = 0x7fff604c14c0, duid = 0x64c100 "", duid_len = 14, pid_fd = 3, link_fd = 6, ifaces = 0x64dc80, eloop = 0x63e430, control_fd = 4, control_fds = 0x0, control_sock = "/run/dhcpcd.sock", '\000' <repeats 20 times>, control_group = 0, vivso = 0x0, vivso_len = 0, dhcp_opts = 0x63c5e0, dhcp_opts_len = 121, ipv4_routes = 0x64b1f0, udp_fd = -1, packet = 0x0, opt_buffer = 0x0, secret = '\000' <repeats 63 times>, secret_len = 0, dhcp6_opts = 0x643810, dhcp6_opts_len = 69, ipv6 = 0x64b240, ra_restore = 0x64b1b0, ra_restore_len = 2, dev_load = 0x0, dev_fd = 8, dev = 0x64da80, dev_handle = 0x64c990}

        pidfile = "/run/dhcpcd.pid\000 Ë;a¸\177\000\000ôÇ\031a¸\177\000\000p\017À`¸\177"

        ifo = 0x0

        ifp = 0x0

        family = <optimized out>

        opt = 0

        oi = 25

        i = <optimized out>

        t = <optimized out>

        len = <optimized out>

        pid = <optimized out>

        sig = <optimized out>

        siga = <optimized out>

        ts = {tv_sec = 140429873909328, tv_nsec = 140429879826779}

        __func__ = "main"
```

----------

## UberLord

OK, fixed here I think: http://roy.marples.name/projects/dhcpcd/fdiff?v1=c2f0f356fbb7ba56801b45f38b52ac89976cca7d&v2=0e945dc9ec65fed2f41c0e27f80d9c8145cae181&sbs=0

Requires the previous patch as well.

----------

## theit8514

Thanks! I was unable to apply the patch directly using the 6.4.0 codebase, so I switched to dhcpcd-9999 and the patch you have committed has not crashed in 4-5 reboots now.

----------

## UberLord

Nice!

----------

