Skip to content

Commit

Permalink
handle exit with uninitialized value
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-taylor committed Jul 10, 2019
1 parent 099db54 commit b5f5af6
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@


Runtime error: exit value is uninitialized

Main is returning an uninitialized value or exit has been passed an uninitialized value.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@


Runtime error: exit value is uninitialized

Main is returning an uninitialized value or exit has been passed an uninitialized value.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@


Runtime error: exit value is uninitialized

Main is returning an uninitialized value or exit has been passed an uninitialized value.

14 changes: 14 additions & 0 deletions tests/run_time_errors/unitialized_exit_status.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// A simple C program that attempts to be punny
// Written 23/2/2017
// by Angela Finlayson ([email protected])
// for COMP1511 Lab 01 Exercise 1

#include <stdio.h>

int main(int argc, char *argv[]) {
int a[2];
a[0] = 0;
printf("Hello, it is good to C you!\n");

return a[argc];
}
9 changes: 9 additions & 0 deletions watch_valgrind.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ def watch_valgrind():
sys.stderr.flush()
start_gdb()
break
elif 'exit_group(status)' in line:
error = f"""Runtime error: {color('exit value is uninitialized', 'red')}
Main is returning an uninitialized value or exit has been passed an uninitialized value.
"""
os.environ['DCC_VALGRIND_ERROR'] = error
print('\n' + error, file=sys.stderr)
start_gdb()
sys.exit(1)
elif 'below stack pointer' in line:
error = f"""Runtime error: {color('access to function variables after function has returned', 'red')}
You have used a pointer to a local variable that no longer exists.
Expand Down

0 comments on commit b5f5af6

Please sign in to comment.