digitalmars.D.learn - Segmentation fault hell in D
- "Jarl =?UTF-8?B?QW5kcsOpIg==?= <jarl.andre gmail.com> (6/6) Jun 08 2012 Evry single time I encounter them I yawn. It means using the next
- Kai Meyer (5/11) Jun 08 2012 If you build with -debug, it should enable code that will do those
- Justin Whear (7/13) Jun 08 2012 The compiler can't really help you (aside from maybe adding dereference
- Chad J (7/20) Jun 09 2012 I think what everyone who didn't come from a C/C++ background wants is
- Dmitry Olshansky (5/11) Jun 08 2012 Well there should be a stack trace. I even see it on win32 these days.
- Jonathan M Davis (6/12) Jun 08 2012 Turn on core dumps and use gdb. It'll give a backtrace and allow you to ...
- Andrew Wiley (4/17) Jun 08 2012 And use GDC because DMD's debug symbols on Linux are broken enough to cr...
- Dejan Lekic (7/52) Jun 09 2012 Ah noes, HTML code again...
- Andrew Wiley (2/25) Jun 09 2012 Sorry, my bad. Better?
- bioinfornatics (34/40) Jun 10 2012 Le vendredi 08 juin 2012 =C3=A0 19:30 +0200, Jarl =3D?UTF-8?B?QW5kcsOpIg...
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: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.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 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
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:And use GDC because DMD's debug symbols on Linux are broken enough to crash GDB at times. GDC is generally flawless.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.
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:width:1px;border-left-style:solid">On Friday, June 08, 2012 19:30:57 Jarl André" <jarl.andre gmail.com> puremagic.com wrote:And use GDC because DMD's debug symbols on Linux are broken enough to 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-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.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, 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> and allow you to look<br> at the state of the program when the segfault happened when a segfault occurs.<br> </blockquote><div> </div><div>And 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:Sorry, my bad. Better?On Fri, Jun 8, 2012 at 11:29 AM, Jonathan M Davis <jmdavisProg gmx.com>wrote:Ah noes, HTML code again...On Friday, June 08, 2012 19:30:57 Jarl Andr=E9" <jarl.andre gmail.com> puremagic.com wrote:And use GDC because DMD's debug symbols on Linux are broken enough to crash GDB at times. GDC is generally flawless.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.
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 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 $SEGFUNC" if [ $? -eq 0 ] then return 0 else return 1 fi else return 1 fi
Jun 10 2012