Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 153838 - mail-client/nmh: repl program segfaults when compiled with gcc 4.1.1 -O2 on amd64
Summary: mail-client/nmh: repl program segfaults when compiled with gcc 4.1.1 -O2 on a...
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: High normal (vote)
Assignee: Net-Mail Packages
URL:
Whiteboard:
Keywords:
Depends on: 189519 219333
Blocks: 336057
  Show dependency tree
 
Reported: 2006-11-02 10:06 UTC by David Fellows
Modified: 2010-09-05 10:01 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
patch to the nmh-1.1-r1 ebuild to force -O1 compiler optimaization (gcc.patch,725 bytes, patch)
2006-11-02 10:09 UTC, David Fellows
Details | Diff
file containing message being repied to. (1732,1.75 KB, text/plain)
2006-11-02 14:05 UTC, David Fellows
Details
cvs ebuild (nmh-9999.ebuild,1.66 KB, text/plain)
2008-09-15 08:29 UTC, Anders Eriksson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Fellows 2006-11-02 10:06:33 UTC
I have been using nmh regularly for 2 years. After recently doing the gcc upgrade to 4.1.1 amd emerge -e world the repl program began to seg fault.

Reproducible - always
Steps to reproduce:
1 emerge nmh using gcc 4.1.1 compiler
2 repl +somefolder some_msg_number.
where somefolder contains an email identified by some_msg_number that you wish to reply to.

Expected result: invocation of preferred editor with appropriately formatted  message headers and quoted body text ready for insertion of reply text.

Actual result: Segmentation fault.

I forced compilation with -O1 instead of -O2 and the seg fault no longer occurred.

The (soon to be) attached patch solves the problem for me.

 $ emerge --info
Portage 2.1.1-r1 (default-linux/amd64/2006.0, gcc-4.1.1, glibc-2.4-r3, 2.6.17-gentoo-r7 x86_64)
=================================================================
System uname: 2.6.17-gentoo-r7 x86_64 AMD Opteron(tm) Processor 246
Gentoo Base System version 1.12.5
Last Sync: Fri, 27 Oct 2006 10:30:01 +0000
app-admin/eselect-compiler: [Not Present]
dev-java/java-config: 1.3.7, 2.0.30
dev-lang/python:     2.3.5-r3, 2.4.3-r4
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     [Not Present]
dev-util/confcache:  [Not Present]
sys-apps/sandbox:    1.2.17
sys-devel/autoconf:  2.13, 2.59-r7
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2
sys-devel/binutils:  2.16.1-r3
sys-devel/gcc-config: 1.3.13-r4
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.11-r2
ACCEPT_KEYWORDS="amd64"
AUTOCLEAN="yes"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.2/share/config /usr/kde/3.3/env /usr/kde/3.3/share/config /usr/kde/3.3/shutdown /usr/kde/3.4/env /usr/kde/3.4/share/config /usr/kde/3.4/shutdown /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/X11/xkb /usr/share/config"
CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/gconf /etc/java-config/vms/ /etc/revdep-rebuild /etc/terminfo /etc/texmf/web2c"
CXXFLAGS="-O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig distlocks metadata-transfer sandbox sfperms strict"
GENTOO_MIRRORS="http://adelie.polymtl.ca/ http://gentoo.mirrored.ca/ http://gentoo.osuosl.org/ "
MAKEOPTS="-j4"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude='/distfiles' --exclude='/local' --exclude='/packages'"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="amd64 X alsa berkdb bitmap-fonts cli cracklib crypt cups dbus dlloader doc dri eds elibc_glibc emboss encode foomaticdb fortran gcj gif gnome gpm gstreamer gtk gtk2 guile imlib input_devices_evdev input_devices_keyboard input_devices_mouse ipv6 isdnlog java jpeg kde kernel_linux lzw lzw-tiff mp3 mpeg ncurses nls nptl nptlonly nsplugin opengl pam pcre perl png pppd python qt3 qt4 quicktime readline reflection sdl session spell spl ssl tcltk tcpd tiff truetype truetype-fonts type1-fonts usb userland_GNU video_cards_fbdev video_cards_nv video_cards_radeon video_cards_vesa video_cards_vga xorg xpm xv zlib"
Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, LINGUAS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 David Fellows 2006-11-02 10:09:02 UTC
Created attachment 101060 [details, diff]
patch to the nmh-1.1-r1 ebuild to force -O1 compiler optimaization
Comment 2 Jakub Moc (RETIRED) gentoo-dev 2006-11-02 10:10:51 UTC
Can you attach a backtrace please?

http://www.gentoo.org/proj/en/qa/backtraces.xml
Comment 3 David Fellows 2006-11-02 13:09:58 UTC
fellows@kanga ~ $ repl +inbox 1732
Segmentation fault
fellows@kanga ~ $ gdb repl
GNU gdb 6.4
Copyright 2005 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu"...(no debugging symbols found)
Using host libthread_db library "/lib/libthread_db.so.1".

