Bug#388256: tinysnmp-agent: SIGBUS on sparc at startup
On Tue, Sep 19, 2006 at 03:01:51PM +0200, Abraham vd Merwe wrote: Thanks for the help. Can you send me your patch with the memmove()'s and I'll have a look at it? The attached patch makes tinysnmpd survive a full snmpwalk on sparc. As I said, I don't think this is the correct fix, since nothing in memmove(3) indicates it can be relied on for copying non-aligned data. But at least it shows some of the problematic points. FWIW, this seems to work with -Os as well, so -O0 is no longer needed. Cheers, -- Niko Tyni [EMAIL PROTECTED] --- /tmp/GdYvJ6nBqN/tinysnmp-0.8.4/agent/odb.c 2004-07-30 19:59:29.0 +0300 +++ /tmp/vKVcLAvHZW/tinysnmp-0.8.4+memmove/agent/odb.c 2006-09-19 23:27:33.0 +0300 @@ -80,7 +80,7 @@ static int snmp_copy_value (snmp_value_t *dest,const snmp_value_t *src) { - memcpy (dest,src,sizeof (snmp_value_t)); + memmove (dest,src,sizeof (snmp_value_t)); if (src-type == BER_OCTET_STRING) { @@ -145,7 +145,7 @@ odb-parent = odb-sibling = odb-child = NULL; if (type == VALUE) -odb-data.value = node-value; +memmove((odb-data.value), (node-value), sizeof(snmp_value_t)); else odb-data.node = node-oid[0]; --- /tmp/GdYvJ6nBqN/tinysnmp-0.8.4/modules/resources/diskinfo_linux.c 2004-07-17 17:02:24.0 +0300 +++ /tmp/vKVcLAvHZW/tinysnmp-0.8.4+memmove/modules/resources/diskinfo_linux.c 2006-09-19 23:40:33.0 +0300 @@ -137,6 +137,7 @@ struct statfs fs; struct mntent *entry; struct diskinfo *pt; + uint64_t tmp; FILE *fp; abz_clear_error (); @@ -194,8 +195,10 @@ strcpy (pt-d_dev,entry-mnt_fsname); strcpy (pt-d_dir,entry-mnt_dir); pt-d_type = type; - pt-d_total = ((uint64_t) fs.f_bsize * (uint64_t) fs.f_blocks) 20; - pt-d_free = ((uint64_t) fs.f_bsize * (uint64_t) fs.f_bavail) 20; + tmp = ((uint64_t) fs.f_bsize * (uint64_t) fs.f_blocks) 20; + memmove((pt-d_total), tmp, sizeof(uint64_t)); + tmp = ((uint64_t) fs.f_bsize * (uint64_t) fs.f_bavail) 20; + memmove((pt-d_free), tmp, sizeof(uint64_t)); disk_insert (list,pt); } --- /tmp/GdYvJ6nBqN/tinysnmp-0.8.4/modules/resources/main.c 2004-07-31 21:13:01.0 +0300 +++ /tmp/vKVcLAvHZW/tinysnmp-0.8.4+memmove/modules/resources/main.c 2006-09-19 23:44:44.0 +0300 @@ -134,13 +134,15 @@ static void diskTotal (snmp_value_t *value,const struct diskinfo *disk) { value-type = BER_Gauge32; - value-data.Gauge32 = disk-d_total; + /* should this be uint64_t or uint32_t ? */ + memmove(value-data.Gauge32, disk-d_total, sizeof(uint64_t)); } static void diskFree (snmp_value_t *value,const struct diskinfo *disk) { value-type = BER_Gauge32; - value-data.Gauge32 = disk-d_free; + /* should this be uint64_t or uint32_t ? */ + memmove(value-data.Gauge32, disk-d_free, sizeof(uint64_t)); } static int storage_update (struct odb **odb)
Bug#388256: tinysnmp-agent: SIGBUS on sparc at startup
Package: tinysnmp-agent Version: 0.8.4 Severity: grave Justification: renders package unusable This is the same as #282260, but as that's already archived, I'm opening a new bug. The tinysnmpd daemon still doesn't start on sparc but gives a SIGBUS instead. This is with a recompiled (with -O0, as is the default on sparc) package due to #385881. The stack trace with symbols is the same as in #282260: (gdb) run -l debug /etc/tinysnmp.conf /usr/lib/tinysnmp Starting program: /home/niko/src/tinysnmp-0.8.4+debug/agent/tinysnmpd -l debug /etc/tinysnmp.conf /usr/lib/tinysnmp VERBOSE: log.c:603: Starting to log output. VERBOSE: module.c:185: registered module system VERBOSE: module.c:185: registered module snmp Program received signal SIGBUS, Bus error. 0x00017838 in tree_create (type=VALUE, node=0xef897010) at odb.c:148 148 odb-data.value = node-value; (gdb) bt #0 0x00017838 in tree_create (type=VALUE, node=0xef897010) at odb.c:148 #1 0x00017b38 in tree_add (odb=0x2e414, node=0xef897010) at odb.c:215 #2 0x00017a14 in tree_add_child (odb=0x2e3b4, node=0xef897110) at odb.c:188 #3 0x00017be0 in tree_add (odb=0x2e3b4, node=0xef897110) at odb.c:223 #4 0x00017a14 in tree_add_child (odb=0x2e354, node=0xef897210) at odb.c:188 #5 0x00017be0 in tree_add (odb=0x2e354, node=0xef897210) at odb.c:223 #6 0x00017a14 in tree_add_child (odb=0x2e2f4, node=0xef897310) at odb.c:188 #7 0x00017be0 in tree_add (odb=0x2e2f4, node=0xef897310) at odb.c:223 #8 0x00017a14 in tree_add_child (odb=0x2e294, node=0xef897410) at odb.c:188 #9 0x00017be0 in tree_add (odb=0x2e294, node=0xef897410) at odb.c:223 #10 0x00017a14 in tree_add_child (odb=0x2e234, node=0xef897510) at odb.c:188 #11 0x00017be0 in tree_add (odb=0x2e234, node=0xef897510) at odb.c:223 #12 0x00017a14 in tree_add_child (odb=0x2e1d4, node=0xef897610) at odb.c:188 #13 0x00017be0 in tree_add (odb=0x2e1d4, node=0xef897610) at odb.c:223 #14 0x00017a14 in tree_add_child (odb=0x2e14c, node=0xef897710) at odb.c:188 #15 0x00017be0 in tree_add (odb=0x2e14c, node=0xef897710) at odb.c:223 #16 0x00017a14 in tree_add_child (odb=0x2e0ec, node=0xef897810) at odb.c:188 #17 0x00017be0 in tree_add (odb=0x2e0ec, node=0xef897810) at odb.c:223 #18 0x00017a14 in tree_add_child (odb=0x2e0b4, node=0xef897910) at odb.c:188 #19 0x00017be0 in tree_add (odb=0x2e0b4, node=0xef897910) at odb.c:223 #20 0x00017a14 in tree_add_child (odb=0x2d744, node=0xef897a10) at odb.c:188 #21 0x00017be0 in tree_add (odb=0x2d744, node=0xef897a10) at odb.c:223 #22 0x00017de4 in odb_add (odb=0x2d744, oid=0x2d758, value=0xef897a98) at odb.c:266 #23 0x0001a260 in module_extend (oid=0x1c13c, descr=0x1c158 The MIB module for SNMP entities) at module-system.c:369 #24 0x000142c8 in module_open (path=0xef897df6 /usr/lib/tinysnmp) at module.c:247 #25 0x0001a89c in main (argc=5, argv=0xef897cc4) at main.c:184 The problem seems to be data alignment: (gdb) print (odb-data.value) $1 = (snmp_value_t *) 0x2e45c which is not word-aligned. FWIW, I had some success working around this by replacing the assignment with memmove(). This led to other similar bus errors surfacing from either assignments or memcpy() calls, which I also replaced. I did get tinysnmpd to apparently work this way. I don't think it's the right solution, though, but more like a side effect of memmove() copying the data byte-by-byte or something like that. -- System Information: Debian Release: testing/unstable APT prefers testing APT policy: (500, 'testing') Architecture: sparc (sparc64) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.15-1-sparc64 Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Versions of packages tinysnmp-agent depends on: Ii libabz0 0.6.3 Miscellaneous useful routines ii libber0 0.4.1 A Basic Encoding Rules (ITU X.690) ii libc62.3.6.ds1-4 GNU C Library: Shared libraries ii libdebug00.4.2 Memory leak detection system and l ii libevent11.1a-1 An asynchronous event notification Versions of packages tinysnmp-agent recommends: pn tinysnmp-module-interfacesnone (no description available) pn tinysnmp-module-resources none (no description available) -- no debconf information -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Bug#388256: tinysnmp-agent: SIGBUS on sparc at startup
Hi Niko @2006.09.19_13:36:02_+0200 Thanks for the help. Can you send me your patch with the memmove()'s and I'll have a look at it? Package: tinysnmp-agent Version: 0.8.4 Severity: grave Justification: renders package unusable This is the same as #282260, but as that's already archived, I'm opening a new bug. The tinysnmpd daemon still doesn't start on sparc but gives a SIGBUS instead. This is with a recompiled (with -O0, as is the default on sparc) package due to #385881. The stack trace with symbols is the same as in #282260: (gdb) run -l debug /etc/tinysnmp.conf /usr/lib/tinysnmp Starting program: /home/niko/src/tinysnmp-0.8.4+debug/agent/tinysnmpd -l debug /etc/tinysnmp.conf /usr/lib/tinysnmp VERBOSE: log.c:603: Starting to log output. VERBOSE: module.c:185: registered module system VERBOSE: module.c:185: registered module snmp Program received signal SIGBUS, Bus error. 0x00017838 in tree_create (type=VALUE, node=0xef897010) at odb.c:148 148odb-data.value = node-value; (gdb) bt #0 0x00017838 in tree_create (type=VALUE, node=0xef897010) at odb.c:148 #1 0x00017b38 in tree_add (odb=0x2e414, node=0xef897010) at odb.c:215 #2 0x00017a14 in tree_add_child (odb=0x2e3b4, node=0xef897110) at odb.c:188 #3 0x00017be0 in tree_add (odb=0x2e3b4, node=0xef897110) at odb.c:223 #4 0x00017a14 in tree_add_child (odb=0x2e354, node=0xef897210) at odb.c:188 #5 0x00017be0 in tree_add (odb=0x2e354, node=0xef897210) at odb.c:223 #6 0x00017a14 in tree_add_child (odb=0x2e2f4, node=0xef897310) at odb.c:188 #7 0x00017be0 in tree_add (odb=0x2e2f4, node=0xef897310) at odb.c:223 #8 0x00017a14 in tree_add_child (odb=0x2e294, node=0xef897410) at odb.c:188 #9 0x00017be0 in tree_add (odb=0x2e294, node=0xef897410) at odb.c:223 #10 0x00017a14 in tree_add_child (odb=0x2e234, node=0xef897510) at odb.c:188 #11 0x00017be0 in tree_add (odb=0x2e234, node=0xef897510) at odb.c:223 #12 0x00017a14 in tree_add_child (odb=0x2e1d4, node=0xef897610) at odb.c:188 #13 0x00017be0 in tree_add (odb=0x2e1d4, node=0xef897610) at odb.c:223 #14 0x00017a14 in tree_add_child (odb=0x2e14c, node=0xef897710) at odb.c:188 #15 0x00017be0 in tree_add (odb=0x2e14c, node=0xef897710) at odb.c:223 #16 0x00017a14 in tree_add_child (odb=0x2e0ec, node=0xef897810) at odb.c:188 #17 0x00017be0 in tree_add (odb=0x2e0ec, node=0xef897810) at odb.c:223 #18 0x00017a14 in tree_add_child (odb=0x2e0b4, node=0xef897910) at odb.c:188 #19 0x00017be0 in tree_add (odb=0x2e0b4, node=0xef897910) at odb.c:223 #20 0x00017a14 in tree_add_child (odb=0x2d744, node=0xef897a10) at odb.c:188 #21 0x00017be0 in tree_add (odb=0x2d744, node=0xef897a10) at odb.c:223 #22 0x00017de4 in odb_add (odb=0x2d744, oid=0x2d758, value=0xef897a98) at odb.c:266 #23 0x0001a260 in module_extend (oid=0x1c13c, descr=0x1c158 The MIB module for SNMP entities) at module-system.c:369 #24 0x000142c8 in module_open (path=0xef897df6 /usr/lib/tinysnmp) at module.c:247 #25 0x0001a89c in main (argc=5, argv=0xef897cc4) at main.c:184 The problem seems to be data alignment: (gdb) print (odb-data.value) $1 = (snmp_value_t *) 0x2e45c which is not word-aligned. FWIW, I had some success working around this by replacing the assignment with memmove(). This led to other similar bus errors surfacing from either assignments or memcpy() calls, which I also replaced. I did get tinysnmpd to apparently work this way. I don't think it's the right solution, though, but more like a side effect of memmove() copying the data byte-by-byte or something like that. -- System Information: Debian Release: testing/unstable APT prefers testing APT policy: (500, 'testing') Architecture: sparc (sparc64) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.15-1-sparc64 Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Versions of packages tinysnmp-agent depends on: Ii libabz0 0.6.3 Miscellaneous useful routines ii libber0 0.4.1 A Basic Encoding Rules (ITU X.690) ii libc62.3.6.ds1-4 GNU C Library: Shared libraries ii libdebug00.4.2 Memory leak detection system and l ii libevent11.1a-1 An asynchronous event notification Versions of packages tinysnmp-agent recommends: pn tinysnmp-module-interfacesnone (no description available) pn tinysnmp-module-resources none (no description available) -- no debconf information -- Regards Abraham ___ Abraham vd Merwe - The Debian Project 1st Floor, Albion Springs, 183 Main Road, Newlands Phone: +27 21 689 3867 Cell: +27 82 565 4451 Http: http://people.debian.org/~abz/ Email: [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]