Skip to content

Commit

Permalink
Add test invalid_interpreter.
Browse files Browse the repository at this point in the history
Retrieving the interpreter_base fails if done after
interpreter gets invalidated.
Related to #2740
  • Loading branch information
bernhardu authored and rocallahan committed Nov 21, 2020
1 parent 99d680b commit 79ac37a
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,7 @@ set(TESTS_WITH_PROGRAM
x86/int3_ok
interrupt
intr_ptrace_decline
invalid_interpreter
invalid_jump
jit_proc_mem
link
Expand Down
26 changes: 26 additions & 0 deletions src/test/invalid_interpreter.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* -*- Mode: C; tab-width: 8; c-basic-offset: 2; indent-tabs-mode: nil; -*- */

#include "util.h"

size_t page_size;

static void breakpoint(void) {
int break_here = 1;
(void)break_here;
}

void callback(__attribute__((unused)) uint64_t env, char* name, map_properties_t* props) {
if (strstr(name, "/ld-") != 0) {
test_assert(0 == munmap((void*)(uintptr_t)props->start, page_size));
void* p = (void*)mmap((void*)(uintptr_t)props->start, page_size, PROT_NONE, MAP_PRIVATE | MAP_FIXED | MAP_ANONYMOUS, -1, 0);
test_assert(p != MAP_FAILED);
}
}

int main(void) {
page_size = sysconf(_SC_PAGESIZE);
FILE* maps_file = fopen("/proc/self/maps", "r");
iterate_maps(0, callback, maps_file);
breakpoint();
return 0;
}
12 changes: 12 additions & 0 deletions src/test/invalid_interpreter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from util import *

send_gdb('break breakpoint')
expect_gdb('Breakpoint 1')
send_gdb('c')
expect_gdb('Breakpoint 1')
send_gdb('checkpoint')
expect_gdb('Checkpoint 1 at')
send_gdb('restart 1')
expect_gdb('stopped')

ok()
3 changes: 3 additions & 0 deletions src/test/invalid_interpreter.run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source `dirname $0`/util.sh
record invalid_interpreter$bitness
debug invalid_interpreter

0 comments on commit 79ac37a

Please sign in to comment.