Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/index.php/Reporting_Bug_Guidelines

Do NOT report bugs when a package is just outdated, or it is in Unsupported. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#37161 - [s-nail] I get "Segmentation fault (core dumped)" with settings that work with heirloom-mailx

Attached to Project: Arch Linux
Opened by Karol Błażewicz (karol) - Wednesday, 02 October 2013, 00:49 GMT
Last edited by Gaetan Bisson (vesath) - Thursday, 03 October 2013, 16:26 GMT
Task Type Bug Report
Category Packages: Testing
Status Closed
Assigned To Gaetan Bisson (vesath)
Architecture i686
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

I use mailx to send e-mails to my gmail account. My /etc/mail.rc setup works with heirloom-mailx but not with s-nail:

$ echo "foo" | mailx -s "test" karol.blazewicz@gmail.com
Segmentation fault (core dumped)


How to debug this?
This task depends upon

Closed by  Gaetan Bisson (vesath)
Thursday, 03 October 2013, 16:26 GMT
Reason for closing:  Fixed
Additional comments about closing:  s-nail-14.4.3-1 in [testing]
Comment by Gerardo Exequiel Pozzi (djgera) - Wednesday, 02 October 2013, 01:00 GMT
works for me (x86_64) using msmtp. My configs are here https://wiki.archlinux.org/index.php/User:Djgera#s-nail
Comment by Karol Błażewicz (karol) - Wednesday, 02 October 2013, 01:15 GMT
On my 32-bit it doesn't work. Doesn't matter if I use msmtp or some other program.
Comment by Gerardo Exequiel Pozzi (djgera) - Wednesday, 02 October 2013, 01:24 GMT
Now tested on i686 with same configs (~/.mailrc and ~/.msmtprc), and also works for me. Other config files are untouched.
Comment by Gaetan Bisson (vesath) - Wednesday, 02 October 2013, 01:34 GMT
The best way to debug is to recompile the package with debug symbols and get a backtrace of its segfault:
- get the PKGBUILD
- add options=('debug') to it
- run makepkg in the same directory
- install the resulting package
- run `gdb mailx`
- in gdb, type `run -s test`
- when the segfault appears, type `bt` in gdb
- post output here

I cannot reproduce your issue either, but since there is some doubt on the stability of s-nail I will hold back from moving it to [core] until we can get to the bottom of this.
Comment by Karol Błażewicz (karol) - Wednesday, 02 October 2013, 02:50 GMT
I installed s-nail and s-nail-debug.

