NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/47101: imon(8) alignment problem on 32-bit sparc

>Number:         47101
>Category:       bin
>Synopsis:       imon(8) alignment problem on 32-bit sparc
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Oct 21 22:05:00 +0000 2012
>Originator:     Takeshi Nakayama
>Release:        NetBSD 6.0
System: NetBSD nyx 6.0 NetBSD 6.0 (NYX32) #0: Mon Oct 15 08:57:59 JST 2012
 takeshi@nyx:/usr/src/sys/arch/sparc64/compile/NYX32 sparc64
Architecture: sparc
Machine: sparc64


ipmon(8) sometimes dies with bus error on 32-bit sparc.  Since 6.0,
ipf log records contain time_t data and read it with "ldd"
instruction, but it requires 8-byte alignment.

nyx# gdb ipmon /ipmon.core
GNU gdb (GDB) 7.3.1
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "sparc--netbsdelf".
For bug reporting instructions, please see:
Reading symbols from /w1/obj/6-sparc64_32/usr.sbin/ipf/ipmon/ipmon...(no 
debugging symbols found)...done.
[New process 1]
Core was generated by `ipmon'.
Program terminated with signal 10, Bus error.
#0  0x00012430 in print_log ()
(gdb) where
#0  0x00012430 in print_log ()
#1  0x000145b8 in main ()
(gdb) disas
Dump of assembler code for function print_log:
   0x00011e20 <+0>:     save  %sp, -232, %sp
   0x00011e24 <+4>:     sethi  %hi(0x2b000), %l0
   0x00011e28 <+8>:     cmp  %i3, 0
   0x00012424 <+1540>:  clrb  [ %i5 + 0x2c8 ]
   0x00012428 <+1544>:  add  %i2, 0x6c, %g4
   0x0001242c <+1548>:  or  %i4, 0x2a0, %o5
=> 0x00012430 <+1552>:  ldd  [ %i2 + 8 ], %g2
   0x00012434 <+1556>:  srl  %g1, 4, %g1
---Type <return> to continue, or q <return> to quit---q
(gdb) p/x $i2
$1 = 0xffffa9c4
(gdb) p/x $g4
$2 = 0xffffaa30
(gdb) quit


Run ipmon(8) on 32-bit sparc, NetBSD 6.0.  I guess -current has the
same problem.


I'm not sure ALIGNBYTES is suitable for all ports, but it's fine at
least on 32-bit saprc.

--- dist/ipf/tools/ipmon.c.orig 2012-02-16 11:46:21.000000000 +0900
+++ dist/ipf/tools/ipmon.c      2012-10-16 11:34:26.000000000 +0900
@@ -946,7 +946,7 @@
        while (blen > 0) {
                ipl = (iplog_t *)buf;
-               if ((u_long)ipl & (sizeof(long)-1)) {
+               if ((u_long)ipl & ALIGNBYTES) {
                        if (bp)
                                bpo = bp;
                        bp = (char *)malloc(blen);

Home | Main Index | Thread Index | Old Index