digitalmars.D.learn - Segmentation fault hell in D
- "Jarl =?UTF-8?B?QW5kcsOpIg==?= <jarl.andre gmail.com> Jun 08 2012
- Kai Meyer <kai unixlords.com> Jun 08 2012
- Justin Whear <justin economicmodeling.com> Jun 08 2012
- Chad J <chadjoan __spam.is.bad__gmail.com> Jun 09 2012
- Dmitry Olshansky <dmitry.olsh gmail.com> Jun 08 2012
- "Jonathan M Davis" <jmdavisProg gmx.com> Jun 08 2012
- Andrew Wiley <wiley.andrew.j gmail.com> Jun 08 2012
- Dejan Lekic <dejan.lekic gmail.com> Jun 09 2012
- Andrew Wiley <wiley.andrew.j gmail.com> Jun 09 2012
- bioinfornatics <bioinfornatics fedoraproject.org> Jun 10 2012
Evry single time I encounter them I yawn. It means using the next frickin hour to comment away code, add more log statements and try to eleminate whats creating the hell of bugz, segmantation fault. Why can't the compiler tell me anything else than the fact that i have referenced data that does not exist? Thanks I knew that. Now, please tell me where the error occured.... Jeezes.
Jun 08 2012
On 06/08/2012 11:30 AM, "Jarl André" <jarl.andre gmail.com>" wrote:Evry single time I encounter them I yawn. It means using the next frickin hour to comment away code, add more log statements and try to eleminate whats creating the hell of bugz, segmantation fault. Why can't the compiler tell me anything else than the fact that i have referenced data that does not exist? Thanks I knew that. Now, please tell me where the error occured.... Jeezes.
If you build with -debug, it should enable code that will do those checks for you in things like arrays and associative arrays (where I find I have the most problems). It'll throw an exception rather than segfault. Very handy.
Jun 08 2012
On Fri, 08 Jun 2012 19:30:57 +0200, Jarl André wrote:Evry single time I encounter them I yawn. It means using the next frickin hour to comment away code, add more log statements and try to eleminate whats creating the hell of bugz, segmantation fault. Why can't the compiler tell me anything else than the fact that i have referenced data that does not exist? Thanks I knew that. Now, please tell me where the error occured.... Jeezes.
The compiler can't really help you (aside from maybe adding dereference checks everywhere) because you have a logic error, not something that can be statically determined. This is why debuggers exist. Whenever I get a segfault, I fire up GDB and recreate it. If you've compiled with -g, GDB can usually tell you the exact line the problem occurred on and a full backtrace to help you figure out how you got there.
Jun 08 2012
On 06/08/2012 02:00 PM, Justin Whear wrote:On Fri, 08 Jun 2012 19:30:57 +0200, Jarl André wrote:Evry single time I encounter them I yawn. It means using the next frickin hour to comment away code, add more log statements and try to eleminate whats creating the hell of bugz, segmantation fault. Why can't the compiler tell me anything else than the fact that i have referenced data that does not exist? Thanks I knew that. Now, please tell me where the error occured.... Jeezes.
The compiler can't really help you (aside from maybe adding dereference checks everywhere) because you have a logic error, not something that can be statically determined. This is why debuggers exist. Whenever I get a segfault, I fire up GDB and recreate it. If you've compiled with -g, GDB can usually tell you the exact line the problem occurred on and a full backtrace to help you figure out how you got there.
I think what everyone who didn't come from a C/C++ background wants is backtraces without having to drop into a debugger. I just don't think the folks that haven't used modern JITed/interpreted languages for a long period of time understand how inconvenient (and sometimes completely impractical) it is to drop into a debugger every time there is a segfault.
Jun 09 2012
On 08.06.2012 21:30, "Jarl André" <jarl.andre gmail.com>" wrote:Evry single time I encounter them I yawn. It means using the next frickin hour to comment away code, add more log statements and try to eleminate whats creating the hell of bugz, segmantation fault. Why can't the compiler tell me anything else than the fact that i have referenced data that does not exist? Thanks I knew that. Now, please tell me where the error occured.... Jeezes.
Well there should be a stack trace. I even see it on win32 these days. try compiling with -g flag. -- Dmitry Olshansky
Jun 08 2012
On Friday, June 08, 2012 19:30:57 Jarl André" <jarl.andre gmail.com> puremagic.com wrote:Evry single time I encounter them I yawn. It means using the next frickin hour to comment away code, add more log statements and try to eleminate whats creating the hell of bugz, segmantation fault. Why can't the compiler tell me anything else than the fact that i have referenced data that does not exist? Thanks I knew that. Now, please tell me where the error occured.... Jeezes.
Turn on core dumps and use gdb. It'll give a backtrace and allow you to look at the state of the program when the segfault occured. That's pretty much the standard way to figure out what happened when a segfault occurs. - Jonathan M Davis
Jun 08 2012
--f46d04088ee553ea8b04c2014924 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Fri, Jun 8, 2012 at 11:29 AM, Jonathan M Davis <jmdavisProg gmx.com>wrot= e:On Friday, June 08, 2012 19:30:57 Jarl Andr=E9" <jarl.andre gmail.com> puremagic.com wrote:Evry single time I encounter them I yawn. It means using the next frickin hour to comment away code, add more log statements and try to eleminate whats creating the hell of bugz, segmantation fault. Why can't the compiler tell me anything else than the fact that i have referenced data that does not exist? Thanks I knew that. Now, please tell me where the error occured.... Jeezes.
Turn on core dumps and use gdb. It'll give a backtrace and allow you to look at the state of the program when the segfault occured. That's pretty much the standard way to figure out what happened when a segfault occurs.
And use GDC because DMD's debug symbols on Linux are broken enough to crash GDB at times. GDC is generally flawless. --f46d04088ee553ea8b04c2014924 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote">On Fri, Jun 8, 2012 at 11:29 AM, Jonathan M Davi= s <span dir=3D"ltr"><<a href=3D"mailto:jmdavisProg gmx.com" target=3D"_b= lank">jmdavisProg gmx.com</a>></span> wrote:<br><blockquote class=3D"gma= il_quote" style=3D"margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-co= lor:rgb(204,204,204);border-left-width:1px;border-left-style:solid"> On Friday, June 08, 2012 19:30:57 Jarl Andr=E9"<br> <div><div><<a href=3D"mailto:jarl.andre gmail.com" target=3D"_blank">jar= l.andre gmail.com</a>> <a href=3D"http://puremagic.com" target=3D"_blank= ">puremagic.com</a> wrote:<br> > Evry single time I encounter them I yawn. It means using the next<br> > frickin hour to comment away code, add more log statements and<br> > try to eleminate whats creating the hell of bugz, segmantation<br> > fault. Why can't the compiler tell me anything else than the fact<= br> > that i have referenced data that does not exist? Thanks I knew<br> > that. Now, please tell me where the error occured.... Jeezes.<br> <br> </div></div>Turn on core dumps and use gdb. It'll give a backtrace and = allow you to look<br> at the state of the program when the segfault occured. That's pretty mu= ch the<br> standard way to figure out what happened when a segfault occurs.<br> </blockquote><div>=A0</div><div>And use GDC because DMD's debug symbols= on Linux are broken enough to crash GDB at times.=A0GDC=A0is generally fla= wless.=A0</div></div> --f46d04088ee553ea8b04c2014924--
Jun 08 2012
On Fri, 08 Jun 2012 19:57:47 -0700, Andrew Wiley wrote:On Fri, Jun 8, 2012 at 11:29 AM, Jonathan M Davis <jmdavisProg gmx.com>wrote:On Friday, June 08, 2012 19:30:57 Jarl André" <jarl.andre gmail.com> puremagic.com wrote:Evry single time I encounter them I yawn. It means using the next frickin hour to comment away code, add more log statements and try to eleminate whats creating the hell of bugz, segmantation fault. Why can't the compiler tell me anything else than the fact that i have referenced data that does not exist? Thanks I knew that. Now, please tell me where the error occured.... Jeezes.
Turn on core dumps and use gdb. It'll give a backtrace and allow you to look at the state of the program when the segfault occured. That's pretty much the standard way to figure out what happened when a segfault occurs.
crash GDB at times. GDC is generally flawless. <div class="gmail_quote">On Fri, Jun 8, 2012 at 11:29 AM, Jonathan M Davis <span dir="ltr"><<a href="mailto:jmdavisProg gmx.com" target="_blank">jmdavisProg gmx.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-
On Friday, June 08, 2012 19:30:57 Jarl André"<br> <div><div><<a href="mailto:jarl.andre gmail.com" target="_blank">jarl.andre gmail.com</a>> <a href="http://puremagic.com" target="_blank">puremagic.com</a> wrote:<br> > Evry single time I encounter them I yawn. It means using the next<br> > frickin hour to comment away code, add more log statements and<br> > try to eleminate whats creating the hell of bugz, segmantation<br> > fault. Why can't the compiler tell me anything else than the fact<br> > that i have referenced data that does not exist? Thanks I knew<br> > that. Now, please tell me where the error occured.... Jeezes.<br> <br> </div></div>Turn on core dumps and use gdb. It'll give a backtrace and allow you to look<br> at the state of the program when the segfault occured. That's pretty much the<br> standard way to figure out what happened when a segfault occurs.<br> </blockquote><div> </div><div>And use GDC because DMD's debug symbols on Linux are broken enough to crash GDB at times. GDC is generally flawless. </div></div>
Ah noes, HTML code again... -- Dejan Lekic mailto:dejan.lekic(a)gmail.com http://dejan.lekic.org
Jun 09 2012
On Sat, Jun 9, 2012 at 6:09 AM, Dejan Lekic <dejan.lekic gmail.com> wrote:On Fri, 08 Jun 2012 19:57:47 -0700, Andrew Wiley wrote:On Fri, Jun 8, 2012 at 11:29 AM, Jonathan M Davis <jmdavisProg gmx.com>wrote:On Friday, June 08, 2012 19:30:57 Jarl Andr=E9" <jarl.andre gmail.com> puremagic.com wrote:Evry single time I encounter them I yawn. It means using the next frickin hour to comment away code, add more log statements and try to eleminate whats creating the hell of bugz, segmantation fault. Why can't the compiler tell me anything else than the fact that i have referenced data that does not exist? Thanks I knew that. Now, please tell me where the error occured.... Jeezes.
Turn on core dumps and use gdb. It'll give a backtrace and allow you to look at the state of the program when the segfault occured. That's pretty much the standard way to figure out what happened when a segfault occurs.
crash GDB at times. GDC is generally flawless.
Sorry, my bad. Better?
Jun 09 2012
Le vendredi 08 juin 2012 =C3=A0 19:30 +0200, Jarl =3D?UTF-8?B?QW5kcsOpIg=3D= =3D?=3D a =C3=A9crit :Evry single time I encounter them I yawn. It means using the next=20 frickin hour to comment away code, add more log statements and=20 try to eleminate whats creating the hell of bugz, segmantation=20 fault. Why can't the compiler tell me anything else than the fact=20 that i have referenced data that does not exist? Thanks I knew=20 that. Now, please tell me where the error occured.... Jeezes.
Hi, te best way that is to use ldc or gdc with -g flag i use ldc2 me from fedora repo $ sudo yum install ldc2* // install D compiler, D standard library, headers ... $ sudo yum install dustmite // this tool are really help full to get a minimall test cease $ ulimit -c unlimited // able to generate core dump $ ldc2 myProgram.d $ ./dustmite_snippet.sh myProgram --------------------- $ cat ./dustmite_snippet.sh #!/bin/sh BINARY=3D$1 #the binary to test SEGFUNC=3D"_aaDelX" #the function where the segfault occurs (as in the gdb backtrace!) ldc2 $1.d -of$BINARY 2>/dev/null #Your compile command echo $(sh -c "./$BINARY" 2>&1) | grep -q "Erreur de segmentation" #Make sure there was a segfault if [ $? -eq 0 ] then gdb --batch -ex 'backtrace' $BINARY core 2>&1 | grep -q "#0 .* in $SEGFUNC" if [ $? -eq 0 ] then return 0 else return 1 fi else return 1 fi
Jun 10 2012









Kai Meyer <kai unixlords.com> 