$ gdb mailx
GNU gdb (GDB) 7.6.1
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
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 "i686-pc-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/bin/mail...Reading symbols from /usr/lib/debug/usr/bin/mail.debug...(no debugging symbols found)...done.
(no debugging symbols found)...done.
(gdb) run -s test
Starting program: /usr/bin/mailx -s test
warning: Could not load shared library symbols for linux-gate.so.1.
Do you need "set solib-search-path" or "set sysroot"?
Send options without primary recipient specified.
Synopsis:
mailx [-BDdEFintv~] [-A acc] [-a attachment] [-b bcc-addr] [-c cc-addr]
[-O mtaopt [-O mtaopt-arg]] [-q file] [-r from-addr] [-S var[=value]]
[-s subject] to-addr...
mailx [-BDdEeHiNnRv~#] [-A acct] [-S var[=value]] -f [file]
mailx [-BDdEeiNnRv~#] [-A acc] [-S var[=value]] [-u user]
[Inferior 1 (process 27128) exited with code 02]
(gdb) bt
No stack.

Then I tried with the recipient:
(gdb) run -s test karol
Starting program: /usr/bin/mailx -s test karol
warning: Could not load shared library symbols for linux-gate.so.1.
Do you need "set solib-search-path" or "set sysroot"?
test test
^DEOT

Program received signal SIGSEGV, Segmentation fault.
0x0807f4f2 in ?? ()
(gdb) bt
#0 0x0807f4f2 in ?? ()
#1 0x0807cd5b in ?? ()
#2 0x0807d131 in ?? ()
#3 0x0807ebbe in ?? ()
#4 0x0807ed67 in ?? ()
#5 0x0806d981 in ?? ()
#6 0xb7bd59d3 in __libc_start_main () from /usr/lib/libc.so.6
#7 0x0804b2d1 in ?? ()
Comment by Gaetan Bisson (vesath) - Wednesday, 02 October 2013, 02:57 GMT
Thanks but that appears to be a backtrace for s-nail *without* debugging symbols. Could you make sure s-nail-debug is installed, but *not* s-nail? Then, the "??" in the backtrace should be replaced with more useful information. Cheers.
Comment by Doug Newgard (Scimmia) - Wednesday, 02 October 2013, 05:08 GMT
s-nail-debug is just the debugging symbols only, it won't do anything without s-nail and in fact depends on s-nail.
Comment by Karol Błażewicz (karol) - Wednesday, 02 October 2013, 10:01 GMT
Doug Newgard (Scimmia) is right.

$ pacman -Qi s-nail-debug | grep -e Name -e Description -e Depends
Name : s-nail-debug
Description : Detached debugging symbols for s-nail
Depends On : s-nail=14.4.2-2
$ pacman -Ql s-nail-debug
s-nail-debug /usr/
s-nail-debug /usr/lib/
s-nail-debug /usr/lib/debug/
s-nail-debug /usr/lib/debug/.build_id/
s-nail-debug /usr/lib/debug/.build_id/0d/
s-nail-debug /usr/lib/debug/.build_id/0d/3374be8da580590bd65d161a609b74c47e3153
s-nail-debug /usr/lib/debug/.build_id/0d/3374be8da580590bd65d161a609b74c47e3153.debug
s-nail-debug /usr/lib/debug/usr/
s-nail-debug /usr/lib/debug/usr/bin/
s-nail-debug /usr/lib/debug/usr/bin/mail.debug


Should I open a thread on the forums not to clutter the bug tracker with discussion how to properly debug stuff?
Comment by Steffen Nurpmeso (sdaoden) - Wednesday, 02 October 2013, 12:41 GMT
Hello, i'm the maintainer of S-nail, and i would be happy to help you fix the issue.

I'm new to Arch Linux, however, and have yet zero knowledge of the package manager.
Assuming that it has downloaded the s-nail-14_4_2.tar.gz tarball to your system, you could also simply extract that and run 'make WANT_ASSERTS=1', then run 'gdb ./s-nail', just as Gaetan Bisson has shown.

If that doesn't crash, maybe run 'make WANT_ASSERTS=1 PREFIX=/usr SYSCONFDIR=/etc MANDIR=/usr/share/man MAILSPOOL=/var/spool/mail SID= NAIL=mail DESTDIR=pkg install', and then try to crash ./pkg/bin/mail. (This is the configuration that Arch Linux uses to install mailx(1).)

Whatever you do, please ensure that the shown CFLAGS include the '-g' flag, because that enables debugging symbols. You may simply pass CFLAGS='-O2 -g' to the shown make(1) invocations, too.

If you get a backtrace i'm happy to see that.
Comment by Doug Newgard (Scimmia) - Wednesday, 02 October 2013, 16:13 GMT
karol, you can always just add !strip to the options array along with debug, that way the symbols will stay in the files themselves instead of being stripped out into separate files.
Comment by Karol Błażewicz (karol) - Wednesday, 02 October 2013, 17:21 GMT
With options=('debug' '!strip') I get the same result as with debug alone.

Below is the 'make WANT_ASSERTS=1' magic:
$ gdb ./s-nail
GNU gdb (GDB) 7.6.1
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
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 "i686-pc-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/karol/apps/s-nail/src/s-nail-14.4.2/s-nail...done.
(gdb) run -s test karol
Starting program: /home/karol/apps/s-nail/src/s-nail-14.4.2/./s-nail -s test karol
warning: Could not load shared library symbols for linux-gate.so.1.
Do you need "set solib-search-path" or "set sysroot"?
test
^DEOT

Program received signal SIGSEGV, Segmentation fault.
0xb7c3e016 in __strlen_sse2_bsf () from /usr/lib/libc.so.6
(gdb) bt
#0 0xb7c3e016 in __strlen_sse2_bsf () from /usr/lib/libc.so.6
#1 0x0808978c in smtp_auth_var (atype=atype@entry=0x809c5b7 "-user", addr=addr@entry=0x0) at smtp.c:316
#2 0x08086293 in start_mta (to=to@entry=0x80a84d0 <_builtin_buf+16>, input=input@entry=0x80ca678, hp=hp@entry=0xbffff500) at sendout.c:894
#3 0x08086936 in transfer (to=to@entry=0x80a84d0 <_builtin_buf+16>, input=input@entry=0x80ca678, hp=hp@entry=0xbffff500) at sendout.c:848
#4 0x08088d2f in mail1 (hp=hp@entry=0xbffff500, printheaders=printheaders@entry=0, quote=quote@entry=0x0, quotefile=quotefile@entry=0x0,
recipient_record=recipient_record@entry=0, doprefix=doprefix@entry=0) at sendout.c:1186
#5 0x08088e82 in mail (to=0x80a84d0 <_builtin_buf+16>, cc=0x0, bcc=0x0, subject=0xbffff898 "test", attach=0x0, quotefile=quotefile@entry=0x0,
recipient_record=0) at sendout.c:766
#6 0x0804c429 in main (argc=4, argv=0xbffff684) at main.c:712
Comment by Doug Newgard (Scimmia) - Wednesday, 02 October 2013, 17:23 GMT
That's not the same result, that's an actual backtrace instead of a bunch of ??s.
Comment by Karol Błażewicz (karol) - Wednesday, 02 October 2013, 17:27 GMT
I meant there was no reason to post the output for s-nail compiled with options=('debug' '!strip') because it was the same as with options=('debug').
I posted what Steffen Nurpmeso (sdaoden) asked me to do: compiled with 'make WANT_ASSERTS=1' and run 'gdb ./s-nail'.
Comment by Gaetan Bisson (vesath) - Wednesday, 02 October 2013, 17:39 GMT
Karol, does your CPU supports SSE2 instructions? I suspect not.
They should not be enabled for i686 builds; I wonder what calls __strlen_sse2_bsf and/or whether I forgot to turn them off somewhere...