(gdb) run +inbox 1732
Starting program: /usr/bin/repl +inbox 1732
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)

Program received signal SIGSEGV, Segmentation fault.
0x0000000000413ce9 in strcasecmp ()
(gdb) backtrace
#0  0x0000000000413ce9 in strcasecmp ()
#1  0x000000000040379d in ?? ()
#2  0x000000000040dfcd in ?? ()
#3  0x00000000004042ca in ?? ()
#4  0x0000000000402e22 in ?? ()
#5  0x00002ba089e03134 in __libc_start_main () from /lib/libc.so.6
#6  0x0000000000402ab9 in ?? ()
#7  0x00007fff20fedc48 in ?? ()
#8  0x0000000000000000 in ?? ()
(gdb)
Comment 4 David Fellows 2006-11-02 14:05:41 UTC
Created attachment 101094 [details]
file containing message being repied to.
Comment 5 David Fellows 2006-11-02 14:08:49 UTC
OK, I did an ebuild compile of nmh with CFLAGS="-o2 -g"> here is the output of running the repl from that.

This GDB was configured as "x86_64-pc-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".

(gdb) run +inbox 1732
Starting program: /var/tmp/portage/nmh-1.1-r1/work/nmh/uip/repl +inbox 1732

Program received signal SIGSEGV, Segmentation fault.
strcasecmp (s1=<value optimized out>, s2=<value optimized out>)
    at strcasecmp.c:33
33          while (tolower(*us1) == tolower(*us2++))
(gdb) backtrace
#0  strcasecmp (s1=<value optimized out>, s2=<value optimized out>)
    at strcasecmp.c:33
#1  0x000000000040389d in formataddr (orig=<value optimized out>,
    str=0x547080 "fellows") at replsbr.c:390
#2  0x000000000040e0cd in fmt_scan (format=<value optimized out>,
    scanl=0x5618f0 "To: \"David M. Fellows\" <fellows@unb.ca>\n", width=1640,
    dat=0x527b10) at fmt_scan.c:719
#3  0x00000000004043ca in replout (inb=0x556020, msg=<value optimized out>,
    drft=0x7fffe7eb7900 "/home/fellows/Mail/drafts/130", mp=0x555ed0,
    outputlinelen=72, mime=0, form=0x529d00 "/etc/nmh/replcomps",
    filter=0x554ce0 "/home/fellows/Mail/repf2", fcc=0x554ca0 "+outgoing")
    at replsbr.c:238
#4  0x0000000000402f22 in main (argc=<value optimized out>,
    argv=<value optimized out>) at repl.c:437
(gdb)

The contents of Mail/repf2 are:

fellows@kanga ~ $ cat Mail/repf2
; Reply with original included with >, no identification
body:component="> ",compwidth=0,offset=0,overflowtext="> ",overflowoffset=0
:
:Dave F
:

fellows@kanga ~ $

Comment 6 Mark Reinhold 2006-11-29 13:48:44 UTC
Not amd64-specific; reproducible on a plain i686 laptop.

Portage 2.1.1-r2 (default-linux/x86/2006.1, gcc-4.1.1, glibc-2.4-r3, 2.6.16-gentoo-r7 i686)
=================================================================
System uname: 2.6.16-gentoo-r7 i686 Intel(R) Pentium(R) M processor 1300MHz
Gentoo Base System version 1.12.5
Last Sync: Tue, 28 Nov 2006 23:02:01 +0000
app-admin/eselect-compiler: [Not Present]
dev-java/java-config: 1.2.11-r1
dev-lang/python:     2.3.5-r2, 2.4.3-r4
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     [Not Present]
dev-util/confcache:  [Not Present]
sys-apps/sandbox:    1.2.17
sys-devel/autoconf:  2.13, 2.59-r7
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2
sys-devel/binutils:  2.16.1-r3
sys-devel/gcc-config: 1.3.13-r4
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.17-r1
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O3 -fomit-frame-pointer -march=pentium3 -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/X11/xkb /usr/share/config"
CONFIG_PROTECT_MASK="/etc/env.d /etc/gconf /etc/terminfo /etc/texmf/web2c"
CXXFLAGS="-O3 -fomit-frame-pointer -march=pentium3 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig distlocks metadata-transfer sandbox sfperms strict"
GENTOO_MIRRORS="http://gentoo.osuosl.org/ http://cudlug.cudenver.edu/gentoo/ http://gentoo.chem.wisc.edu/gentoo/ http://gentoo.mirrors.tds.net/gentoo"
LC_ALL="C"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude='/distfiles' --exclude='/local' --exclude='/packages'"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="x86 acpi berkdb bitmap-fonts bzip2 cli cracklib crypt cups dlloader dri elibc_glibc fortran gdbm gpm iconv input_devices_keyboard input_devices_mouse ipv6 isdnlog kernel_linux libg++ ncurses nls nptl nptlonly pam pcre perl ppds pppd python readline reflection session spl ssl tcpd truetype-fonts type1-fonts udev unicode userland_GNU video_cards_radeon xorg zlib"
Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LDFLAGS, LINGUAS, PORTAGE_RSYNC_EXTRA_OPTS, PORTDIR_OVERLAY
Comment 7 Timothy Stotts 2007-01-04 16:06:44 UTC
mail-client/nmh

