www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Segfault on simple program?

reply Shriramana Sharma <samjnaa gmail.com> writes:
aW1wb3J0IHN0ZC5zdGRpbyA7DQoNCnZvaWQgZm9vICggaW50W10gYXJyYXkgKSB7DQoJZm9yZWFj
aCAoIGkgOyBhcnJheSApIHsgd3JpdGVsbiAoIGkgKSA7IH0NCn0NCg0Kdm9pZCBtYWluICgpIHsN
Cglmb28gKCBbIDEsIDIsIDMgXSApIDsNCn0NCg0KT24gYm90aCBETUQgMi4wNjIgYW5kIDIuMDYz
IHRoaXMgY29tcGlsZXMgT0sgYnV0IGNhdXNlcyBhIHNlZ2ZhdWx0Lg0KSSdtIHJ1bm5pbmcgS3Vi
dW50dSBSYXJpbmcgNjQtYml0LiBBbnkgaGludHM/DQoNCi0tIA0KU2hyaXJhbWFuYSBTaGFybWEg
4K624K+N4K6w4K+A4K6w4K6u4K6j4K624K6w4K+N4K6u4K6+IOCktuCljeCksOClgOCksOCkruCk
o+CktuCksOCljeCkruCkvg0K
May 31 2013
next sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
Shriramana Sharma:

 On both DMD 2.062 and 2.063 this compiles OK but causes a 
 segfault.
 I'm running Kubuntu Raring 64-bit. Any hints?
I have no hints. But on Windows32 I see no segfault. And the online 64 bit Linux (dpaste) gives no errors. Bye, bearophile
May 31 2013
prev sibling next sibling parent reply "John Colvin" <john.loughran.colvin gmail.com> writes:
On Friday, 31 May 2013 at 17:14:46 UTC, Shriramana Sharma wrote:
 import std.stdio ;

 void foo ( int[] array ) {
 	foreach ( i ; array ) { writeln ( i ) ; }
 }

 void main () {
 	foo ( [ 1, 2, 3 ] ) ;
 }

 On both DMD 2.062 and 2.063 this compiles OK but causes a 
 segfault.
 I'm running Kubuntu Raring 64-bit. Any hints?
Can't reproduce this. Any chance of a stacktrace and/or disassembly?
May 31 2013
parent reply Shriramana Sharma <samjnaa gmail.com> writes:
T24gRnJpLCBNYXkgMzEsIDIwMTMgYXQgMTE6NDYgUE0sIEpvaG4gQ29sdmluDQo8am9obi5sb3Vn
aHJhbi5jb2x2aW5AZ21haWwuY29tPiB3cm90ZToNCj4NCj4gQ2FuJ3QgcmVwcm9kdWNlIHRoaXMu
IEFueSBjaGFuY2Ugb2YgYSBzdGFja3RyYWNlIGFuZC9vciBkaXNhc3NlbWJseT8NCg0KUGxlYXNl
IGdpdmUgaW5zdHJ1Y3Rpb25zIGFzIHRvIGhvdyBJIGNhbiBnZXQgZWl0aGVyIG9mIHRob3NlIHR3
byBmb3INCnlvdS4gV291bGQgeW91IGxpa2UgdGhlIGJpbmFyeSBwcm9kdWNlZD8NCg0KLS0gDQpT
aHJpcmFtYW5hIFNoYXJtYSDgrrbgr43grrDgr4DgrrDgrq7grqPgrrbgrrDgr43grq7grr4g4KS2
4KWN4KSw4KWA4KSw4KSu4KSj4KS24KSw4KWN4KSu4KS+DQo=
May 31 2013
parent reply "John Colvin" <john.loughran.colvin gmail.com> writes:
On Friday, 31 May 2013 at 18:22:44 UTC, Shriramana Sharma wrote:
 On Fri, May 31, 2013 at 11:46 PM, John Colvin
 <john.loughran.colvin gmail.com> wrote:
 Can't reproduce this. Any chance of a stacktrace and/or 
 disassembly?
