PDA

View Full Version : How to detect Release crash that is not produced on Debug



^NyAw^
30th May 2010, 19:29
Hi,

I have an application that crashes when runs on release mode but works fine on debug version.

Is there a way to detect the error?

Thanks,

tbscope
30th May 2010, 19:51
You can use a debugger like gdb.

What is the error you get?

SixDegrees
30th May 2010, 20:43
There's also the old standby of using printf debugging, dropping print statements into your code at strategic points to locate where the error occurs. Even with quite large programs, this technique can locate a point of failure in a very small number of trials, since you can normally eliminate half of the remaining code, on average, at each step. Useful when debugging instrumentation masks failures, but it won't be useful if whatever is going wrong is causing stack corruption, in which your failure point will move around with each minor code change. Still, it's often useful.

^NyAw^
30th May 2010, 22:19
Hi,

You can use a debugger like gdb.


Note that on release compilation I don't get debug information so I can't debug it.

^NyAw^
30th May 2010, 22:29
Hi,

I found that a call to "flush()" method to a socket causes the problem.
I can't explain why I have this problem. This code has worked for a long time. Last friday I compiled the last version of the software and installed on the target machine with no errors. Then, at home I just wanted to make some tests and it starts crashing.

It seems that just not using the "flush(" method, the socket sends the data inmediatly, so I think that there is no need to call it. Take in consideration that this calls are done in a Thread, but the socket is created on the main thread. I know that it can reach some problems but I don't know why they started now.

Any help will be wellcome

Thanks,

tbscope
30th May 2010, 22:34
Hi,


Note that on release compilation I don't get debug information so I can't debug it.

Ohh? Do you now what debugging information is?
Sure, it will be more difficult but that's where your masters degree in computer sciences kicks in ;-)

^NyAw^
30th May 2010, 23:02
Hi,

Ohh? Do you now what debugging information is?


The compiler generates it so you can debug the application. If there is no debug information such symbols, data names, ... the debugger will tell you that it don't have debug information. So really, if you don't know how to help me, don't waste time writing here. Thanks,

SixDegrees
30th May 2010, 23:12
Most modern debuggers don't need the special debugging information the compiler inserts into the object file; they can produce a stack trace without it, although they may not have access to symbolic names or line numbers. It is still quite possible to use the debugger to locate the point of failure, however.

As noted above, stick some print statements in your code and you can quickly find the failure point without such aids.

Failure in release mode with success in debug mode is often an indicator of walking off an array; the debugger "pads" array allocations in order to avoid segmentation faults, and that coupled with various indexing errors often produces programs that run fine with debug settings but fail otherwise. But there are litteraly hundreds, if not thousands of other likely causes. You'll need to narrow the problem down before you can analyze it.

tbscope
31st May 2010, 06:10
Hi,


The compiler generates it so you can debug the application. If there is no debug information such symbols, data names, ... the debugger will tell you that it don't have debug information. So really, if you don't know how to help me, don't waste time writing here. Thanks,

Ok, maybe I'm a little bit too hard.
But what you tell is bullshit. There are complete businesses around debugging applications.

Programming is a lot more than just sitting behind your pc and writing a little program as a hobby.
You need to educate yourself to an engineering level to understand what goes on inside a computer. I do not pretend to know all of this as computer sciences are not my main speciality.
But what I do know, and this is from experience, is that you can certainly debug applications without debugging symbols in a debugger. But you'll need to know how the computer, the operating system, the compiler and the debugger work. This is not a quick question on a forum and 5 minutes later you have a magical answer.

As suggested above, nothing stops you from including a logger in your program to log debugging messages just like if you use qDebug().
But if that fails, you'll need to use a debugger.

One of your next questions could have been: "Where do I find more information about debugging my program?"
I would have responded with: "A good place to start is the documentation of the debugger you're going to use."
Another question could have been: "Can I compile my program in release mode and still have all my symbols available somewhere?"
I would have responded with: "Of course you can, see the manual of your compiler and debugger. You can even split everything up!"
Another question could have been: "What exactly is the difference between a debug and release?"
Even another question could have been: "Why do I get this error in release mode? Does it have something to do with my compiler optimizing some critical code that I didn't guard so well in my application?"
etc...

Did you ever see a crash log in Windows? Can you make sense of it?

I used to play a lot with Lego. It was fun to create little machines. Everyone can do that. Later I got a masters degree in electromechanical engineering. I now work on multi million dollar/euro infrastructure projects. I can tell you this: with the knowledge to put together little lego machines, you get nowhere. You need a much better understanding of how things work to be able to get the errors out of a design.

Today you get all these nifty tools like finite element software. I can tell these programs "look, here's a sketch of a bridge, tell me if it will hold at least 5 cars in the winter". And 5 minutes later the program tells me if it does. But I can tell you this: a lot of people working with these programs do not know the meaning of the results, they do not know how to interpret this. And this is extremely dangerous.

The same can be said with programming. Most people can write program code. But when you get into a situation where you are now, it takes experience and knowledge to understand what goes wrong and to solve it.

^NyAw^
31st May 2010, 14:56
Hi,

Ok, maybe I'm a little bit too hard.

Yes, is what I felt.



Programming is a lot more than just sitting behind your pc and writing a little program as a hobby.
You need to educate yourself to an engineering level to understand what goes on inside a computer. I do not pretend to know all of this as computer sciences are not my main speciality.

I know a little bit programming, I've been 5 years programming on this project that I started myself. It's a machine vision application that uses multiple threads, multiple I/Os, ... and it works well.



But what I do know, and this is from experience, is that you can certainly debug applications without debugging symbols in a debugger. But you'll need to know how the computer, the operating system, the compiler and the debugger work.

This is what I didn't know. I thought that I need to tell the compiler to gereate the debugging information to let the debugger debug it.



As suggested above, nothing stops you from including a logger in your program to log debugging messages just like if you use qDebug().
But if that fails, you'll need to use a debugger.

It's just a bit complicated. As I told, it uses multiple threads, but could be helpful on some situations.



One of your next questions could have been: "Where do I find more information about debugging my program?"
I would have responded with: "A good place to start is the documentation of the debugger you're going to use."

Ok, so if anyone knows how to debug my aplication compiled in release mode on Visual Studio debugger it will be great.



Another question could have been: "Can I compile my program in release mode and still have all my symbols available somewhere?"
I would have responded with: "Of course you can, see the manual of your compiler and debugger. You can even split everything up!"

This is what I need.



Another question could have been: "What exactly is the difference between a debug and release?"
Even another question could have been: "Why do I get this error in release mode? Does it have something to do with my compiler optimizing some critical code that I didn't guard so well in my application?"
etc...

I know about the code optimizations. Read my post, I told that the application had been working well for a lot of time on the target machine.



Did you ever see a crash log in Windows? Can you make sense of it?

No, I didn't check it never. I don't know where to start getting relevant information on it, ...



The same can be said with programming. Most people can write program code. But when you get into a situation where you are now, it takes experience and knowledge to understand what goes wrong and to solve it.
[/QUOTE]
Yes, I know. I'm sure that I'm not a begginer.

Thanks,

The other question is. Anyone have experienced problems when calling "flush()" from a thread that was created on the main thread?

Thanks,