Skip to content

Commit f318cbe

Browse files
committed
ensure stack pages bytes set to 0xbe when using valgrind
1 parent 655026c commit f318cbe

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

main_wrapper.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ int __wrap_main(int argc, char *argv[], char *envp[]) {
100100
setbuf(stdout, NULL);
101101
signal(SIGPIPE, SIG_DFL);
102102
if (debug) fprintf(stderr, "running __real_main\n");
103+
#if !__DCC_STACK_USE_AFTER_RETURN__
104+
clear_stack();
105+
#endif
103106
return __real_main(argc, argv, envp);
104107
}
105108

@@ -112,10 +115,10 @@ int __wrap_main(int argc, char *argv[], char *envp[]) {
112115
setbuf(valgrind_error_pipe, NULL);
113116
valgrind_error_fd = (int)fileno(valgrind_error_pipe);
114117
} else {
118+
if (debug) perror("popen failed");
115119
#if !__DCC_STACK_USE_AFTER_RETURN__
116120
clear_stack();
117121
#endif
118-
if (debug) perror("popen failed");
119122
return __real_main(argc, argv, envp);
120123
}
121124
setenvd("DCC_VALGRIND_RUNNING", "1");
@@ -343,7 +346,6 @@ static void _memset_shim(void *p, int byte, size_t size) {
343346
}
344347
#endif
345348

346-
347349
static void setenvd(char *n, char *v) {
348350
setenv(n, v, 1);
349351
if (debug) fprintf(stderr, "setenv %s=%s\n", n, v);

tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/uninitialized-array-element-printf--valgrind.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Execution stopped here in main() in tests/run_time/uninitialized-array-element-p
1010

1111
Values when execution stopped:
1212

13+
a = <deleted-value>
1314
argc = <deleted-value>
1415
a[42] = <deleted-value>
1516
a[argc] = <deleted-value>

tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/uninitialized-array-element-sum--valgrind.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Execution stopped here in main() in tests/run_time/uninitialized-array-element-s
1111

1212
Values when execution stopped:
1313

14+
a = <deleted-value>
1415
i = <deleted-value>
1516
sum = <deleted-value>
1617
a[42] = <deleted-value>

0 commit comments

Comments
 (0)