Please give instructions as to how I can get either of those two for you. Would you like the binary produced?
given a program named "test" in the current directory gdb ./test run #will segfault bt full and copy the output.
May 31 2013
parent Shriramana Sharma <samjnaa gmail.com> writes:
On Sat, Jun 1, 2013 at 12:07 AM, John Colvin
<john.loughran.colvin gmail.com> wrote:
 given a program named "test" in the current directory

 gdb ./test
 run               #will segfault
 bt full

 and copy the output.
Did it (after installing libc6-dbg just in case) but it doesn't seem to be very useful: (gdb) bt full No symbol table info available. No symbol table info available. No symbol table info available. TypeInfo_PS3std5array17__T8AppenderTAxaZ8Appender4Data.__init() () No symbol table info available. No symbol table info available. No symbol table info available. No symbol table info available. No symbol table info available. No symbol table info available. No symbol table info available. argc=3D1, ubp_av=3D0x7fffffffdf58, init=3D0x4578b0 <__libc_csu_init>, fini=3D<optimized out>, rtld_fini=3D<optimized out>, stack_end=3D0x7fffffffdf48) at libc-start.c:219 result =3D <optimized out> unwind_buf =3D {cancel_jmp_buf =3D {{jmp_buf =3D {0, 140737351945365, 140733193388033, 0, 1, 140737343639840, 0, 0}, mask_was_saved =3D 4392416}}, priv =3D {pad =3D {0x7ffff7def725 <_dl_runtime_resolve+53>, 0x1c, 0x4578b0 <__libc_csu_init>, 0x7fffffffdf58}, data =3D { prev =3D 0x7ffff7def725 <_dl_runtime_resolve+53>, cleanup =3D 0x1c, canceltype =3D 4552880}}} not_first_call =3D <optimized out> No symbol table info available. --=20 Shriramana Sharma =E0=AE=B6=E0=AF=8D=E0=AE=B0=E0=AF=80=E0=AE=B0=E0=AE=AE=E0= =AE=A3=E0=AE=B6=E0=AE=B0=E0=AF=8D=E0=AE=AE=E0=AE=BE =E0=A4=B6=E0=A5=8D=E0= =A4=B0=E0=A5=80=E0=A4=B0=E0=A4=AE=E0=A4=A3=E0=A4=B6=E0=A4=B0=E0=A5=8D=E0=A4= =AE=E0=A4=BE
May 31 2013
prev sibling next sibling parent reply "Anthony Goins" <neontotem gmail.com> writes:
On Friday, 31 May 2013 at 17:14:46 UTC, Shriramana Sharma wrote:
 import std.stdio ;

 void foo ( int[] array ) {
 	foreach ( i ; array ) { writeln ( i ) ; }
 }

 void main () {
 	foo ( [ 1, 2, 3 ] ) ;
 }

 On both DMD 2.062 and 2.063 this compiles OK but causes a 
 segfault.
 I'm running Kubuntu Raring 64-bit. Any hints?
Works for me ubuntu 64. Do you have both versions installed? Would it compile if you used the wrong druntime / phobos libraries?
May 31 2013
next sibling parent reply Shriramana Sharma <samjnaa gmail.com> writes:
On Sat, Jun 1, 2013 at 6:02 AM, Anthony Goins <neontotem gmail.com> wrote:
 Works for me ubuntu 64.
 Do you have both versions installed?
Of course not. The later install from the distributed DEB (from dlang.org) overwrites the earlier one by apt install.
 Would it compile if you used the wrong druntime / phobos libraries?
I don't have any D-related packages on my system other than the stock DMD AMD64 package. Even libphobos2-4.6-dev which is available for Raring is not installed. --=20 Shriramana Sharma =E0=AE=B6=E0=AF=8D=E0=AE=B0=E0=AF=80=E0=AE=B0=E0=AE=AE=E0= =AE=A3=E0=AE=B6=E0=AE=B0=E0=AF=8D=E0=AE=AE=E0=AE=BE =E0=A4=B6=E0=A5=8D=E0= =A4=B0=E0=A5=80=E0=A4=B0=E0=A4=AE=E0=A4=A3=E0=A4=B6=E0=A4=B0=E0=A5=8D=E0=A4= =AE=E0=A4=BE
May 31 2013
parent "Rob T" <alanb ucora.com> writes:
On Saturday, 1 June 2013 at 01:10:05 UTC, Shriramana Sharma wrote:
 On Sat, Jun 1, 2013 at 6:02 AM, Anthony Goins 
 <neontotem gmail.com> wrote:
 Works for me ubuntu 64.
 Do you have both versions installed?
