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:
Created attachment 160478 [details] emerge --info
Created attachment 160480 [details] texlive-core-2007-r13 build.log showing ed seg fault
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
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}}
good backtrace
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.
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.
i get no crashes in testsuite on alpha w/gcc-4.3.2 ... maybe this is just a dupe of Bug 208382 ...
i'm assuming this is the same as Bug 208382, so it should be fixed with ed-1.1
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.
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.
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...
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.
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.
Patch has been applied for ed-1.3.
I just stabilized sys-apps/ed-1.3, so closing.