Fwd: [ net-snmp-Bugs-3434824 ] coredump on HUP while disks read

Alexey Kouznetsov alexey at kouznetsov.com
Fri Jan 27 14:18:23 UTC 2012


Hello!

There are bug in net-snmp. net-snmp die (coredump) on SIGHUP while we have
disk command defined in snmpd.*conf.  Bellow fix in main net-snmp tree. I
think it is good idea to add such small patch to the FreeBSD port unlil
they release new version an new version will be included to the ports. You
can see path an butom of mail conversation bellow

Thank you!

With best regards
/Alexey

---------- Forwarded message ----------
From: SourceForge.net <noreply at sourceforge.net>
Date: 2011/11/11
Subject: [ net-snmp-Bugs-3434824 ] coredump on HUP while disks read
To: "SourceForge.net" <noreply at sourceforge.net>


Bugs item #3434824, was opened at 2011-11-07 23:45
Message generated for change (Comment added) made by nba
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112694&aid=3434824&group_id=12694

Please note that this message will contain a full copy of the comment
thread,
including the initial issue submission, for this request,
not just the latest update.
Category: agent
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Alexey (st-da)
Assigned to: Niels Baggesen (nba)
Summary: coredump on HUP while disks read

Initial Comment:
FreeBSD xxx 8.2-STABLE FreeBSD 8.2-STABLE #9: Tue Oct 11 07:07:46 UTC 2011
    root at xxx:/usr/obj/usr/src/sys/AAASMP  i386
but some error reproduced at amd64 system
net-snmp from ports net-snmp-5.7_4
net snmp started as:
---
/usr/local/sbin/snmpd -p /var/run/snmpd.pid -Lf /var/log/snmpd.log
---

We have commands like:

disk /
disk /usr
disk /var
in config.
when we
kill -HUP ` cat /var/run/snmpd.pid `
we got "kernel: pid 61129 (snmpd), uid 0: exited on signal 11 (core dumped)"

If we remove disk commands error disapear. if we add includeAllDisks or any
single disk we got an error. snmpd.cons is simple some access lines and
this disk lines. snmpd works untill we send sighup. (unlill we logrotate,
and logrotate send sighup for reopen log file). If we disable logging
problem hides (we do not need sent sighup, so it will work)

gdb output bellow:

Core was generated by `snmpd'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/local/lib/libnetsnmpagent.so.30...done.
Loaded symbols for /usr/local/lib/libnetsnmpagent.so.30
Reading symbols from /usr/local/lib/libnetsnmpmibs.so.30...done.
Loaded symbols for /usr/local/lib/libnetsnmpmibs.so.30
Reading symbols from /usr/lib/libwrap.so.6...done.
Loaded symbols for /usr/lib/libwrap.so.6
Reading symbols from /usr/local/lib/libnetsnmp.so.30...done.
Loaded symbols for /usr/local/lib/libnetsnmp.so.30
Reading symbols from /lib/libm.so.5...done.
Loaded symbols for /lib/libm.so.5
Reading symbols from /lib/libkvm.so.5...done.
Loaded symbols for /lib/libkvm.so.5
Reading symbols from /lib/libdevstat.so.7...done.
Loaded symbols for /lib/libdevstat.so.7
Reading symbols from /lib/libcrypto.so.6...done.
Loaded symbols for /lib/libcrypto.so.6
Reading symbols from /usr/lib/libelf.so.1...done.
Loaded symbols for /usr/lib/libelf.so.1
Reading symbols from /lib/libc.so.7...done.
Loaded symbols for /lib/libc.so.7
Reading symbols from /libexec/ld-elf.so.1...done.
Loaded symbols for /libexec/ld-elf.so.1
#0  0x2814a8a5 in disk_parse_config (token=0xbfbfdb8c "disk",
cptr=0xbfbfdf9c "10240") at ucd-snmp/disk_hw.c:193
193           disks[numdisks++] = entry;

(gdb) where
#0  0x2814a8a5 in disk_parse_config (token=0xbfbfdb8c "disk",
cptr=0xbfbfdf9c "10240") at ucd-snmp/disk_hw.c:193
#1  0x28269830 in run_config_handler (lptr=0x286878a0, token=0xbfbfdb8c
"disk", cptr=0xbfbfdf91 "/          10240", when=0)
   at read_config.c:546
#2  0x2826a70a in read_config (filename=0xbfbfe440
"/usr/local/etc/snmp/snmpd.conf", line_handler=0x2860f080, when=0)
   at read_config.c:939
#3  0x2826b7ae in read_config_files_in_path (path=Variable "path" is not
available.
) at read_config.c:1282
#4  0x2826bb86 in read_config_files_of_type (when=0, ctmp=0x28620040) at
read_config.c:1365
#5  0x2826bc14 in read_config_files (when=0) at read_config.c:1406
#6  0x2826c39f in read_configs () at read_config.c:1018
#7  0x280bc928 in update_config () at agent_read_config.c:292
#8  0x0804b91b in SnmpdReconfig ()
#9  0x0804a127 in ?? ()
#10 0x00000000 in ?? ()
#11 0x00000000 in ?? ()
#12 0xbfbfea08 in ?? ()
#13 0x0804a127 in ?? ()
#14 0x00000005 in ?? ()
#15 0xbfbfea30 in ?? ()
#16 0xbfbfea48 in ?? ()
#17 0xbfbfea10 in ?? ()
#18 0xbfbfea2c in ?? ()
#19 0x00000000 in ?? ()
#20 0xbfbfea28 in ?? ()
#21 0x0804a098 in ?? ()
Previous frame inner to this frame (corrupt stack?)

(gdb) list
292         read_configs();
293     }
294
295
296     void
297     snmpd_register_config_handler(const char *token,
298                                   void (*parser) (const char *, char *),
299                                   void (*releaser) (void), const char
*help)
300     {
301         DEBUGMSGTL(("snmpd_register_app_config_handler",



----------------------------------------------------------------------

>Comment By: Niels Baggesen (nba)
Date: 2011-11-10 12:42

Message:
Best I can tell this fiexed the problem, and I have applied this fix to
Net-SNMP

Thanks for the bug report.

----------------------------------------------------------------------

Comment By: Niels Baggesen (nba)
Date: 2011-11-08 12:55

Message:
I think a single missing line is causing the trouble. Please try this:

--- a/agent/mibgroup/ucd-snmp/disk_hw.c
+++ b/agent/mibgroup/ucd-snmp/disk_hw.c
@@ -137,6 +137,7 @@ disk_free_config(void)
  if (disks) {
     free( disks );
     disks = NULL;
+     maxdisks = numdisks = 0;
  }
  allDisksIncluded = 0;
 }


----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112694&aid=3434824&group_id=12694


More information about the freebsd-net mailing list