Skip to content

How to debug "Test case crashed" for users using C ? #3322

Closed Answered by hobovsky
M0hanrajp asked this question in Q&A
Discussion options

You must be logged in to vote

When I face a crash in a C or C++ solution, my procedure usually is:

  1. I look at the signal. Knowing what signal caused your crash can help with debugging: SIGFPE usually means division by 0, modulo by 0, or domain error (like a negative argument to sqrt or logarithm). Signal 6 usually means invalid call to free: calling it on a string literal, or on a moved pointer. There is a chance you returned an invalid pointer which cannot be freed. SIGSEGV is the most problematic because it can mean anything related to invalid handling of memory, but the first thing to check is usually an out-of-bounds access to arrays or strings.
  2. Use printf or std::cout to print out the input causing my crash. It i…

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by M0hanrajp

This comment was marked as spam.

@hobovsky
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants