Subject: Re: mutt-1.4.2 (from pkgsrc) broken on -current/alpha?
To: None <current-users@NetBSD.org, tech-pkg@NetBSD.org>
From: Dave Huang <khym@azeotrope.org>
List: current-users
Date: 02/21/2004 16:46:11
[ Sorry, tech-pkg probably isn't exactly the right place for this, but
  I figure you guys know about autoconf ]

First, a recap for those on tech-pkg:

I updated my mutt package from 1.4.1 to 1.4.2, and it now crashes soon
after starting (it clears the screen, and that's it).

On Wed, Feb 18, 2004 at 04:30:47PM -0600, Dave Huang wrote:
> Manuel Bouyer wrote:
> 
> >>The system is running -current with userland from Jan 21 and kernel from 
> >>Jan 24; perhaps I should try updating both (libc, in particular), but it 
> >>doesn't look like wcrtomb() has had any changes in a while.
> >>
> >
> >I'm running 1.6.x on this box, maybe that's the key.
> >
> Perhaps so... I think -current has many changes in the wide character 
> support. I recompiled mutt with -g, and now get:
> 
> pid 2443 (mutt): unaligned access: va=0x1ffffeaa4 pc=0x160414670 
> ra=0x120021d28 sp=0x1ffffe9f0 op=ldq
> pid 2443 (mutt): unaligned access: va=0x1ffffeaa4 pc=0x1604146b0 
> ra=0x120021d28 sp=0x1ffffe9f0 op=ldq
> pid 2443 (mutt): unaligned access: va=0x200fba1800000c79 pc=0x1604146b8 
> ra=0x120021d28 sp=0x1ffffe9f0 op=ldq
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x00000001604146bc in wcrtomb () from /usr/lib/libc.so.12
> (gdb) where
> #0  0x00000001604146bc in wcrtomb () from /usr/lib/libc.so.12
> #1  0x0000000120021d28 in mutt_format_string (
>    dest=0x1200f7798 "/var/mail/khym: No such file or directory (errno = 
> 2)",
>    destlen=255, min_width=0, max_width=78, right_justify=0,
>    m_pad_char=0 '\0',
>    s=0x1200f7798 "/var/mail/khym: No such file or directory (errno = 2)",
>    n=256, arboreal=0) at curs_lib.c:565
> #2  0x0000000120020a70 in mutt_curses_error (
>    fmt=0x1200cfa6c "%s: %s (errno = %d)") at curs_lib.c:255
> #3  0x0000000120020fd8 in mutt_perror (s=0x1ffffec20 "/var/mail/khym")
>    at curs_lib.c:326
> #4  0x000000012005bce4 in mx_open_mailbox (path=0x1ffffec20 
> "/var/mail/khym",
>    flags=0, pctx=0x0) at mx.c:657
> #5  0x000000012004d550 in main (argc=1, argv=0x1fffff498) at main.c:838
> (gdb) up
> #1  0x0000000120021d28 in mutt_format_string (
>    dest=0x1200f7798 "/var/mail/khym: No such file or directory (errno = 
> 2)",
>    destlen=255, min_width=0, max_width=78, right_justify=0,
>    m_pad_char=0 '\0',
>    s=0x1200f7798 "/var/mail/khym: No such file or directory (errno = 2)",
>    n=256, arboreal=0) at curs_lib.c:565
> 565           if (w > max_width || (k2 = wcrtomb (scratch, wc, 
> &mbstate2)) > destlen)
> 
> I set machdep.unaligned_sigbus=1, and the unaligned access happens 
> within wcrtomb() also. However, a test program that calls 
> setlocale(LC_ALL, ""), then wcrtomb() works fine. I guess I'll just try 
> upgrading my system to the latest -current first :)

I tracked it down, and the problem isn't in NetBSD's libc, the problem
is that mutt's configure script doesn't think NetBSD has wchar.h, so
it makes up bogus types for various wchar-related things (namely, it
does a "#define mbstate_t int"). The reason it can't find wchar.h is:

configure:7529: checking for wchar.h
configure:7539: gcc -E -I/usr/include -I/usr/include -I$(top_srcdir)/intl conftest.c >/dev/null 2>conftest.out
top_srcdir: not found
configure: failed program was:
#line 7534 "configure"
#include "confdefs.h"
#include <wchar.h>

What's this $(top_srcdir) about, and why isn't it being expanded? It's
coming from line 7458 of the configure script (or line 758 of
configure.in):

CPPFLAGS="$CPPFLAGS -I\$(top_srcdir)/intl"

Any thoughts on how to fix it? Or perhaps someone could just commit a
patch to pkgsrc? :)
-- 
Name: Dave Huang         |  Mammal, mammal / their names are called /
INet: khym@azeotrope.org |  they raise a paw / the bat, the cat /
FurryMUCK: Dahan         |  dolphin and dog / koala bear and hog -- TMBG
Dahan: Hani G Y+C 28 Y++ L+++ W- C++ T++ A+ E+ S++ V++ F- Q+++ P+ B+ PA+ PL++