Discussion:
How to locate Secure CRT abort ?
(too old to reply)
PhilTen
2008-10-22 14:14:17 UTC
Permalink
I ported to VS2008 an C++ application (a win32 service) previously build with
VS2003 and running successfully for years.

When I ported my source code I changed all legacy CRT calls to secure CRT
(xxxx_s) calls

Now, my application just abort at some point I can't locate.

I mention it is a server application running many threads, it has
no user interface which could provide helpful information on what
it is doing at one point.

All my code is surrounded by exceptions sections but it has no effect,
obvioulsy the problem is not catched by an exception handler.

I made some research and understood that the secure CRT would just abort
the application if it detect problems, in particular for invalid parameters.
I guess this is what is happening.

My problem now is to locate where in the source code the failure occurs.

When I check the address reported by DR. Watson it points a to generic
function and is helpless.

I found information about "_set_invalid_parameter_handler" to try to
workaround
the problem. It seem that if I use my own invalid parameter handler I can
hide the symptom,
but since with release builds it does not provide the file,line and
expression informations,
it's useless to locate the problem.

In a similar case, With my VS2003 project, I could always locate the problem
in the
source code thanks to structured exceptions, with VS2008 I can't.

I guess I must somehow get the execution stack frame of the thread
when the problem occurs and search the map to locate the calling
faulty function ?

Is this the right way to proceed ?
If yes, can I get the execution stack at failure ?

Is there any other way to locate the problem ?

Thank you idvance for help help.

ps: By the way, why Secure CRT does not uses exceptions ?
Nathan Mates
2008-10-22 16:58:59 UTC
Permalink
Post by PhilTen
I guess I must somehow get the execution stack frame of the thread
when the problem occurs and search the map to locate the calling
faulty function ?
See http://blog.kalmbachnet.de/?postid=75 for how to intercept
buffer overrun failures, and redirect them to your handler (set with
SetUnhandledExceptionFilter).
Post by PhilTen
ps: By the way, why Secure CRT does not uses exceptions ?
Here's my guess: because the secure string functions can be called
from a C program, too. Exceptions can be turned off in C++ programs
too, and errors would still need to be reported.

Nathan Mates

--
<*> Nathan Mates - personal webpage http://www.visi.com/~nathan/
# Programmer at Pandemic Studios -- http://www.pandemicstudios.com/
# NOT speaking for Pandemic Studios. "Care not what the neighbors
# think. What are the facts, and to how many decimal places?" -R.A. Heinlein
PhilTen
2008-10-27 09:18:02 UTC
Permalink
Thank you very much for your post. The link about
SetUnhandledExceptionFilter is indeed very usefull.

Phil Ten
Post by Nathan Mates
Post by PhilTen
I guess I must somehow get the execution stack frame of the thread
when the problem occurs and search the map to locate the calling
faulty function ?
See http://blog.kalmbachnet.de/?postid=75 for how to intercept
buffer overrun failures, and redirect them to your handler (set with
SetUnhandledExceptionFilter).
Post by PhilTen
ps: By the way, why Secure CRT does not uses exceptions ?
Here's my guess: because the secure string functions can be called
from a C program, too. Exceptions can be turned off in C++ programs
too, and errors would still need to be reported.
Nathan Mates
--
<*> Nathan Mates - personal webpage http://www.visi.com/~nathan/
# Programmer at Pandemic Studios -- http://www.pandemicstudios.com/
# NOT speaking for Pandemic Studios. "Care not what the neighbors
# think. What are the facts, and to how many decimal places?" -R.A. Heinlein
Loading...