Of course not. The later install from the distributed DEB (from dlang.org) overwrites the earlier one by apt install.
I would not trust the DEB package as my understanding is that the deb are not being properly produced at this time. Like I said, try a full removal using "purge" and reinstalling again. See this ... http://forum.dlang.org/thread/ffoovmyiwytfbvykcaew forum.dlang.org?page=7#post-koionl:241d0t:241:40digitalmars.com --rt
Jun 05 2013
prev sibling next sibling parent Shriramana Sharma <samjnaa gmail.com> writes:
On Sat, Jun 1, 2013 at 6:39 AM, Shriramana Sharma <samjnaa gmail.com> wrote=
:
 I don't have any D-related packages on my system other than the stock
 DMD AMD64 package. Even libphobos2-4.6-dev which is available for
 Raring is not installed.
That was actually slightly incorrect. I had installed gdc apart from dmd -- just to see how the two work out. It's only after that I installed gdc (I had only used dmd) that D programs segfaulted. Now I went into /var/log/ and extracted yesterday's installation details from dpkg.log and purged all the packages that gdc pulled in -- mostly it was old gcc-4.6 and related files. Nevertheless, the horrible fact is that not only this program I initially posted on this thread but any and all D programs I compile produce a segfault! Please help! --=20 Shriramana Sharma =E0=AE=B6=E0=AF=8D=E0=AE=B0=E0=AF=80=E0=AE=B0=E0=AE=AE=E0= =AE=A3=E0=AE=B6=E0=AE=B0=E0=AF=8D=E0=AE=AE=E0=AE=BE =E0=A4=B6=E0=A5=8D=E0= =A4=B0=E0=A5=80=E0=A4=B0=E0=A4=AE=E0=A4=A3=E0=A4=B6=E0=A4=B0=E0=A5=8D=E0=A4= =AE=E0=A4=BE
Jun 01 2013
prev sibling parent reply Shriramana Sharma <samjnaa gmail.com> writes:
On Sat, Jun 1, 2013 at 1:27 PM, Shriramana Sharma <samjnaa gmail.com> wrote=
:
 Nevertheless, the horrible fact is that not only this program I
 initially posted on this thread but any and all D programs I compile
 produce a segfault!
All programs compiled by *DMD* produce a segfault. Programs compiled by GDC work just fine. What is this, some sort of incompatibility between compilers? Like GDC went and told my system "hey look only D programs compiled by me should work"?! I couldn't try LDC since they don't have Ubuntu packages and I couldn't figure out how to install the binary tarball. Please help! --=20 Shriramana Sharma =E0=AE=B6=E0=AF=8D=E0=AE=B0=E0=AF=80=E0=AE=B0=E0=AE=AE=E0= =AE=A3=E0=AE=B6=E0=AE=B0=E0=AF=8D=E0=AE=AE=E0=AE=BE =E0=A4=B6=E0=A5=8D=E0= =A4=B0=E0=A5=80=E0=A4=B0=E0=A4=AE=E0=A4=A3=E0=A4=B6=E0=A4=B0=E0=A5=8D=E0=A4= =AE=E0=A4=BE
Jun 01 2013
parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 06/01/2013 01:34 AM, Shriramana Sharma wrote:

 All programs compiled by *DMD* produce a segfault. Programs compiled
 by GDC work just fine.
It is likely that GDC is from the D1 era.
 What is this, some sort of incompatibility between compilers?
If one is D1 and the other is current D, it is possible.
 Like GDC went and told my system "hey look only D programs compiled by me
 should work"?!
Of courne not intentional like that but clearly there is some incompatibility there.
 I couldn't try LDC since they don't have Ubuntu packages
I don't know for sure but neither GDC nor LDC packages that come under Linux distributions are modern enough. If so, I would remove GDC and try installing only dmd 2.063 again. Ali
Jun 01 2013
next sibling parent reply Shriramana Sharma <samjnaa gmail.com> writes:
On Jun 1, 2013 3:46 PM, "Ali =C7ehreli" <acehreli yahoo.com> wrote:
 If so, I would remove GDC
 and try installing only dmd
 2.063 again.
