December 18, 2010 [Issue 5278] DMD generates programs that immediately segfault. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chad Joan | http://d.puremagic.com/issues/show_bug.cgi?id=5278 --- Comment #10 from Chad Joan <chadjoan@gmail.com> 2010-12-18 08:28:45 PST --- So I thought it'd be wise to try it with both the working compiler version and the not working compiler version and see what changed in the linker string. Here it is: chad@Hugin /mnt/sharedhd/dprojects/dtesting $ dmd trivial.d -L-v 2> dmd2048.link GNU ld (GNU Binutils) 2.20.1.20100303 chad@Hugin /mnt/sharedhd/dprojects/dtesting $ dmd trivial.d -L-v 2> dmd2050.link GNU ld (GNU Binutils) 2.20.1.20100303 chad@Hugin /mnt/sharedhd/dprojects/dtesting $ diff dmd2048.link dmd2050.link 2c2 < /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../x86_64-pc-linux-gnu/bin/ld --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -pie -z now -o trivial /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../lib32/Scrt1.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../lib32/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/32/crtbeginS.o -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/32 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/32 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../lib32 -L/lib/../lib32 -L/usr/lib/../lib32 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../x86_64-pc-linux-gnu/lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../.. trivial.o -v -L/usr/local/share/dcompilers/dmd/linux/bin/../lib -lphobos2 -lpthread -lm -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/32/crtendS.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../lib32/crtn.o --- > /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../x86_64-pc-linux-gnu/bin/ld --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -pie -z now -o trivial /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../lib32/Scrt1.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../lib32/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/32/crtbeginS.o -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/32 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/32 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../lib32 -L/lib/../lib32 -L/usr/lib/../lib32 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../x86_64-pc-linux-gnu/lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../.. trivial.o -v -L/usr/local/share/dcompilers/dmd/linux/bin/../lib --export-dynamic -lphobos2 -lpthread -lm -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/32/crtendS.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../lib32/crtn.o Note the that --export-dynamic is only present in the one that segfaults. I'm in a bit of a rush at the moment and I don't remember how to mess with --export-dynamic, so that's all for now. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
December 18, 2010 [Issue 5278] DMD generates programs that immediately segfault. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chad Joan | http://d.puremagic.com/issues/show_bug.cgi?id=5278 --- Comment #11 from Chad Joan <chadjoan@gmail.com> 2010-12-18 08:31:23 PST --- (In reply to comment #10) > So I thought it'd be wise to try it with both the working compiler version and the not working compiler version and see what changed in the linker string. Here it is: > > ... Whoops, diff formatting messed things up on that second line. Here it is again, minus the angle brackets: -------------- dmd 2.048 -------------- /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../x86_64-pc-linux-gnu/bin/ld --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -pie -z now -o trivial /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../lib32/Scrt1.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../lib32/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/32/crtbeginS.o -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/32 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/32 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../lib32 -L/lib/../lib32 -L/usr/lib/../lib32 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../x86_64-pc-linux-gnu/lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../.. trivial.o -v -L/usr/local/share/dcompilers/dmd/linux/bin/../lib -lphobos2 -lpthread -lm -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/32/crtendS.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../lib32/crtn.o -------------- dmd 2.050 -------------- /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../x86_64-pc-linux-gnu/bin/ld --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -pie -z now -o trivial /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../lib32/Scrt1.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../lib32/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/32/crtbeginS.o -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/32 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/32 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../lib32 -L/lib/../lib32 -L/usr/lib/../lib32 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../x86_64-pc-linux-gnu/lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../.. trivial.o -v -L/usr/local/share/dcompilers/dmd/linux/bin/../lib --export-dynamic -lphobos2 -lpthread -lm -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/32/crtendS.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../lib32/crtn.o -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 20, 2011 [Issue 5278] DMD generates programs that immediately segfault. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chad Joan | http://d.puremagic.com/issues/show_bug.cgi?id=5278 Vladimir <thecybershadow@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |thecybershadow@gmail.com --- Comment #12 from Vladimir <thecybershadow@gmail.com> 2011-02-20 15:27:04 PST --- I just thought I'd mention that I had some similar problems with DMD on Gentoo due to bad permissions of certain libraries. Do your programs run under root? If so, check permissions for libphobos and whatever 32-bit libraries your program / libphobos uses (glibc? libstdc++?). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 20, 2011 [Issue 5278] DMD generates programs that immediately segfault. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chad Joan | http://d.puremagic.com/issues/show_bug.cgi?id=5278 --- Comment #13 from Chad Joan <chadjoan@gmail.com> 2011-09-19 23:26:19 PDT --- I have taken another crack at this. After some compiling of D on a roommate's non-hardened Gentoo system I found that if I recompile my gcc without the hardened useflag and then compile my D programs, the D programs won't segfault. This round of testing was done with 64-bit DMD. In short: using hardened GCC will trigger this. I was pointed in this direction by observing the last line of the output of compiling with dmd -v: gcc main.o -o main -m64 -Xlinker -L/usr/local/share/dcompilers/dmd/linux/bin64/../lib64 -Xlinker -L/usr/local/share/dcompilers/dmd/linux/bin64/../lib32 -Xlinker --no-warn-search-mismatch -Xlinker --export-dynamic -lrt -lphobos2 -lpthread -lm Notably, it is using gcc for its linking step. After a bit of browsing in the DMD sources, a workaround presents itself. DMD just uses the CC environment variable to determine what to use for linking, so it is possible to build an isolated non-hardened GCC and then use that to compile D programs. It would look like this: CC=custom-gcc dmd -v main.d -ofmain At some point I may bisect the older changes in DMD to find out where this regression was introduced. I can see this ending up in the backend though, so I'm not sure I'll be able to understand the code I end up in. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 20, 2011 [Issue 5278] DMD generates programs that immediately segfault. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chad Joan | http://d.puremagic.com/issues/show_bug.cgi?id=5278 --- Comment #14 from Chad Joan <chadjoan@gmail.com> 2011-09-19 23:28:48 PDT --- (In reply to comment #12) > I just thought I'd mention that I had some similar problems with DMD on Gentoo due to bad permissions of certain libraries. Do your programs run under root? If so, check permissions for libphobos and whatever 32-bit libraries your program / libphobos uses (glibc? libstdc++?). I almost forgot to mention this... My programs still segfault under root. Permissions are fine. Everything works if I use a non-hardened GCC. Thanks for the suggestions! -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 23, 2011 [Issue 5278] gentoo's 'hardended' gcc doesn't work with dmd | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chad Joan | http://d.puremagic.com/issues/show_bug.cgi?id=5278 Brad Roberts <braddr@puremagic.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|DMD generates programs that |gentoo's 'hardended' gcc |immediately segfault. |doesn't work with dmd --- Comment #15 from Brad Roberts <braddr@puremagic.com> 2011-10-23 14:47:31 PDT --- I recall some changes going in that addressed some hardening issues along the way. I don't have a gentoo based system to test this on. Please try the most recent beta to see if the problem still exists. http://ftp.digitalmars.com/dmd2beta.zip -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 24, 2011 [Issue 5278] gentoo's 'hardended' gcc doesn't work with dmd | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chad Joan | http://d.puremagic.com/issues/show_bug.cgi?id=5278 --- Comment #16 from Chad Joan <chadjoan@gmail.com> 2011-10-24 01:33:51 PDT --- I'm afraid it doesn't seem to be working. It went something like this: chad@Hugin /mnt/bulk/dprojects/helloD2 $ ls main.d chad@Hugin /mnt/bulk/dprojects/helloD2 $ cat main.d import std.stdio; void main() { writefln("hello world!"); } chad@Hugin /mnt/bulk/dprojects/helloD2 $ dmd DMD64 D Compiler v2.056 Copyright (c) 1999-2011 by Digital Mars written by Walter Bright Documentation: http://www.digitalmars.com/d/2.0/index.html Usage: dmd files.d ... { -switch } files.d D source files @cmdfile read arguments from cmdfile -c do not link -cov do code coverage analysis -D generate documentation -Dddocdir write documentation file to docdir directory -Dffilename write documentation file to filename -d allow deprecated features -debug compile in debug code -debug=level compile in debug code <= level -debug=ident compile in debug code identified by ident -debuglib=name set symbolic debug library to name -defaultlib=name set default library to name -deps=filename write module dependencies to filename -fPIC generate position independent code -g add symbolic debug info -gc add symbolic debug info, pretend to be C -gs always emit stack frame -H generate 'header' file -Hddirectory write 'header' file to directory -Hffilename write 'header' file to filename --help print help -Ipath where to look for imports -ignore ignore unsupported pragmas -inline do function inlining -Jpath where to look for string imports -Llinkerflag pass linkerflag to link -lib generate library rather than object files -man open web browser on manual page -map generate linker .map file -noboundscheck turns off array bounds checking for all functions -nofloat do not emit reference to floating point -O optimize -o- do not write object file -odobjdir write object & library files to directory objdir -offilename name output file to filename -op do not strip paths from source file -profile profile runtime performance of generated code -property enforce property syntax -quiet suppress unnecessary messages -release compile release version -run srcfile args... run resulting program, passing args -unittest compile in unit tests -v verbose -version=level compile in version code >= level -version=ident compile in version code identified by ident -vtls list all variables going into thread local storage -w enable warnings -wi enable informational warnings -X generate JSON file -Xffilename write JSON file to filename chad@Hugin /mnt/bulk/dprojects/helloD2 $ dmd main.d -ofmain /usr/lib/gcc/x86_64-pc-linux-gnu/4.4.5/../../../../x86_64-pc-linux-gnu/bin/ld: main.o: relocation R_X86_64_32 against `.data' can not be used when making a shared object; recompile with -fPIC main.o: could not read symbols: Bad value collect2: ld returned 1 exit status --- errorlevel 1 chad@Hugin /mnt/bulk/dprojects/helloD2 $ ls main.d main.o chad@Hugin /mnt/bulk/dprojects/helloD2 $ dmd main.d -ofmain -m32 /usr/lib/gcc/x86_64-pc-linux-gnu/4.4.5/../../../../x86_64-pc-linux-gnu/bin/ld: warning: creating a DT_TEXTREL in object. chad@Hugin /mnt/bulk/dprojects/helloD2 $ ls main main.d main.o chad@Hugin /mnt/bulk/dprojects/helloD2 $ main main: error while loading shared libraries: cannot make segment writable for relocation: Permission denied chad@Hugin /mnt/bulk/dprojects/helloD2 $ sudo paxctl -m main chad@Hugin /mnt/bulk/dprojects/helloD2 $ main Segmentation fault chad@Hugin /mnt/bulk/dprojects/helloD2 $ ls main main.d main.o chad@Hugin /mnt/bulk/dprojects/helloD2 $ (I don't have any other 2.056 D compilers on my system; so the part where I ran dmd to get the help text should confirm that the correct compiler is in use.) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 24, 2011 [Issue 5278] gentoo's 'hardended' gcc doesn't work with dmd | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chad Joan | http://d.puremagic.com/issues/show_bug.cgi?id=5278 --- Comment #17 from Chad Joan <chadjoan@gmail.com> 2011-10-24 01:36:49 PDT --- Created an attachment (id=1043) More detailed info of dmd run on hardened gentoo 64-bit. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 24, 2011 [Issue 5278] gentoo's 'hardended' gcc doesn't work with dmd | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chad Joan | http://d.puremagic.com/issues/show_bug.cgi?id=5278 --- Comment #18 from Chad Joan <chadjoan@gmail.com> 2011-10-24 01:37:39 PDT --- Here is the output of dmd -v for both 32-bit (-m32) and 64-bit runs, just in-case it helps. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
December 18, 2011 [Issue 5278] gentoo's 'hardended' gcc doesn't work with dmd | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chad Joan | http://d.puremagic.com/issues/show_bug.cgi?id=5278 --- Comment #19 from Chad Joan <chadjoan@gmail.com> 2011-12-18 07:42:42 PST --- Well, I tried bisecting dmd to find which change caused this. It didn't work because this problem does not care which version of dmd I am using, it cares which RELEASE I am using. I narrowed it down to the "-L--export-dynamic" flag in $DPATH/linux/bin64/dmd.conf If I remove that export-dynamic flag AND rebuild druntime/phobos from scratch, everything is fine. Of course, if I remove -L--export-dynamic AND I do NOT rebuild druntime/phobos from scratch, I get this: /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: main.o: relocation R_X86_64_32 against `.data' can not be used when making a shared object; recompile with -fPIC main.o: could not read symbols: Bad value collect2: ld returned 1 exit status --- errorlevel 1 I take it this means that the executable and the library must agree on whether or not to use -L--export-dynamic. I guess it makes sense. By removing -L--export-dynamic and building dmd/druntime/phobos all from git at v2.057, I was able to get the recent release of dmd to run on my machine without using a special GCC. Any chance we can remove -L--export-dynamic or fix it so that it does not do this? (I have no idea how to fix it, but removing it is easy enough!) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation