[Issue 5278] DMD generates programs that immediately segfault.

2011-09-20 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5278



--- Comment #13 from Chad Joan chadj...@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: ---


[Issue 5278] DMD generates programs that immediately segfault.

2011-09-20 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5278



--- Comment #14 from Chad Joan chadj...@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: ---


[Issue 5278] DMD generates programs that immediately segfault.

2011-02-20 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5278


Vladimir thecybersha...@gmail.com changed:

   What|Removed |Added

 CC||thecybersha...@gmail.com


--- Comment #12 from Vladimir thecybersha...@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: ---


[Issue 5278] DMD generates programs that immediately segfault.

2010-12-07 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5278



--- Comment #8 from Sobirari Muhomori dfj1es...@sneakemail.com 2010-12-07 
22:21:57 PST ---
 I don't know if it's
 related because the segfault is such a terribly vague error and I don't feel
 like learning how to disassemble executables again right now

If dmd can generate debug info, you shouldn't need to disassemble. At least
you'll know, where it crashes.

d2 is a sophisticated system, it can use nifty functions in trivial cases.
AFAIK, Gentoo is compiled from the source, did you use any special options like
strong optimization etc?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5278] DMD generates programs that immediately segfault.

2010-12-07 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5278



--- Comment #9 from Chad Joan chadj...@gmail.com 2010-12-07 23:29:58 PST ---
(In reply to comment #8)
  I don't know if it's
  related because the segfault is such a terribly vague error and I don't feel
  like learning how to disassemble executables again right now
 
 If dmd can generate debug info, you shouldn't need to disassemble. At least
 you'll know, where it crashes.
 
 d2 is a sophisticated system, it can use nifty functions in trivial cases.
 AFAIK, Gentoo is compiled from the source, did you use any special options 
 like
 strong optimization etc?

For DMD I just grab the binary releases.  I've never been very confident in the
D-related ebuilds :(

As for my system configuration and its optimization, I don't think I have
anything too exotic.  Here are my CFLAGS:
CFLAGS=-march=nocona -O2 -finline-functions -fgcse-after-reload -pipe

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5278] DMD generates programs that immediately segfault.

2010-12-06 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5278



--- Comment #3 from Chad Joan chadj...@gmail.com 2010-12-06 18:12:22 PST ---
(In reply to comment #2)
 Something looks wrong with your 32 bit gcc installation.  Notice that gcc is
 invoking the 64 bit linker.  Can you successfully build any 32 bit C apps with
 gcc?  I'm going to guess no.

Good thought.  I still seem to be able to build 32 bit C apps though:

c...@hugin ~/cprojects/ctesting $ gcc trivial.c -o trivial
c...@hugin ~/cprojects/ctesting $ file trivial
trivial: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically
linked (uses shared libs), for GNU/Linux 2.6.9, not stripped
c...@hugin ~/cprojects/ctesting $ ./trivial
c...@hugin ~/cprojects/ctesting $ gcc trivial.c -m32 -o trivial
c...@hugin ~/cprojects/ctesting $ file trivial
trivial: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV),
dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped
c...@hugin ~/cprojects/ctesting $ ./trivial
c...@hugin ~/cprojects/ctesting $ cat trivial.c
int main(int argc, char *argv[])
{
return 0;
}

I checked dmd 2.050 at the same time just to make sure this isn't because I
changed my system config.  It still produces segfaulting executables.  I have
encountered another program that I didn't expect to segfault but did: the Gish
demo (http://www.chroniclogic.com/gish_download.htm).  I don't know if it's
related because the segfault is such a terribly vague error and I don't feel
like learning how to disassemble executables again right now :/  If someone
wants to point me in the right directions to do that though, I wouldn't mind.

So hey, maybe there is something special about my system that makes things
crashy, but it'd be nice if the D executables could run on my system without
crashing like all of the other executables on my system that don't crash.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5278] DMD generates programs that immediately segfault.

2010-12-06 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5278



--- Comment #4 from Brad Roberts bra...@puremagic.com 2010-12-06 18:38:25 PST 
---
Try gcc -v trivial.c -m32 -o trivial to see which linker is being invoked in
the working 32 bit case.

Also try gcc -v trivial.c -o trivial -m32 to closer match the way dmd is
invoking gcc.  Which linker is being invoked now?

I just tried those experiments on my box, and both forms correctly built 32 bit
binaries.

Another thing to do to try to gather more information, on the dmd command line,
add: -L-v.  That should be enough to show that collect2 is being invoked with
-m elf_i386.  For even more details, try running dmd with: -L-v -L-Wl,-v.  That
will add another -v down at the ld command which will give even more output,
showing that ld is being invoked with -m elf_i386 as well.

I assure you that dmd produces proper 32 bit executables on my linux x86_64
box.  So, the exercise here is to figure out what's different, why, and how to
resolve it.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5278] DMD generates programs that immediately segfault.

2010-12-06 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5278



--- Comment #5 from Chad Joan chadj...@gmail.com 2010-12-06 19:35:47 PST ---
Alright, here goes:

c...@hugin ~/cprojects/ctesting $ gcc -v trivial.c -m32 -o trivial
Reading specs from /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/specs
Target: x86_64-pc-linux-gnu
Configured with:
/var/tmp/portage/sys-devel/gcc-4.3.2-r3/work/gcc-4.3.2/configure --prefix=/usr
--bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.3.2
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.3.2
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.3.2/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.3.2/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/include/g++-v4
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec
--disable-fixed-point --enable-nls --without-included-gettext
--with-system-zlib --disable-werror --enable-secureplt --enable-multilib
--enable-libmudflap --disable-libssp --disable-libgomp
--enable-checking=release --disable-libgcj --enable-languages=c,c++,treelang
--enable-shared --enable-threads=posix --enable-__cxa_atexit
--enable-clocale=gnu --with-bugurl=http://bugs.gentoo.org/
--with-pkgversion='Gentoo Hardened 4.3.2-r3 p1.6, pie-10.1.5'
Thread model: posix
gcc version 4.3.2 (Gentoo Hardened 4.3.2-r3 p1.6, pie-10.1.5) 
COLLECT_GCC_OPTIONS='-v' '-m32' '-o' 'trivial' '-mtune=generic'
 /usr/libexec/gcc/x86_64-pc-linux-gnu/4.3.2/cc1 -quiet -v -imultilib 32
trivial.c -fPIE -fno-strict-overflow -quiet -dumpbase trivial.c -m32
-mtune=generic -auxbase trivial -version -o /tmp/cc4qEg6K.s
ignoring nonexistent directory
/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../x86_64-pc-linux-gnu/include
#include ... search starts here:
#include ... search starts here:
 /usr/local/include
 /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/include
 /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/include-fixed
 /usr/include
End of search list.
GNU C (Gentoo Hardened 4.3.2-r3 p1.6, pie-10.1.5) version 4.3.2
(x86_64-pc-linux-gnu)
compiled by GNU C version 4.3.2, GMP version 4.3.2, MPFR version
2.4.2-p3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: e8faf928abdbcb1acb2166e18d14ae3d
COLLECT_GCC_OPTIONS='-v' '-m32' '-o' 'trivial' '-mtune=generic'
 /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../x86_64-pc-linux-gnu/bin/as
-V -Qy --32 -o /tmp/ccEd2Qcf.o /tmp/cc4qEg6K.s
GNU assembler version 2.20.1 (x86_64-pc-linux-gnu) using BFD version (GNU
Binutils) 2.20.1.20100303
COMPILER_PATH=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.3.2/:/usr/libexec/gcc/x86_64-pc-linux-gnu/4.3.2/:/usr/libexec/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/:/usr/lib/gcc/x86_64-pc-linux-gnu/:/usr/libexec/gcc/x86_64-pc-linux-gnu/4.3.2/:/usr/libexec/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/:/usr/lib/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../x86_64-pc-linux-gnu/bin/
LIBRARY_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/32/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/32/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../lib32/:/lib/../lib32/:/usr/lib/../lib32/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../x86_64-pc-linux-gnu/lib/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-m32' '-o' 'trivial' '-mtune=generic'
 /usr/libexec/gcc/x86_64-pc-linux-gnu/4.3.2/collect2 --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/../../.. /tmp/ccEd2Qcf.o -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
c...@hugin ~/cprojects/ctesting $ ./trivial
c...@hugin ~/cprojects/ctesting $








c...@hugin ~/cprojects/ctesting $ gcc -v trivial.c -o trivial -m32
Reading specs from /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/specs
Target: x86_64-pc-linux-gnu
Configured with:
/var/tmp/portage/sys-devel/gcc-4.3.2-r3/work/gcc-4.3.2/configure --prefix=/usr
--bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.3.2
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.3.2
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.3.2/man

[Issue 5278] DMD generates programs that immediately segfault.

2010-12-06 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5278



--- Comment #6 from Brad Roberts bra...@puremagic.com 2010-12-06 20:05:09 PST 
---
Does this bug report shed any light, specifically the part about changing the
CHOST towards the bottom of the report?  (I'm not a gentoo user, just using
google to investigate similar issues).

http://bugs.gentoo.org/show_bug.cgi?id=332663

If that's not it, then I'm running out of obvious things to check.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5278] DMD generates programs that immediately segfault.

2010-12-06 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5278



--- Comment #7 from Chad Joan chadj...@gmail.com 2010-12-06 23:44:30 PST ---
(In reply to comment #6)
 Does this bug report shed any light, specifically the part about changing the
 CHOST towards the bottom of the report?  (I'm not a gentoo user, just using
 google to investigate similar issues).
 
 http://bugs.gentoo.org/show_bug.cgi?id=332663
 
 If that's not it, then I'm running out of obvious things to check.

I'm afraid not.  I haven't changed my CHOST; it's x86_64-pc-linux-gnu like
always.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5278] DMD generates programs that immediately segfault.

2010-11-26 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5278



--- Comment #1 from Chad Joan chadj...@gmail.com 2010-11-26 09:38:22 PST ---
Additional note: as far as I can tell this afflicts ALL programs I write with
DMD, not just the trivial do-nothing program.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---