Skip to main content

Runtime Errors

As programmers we come across various types of errors. Some errors can be fixed using the message associated with that error while some of them are not clear. One such type of error is the "RUNTIME ERROR".

What is a runtime error?

A runtime error means that the program was compiled successfully, but it exited with a runtime error or crashed. You will receive an additional error message, which is most commonly one of the following:


This is the most common error, i.e., a "segmentation fault". This may be caused e.g. by an out-of-scope array index causing a buffer overflow, an incorrectly initialized pointer, etc. This signal is generated when a program tries to read or write outside the memory that is allocated for it, or to write memory that can only be read. For example, you’re accessing a[-1] in a language which does not support negative indices for an array.

"output limit exceeded". Your program has printed too much data to output.

"floating point error". This usually occurs when you’re trying to divide a number by 0, or trying to take the square root of a negative number.

These are raised by the program itself. The program is stopped due to insufficient memory.

(non-zero exit code) - this message means that the program exited returning a value different from 0 to the shell. For languages such as C/C++, this probably means you forgot to add "return 0" at the end of the program. It could happen if your program threw an exception which was not caught. Trying to allocate too much memory during code execution may also be one of the reasons.
For interpreted languages like Python, NZEC will usually mean that your program either crashed or raised an uncaught exception. Some of the reasons being in such cases would be: the above mentioned runtime errors. Or, for instance usage of an external library which is causing some error.

6) MLE (Memory Limit Exceeded)
This error means that your program tried to allocate memory beyond the memory limit indicated. This can occur if you declare a very large array, or if a data structure in your program becomes too large.

This type of error is sometimes generated if you use too much memory. Check for arrays that are too large, or other elements that could grow to a size too large to fit in memory. It can also be sometimes be generated for similar reasons to the SIGSEGV error.

So what are the ways to avoid runtime errors?

Some ways to avoid runtime errors: 
1) Make sure you aren't using variables that haven't been initialized.
2) Check every single occurrence of accessing an array element and see if it could possibly be out of bounds. 
3) Make sure you aren't declaring too much memory. 64 MB is guaranteed, but having an array of size [100000] * [100000] will never work.
4) Make sure you aren't declaring too much stack memory. Any large arrays should be declared globally, outside of any functions, as putting an array of 100000 ints inside a function probably won't work


Popular posts from this blog

What’s the difference between AngularJS, Angular2 and Angular4?

One question that often comes out is “What is the basic difference between AngularJS, Angular 2 and Angular 4 and how to jump from Angular 2 to Angular 4?”

Angular JS was introduced in 2010 as a JavaScript framework for building client side single page web applications. So it gained popularity and the Angular team at google started to add some more features to the core. But the framework was not designed with the needs of today’s applications in mind and moreover it was totally complex. So the Angular team decided to rewrite the entire framework using TYPESCRIPT and as a result Angular 2 was released in mid 2016. The new Angular framework is completely different from the previous version and we can think of it as a completely different framework compared to the earlier one.

The decision was frustrating to most of the developers since a lot of applications have been designed using AngularJS. I personally liked the direction that Angular developers took in rewriting the entire framework a…


Angular JS is an open source framework built on JavaScript. It was built by the
developers at Google. This framework was used to overcome obstacles encountered while
working with Single Page applications. Also, testing was considered as a key aspect while
building the framework. It was ensured that the framework could be easily tested. The
initial release of the framework was in October 2010.

Features of Angular 2:Components: The earlier version of Angular had a focus of Controllers but now has changed the focus to having components over controllers. Components help to
build the applications into many modules. This helps in better maintaining the
application over a period of time.

TypeScript: The newer version of Angular is based on TypeScript. This is a
superset of JavaScript and is maintained by Microsoft.

Services: Services are a set of code that can be shared by different components
of an application. So for example, if you had a data component that picked data
from a database, you …