Sorry for the trouble Steffen, apparently this has nothing to do with your code, it looks like my own packaging mistake... :)
Comment by Dave Reisner (falconindy) - Wednesday, 02 October 2013, 17:40 GMT
The problem isn't lack of support for SSE2, it's a simple crash on calling strlen(NULL) at smtp.c:316.
Comment by Doug Newgard (Scimmia) - Wednesday, 02 October 2013, 17:43 GMT
grr, their configure script completely overwrites CFLAGS, which is why the debug option didn't work.
Comment by Steffen Nurpmeso (sdaoden) - Wednesday, 02 October 2013, 17:46 GMT
Yes, i asked him to do that.
And thanks a lot for posting this, Karol!
I can reproduce the segmentation fault if i ensure neither *from* nor *hostname* are set, and am looking into this.
Comment by Gaetan Bisson (vesath) - Wednesday, 02 October 2013, 17:48 GMT
Okay, that's probably because s-nail's build system disregards the environment variables CFLAGS, LDFLAGS, CPPFLAGS. I'll fix that in just a sec.
Comment by Steffen Nurpmeso (sdaoden) - Wednesday, 02 October 2013, 17:50 GMT
Aeh, no, we do not overwrite CFLAGS; i've posted the fix as [e6b2652] on the nail-devel@ list. This is a user-inconvenience of GNU make(1), simply ensure the .POSIX: lines at the top of the makefile is removed.
Comment by Steffen Nurpmeso (sdaoden) - Wednesday, 02 October 2013, 17:53 GMT
But note - when i've fixed the misbehaviour in respect to unset *from* and *hostname* i'll release a v14.4.3, which then also includes the makefile fix (yet on [master] branch).
@Gaetan: it's not worth the effort, that new package will include all the necessary things.
Thanks.
Comment by Gaetan Bisson (vesath) - Wednesday, 02 October 2013, 18:01 GMT
Thanks Steffen. We really need to override CPPFLAGS, CFLAGS, LDFLAGS, even if that's unrelated to Karol's issue. I'll wait for the new version then.
Comment by Steffen Nurpmeso (sdaoden) - Wednesday, 02 October 2013, 18:06 GMT
No, i'm thankful for the patience.
:)
Comment by Gaetan Bisson (vesath) - Wednesday, 02 October 2013, 18:12 GMT
Thanks Dave also for catching what I didn't. So we also need to address this strlen(NULL). I'll try to find some time to see about that.
Comment by Steffen Nurpmeso (sdaoden) - Wednesday, 02 October 2013, 19:21 GMT
Hello all, Karol.
Karol, thanks again for reporting this dumbness of mine!
It's a one-line problem i've introduced last year, i didn't know much of the code and tried to get through, moving around things and slightly changing to a syntax that i can deal with. Unfortunately it seems that i have been sloppy sometimes.

The attached patch corrects the problem, but i will release 14.4.3 in a few minutes, too.
Ciao.
Comment by Gaetan Bisson (vesath) - Thursday, 03 October 2013, 01:57 GMT
Karol, could you confirm that your issue is fixed with s-nail-14.4.3-1 from [testing]?
Comment by Gerardo Exequiel Pozzi (djgera) - Thursday, 03 October 2013, 04:16 GMT
stills works for me, so there are no regressions ;)
Comment by Karol Błażewicz (karol) - Thursday, 03 October 2013, 13:40 GMT
Version 14.4.3 works for me. Thanks, guys :-)

Loading...