Not specific to any architecture. Reproduced on G4 PPC with -O2.
CFLAGS="-O0" was necessary to fix many of the binaries, including mhe and repl.

Please consider striping flags on this ebuild for gcc 4.
Comment 8 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2008-06-05 23:53:19 UTC
(In reply to comment #7)
> mail-client/nmh
> 
> Not specific to any architecture. Reproduced on G4 PPC with -O2.
> CFLAGS="-O0" was necessary to fix many of the binaries, including mhe and repl.
> 
> Please consider striping flags on this ebuild for gcc 4.


So, Let us pretend that I have ~/Mail/inbox/ - what do I need to do to reproduce this error?

% pwd
~/Mail/inbox
% repl +inbox 
repl: no messages in inbox
%% ls 
msg.txt

where msg.txt is Comment #4

I know next to nothing about how this works but it is such a trivial fix. I would still like to test it first. (Also, in the bug alone we have two different fixes, -O1 & -O0)

Thanks and sorry it has taken so long to fix! =/
Comment 9 Anders Eriksson 2008-06-06 06:39:26 UTC
(In reply to comment #8)
> (In reply to comment #7)
> > mail-client/nmh
> > 
> > Not specific to any architecture. Reproduced on G4 PPC with -O2.
> > CFLAGS="-O0" was necessary to fix many of the binaries, including mhe and repl.
> > 
> > Please consider striping flags on this ebuild for gcc 4.
> 
> 
> So, Let us pretend that I have ~/Mail/inbox/ - what do I need to do to
> reproduce this error?
> 
> % pwd
> ~/Mail/inbox
> % repl +inbox 
> repl: no messages in inbox
> %% ls 
> msg.txt
> 
> where msg.txt is Comment #4
> 
> I know next to nothing about how this works but it is such a trivial fix. I
> would still like to test it first. (Also, in the bug alone we have two
> different fixes, -O1 & -O0)
> 
> Thanks and sorry it has taken so long to fix! =/
> 

I've investigated this quite a bit. The deal is that nmh has its own version of strncpy. The nmh version accepts NULL as input arguments, while the standard's and/or gcc's assumes/requires non-NULL arguments.

This fails in gcc >4.x and higher optimizations where gcc uses its own builtin version rather than linking in the one provided in the source.

Anyway, the recently released nmh 1.3 now calls the function nmh_strncpy and everybody's happy. 
Comment 10 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2008-09-15 02:24:21 UTC
(In reply to comment #9)

> Anyway, the recently released nmh 1.3 now calls the function nmh_strncpy and
> everybody's happy. 
> 

Do you have an ebuild that you used? I tried simply renaming the existing ebuild and all the patches failed to apply.
Comment 11 Anders Eriksson 2008-09-15 08:29:37 UTC
Created attachment 165462 [details]
cvs ebuild

The attached ebuild builds ok from CVS (as of today).
Comment 12 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2008-12-05 01:54:21 UTC
1.3 is in the tree. Please confirm that it fixes this.
Comment 13 Anders Eriksson 2008-12-06 08:49:12 UTC
Work here wit the same test case. 

Comment 14 David Fellows 2008-12-09 02:37:02 UTC
(In reply to comment #12)
> 1.3 is in the tree. Please confirm that it fixes this.
> 
Yes, seems OK.
Comment 15 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2008-12-09 04:02:28 UTC
Thanks for the confirmation. I think I would like to wait it out and once 1.3 is stabled, remove this version. (So, please file a stablereq bug after 30 days) BTW, thanks for using Gentoo all these years ;)
Comment 16 David Fellows 2008-12-09 21:40:00 UTC
(In reply to comment #15)
> Thanks for the confirmation. I think I would like to wait it out and once 1.3
> is stabled, remove this version. (So, please file a stablereq bug after 30
> days) BTW, thanks for using Gentoo all these years ;)
> 
OK, will do.  Thanks to you guys for providing Gentoo all these years.  
Comment 17 Anders Eriksson 2009-06-05 11:57:28 UTC
I'm pretty certain this bug has been solved in current, packaged, release(s) of nmh. Not entirely sure which version thugh.

Time to close it?

Comment 18 David Fellows 2009-06-05 13:44:00 UTC
(In reply to comment #17)
> I'm pretty certain this bug has been solved in current, packaged, release(s) of
> nmh. Not entirely sure which version thugh.
> 
> Time to close it?
> 

I think so. Also time to stabilize nmh-1.3-r1 at least for amd64. See bug #254627.
Comment 19 Samuli Suominen (RETIRED) gentoo-dev 2010-09-05 10:01:02 UTC
nmh was removed from portage, therefore closing as wontfix for now.
new ebuilds should go in bug 336057.