Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 231893 - sys-apps/ed: Segmentation Fault on Alpha when built with -O2 -finline-functions
Summary: sys-apps/ed: Segmentation Fault on Alpha when built with -O2 -finline-functions
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: Alpha Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-15 19:56 UTC by Matt Turner
Modified: 2009-06-28 17:42 UTC (History)
3 users (show)

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


Attachments
emerge --info (emerge-info,3.49 KB, text/plain)
2008-07-15 19:57 UTC, Matt Turner
Details
texlive-core-2007-r13 build.log showing ed seg fault (build.log,636.18 KB, text/plain)
2008-07-15 19:58 UTC, Matt Turner
Details
patch against 1.2 (should work on other versions) (inline_segfault.patch,884 bytes, patch)
2009-04-12 14:54 UTC, Matthew Kern
Details | Diff
newer patch against 1.2 (ed_patch1.diff,2.19 KB, patch)
2009-04-14 12:26 UTC, Matthew Kern
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Turner gentoo-dev 2008-07-15 19:56:29 UTC
ed will crash when used by portage. For instance, attempting to compile app-text/texlive-core-2007-r13.

It attempts to run the script located at /var/tmp/portage/app-text/texlive-core-2007-r13/work/texk/dvipsk/texc.script

# texc.script tex.lpro texc.lpro

At which time ed segfaults.


Reproducible: Always

Steps to Reproduce:
Comment 1 Matt Turner gentoo-dev 2008-07-15 19:57:47 UTC
Created attachment 160478 [details]
emerge --info
Comment 2 Matt Turner gentoo-dev 2008-07-15 19:58:48 UTC
Created attachment 160480 [details]
texlive-core-2007-r13 build.log showing ed seg fault
Comment 3 Doug Goldstein (RETIRED) gentoo-dev 2008-07-15 20:22:25 UTC
Run the command by hand in the tarball and follow the Gentoo Backtrace Guide to get a meaningful backtrace.

http://www.gentoo.org/proj/en/qa/backtraces.xml
Comment 4 Matt Turner gentoo-dev 2008-07-15 21:30:51 UTC
Backtrace. Also note, it only segfaults when compiled with -O3. The -funroll-loops and -ftree-vectorize flags do not affect it. -O2 -mcpu=ev67 -mieee -ftree-vectorize -funroll-loops -pipe works fine. -O3 -mcpu=ev67 -mieee -pipe segfaults.

(gdb) set args `cat test`
(gdb) run
Starting program: /bin/ed `cat test`

Program received signal SIGSEGV, Segmentation fault.
push_back_record (ap=0x11f860b60, code=0, argument=0x11f8610fa "tex.lpro") at carg_parser.c:48
48      carg_parser.c: No such file or directory.
        in carg_parser.c
(gdb) bt
#0  push_back_record (ap=0x11f860b60, code=0, argument=0x11f8610fa "tex.lpro") at carg_parser.c:48
#1  0x0000000120007144 in ap_init (ap=0x11f860b60, argc=29, argv=0x11f860da8, options=0x120010320, in_order=0 '\0') at carg_parser.c:244
#2  0x00000001200090d4 in main (argc=29, argv=0x11f860da8) at main.c:150
(gdb) bt full
#0  push_back_record (ap=0x11f860b60, code=0, argument=0x11f8610fa "tex.lpro") at carg_parser.c:48
        p = (ap_Record *) 0x0
#1  0x0000000120007144 in ap_init (ap=0x11f860b60, argc=29, argv=0x11f860da8, options=0x120010320, in_order=0 '\0') at carg_parser.c:244
        arg = <value optimized out>
        non_options = (const char **) 0x120024010
        non_options_size = <value optimized out>
        argind = 29
        i = 1
#2  0x00000001200090d4 in main (argc=29, argv=0x11f860da8) at main.c:150
        n = <value optimized out>
        loose = <value optimized out>
        parser = {data = 0x120024100, error = 0x0, data_size = 0, error_size = 0}
        argind = <value optimized out>
        options = {{code = 71, name = 0x120010223 "traditional", has_arg = ap_no}, {code = 104, name = 0x12001022f "help", has_arg = ap_no}, {code = 108, 
    name = 0x120010234 "loose-exit-status", has_arg = ap_no}, {code = 112, name = 0x1200100d6 "prompt", has_arg = ap_yes}, {code = 115, 
    name = 0x120010246 "quiet", has_arg = ap_no}, {code = 115, name = 0x12001024c "silent", has_arg = ap_no}, {code = 118, name = 0x12001012f "verbose", 
    has_arg = ap_no}, {code = 86, name = 0x120010253 "version", has_arg = ap_no}, {code = 0, name = 0x0, has_arg = ap_no}}