Tried that in all sorts of combinations. Still no use. Would there be some config files conflicting? But such conflicts would be reflected at compile time, not runtime, right? Since I don't want to reinstall my Ubuntu system just for this (that would be so Windows-like!), I'd appreciate pointers to resolve the situation. Thanks. Or should I take this to the d.gnu list or something?
Jun 01 2013
parent reply "Anthony Goins" <neontotem gmail.com> writes:
On Saturday, 1 June 2013 at 11:43:15 UTC, Shriramana Sharma wrote:
 On Jun 1, 2013 3:46 PM, "Ali Çehreli" <acehreli yahoo.com> 
 wrote:
 If so, I would remove GDC
 and try installing only dmd
 2.063 again.
Tried that in all sorts of combinations. Still no use. Would there be some config files conflicting? But such conflicts would be reflected at compile time, not runtime, right? Since I don't want to reinstall my Ubuntu system just for this (that would be so Windows-like!), I'd appreciate pointers to resolve the situation. Thanks. Or should I take this to the d.gnu list or something?
Sometimes running ldconfig will solve wierd problems like this.
Jun 01 2013
parent reply Shriramana Sharma <samjnaa gmail.com> writes:
T24gU2F0LCBKdW4gMSwgMjAxMyBhdCA3OjU3IFBNLCBBbnRob255IEdvaW5zIDxuZW9udG90ZW1A
Z21haWwuY29tPiB3cm90ZToNCj4NCj4gU29tZXRpbWVzIHJ1bm5pbmcgbGRjb25maWcgd2lsbCBz
b2x2ZSB3aWVyZCBwcm9ibGVtcyBsaWtlIHRoaXMuDQoNClRoYW5rcyBhbmQgSSB0cmllZCB0aGF0
IGp1c3Qgbm93IGJ1dCBubyBmcnVpdC4gOi0oDQoNCi0tIA0KU2hyaXJhbWFuYSBTaGFybWEg4K62
4K+N4K6w4K+A4K6w4K6u4K6j4K624K6w4K+N4K6u4K6+IOCktuCljeCksOClgOCksOCkruCko+Ck
tuCksOCljeCkruCkvg0K
Jun 01 2013
parent "Rob T" <alanb ucora.com> writes:
On Saturday, 1 June 2013 at 14:41:13 UTC, Shriramana Sharma wrote:
 On Sat, Jun 1, 2013 at 7:57 PM, Anthony Goins 
 <neontotem gmail.com> wrote:
 Sometimes running ldconfig will solve wierd problems like this.
Thanks and I tried that just now but no fruit. :-(
Try a *full* removal of the deb installations (dmd and gdc). apt-get purge <program_name> Then reinstall latest DMD first. and test before moving on with GDC. If you are installing GDC from the distro, it's likely to be very old and of questionable use. --rt
Jun 05 2013
prev sibling parent "Iain Buclaw" <ibuclaw gdcproject.org> writes:
On Saturday, 1 June 2013 at 10:11:35 UTC, Ali Çehreli wrote:
 On 06/01/2013 01:34 AM, Shriramana Sharma wrote:

 All programs compiled by *DMD* produce a segfault. Programs
compiled
 by GDC work just fine.
It is likely that GDC is from the D1 era.
Not that package, it's an old D2 release, circa 2.046. and even then it has a different library name (libgphobos.a) and the module headers are installed in a separate directory from dmd.
Jun 04 2013
prev sibling parent "nazriel" <spam dzfl.pl> writes:
On Friday, 31 May 2013 at 17:14:46 UTC, Shriramana Sharma wrote:
 import std.stdio ;

 void foo ( int[] array ) {
 	foreach ( i ; array ) { writeln ( i ) ; }
 }

 void main () {
 	foo ( [ 1, 2, 3 ] ) ;
 }

 On both DMD 2.062 and 2.063 this compiles OK but causes a 
 segfault.
 I'm running Kubuntu Raring 64-bit. Any hints?
If you can attach your test-case program that segfaults compiled on that Kubuntu x86_64 I would be grateful. It will allow to see if it is OS problem, hardware problem or it is DMD that is producing bad code in some specific scenarios. Also it is easier to debug and reverse program when binary is given. Thanks in advance.
Jun 11 2013