is there any efficient way to solve the runtime error? - runtime

In competitive programming your code should be error free. The runtime error is common when you go for writing a code. So can anyone help me to find why this error occur.

There's no one fix way to solve run time error. This is because runtime errors are caused by a bunch of reasons. Some common reasons are :
Division by zero.
Trying to access or modify Invalid or out of bounds array/vector/string index.
Very large memory allocation.
Data type mismatch errors
Most of these require you to correct them in different way through debugging process and checking your code. There's no fix one stop solution for it.

Related

What are the different causes for error code 0x3?

It's been a couple times now I end up with programs crashing with a return value of 3. Although I've always managed to solve it by re-writing or changing my code, I am now getting curious for the causes of this error code(And Google doesn't seem to have nearly as much data on it as 0xc0000005). According to the Microsoft docs, it happens when the system cannot find the path specified.
Now, I might just be bad at understanding english, but I cannot understand how this error can possibly relate to my codes(No files/pointers involved or manipulated in these specific cases). My only guess is the problem being related to some internal DLLs missing.
Could anybody please provide me with further explanation over this error code? I feel like I should understand what is the cause of a problem before trying to even solve it, and it might help in future cases.
Thank you very much.

Exception during running custom clang Frontend tool on some input files

I have written a custom clang Frontend tool according to the following link.
http://clang.llvm.org/docs/RAVFrontendAction.html
Now I am giving clang source code itself to my frontend tool for static analysis.
My tool is throwing an exception for this test case
https://llvm.org/svn/llvm-project/cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp
From the documentation of this test case, It is written for undefined behavior.
And while running ClangTool on this test it throws stackoverflow exception even before the control comes in HandleTranslationUnit.
As clang can generate AST for the above test case, I assume the exception might be coming during compilation. Now the question is can't I continue visiting AST nodes for such files as I don't care about the semantics of input source files. I am only interested in static analysis.
Is this the expected behavior? Then how to traverse the generated AST and visit the nodes. I am really stuck at this moment and have no clue how to proceed.
Would you please help me to fix this issue.
Thanks in advance!
Thanks,
Hemant Bhagat
I found the answer. There is problem with system recursion depth. On Windows default recursion depth limit is 512. So in the case of test case mentioned in question, stack is getting overflowed even before reaching recursion limit. Hence decreasing the recursion depth limit to 27 avoided stack overflow exception.
Similar is the case with template depth.

More specific OpenGL error information

Is there a way to retrieve more detailed error information when OpenGL has flagged an error? I know there isn't in core OpenGL, but is there perhaps some common extension or platform- or driver-dependent way or anything at all?
My basic problem is that I have a game (written in Java with JOGL), and when people have trouble with it, which they do on certain hardware/software configurations, it can be quite hard to trace down where the root of the problem lies. For performance reasons, I can't keep calling glGetError for each command but only do so at a few points in the program, so it's kind of hard to even find what command even flagged the error to begin with. Even if I could, however, the extremely general error codes that OpenGL have don't really tell me all that much about what happened (seeing as how the manpages on the commands even describe how the various error codes are reused for sometimes quite many different actual error conditions).
It would be tremendously helpful if there were a way to find out what OpenGL command actually flagged the error, and also more details about the error that was flagged (like, if I get GL_INVALID_VALUE, what value to what argument was invalid and why?).
It seems a bit strange that drivers wouldn't provide this information, even if in a completely custom way, but looked as I have, I sure haven't found any way to find it. If it really is that they don't, is there any good reason for why that is so?
Actually, there is a feature in core OpenGL that will give you detailed debug information. But you are going to have to set your minimum version requirement pretty high to have this as a core feature.
Nevertheless, see this article -- even though it only went core in OpenGL 4.3, it existed in extension form for quite some time and it does not require any special hardware feature. So for the most part all you really need is a recent driver from NV or AMD.
I have an example of how to use this extension in an answer I wrote a while back, complete with a few utility functions to make the output easier to read. It is written in C, so I do not know how helpful it will be, but you might find something useful.
Here is the sort of output you can expect from this extension (AMD Catalyst):
OpenGL Error:
=============
Object ID: 102
Severity: Medium
Type: Performance
Source: API
Message: glDrawElements uses element index type 'GL_UNSIGNED_BYTE' that is not
optimal for the current hardware configuration; consider using
'GL_UNSIGNED_SHORT' instead.
Not only will it give you error information, but it will even give you things like performance warnings for doing something silly like using 8-bit vertex indices (which desktop GPUs do not like).
To answer another one of your questions, if you set the debug output to synchronous and install a breakpoint in your debug callback you can easily make any debugger break on an OpenGL error. If you examine the callstack you should be able to quickly identify exactly what API call generated most errors.
Here are some suggestions.
According to the man pages, glGetError returns the value of the error flag and then resets it to GL_NO_ERROR. I would use this property to track down your bug - if nothing else you can switch up where you call it and do a binary search to find where the error occurs.
I doubt calling glGetError will give you a performance hit. All it does is read back an error flag.
If you don't have the ability to test this on the specific hardware/software configurations those people have, it may be tricky. OpenGL drivers are implemented for specific devices, after all.
glGetError is good for basically saying that the previous line screwed up. That should give you a good starting point - you can look up in the man pages why that function will throw the error, rather than trying to figure it out based on its enum name.
There are other specific error functions to call, such as glGetProgramiv, and glGetFramebufferStatus, that you may want to check, as glGetError doesn't check for every type of error. IE Just because it reads clean doesn't mean another error didn't happen.

BSOD Error Code Explanation

I am retrieving system failure information from the event logs for diagnosis of system crash and displaying a list of possible issues.
In a generic BSOD, what do the four hex values in brackets signify. Is there anyway they can be used for further diagnosis of the problem, beyond the main error code? i.e 0x000000A. If yes, how?
The first number is a bug check code.
The following numbers will be whatever the driver passed to KeBugCheckEx, so they're only really useful if you have the driver source code.

What is "unknown software exception (0xc00000fd)" error and how to avoid it?

I have created an AHK script named code_2, compiled it and placed it into my Startup folder so that it would automatically start running each time I turn on the computer.
The script checks a website for new updates and whenever an update on the website is detected, it downloads those updates using UrlDownloadToFile.
At first the script seemed to work fine, but recently I started receiving the following messages from my computer after my script has been running for about 15 minutes:
C:\Documents and Settings\Administrator\「開始」功能表\程式集\啟動\code_2.exe:
code_2.exe - 應用程式錯誤
應用程式發生例外 unknown software exception (0xc00000fd) 於位置 0x7c92eddc。
請按 [確定] 終止程式
請按 [取消] 進行程式偵錯
Any idea what this message is all about? (Sorry for the Chinese here, but I'd think that if you know this message by its number, you should be familiar with the contents.)
Anyway, here is the translated message:
C:\Documents and Settings\Administrator\Start Menu\Programs\Startup\code_2.exe: code_2.exe - Application Error
The exception unknown software exception (0xc00000fd) occurred in the application at location 0x7c92eddc.
Click on OK to terminate the program
Click on CANCEL to debug the program
I believe that 0xc00000fd is a stack overflow exception (http://support.microsoft.com/kb/315937). Without seeing your script, it is hard to say for sure what is going wrong, but this sort of thing is generally caused by recursing too deeply. I would check your script for any recursive functions and make sure that they are exiting before reaching too great a depth.
It's possible you're actually allocating too much on the stack. I'm not familiar with AHK, but it's possible the compiler is allocating a large amount of data (probably local variables) on the stack, too. If you define a large number of (or a number of large) local variables, this could happen.
It's also possible that the stack/memory is somehow getting corrupted, although this seems less likely to be the case when using a scripting language. It might be more likely when accessing native API from a scripting language, depending on how that is done.
The last possiblity I'm going to suggest here is that you're calling some API and causing it to allocate a lot of stack space as well, possibly by passing in bad parameters. Again, without knowing more specifics (especially what it's doing when it hits that exception), it's hard to say for sure.
I can think of some other reasons, but they're even less likely.

Resources