Comment 5 Doug Goldstein (RETIRED) gentoo-dev 2008-07-15 21:33:03 UTC
good backtrace
Comment 6 Jose Luis Rivero (yoswink) (RETIRED) gentoo-dev 2008-09-04 09:36:11 UTC
The one to blame is -finline-functions in combination with -O2. Exploring the scene we have:

-02: OK
-02 -finline-functions: segfault.
-02 + rest of 03 optimizations: OK
-01 -finline-functions: OK

UPSTREAM is delivering the code with a hardcode -O2 which gentoo patches to allow people to use whatever they want. Easy way to fix is introduce a line in the ebuild this way:

use alpha && replace-flags 03 02

The cool way is to inspect the code and the compiler optimization actions to know what is breaking the app. 
Comment 7 Matt Turner gentoo-dev 2008-12-17 01:26:44 UTC
The test suite (FEATURES=test emerge ed) also fails when compiled with -O2 -finline-functions.

I've tried with gcc versions 4.1.2 and 4.3.2.

I could not make the test fail with any of the flags yoswink used on my AMD64 box.

Either the bug is very alpha specific in the ed code or it's a gcc bug that has spanned minor versions. I tend to think the later.

I'll investigate more and see if I can narrow down the failure.
Comment 8 SpanKY gentoo-dev 2008-12-31 09:18:56 UTC
i get no crashes in testsuite on alpha w/gcc-4.3.2 ...

maybe this is just a dupe of Bug 208382 ...
Comment 9 SpanKY gentoo-dev 2009-01-03 11:23:14 UTC
i'm assuming this is the same as Bug 208382, so it should be fixed with ed-1.1
Comment 10 Matt Turner gentoo-dev 2009-01-13 00:25:25 UTC
No, it appears that this is a distinct bug.

-O2 -finline-functions still fails with ed-1.1

The CFLAGS from the other bug report do not yield test failures on Alpha with ed-1.1.

It's definitely a different bug.
Comment 11 Andreas Deresch 2009-02-15 12:41:20 UTC
I have the same situation here on ~sparc with texlive-core-2008-r4, ed-1.2 and gcc-4.3.3: texc.script runs fine if ed has been compiled with "-mcpu=ultrasparc -mvis -O2", but not for "-O3" or an additional "-finline-functions" -- I didn't check any other CFLAGS. SO it's not specific to alpha.
Comment 12 Matthew Kern 2009-04-11 03:50:05 UTC
hmm, figured, why not try to squash some old alpha bugs? :P

Anyway, trying out some of the testsuites that fail (gcc-4.1.2, ev56 processor, trying out ed-1.1 right now.. ed-1.2 fails as well, but I was playing specifically with 1.1)...

#!/bin/sh -
/root/ed/ed-1.1/ed -s <<'EOT'
H
r /root/ed/ed-1.1/testsuite/s2.err
a
a
.
s/x*/a/g
w s2.ro
EOT


^- that fails with a segfault pointing to the line "EOT"... typing in the commands that would be executed by hand works without segfault. Obviously, the error is in the interaction between the shell and ed - perhaps the stdin read loop is broken?

I don't have time tonight or tomorrow to play with it, but this might help get a start to the fix...
Comment 13 Matthew Kern 2009-04-12 14:54:19 UTC
Created attachment 188091 [details, diff]
patch against 1.2 (should work on other versions)

This patch should fix things... also sent it upstream, assuming they are alive :P

Keep in mind that it's only gentoo that will probably ever compile this thing with cflags other than their hard-coded safe values (there was a previous discussion about this on their bug list - they are not un-hard-coding CFLAGS).

I'll make an ebuild in a little bit - should be trivial to just add the patch line in there.
Comment 14 Matthew Kern 2009-04-14 12:26:09 UTC
Created attachment 188308 [details, diff]
newer patch against 1.2

again, should work against other versions.

After submitting my patch to bug-ed, got this back instead. Works fine, and this'll probably make it upstream next release.
Comment 15 Matt Turner gentoo-dev 2009-06-15 19:31:10 UTC
Patch has been applied for ed-1.3.
Comment 16 Tobias Klausmann (RETIRED) gentoo-dev 2009-06-28 17:42:58 UTC
I just stabilized sys-apps/ed-1.3, so closing.