[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r21496 - monkey/branches/MonkeyBacktracking/monkey/src/monk
From: |
gnunet |
Subject: |
[GNUnet-SVN] r21496 - monkey/branches/MonkeyBacktracking/monkey/src/monkey |
Date: |
Tue, 15 May 2012 14:51:29 +0200 |
Author: safey
Date: 2012-05-15 14:51:29 +0200 (Tue, 15 May 2012)
New Revision: 21496
Added:
monkey/branches/MonkeyBacktracking/monkey/src/monkey/bug_sigbus.c
Modified:
monkey/branches/MonkeyBacktracking/monkey/src/monkey/Makefile.am
monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c
monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey.c
monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_action.h
Log:
Monkey supports SIGBUS. A SIGBUS testcase (the code does not produce a sigbus
on x86 though).
Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/Makefile.am
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/Makefile.am
2012-05-15 12:46:22 UTC (rev 21495)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/Makefile.am
2012-05-15 12:51:29 UTC (rev 21496)
@@ -51,7 +51,8 @@
bug_assertion_failure \
bug_crypto_crc \
bug_division_by_zero_loop \
- bug_null_pointer_exception_modified
+ bug_null_pointer_exception_modified \
+ bug_sigbus
#noinst_PROGRAMS = \
bug_null_pointer_exception \
@@ -59,7 +60,8 @@
bug_assertion_failure \
bug_crypto_crc \
bug_division_by_zero_loop \
- bug_null_pointer_exception_modified
+ bug_null_pointer_exception_modified \
+ bug_sigbus
monkey_SOURCES = \
gdbmi.h \
@@ -106,7 +108,10 @@
gcc -g -O0 -o bug_division_by_zero_loop bug_division_by_zero_loop.c
bug_null_pointer_exception_modified:
- gcc -g -O0 -o bug_null_pointer_exception_modified
bug_null_pointer_exception_modified.c
+ gcc -g -O0 -o bug_null_pointer_exception_modified
bug_null_pointer_exception_modified.c
+
+bug_sigbus:
+ gcc -g -O0 -o bug_sigbus bug_sigbus.c
check_PROGRAMS = \
Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c
2012-05-15 12:46:22 UTC (rev 21495)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/action_api.c
2012-05-15 12:51:29 UTC (rev 21496)
@@ -17,6 +17,7 @@
static int async_c = 0;
static char *signalMeaning = NULL;
+static char *signalName = NULL;
static int stoppedInSharedLib = MONKEY_NO;
static int failureFunctionStartLine = 0; // start line number of the
function in which the failure occurs
static struct WatchInfo *watchInfoListHead = NULL;
@@ -579,8 +580,10 @@
static int stackDepth = 0;
static struct MONKEY_EDB_Context *edbCntxt;
- if (NULL == signalMeaning)
- signalMeaning = cntxt->gdb_stop_reason->signal_meaning;
+ if (NULL == signalMeaning) {
+ signalMeaning = cntxt->gdb_stop_reason->signal_meaning;
+ signalName = cntxt->gdb_stop_reason->signal_name;
+ }
if (NULL == epoch) {
epoch = MONKEY_malloc(sizeof(struct Epoch));
@@ -691,6 +694,9 @@
cntxt->gdb_frames->line, endScope,
&iterateExpressions, function);
ret = analyzeSegmentationFault(function, cntxt); // will decide
whether the problem is a NULL Pointer Exception or a Bad Memory Access
+ if (BUG_NULL_POINTER != cntxt->bug_detected) {
+ cntxt->bug_detected = BUG_BAD_MEM_ACCESS;
+ }
} else if (strcasecmp(signalMeaning, "Aborted") == 0) {
cntxt->bug_detected = BUG_ABORT;
/*
@@ -705,29 +711,35 @@
cntxt->gdb_frames->line, endScope,
&iterateExpressions, function);
ret = analyzeCustomFault(function, cntxt);
- } else if (strcasecmp(signalMeaning, "Arithmetic exception") == 0) {
- cntxt->bug_detected = BUG_ARITHMETIC;
- /*
- MONKEY_EDB_get_sub_expressions (edbCntxt,
- cntxt->gdb_frames->file,
- cntxt->gdb_frames->line,
- endScope, &iterateExpressions,
- NULL);
- */
- if (cntxt->scope_depth > 0)
- MONKEY_EDB_get_expressions_outer_scopes(edbCntxt,
- cntxt->gdb_frames->
- file,
- failureFunctionStartLine,
endScope,
- &iterateExpressions,
- function);
- else
- MONKEY_EDB_get_expressions(edbCntxt,
- cntxt->gdb_frames->file,
- cntxt->gdb_frames->line, endScope,
- &iterateExpressions, function);
- ret = analyzeCustomFault(function, cntxt);
}
+ else {
+ if (strcasecmp(signalMeaning, "Arithmetic exception") == 0) {
+ cntxt->bug_detected = BUG_ARITHMETIC;
+ }
+ else if (strcasecmp(signalName, "SIGBUS") == 0) {
+ cntxt->bug_detected = BUG_SIG_BUS;
+ }
+ /*
+ MONKEY_EDB_get_sub_expressions (edbCntxt,
+ cntxt->gdb_frames->file,
+ cntxt->gdb_frames->line,
+ endScope, &iterateExpressions,
+ NULL);
+ */
+ if (cntxt->scope_depth > 0)
+ MONKEY_EDB_get_expressions_outer_scopes(edbCntxt,
+
cntxt->gdb_frames->
+ file,
+
failureFunctionStartLine, endScope,
+
&iterateExpressions,
+ function);
+ else
+ MONKEY_EDB_get_expressions(edbCntxt,
+ cntxt->gdb_frames->file,
+ cntxt->gdb_frames->line,
endScope,
+ &iterateExpressions,
function);
+ ret = analyzeCustomFault(function, cntxt);
+ }
//printTrace();
/* Now, dive deeper into the stack trace */
@@ -833,7 +845,6 @@
pclose(valgrindPipe);
MONKEY_free(valgrindCommand);
- cntxt->bug_detected = BUG_BAD_MEM_ACCESS;
return MONKEY_OK;
}
Added: monkey/branches/MonkeyBacktracking/monkey/src/monkey/bug_sigbus.c
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/bug_sigbus.c
(rev 0)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/bug_sigbus.c
2012-05-15 12:51:29 UTC (rev 21496)
@@ -0,0 +1,50 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+int main(int argc, char **argv)
+{
+
+ __asm__("pushf\n"
+ "orl $0x40000, (%esp)\n"
+ "popf");
+
+ int testvar = 0x12345678;
+ int *testvarp;
+
+ testvarp = &testvar;
+ printf("testvarp was %lx\n", testvarp);
+ printf("testvar was %lx\n", *testvarp);
+
+ testvarp = (int *)(((char *)testvarp) + 1);
+ printf("testvarp is %lx\n", testvarp);
+ printf("testvar is %lx\n", *testvarp);
+
+
+// char* str;
+// str = realloc(str,10);
+// */
+//
+// /*
+// char *p;
+//
+// __asm__("pushf\n"
+// "orl $0x40000, (%esp)\n"
+// "popf");
+//
+// /*
+// * malloc() always provides aligned memory.
+// * Do not use stack variable like a[9], depending on the compiler you
use,
+// * a may not be aligned properly.
+// */
+// p = malloc(sizeof(int) + 1);
+// memset(p, 0, sizeof(int) + 1);
+//
+// /* making p unaligned */
+// p++;
+//
+// printf("%d\n", *(int *)p);
+//
+// return 0;
+
+}
Property changes on:
monkey/branches/MonkeyBacktracking/monkey/src/monkey/bug_sigbus.c
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey.c
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey.c
2012-05-15 12:46:22 UTC (rev 21495)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey.c
2012-05-15 12:51:29 UTC (rev 21496)
@@ -97,6 +97,7 @@
cntxt->inspect_expression = inspectExpression;
cntxt->inspect_function = inspectFunction;
cntxt->scope_depth = (NULL == scopeDepth) ? 0 : atoi(scopeDepth);
+ cntxt->bug_detected = 0;
cntxt->xml_report_node = NULL;
cntxt->run_reverse = reverseExecutionAllowed;
@@ -120,11 +121,10 @@
ret = 1;
break;
}
- else if (BUG_NULL_POINTER != cntxt->bug_detected
- && BUG_ABORT != cntxt->bug_detected
- && BUG_ARITHMETIC != cntxt->bug_detected)
+ else if (BUG_BAD_MEM_ACCESS == cntxt->bug_detected
+ || BUG_SIG_BUS == cntxt->bug_detected)
{
- /* GDB could not locate a NULL value expression, launch Valgrind */
+ /* launch valgrind */
retVal = MONKEY_ACTION_rerun_with_valgrind (cntxt);
if (MONKEY_NO == retVal)
{
Modified: monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_action.h
===================================================================
--- monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_action.h
2012-05-15 12:46:22 UTC (rev 21495)
+++ monkey/branches/MonkeyBacktracking/monkey/src/monkey/monkey_action.h
2012-05-15 12:51:29 UTC (rev 21496)
@@ -30,6 +30,7 @@
#define BUG_ABORT 7
#define BUG_ARITHMETIC 8
#define BUG_BAD_MEM_ACCESS 9
+#define BUG_SIG_BUS 10
#define GDB_MI_ASYNC_WAIT 5
/**
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r21496 - monkey/branches/MonkeyBacktracking/monkey/src/monkey,
gnunet <=