/src/r-oss-fuzz/harnesses/common.h
Line | Count | Source |
1 | | /* |
2 | | * Shared helpers for R fuzzing harnesses (libFuzzer). |
3 | | * |
4 | | * Provides: |
5 | | * fuzz_suppress_warnings() - Suppress R warnings to avoid buffer overflow |
6 | | * fuzz_run_on_r_thread() - Run a function on the R thread (1 GiB stack) |
7 | | * fuzz_init_r() - Full R initialization sequence |
8 | | * fuzz_set_string() - Stage a string input under a toplevel context |
9 | | * fuzz_set_string_ce() - Stage a string with an explicit encoding mark |
10 | | * fuzz_set_raw_arg() - Stage a raw-vector input likewise |
11 | | * fuzz_make_wrapper() - Parse an R closure that implements a call slot |
12 | | * fuzz_label_calls() - Name a target's call slots in timeout dumps |
13 | | * fuzz_scratch_file() - Per-process temp file for path-only entry points |
14 | | * fuzz_write_scratch() - Rewrite that file with the current input |
15 | | * fuzz_repeat_product_excessive() - Guard against TRE repeat blowup |
16 | | * LLVMFuzzerInitialize / LLVMFuzzerTestOneInput - forward to the |
17 | | * harness's fuzz_target_init / fuzz_target_run on the R thread |
18 | | * |
19 | | * Adapted from r-afl's fuzz.h for use with libFuzzer instead of AFL++. |
20 | | */ |
21 | | |
22 | | #ifndef FUZZ_COMMON_H |
23 | | #define FUZZ_COMMON_H |
24 | | |
25 | | #include <limits.h> |
26 | | #include <pthread.h> |
27 | | #include <signal.h> |
28 | | #include <stdatomic.h> |
29 | | #include <stdint.h> |
30 | | #include <stdio.h> |
31 | | #include <stdlib.h> |
32 | | #include <string.h> |
33 | | #include <time.h> |
34 | | #include <unistd.h> |
35 | | |
36 | | #define R_NO_REMAP 1 |
37 | | #include <Rembedded.h> |
38 | | #include <Rinternals.h> |
39 | | #define CSTACK_DEFNS 1 /* R_CStackStart, R_CStackLimit */ |
40 | | #define HAVE_UINTPTR_T 1 |
41 | | #include <Rinterface.h> /* R_SignalHandlers */ |
42 | | #include <R_ext/Parse.h> |
43 | | |
44 | | /* |
45 | | * Suppress R warnings globally. |
46 | | * |
47 | | * Many R functions emit warnings on invalid input (e.g., "NAs introduced |
48 | | * by coercion"). In persistent fuzzing, these accumulate and can overflow |
49 | | * R's warning buffer, triggering fatal errors. Setting warn = -1 |
50 | | * suppresses all warnings. |
51 | | */ |
52 | | static void fuzz_suppress_warnings(void) |
53 | 39 | { |
54 | 39 | int error = 0; |
55 | 39 | SEXP warn_call; |
56 | 39 | Rf_protect(warn_call = Rf_lang2(Rf_install("options"), |
57 | 39 | Rf_ScalarInteger(-1))); |
58 | 39 | SET_TAG(CDR(warn_call), Rf_install("warn")); |
59 | 39 | R_tryEval(warn_call, R_GlobalEnv, &error); |
60 | 39 | Rf_unprotect(1); |
61 | 39 | } io.c:fuzz_suppress_warnings Line | Count | Source | 53 | 2 | { | 54 | 2 | int error = 0; | 55 | 2 | SEXP warn_call; | 56 | 2 | Rf_protect(warn_call = Rf_lang2(Rf_install("options"), | 57 | 2 | Rf_ScalarInteger(-1))); | 58 | 2 | SET_TAG(CDR(warn_call), Rf_install("warn")); | 59 | 2 | R_tryEval(warn_call, R_GlobalEnv, &error); | 60 | 2 | Rf_unprotect(1); | 61 | 2 | } |
dcf.c:fuzz_suppress_warnings Line | Count | Source | 53 | 2 | { | 54 | 2 | int error = 0; | 55 | 2 | SEXP warn_call; | 56 | 2 | Rf_protect(warn_call = Rf_lang2(Rf_install("options"), | 57 | 2 | Rf_ScalarInteger(-1))); | 58 | 2 | SET_TAG(CDR(warn_call), Rf_install("warn")); | 59 | 2 | R_tryEval(warn_call, R_GlobalEnv, &error); | 60 | 2 | Rf_unprotect(1); | 61 | 2 | } |
character.c:fuzz_suppress_warnings Line | Count | Source | 53 | 2 | { | 54 | 2 | int error = 0; | 55 | 2 | SEXP warn_call; | 56 | 2 | Rf_protect(warn_call = Rf_lang2(Rf_install("options"), | 57 | 2 | Rf_ScalarInteger(-1))); | 58 | 2 | SET_TAG(CDR(warn_call), Rf_install("warn")); | 59 | 2 | R_tryEval(warn_call, R_GlobalEnv, &error); | 60 | 2 | Rf_unprotect(1); | 61 | 2 | } |
encoding.c:fuzz_suppress_warnings Line | Count | Source | 53 | 2 | { | 54 | 2 | int error = 0; | 55 | 2 | SEXP warn_call; | 56 | 2 | Rf_protect(warn_call = Rf_lang2(Rf_install("options"), | 57 | 2 | Rf_ScalarInteger(-1))); | 58 | 2 | SET_TAG(CDR(warn_call), Rf_install("warn")); | 59 | 2 | R_tryEval(warn_call, R_GlobalEnv, &error); | 60 | 2 | Rf_unprotect(1); | 61 | 2 | } |
sort.c:fuzz_suppress_warnings Line | Count | Source | 53 | 2 | { | 54 | 2 | int error = 0; | 55 | 2 | SEXP warn_call; | 56 | 2 | Rf_protect(warn_call = Rf_lang2(Rf_install("options"), | 57 | 2 | Rf_ScalarInteger(-1))); | 58 | 2 | SET_TAG(CDR(warn_call), Rf_install("warn")); | 59 | 2 | R_tryEval(warn_call, R_GlobalEnv, &error); | 60 | 2 | Rf_unprotect(1); | 61 | 2 | } |
connections.c:fuzz_suppress_warnings Line | Count | Source | 53 | 2 | { | 54 | 2 | int error = 0; | 55 | 2 | SEXP warn_call; | 56 | 2 | Rf_protect(warn_call = Rf_lang2(Rf_install("options"), | 57 | 2 | Rf_ScalarInteger(-1))); | 58 | 2 | SET_TAG(CDR(warn_call), Rf_install("warn")); | 59 | 2 | R_tryEval(warn_call, R_GlobalEnv, &error); | 60 | 2 | Rf_unprotect(1); | 61 | 2 | } |
unserialize.c:fuzz_suppress_warnings Line | Count | Source | 53 | 2 | { | 54 | 2 | int error = 0; | 55 | 2 | SEXP warn_call; | 56 | 2 | Rf_protect(warn_call = Rf_lang2(Rf_install("options"), | 57 | 2 | Rf_ScalarInteger(-1))); | 58 | 2 | SET_TAG(CDR(warn_call), Rf_install("warn")); | 59 | 2 | R_tryEval(warn_call, R_GlobalEnv, &error); | 60 | 2 | Rf_unprotect(1); | 61 | 2 | } |
decompress.c:fuzz_suppress_warnings Line | Count | Source | 53 | 2 | { | 54 | 2 | int error = 0; | 55 | 2 | SEXP warn_call; | 56 | 2 | Rf_protect(warn_call = Rf_lang2(Rf_install("options"), | 57 | 2 | Rf_ScalarInteger(-1))); | 58 | 2 | SET_TAG(CDR(warn_call), Rf_install("warn")); | 59 | 2 | R_tryEval(warn_call, R_GlobalEnv, &error); | 60 | 2 | Rf_unprotect(1); | 61 | 2 | } |
readtable.c:fuzz_suppress_warnings Line | Count | Source | 53 | 2 | { | 54 | 2 | int error = 0; | 55 | 2 | SEXP warn_call; | 56 | 2 | Rf_protect(warn_call = Rf_lang2(Rf_install("options"), | 57 | 2 | Rf_ScalarInteger(-1))); | 58 | 2 | SET_TAG(CDR(warn_call), Rf_install("warn")); | 59 | 2 | R_tryEval(warn_call, R_GlobalEnv, &error); | 60 | 2 | Rf_unprotect(1); | 61 | 2 | } |
format.c:fuzz_suppress_warnings Line | Count | Source | 53 | 2 | { | 54 | 2 | int error = 0; | 55 | 2 | SEXP warn_call; | 56 | 2 | Rf_protect(warn_call = Rf_lang2(Rf_install("options"), | 57 | 2 | Rf_ScalarInteger(-1))); | 58 | 2 | SET_TAG(CDR(warn_call), Rf_install("warn")); | 59 | 2 | R_tryEval(warn_call, R_GlobalEnv, &error); | 60 | 2 | Rf_unprotect(1); | 61 | 2 | } |
datetime.c:fuzz_suppress_warnings Line | Count | Source | 53 | 2 | { | 54 | 2 | int error = 0; | 55 | 2 | SEXP warn_call; | 56 | 2 | Rf_protect(warn_call = Rf_lang2(Rf_install("options"), | 57 | 2 | Rf_ScalarInteger(-1))); | 58 | 2 | SET_TAG(CDR(warn_call), Rf_install("warn")); | 59 | 2 | R_tryEval(warn_call, R_GlobalEnv, &error); | 60 | 2 | Rf_unprotect(1); | 61 | 2 | } |
coerce.c:fuzz_suppress_warnings Line | Count | Source | 53 | 2 | { | 54 | 2 | int error = 0; | 55 | 2 | SEXP warn_call; | 56 | 2 | Rf_protect(warn_call = Rf_lang2(Rf_install("options"), | 57 | 2 | Rf_ScalarInteger(-1))); | 58 | 2 | SET_TAG(CDR(warn_call), Rf_install("warn")); | 59 | 2 | R_tryEval(warn_call, R_GlobalEnv, &error); | 60 | 2 | Rf_unprotect(1); | 61 | 2 | } |
load.c:fuzz_suppress_warnings Line | Count | Source | 53 | 2 | { | 54 | 2 | int error = 0; | 55 | 2 | SEXP warn_call; | 56 | 2 | Rf_protect(warn_call = Rf_lang2(Rf_install("options"), | 57 | 2 | Rf_ScalarInteger(-1))); | 58 | 2 | SET_TAG(CDR(warn_call), Rf_install("warn")); | 59 | 2 | R_tryEval(warn_call, R_GlobalEnv, &error); | 60 | 2 | Rf_unprotect(1); | 61 | 2 | } |
scan.c:fuzz_suppress_warnings Line | Count | Source | 53 | 2 | { | 54 | 2 | int error = 0; | 55 | 2 | SEXP warn_call; | 56 | 2 | Rf_protect(warn_call = Rf_lang2(Rf_install("options"), | 57 | 2 | Rf_ScalarInteger(-1))); | 58 | 2 | SET_TAG(CDR(warn_call), Rf_install("warn")); | 59 | 2 | R_tryEval(warn_call, R_GlobalEnv, &error); | 60 | 2 | Rf_unprotect(1); | 61 | 2 | } |
colors.c:fuzz_suppress_warnings Line | Count | Source | 53 | 2 | { | 54 | 2 | int error = 0; | 55 | 2 | SEXP warn_call; | 56 | 2 | Rf_protect(warn_call = Rf_lang2(Rf_install("options"), | 57 | 2 | Rf_ScalarInteger(-1))); | 58 | 2 | SET_TAG(CDR(warn_call), Rf_install("warn")); | 59 | 2 | R_tryEval(warn_call, R_GlobalEnv, &error); | 60 | 2 | Rf_unprotect(1); | 61 | 2 | } |
parse.c:fuzz_suppress_warnings Line | Count | Source | 53 | 2 | { | 54 | 2 | int error = 0; | 55 | 2 | SEXP warn_call; | 56 | 2 | Rf_protect(warn_call = Rf_lang2(Rf_install("options"), | 57 | 2 | Rf_ScalarInteger(-1))); | 58 | 2 | SET_TAG(CDR(warn_call), Rf_install("warn")); | 59 | 2 | R_tryEval(warn_call, R_GlobalEnv, &error); | 60 | 2 | Rf_unprotect(1); | 61 | 2 | } |
sockets.c:fuzz_suppress_warnings Line | Count | Source | 53 | 1 | { | 54 | 1 | int error = 0; | 55 | 1 | SEXP warn_call; | 56 | 1 | Rf_protect(warn_call = Rf_lang2(Rf_install("options"), | 57 | 1 | Rf_ScalarInteger(-1))); | 58 | 1 | SET_TAG(CDR(warn_call), Rf_install("warn")); | 59 | 1 | R_tryEval(warn_call, R_GlobalEnv, &error); | 60 | 1 | Rf_unprotect(1); | 61 | 1 | } |
sprintf.c:fuzz_suppress_warnings Line | Count | Source | 53 | 2 | { | 54 | 2 | int error = 0; | 55 | 2 | SEXP warn_call; | 56 | 2 | Rf_protect(warn_call = Rf_lang2(Rf_install("options"), | 57 | 2 | Rf_ScalarInteger(-1))); | 58 | 2 | SET_TAG(CDR(warn_call), Rf_install("warn")); | 59 | 2 | R_tryEval(warn_call, R_GlobalEnv, &error); | 60 | 2 | Rf_unprotect(1); | 61 | 2 | } |
eval.c:fuzz_suppress_warnings Line | Count | Source | 53 | 2 | { | 54 | 2 | int error = 0; | 55 | 2 | SEXP warn_call; | 56 | 2 | Rf_protect(warn_call = Rf_lang2(Rf_install("options"), | 57 | 2 | Rf_ScalarInteger(-1))); | 58 | 2 | SET_TAG(CDR(warn_call), Rf_install("warn")); | 59 | 2 | R_tryEval(warn_call, R_GlobalEnv, &error); | 60 | 2 | Rf_unprotect(1); | 61 | 2 | } |
zip.c:fuzz_suppress_warnings Line | Count | Source | 53 | 2 | { | 54 | 2 | int error = 0; | 55 | 2 | SEXP warn_call; | 56 | 2 | Rf_protect(warn_call = Rf_lang2(Rf_install("options"), | 57 | 2 | Rf_ScalarInteger(-1))); | 58 | 2 | SET_TAG(CDR(warn_call), Rf_install("warn")); | 59 | 2 | R_tryEval(warn_call, R_GlobalEnv, &error); | 60 | 2 | Rf_unprotect(1); | 61 | 2 | } |
|
62 | | |
63 | | /* |
64 | | * Set R_HOME based on the fuzzer binary's location. |
65 | | * |
66 | | * OSS-Fuzz places everything in $OUT. The build.sh installs R to |
67 | | * $OUT/r-install, so R_HOME is at $OUT/r-install/lib/R. We derive |
68 | | * this from /proc/self/exe so it works regardless of the mount path. |
69 | | */ |
70 | | static void fuzz_set_r_home(void) |
71 | 39 | { |
72 | | /* Skip if R_HOME is already set (e.g., for local testing) */ |
73 | 39 | if (getenv("R_HOME") != NULL) |
74 | 19 | return; |
75 | | |
76 | 20 | char exe[PATH_MAX]; |
77 | 20 | ssize_t len = readlink("/proc/self/exe", exe, sizeof(exe) - 1); |
78 | 20 | if (len <= 0) |
79 | 0 | return; |
80 | 20 | exe[len] = '\0'; |
81 | | |
82 | | /* Find the directory containing the binary */ |
83 | 20 | char *slash = strrchr(exe, '/'); |
84 | 20 | if (slash == NULL) |
85 | 0 | return; |
86 | 20 | *slash = '\0'; |
87 | | |
88 | 20 | char r_home[PATH_MAX]; |
89 | 20 | snprintf(r_home, sizeof(r_home), "%s/r-install/lib/R", exe); |
90 | 20 | setenv("R_HOME", r_home, 1); |
91 | 20 | } Line | Count | Source | 71 | 2 | { | 72 | | /* Skip if R_HOME is already set (e.g., for local testing) */ | 73 | 2 | if (getenv("R_HOME") != NULL) | 74 | 1 | return; | 75 | | | 76 | 1 | char exe[PATH_MAX]; | 77 | 1 | ssize_t len = readlink("/proc/self/exe", exe, sizeof(exe) - 1); | 78 | 1 | if (len <= 0) | 79 | 0 | return; | 80 | 1 | exe[len] = '\0'; | 81 | | | 82 | | /* Find the directory containing the binary */ | 83 | 1 | char *slash = strrchr(exe, '/'); | 84 | 1 | if (slash == NULL) | 85 | 0 | return; | 86 | 1 | *slash = '\0'; | 87 | | | 88 | 1 | char r_home[PATH_MAX]; | 89 | 1 | snprintf(r_home, sizeof(r_home), "%s/r-install/lib/R", exe); | 90 | 1 | setenv("R_HOME", r_home, 1); | 91 | 1 | } |
Line | Count | Source | 71 | 2 | { | 72 | | /* Skip if R_HOME is already set (e.g., for local testing) */ | 73 | 2 | if (getenv("R_HOME") != NULL) | 74 | 1 | return; | 75 | | | 76 | 1 | char exe[PATH_MAX]; | 77 | 1 | ssize_t len = readlink("/proc/self/exe", exe, sizeof(exe) - 1); | 78 | 1 | if (len <= 0) | 79 | 0 | return; | 80 | 1 | exe[len] = '\0'; | 81 | | | 82 | | /* Find the directory containing the binary */ | 83 | 1 | char *slash = strrchr(exe, '/'); | 84 | 1 | if (slash == NULL) | 85 | 0 | return; | 86 | 1 | *slash = '\0'; | 87 | | | 88 | 1 | char r_home[PATH_MAX]; | 89 | 1 | snprintf(r_home, sizeof(r_home), "%s/r-install/lib/R", exe); | 90 | 1 | setenv("R_HOME", r_home, 1); | 91 | 1 | } |
character.c:fuzz_set_r_home Line | Count | Source | 71 | 2 | { | 72 | | /* Skip if R_HOME is already set (e.g., for local testing) */ | 73 | 2 | if (getenv("R_HOME") != NULL) | 74 | 1 | return; | 75 | | | 76 | 1 | char exe[PATH_MAX]; | 77 | 1 | ssize_t len = readlink("/proc/self/exe", exe, sizeof(exe) - 1); | 78 | 1 | if (len <= 0) | 79 | 0 | return; | 80 | 1 | exe[len] = '\0'; | 81 | | | 82 | | /* Find the directory containing the binary */ | 83 | 1 | char *slash = strrchr(exe, '/'); | 84 | 1 | if (slash == NULL) | 85 | 0 | return; | 86 | 1 | *slash = '\0'; | 87 | | | 88 | 1 | char r_home[PATH_MAX]; | 89 | 1 | snprintf(r_home, sizeof(r_home), "%s/r-install/lib/R", exe); | 90 | 1 | setenv("R_HOME", r_home, 1); | 91 | 1 | } |
encoding.c:fuzz_set_r_home Line | Count | Source | 71 | 2 | { | 72 | | /* Skip if R_HOME is already set (e.g., for local testing) */ | 73 | 2 | if (getenv("R_HOME") != NULL) | 74 | 1 | return; | 75 | | | 76 | 1 | char exe[PATH_MAX]; | 77 | 1 | ssize_t len = readlink("/proc/self/exe", exe, sizeof(exe) - 1); | 78 | 1 | if (len <= 0) | 79 | 0 | return; | 80 | 1 | exe[len] = '\0'; | 81 | | | 82 | | /* Find the directory containing the binary */ | 83 | 1 | char *slash = strrchr(exe, '/'); | 84 | 1 | if (slash == NULL) | 85 | 0 | return; | 86 | 1 | *slash = '\0'; | 87 | | | 88 | 1 | char r_home[PATH_MAX]; | 89 | 1 | snprintf(r_home, sizeof(r_home), "%s/r-install/lib/R", exe); | 90 | 1 | setenv("R_HOME", r_home, 1); | 91 | 1 | } |
Line | Count | Source | 71 | 2 | { | 72 | | /* Skip if R_HOME is already set (e.g., for local testing) */ | 73 | 2 | if (getenv("R_HOME") != NULL) | 74 | 1 | return; | 75 | | | 76 | 1 | char exe[PATH_MAX]; | 77 | 1 | ssize_t len = readlink("/proc/self/exe", exe, sizeof(exe) - 1); | 78 | 1 | if (len <= 0) | 79 | 0 | return; | 80 | 1 | exe[len] = '\0'; | 81 | | | 82 | | /* Find the directory containing the binary */ | 83 | 1 | char *slash = strrchr(exe, '/'); | 84 | 1 | if (slash == NULL) | 85 | 0 | return; | 86 | 1 | *slash = '\0'; | 87 | | | 88 | 1 | char r_home[PATH_MAX]; | 89 | 1 | snprintf(r_home, sizeof(r_home), "%s/r-install/lib/R", exe); | 90 | 1 | setenv("R_HOME", r_home, 1); | 91 | 1 | } |
connections.c:fuzz_set_r_home Line | Count | Source | 71 | 2 | { | 72 | | /* Skip if R_HOME is already set (e.g., for local testing) */ | 73 | 2 | if (getenv("R_HOME") != NULL) | 74 | 1 | return; | 75 | | | 76 | 1 | char exe[PATH_MAX]; | 77 | 1 | ssize_t len = readlink("/proc/self/exe", exe, sizeof(exe) - 1); | 78 | 1 | if (len <= 0) | 79 | 0 | return; | 80 | 1 | exe[len] = '\0'; | 81 | | | 82 | | /* Find the directory containing the binary */ | 83 | 1 | char *slash = strrchr(exe, '/'); | 84 | 1 | if (slash == NULL) | 85 | 0 | return; | 86 | 1 | *slash = '\0'; | 87 | | | 88 | 1 | char r_home[PATH_MAX]; | 89 | 1 | snprintf(r_home, sizeof(r_home), "%s/r-install/lib/R", exe); | 90 | 1 | setenv("R_HOME", r_home, 1); | 91 | 1 | } |
unserialize.c:fuzz_set_r_home Line | Count | Source | 71 | 2 | { | 72 | | /* Skip if R_HOME is already set (e.g., for local testing) */ | 73 | 2 | if (getenv("R_HOME") != NULL) | 74 | 1 | return; | 75 | | | 76 | 1 | char exe[PATH_MAX]; | 77 | 1 | ssize_t len = readlink("/proc/self/exe", exe, sizeof(exe) - 1); | 78 | 1 | if (len <= 0) | 79 | 0 | return; | 80 | 1 | exe[len] = '\0'; | 81 | | | 82 | | /* Find the directory containing the binary */ | 83 | 1 | char *slash = strrchr(exe, '/'); | 84 | 1 | if (slash == NULL) | 85 | 0 | return; | 86 | 1 | *slash = '\0'; | 87 | | | 88 | 1 | char r_home[PATH_MAX]; | 89 | 1 | snprintf(r_home, sizeof(r_home), "%s/r-install/lib/R", exe); | 90 | 1 | setenv("R_HOME", r_home, 1); | 91 | 1 | } |
decompress.c:fuzz_set_r_home Line | Count | Source | 71 | 2 | { | 72 | | /* Skip if R_HOME is already set (e.g., for local testing) */ | 73 | 2 | if (getenv("R_HOME") != NULL) | 74 | 1 | return; | 75 | | | 76 | 1 | char exe[PATH_MAX]; | 77 | 1 | ssize_t len = readlink("/proc/self/exe", exe, sizeof(exe) - 1); | 78 | 1 | if (len <= 0) | 79 | 0 | return; | 80 | 1 | exe[len] = '\0'; | 81 | | | 82 | | /* Find the directory containing the binary */ | 83 | 1 | char *slash = strrchr(exe, '/'); | 84 | 1 | if (slash == NULL) | 85 | 0 | return; | 86 | 1 | *slash = '\0'; | 87 | | | 88 | 1 | char r_home[PATH_MAX]; | 89 | 1 | snprintf(r_home, sizeof(r_home), "%s/r-install/lib/R", exe); | 90 | 1 | setenv("R_HOME", r_home, 1); | 91 | 1 | } |
readtable.c:fuzz_set_r_home Line | Count | Source | 71 | 2 | { | 72 | | /* Skip if R_HOME is already set (e.g., for local testing) */ | 73 | 2 | if (getenv("R_HOME") != NULL) | 74 | 1 | return; | 75 | | | 76 | 1 | char exe[PATH_MAX]; | 77 | 1 | ssize_t len = readlink("/proc/self/exe", exe, sizeof(exe) - 1); | 78 | 1 | if (len <= 0) | 79 | 0 | return; | 80 | 1 | exe[len] = '\0'; | 81 | | | 82 | | /* Find the directory containing the binary */ | 83 | 1 | char *slash = strrchr(exe, '/'); | 84 | 1 | if (slash == NULL) | 85 | 0 | return; | 86 | 1 | *slash = '\0'; | 87 | | | 88 | 1 | char r_home[PATH_MAX]; | 89 | 1 | snprintf(r_home, sizeof(r_home), "%s/r-install/lib/R", exe); | 90 | 1 | setenv("R_HOME", r_home, 1); | 91 | 1 | } |
Line | Count | Source | 71 | 2 | { | 72 | | /* Skip if R_HOME is already set (e.g., for local testing) */ | 73 | 2 | if (getenv("R_HOME") != NULL) | 74 | 1 | return; | 75 | | | 76 | 1 | char exe[PATH_MAX]; | 77 | 1 | ssize_t len = readlink("/proc/self/exe", exe, sizeof(exe) - 1); | 78 | 1 | if (len <= 0) | 79 | 0 | return; | 80 | 1 | exe[len] = '\0'; | 81 | | | 82 | | /* Find the directory containing the binary */ | 83 | 1 | char *slash = strrchr(exe, '/'); | 84 | 1 | if (slash == NULL) | 85 | 0 | return; | 86 | 1 | *slash = '\0'; | 87 | | | 88 | 1 | char r_home[PATH_MAX]; | 89 | 1 | snprintf(r_home, sizeof(r_home), "%s/r-install/lib/R", exe); | 90 | 1 | setenv("R_HOME", r_home, 1); | 91 | 1 | } |
datetime.c:fuzz_set_r_home Line | Count | Source | 71 | 2 | { | 72 | | /* Skip if R_HOME is already set (e.g., for local testing) */ | 73 | 2 | if (getenv("R_HOME") != NULL) | 74 | 1 | return; | 75 | | | 76 | 1 | char exe[PATH_MAX]; | 77 | 1 | ssize_t len = readlink("/proc/self/exe", exe, sizeof(exe) - 1); | 78 | 1 | if (len <= 0) | 79 | 0 | return; | 80 | 1 | exe[len] = '\0'; | 81 | | | 82 | | /* Find the directory containing the binary */ | 83 | 1 | char *slash = strrchr(exe, '/'); | 84 | 1 | if (slash == NULL) | 85 | 0 | return; | 86 | 1 | *slash = '\0'; | 87 | | | 88 | 1 | char r_home[PATH_MAX]; | 89 | 1 | snprintf(r_home, sizeof(r_home), "%s/r-install/lib/R", exe); | 90 | 1 | setenv("R_HOME", r_home, 1); | 91 | 1 | } |
Line | Count | Source | 71 | 2 | { | 72 | | /* Skip if R_HOME is already set (e.g., for local testing) */ | 73 | 2 | if (getenv("R_HOME") != NULL) | 74 | 1 | return; | 75 | | | 76 | 1 | char exe[PATH_MAX]; | 77 | 1 | ssize_t len = readlink("/proc/self/exe", exe, sizeof(exe) - 1); | 78 | 1 | if (len <= 0) | 79 | 0 | return; | 80 | 1 | exe[len] = '\0'; | 81 | | | 82 | | /* Find the directory containing the binary */ | 83 | 1 | char *slash = strrchr(exe, '/'); | 84 | 1 | if (slash == NULL) | 85 | 0 | return; | 86 | 1 | *slash = '\0'; | 87 | | | 88 | 1 | char r_home[PATH_MAX]; | 89 | 1 | snprintf(r_home, sizeof(r_home), "%s/r-install/lib/R", exe); | 90 | 1 | setenv("R_HOME", r_home, 1); | 91 | 1 | } |
Line | Count | Source | 71 | 2 | { | 72 | | /* Skip if R_HOME is already set (e.g., for local testing) */ | 73 | 2 | if (getenv("R_HOME") != NULL) | 74 | 1 | return; | 75 | | | 76 | 1 | char exe[PATH_MAX]; | 77 | 1 | ssize_t len = readlink("/proc/self/exe", exe, sizeof(exe) - 1); | 78 | 1 | if (len <= 0) | 79 | 0 | return; | 80 | 1 | exe[len] = '\0'; | 81 | | | 82 | | /* Find the directory containing the binary */ | 83 | 1 | char *slash = strrchr(exe, '/'); | 84 | 1 | if (slash == NULL) | 85 | 0 | return; | 86 | 1 | *slash = '\0'; | 87 | | | 88 | 1 | char r_home[PATH_MAX]; | 89 | 1 | snprintf(r_home, sizeof(r_home), "%s/r-install/lib/R", exe); | 90 | 1 | setenv("R_HOME", r_home, 1); | 91 | 1 | } |
Line | Count | Source | 71 | 2 | { | 72 | | /* Skip if R_HOME is already set (e.g., for local testing) */ | 73 | 2 | if (getenv("R_HOME") != NULL) | 74 | 1 | return; | 75 | | | 76 | 1 | char exe[PATH_MAX]; | 77 | 1 | ssize_t len = readlink("/proc/self/exe", exe, sizeof(exe) - 1); | 78 | 1 | if (len <= 0) | 79 | 0 | return; | 80 | 1 | exe[len] = '\0'; | 81 | | | 82 | | /* Find the directory containing the binary */ | 83 | 1 | char *slash = strrchr(exe, '/'); | 84 | 1 | if (slash == NULL) | 85 | 0 | return; | 86 | 1 | *slash = '\0'; | 87 | | | 88 | 1 | char r_home[PATH_MAX]; | 89 | 1 | snprintf(r_home, sizeof(r_home), "%s/r-install/lib/R", exe); | 90 | 1 | setenv("R_HOME", r_home, 1); | 91 | 1 | } |
Line | Count | Source | 71 | 2 | { | 72 | | /* Skip if R_HOME is already set (e.g., for local testing) */ | 73 | 2 | if (getenv("R_HOME") != NULL) | 74 | 1 | return; | 75 | | | 76 | 1 | char exe[PATH_MAX]; | 77 | 1 | ssize_t len = readlink("/proc/self/exe", exe, sizeof(exe) - 1); | 78 | 1 | if (len <= 0) | 79 | 0 | return; | 80 | 1 | exe[len] = '\0'; | 81 | | | 82 | | /* Find the directory containing the binary */ | 83 | 1 | char *slash = strrchr(exe, '/'); | 84 | 1 | if (slash == NULL) | 85 | 0 | return; | 86 | 1 | *slash = '\0'; | 87 | | | 88 | 1 | char r_home[PATH_MAX]; | 89 | 1 | snprintf(r_home, sizeof(r_home), "%s/r-install/lib/R", exe); | 90 | 1 | setenv("R_HOME", r_home, 1); | 91 | 1 | } |
Line | Count | Source | 71 | 2 | { | 72 | | /* Skip if R_HOME is already set (e.g., for local testing) */ | 73 | 2 | if (getenv("R_HOME") != NULL) | 74 | 1 | return; | 75 | | | 76 | 1 | char exe[PATH_MAX]; | 77 | 1 | ssize_t len = readlink("/proc/self/exe", exe, sizeof(exe) - 1); | 78 | 1 | if (len <= 0) | 79 | 0 | return; | 80 | 1 | exe[len] = '\0'; | 81 | | | 82 | | /* Find the directory containing the binary */ | 83 | 1 | char *slash = strrchr(exe, '/'); | 84 | 1 | if (slash == NULL) | 85 | 0 | return; | 86 | 1 | *slash = '\0'; | 87 | | | 88 | 1 | char r_home[PATH_MAX]; | 89 | 1 | snprintf(r_home, sizeof(r_home), "%s/r-install/lib/R", exe); | 90 | 1 | setenv("R_HOME", r_home, 1); | 91 | 1 | } |
sockets.c:fuzz_set_r_home Line | Count | Source | 71 | 1 | { | 72 | | /* Skip if R_HOME is already set (e.g., for local testing) */ | 73 | 1 | if (getenv("R_HOME") != NULL) | 74 | 0 | return; | 75 | | | 76 | 1 | char exe[PATH_MAX]; | 77 | 1 | ssize_t len = readlink("/proc/self/exe", exe, sizeof(exe) - 1); | 78 | 1 | if (len <= 0) | 79 | 0 | return; | 80 | 1 | exe[len] = '\0'; | 81 | | | 82 | | /* Find the directory containing the binary */ | 83 | 1 | char *slash = strrchr(exe, '/'); | 84 | 1 | if (slash == NULL) | 85 | 0 | return; | 86 | 1 | *slash = '\0'; | 87 | | | 88 | 1 | char r_home[PATH_MAX]; | 89 | 1 | snprintf(r_home, sizeof(r_home), "%s/r-install/lib/R", exe); | 90 | 1 | setenv("R_HOME", r_home, 1); | 91 | 1 | } |
sprintf.c:fuzz_set_r_home Line | Count | Source | 71 | 2 | { | 72 | | /* Skip if R_HOME is already set (e.g., for local testing) */ | 73 | 2 | if (getenv("R_HOME") != NULL) | 74 | 1 | return; | 75 | | | 76 | 1 | char exe[PATH_MAX]; | 77 | 1 | ssize_t len = readlink("/proc/self/exe", exe, sizeof(exe) - 1); | 78 | 1 | if (len <= 0) | 79 | 0 | return; | 80 | 1 | exe[len] = '\0'; | 81 | | | 82 | | /* Find the directory containing the binary */ | 83 | 1 | char *slash = strrchr(exe, '/'); | 84 | 1 | if (slash == NULL) | 85 | 0 | return; | 86 | 1 | *slash = '\0'; | 87 | | | 88 | 1 | char r_home[PATH_MAX]; | 89 | 1 | snprintf(r_home, sizeof(r_home), "%s/r-install/lib/R", exe); | 90 | 1 | setenv("R_HOME", r_home, 1); | 91 | 1 | } |
Line | Count | Source | 71 | 2 | { | 72 | | /* Skip if R_HOME is already set (e.g., for local testing) */ | 73 | 2 | if (getenv("R_HOME") != NULL) | 74 | 1 | return; | 75 | | | 76 | 1 | char exe[PATH_MAX]; | 77 | 1 | ssize_t len = readlink("/proc/self/exe", exe, sizeof(exe) - 1); | 78 | 1 | if (len <= 0) | 79 | 0 | return; | 80 | 1 | exe[len] = '\0'; | 81 | | | 82 | | /* Find the directory containing the binary */ | 83 | 1 | char *slash = strrchr(exe, '/'); | 84 | 1 | if (slash == NULL) | 85 | 0 | return; | 86 | 1 | *slash = '\0'; | 87 | | | 88 | 1 | char r_home[PATH_MAX]; | 89 | 1 | snprintf(r_home, sizeof(r_home), "%s/r-install/lib/R", exe); | 90 | 1 | setenv("R_HOME", r_home, 1); | 91 | 1 | } |
Line | Count | Source | 71 | 2 | { | 72 | | /* Skip if R_HOME is already set (e.g., for local testing) */ | 73 | 2 | if (getenv("R_HOME") != NULL) | 74 | 1 | return; | 75 | | | 76 | 1 | char exe[PATH_MAX]; | 77 | 1 | ssize_t len = readlink("/proc/self/exe", exe, sizeof(exe) - 1); | 78 | 1 | if (len <= 0) | 79 | 0 | return; | 80 | 1 | exe[len] = '\0'; | 81 | | | 82 | | /* Find the directory containing the binary */ | 83 | 1 | char *slash = strrchr(exe, '/'); | 84 | 1 | if (slash == NULL) | 85 | 0 | return; | 86 | 1 | *slash = '\0'; | 87 | | | 88 | 1 | char r_home[PATH_MAX]; | 89 | 1 | snprintf(r_home, sizeof(r_home), "%s/r-install/lib/R", exe); | 90 | 1 | setenv("R_HOME", r_home, 1); | 91 | 1 | } |
|
92 | | |
93 | | /* |
94 | | * Cap R's vector heap. |
95 | | * |
96 | | * Hostile input reaches R's allocator directly -- a serialized vector can |
97 | | * declare any length it likes, and coercion or scanning can be talked into |
98 | | * asking for one -- so a 64KB input can request gigabytes. |
99 | | * |
100 | | * R enforces R_MAX_VSIZE in allocVector and signals an ordinary R error |
101 | | * ("vector memory limit of N reached"). When it fires inside R_ToplevelExec |
102 | | * the iteration is discarded and fuzzing carries on; every per-iteration |
103 | | * allocation must therefore go through fuzz_set_string / fuzz_set_raw_arg |
104 | | * below, which run under such a context. That catchability is the reason |
105 | | * to prefer this over a sanitizer-level RSS limit: ASAN's soft_rss_limit_mb |
106 | | * either aborts the process or starts handing NULL back to allocators that |
107 | | * never expected it, and both look like crashes. |
108 | | * |
109 | | * Caveats: |
110 | | * - The cap bounds R's cumulative LIVE vector heap, not one input's |
111 | | * allocations. Interned symbols are never collected, so the parse and |
112 | | * unserialize targets ratchet toward the cap over a long run. |
113 | | * - It bounds R's vector heap ONLY. malloc-based allocations, like TRE |
114 | | * compiling a pattern, bypass it entirely; see |
115 | | * fuzz_repeat_product_excessive for that guard. |
116 | | * - It does cost coverage of code paths that need larger results. |
117 | | * A target can change the default by defining FUZZ_R_MAX_VSIZE |
118 | | * before including this header (eval and unserialize lower it). |
119 | | * Raising it past ClusterFuzz's -rss_limit_mb=2560 is pointless: |
120 | | * libFuzzer kills the process as out-of-memory before R's limit |
121 | | * can turn the allocation into an error (decompress, Nov 2026). |
122 | | * - R's suffix parsing is case-sensitive: "4Gb" works, "4gb" silently |
123 | | * leaves the heap uncapped (R only warns on stderr at startup). The |
124 | | * env override is for local runs; the CI runner does not forward |
125 | | * arbitrary environment variables. |
126 | | * |
127 | | * Local reproduction of vector-limit findings under plain Rscript needs |
128 | | * the same value exported; see README.md. |
129 | | */ |
130 | | #ifndef FUZZ_R_MAX_VSIZE |
131 | 18 | # define FUZZ_R_MAX_VSIZE "1Gb" |
132 | | #endif |
133 | | |
134 | | static void fuzz_set_vsize_limit(void) |
135 | 39 | { |
136 | 39 | if (getenv("R_MAX_VSIZE") == NULL) |
137 | 20 | setenv("R_MAX_VSIZE", FUZZ_R_MAX_VSIZE, 1); |
138 | 39 | } io.c:fuzz_set_vsize_limit Line | Count | Source | 135 | 2 | { | 136 | 2 | if (getenv("R_MAX_VSIZE") == NULL) | 137 | 1 | setenv("R_MAX_VSIZE", FUZZ_R_MAX_VSIZE, 1); | 138 | 2 | } |
dcf.c:fuzz_set_vsize_limit Line | Count | Source | 135 | 2 | { | 136 | 2 | if (getenv("R_MAX_VSIZE") == NULL) | 137 | 1 | setenv("R_MAX_VSIZE", FUZZ_R_MAX_VSIZE, 1); | 138 | 2 | } |
character.c:fuzz_set_vsize_limit Line | Count | Source | 135 | 2 | { | 136 | 2 | if (getenv("R_MAX_VSIZE") == NULL) | 137 | 1 | setenv("R_MAX_VSIZE", FUZZ_R_MAX_VSIZE, 1); | 138 | 2 | } |
encoding.c:fuzz_set_vsize_limit Line | Count | Source | 135 | 2 | { | 136 | 2 | if (getenv("R_MAX_VSIZE") == NULL) | 137 | 1 | setenv("R_MAX_VSIZE", FUZZ_R_MAX_VSIZE, 1); | 138 | 2 | } |
sort.c:fuzz_set_vsize_limit Line | Count | Source | 135 | 2 | { | 136 | 2 | if (getenv("R_MAX_VSIZE") == NULL) | 137 | 1 | setenv("R_MAX_VSIZE", FUZZ_R_MAX_VSIZE, 1); | 138 | 2 | } |
connections.c:fuzz_set_vsize_limit Line | Count | Source | 135 | 2 | { | 136 | 2 | if (getenv("R_MAX_VSIZE") == NULL) | 137 | 1 | setenv("R_MAX_VSIZE", FUZZ_R_MAX_VSIZE, 1); | 138 | 2 | } |
unserialize.c:fuzz_set_vsize_limit Line | Count | Source | 135 | 2 | { | 136 | 2 | if (getenv("R_MAX_VSIZE") == NULL) | 137 | 1 | setenv("R_MAX_VSIZE", FUZZ_R_MAX_VSIZE, 1); | 138 | 2 | } |
decompress.c:fuzz_set_vsize_limit Line | Count | Source | 135 | 2 | { | 136 | 2 | if (getenv("R_MAX_VSIZE") == NULL) | 137 | 1 | setenv("R_MAX_VSIZE", FUZZ_R_MAX_VSIZE, 1); | 138 | 2 | } |
readtable.c:fuzz_set_vsize_limit Line | Count | Source | 135 | 2 | { | 136 | 2 | if (getenv("R_MAX_VSIZE") == NULL) | 137 | 1 | setenv("R_MAX_VSIZE", FUZZ_R_MAX_VSIZE, 1); | 138 | 2 | } |
format.c:fuzz_set_vsize_limit Line | Count | Source | 135 | 2 | { | 136 | 2 | if (getenv("R_MAX_VSIZE") == NULL) | 137 | 1 | setenv("R_MAX_VSIZE", FUZZ_R_MAX_VSIZE, 1); | 138 | 2 | } |
datetime.c:fuzz_set_vsize_limit Line | Count | Source | 135 | 2 | { | 136 | 2 | if (getenv("R_MAX_VSIZE") == NULL) | 137 | 1 | setenv("R_MAX_VSIZE", FUZZ_R_MAX_VSIZE, 1); | 138 | 2 | } |
coerce.c:fuzz_set_vsize_limit Line | Count | Source | 135 | 2 | { | 136 | 2 | if (getenv("R_MAX_VSIZE") == NULL) | 137 | 1 | setenv("R_MAX_VSIZE", FUZZ_R_MAX_VSIZE, 1); | 138 | 2 | } |
load.c:fuzz_set_vsize_limit Line | Count | Source | 135 | 2 | { | 136 | 2 | if (getenv("R_MAX_VSIZE") == NULL) | 137 | 1 | setenv("R_MAX_VSIZE", FUZZ_R_MAX_VSIZE, 1); | 138 | 2 | } |
scan.c:fuzz_set_vsize_limit Line | Count | Source | 135 | 2 | { | 136 | 2 | if (getenv("R_MAX_VSIZE") == NULL) | 137 | 1 | setenv("R_MAX_VSIZE", FUZZ_R_MAX_VSIZE, 1); | 138 | 2 | } |
colors.c:fuzz_set_vsize_limit Line | Count | Source | 135 | 2 | { | 136 | 2 | if (getenv("R_MAX_VSIZE") == NULL) | 137 | 1 | setenv("R_MAX_VSIZE", FUZZ_R_MAX_VSIZE, 1); | 138 | 2 | } |
parse.c:fuzz_set_vsize_limit Line | Count | Source | 135 | 2 | { | 136 | 2 | if (getenv("R_MAX_VSIZE") == NULL) | 137 | 1 | setenv("R_MAX_VSIZE", FUZZ_R_MAX_VSIZE, 1); | 138 | 2 | } |
sockets.c:fuzz_set_vsize_limit Line | Count | Source | 135 | 1 | { | 136 | 1 | if (getenv("R_MAX_VSIZE") == NULL) | 137 | 1 | setenv("R_MAX_VSIZE", FUZZ_R_MAX_VSIZE, 1); | 138 | 1 | } |
sprintf.c:fuzz_set_vsize_limit Line | Count | Source | 135 | 2 | { | 136 | 2 | if (getenv("R_MAX_VSIZE") == NULL) | 137 | 1 | setenv("R_MAX_VSIZE", FUZZ_R_MAX_VSIZE, 1); | 138 | 2 | } |
eval.c:fuzz_set_vsize_limit Line | Count | Source | 135 | 2 | { | 136 | 2 | if (getenv("R_MAX_VSIZE") == NULL) | 137 | 1 | setenv("R_MAX_VSIZE", FUZZ_R_MAX_VSIZE, 1); | 138 | 2 | } |
zip.c:fuzz_set_vsize_limit Line | Count | Source | 135 | 2 | { | 136 | 2 | if (getenv("R_MAX_VSIZE") == NULL) | 137 | 1 | setenv("R_MAX_VSIZE", FUZZ_R_MAX_VSIZE, 1); | 138 | 2 | } |
|
139 | | |
140 | | /* |
141 | | * Run R on its own thread with a large stack. |
142 | | * |
143 | | * Several of R's recursive C walkers never call R_CheckStack(): bind.c's |
144 | | * AnswerType behind c(recursive = TRUE), deparse.c behind |
145 | | * as.character(<list>), and the coerce, duplicate, identical and subassign |
146 | | * walkers. A list some tens of thousands deep, which an input can build |
147 | | * at run time, overflows the 8 MiB main-thread stack in them. Plain R |
148 | | * reports "segfault from C stack overflow" and recovers, long-standing |
149 | | * behaviour rather than a defect to report; under the sanitizers it is a |
150 | | * stack-overflow crash that every target walking a nested value would |
151 | | * keep rediscovering. |
152 | | * |
153 | | * The main thread's stack is fixed before the process starts, so R runs |
154 | | * on a worker thread created with FUZZ_R_STACK_SIZE of stack instead: |
155 | | * deep enough that any recursion an input can afford within the per-input |
156 | | * limits completes, and virtual until touched, so it costs an idle target |
157 | | * nothing. |
158 | | * |
159 | | * Everything that touches R -- initialization, every input, the checks |
160 | | * under tests/ -- must run on that thread: R records its stack bounds |
161 | | * once, and R_CheckStack() measures against them. The libFuzzer entry |
162 | | * points at the end of this header forward to fuzz_target_init and |
163 | | * fuzz_target_run there, and fuzz_init_r() refuses to run anywhere else. |
164 | | * |
165 | | * The thread does not survive a fork, and AFL++'s driver forks: its |
166 | | * forkserver starts after LLVMFuzzerInitialize, so every input runs in a |
167 | | * child that inherited the initialized R but no thread to run it on. |
168 | | * An atfork handler forgets the thread in the child, and the next job |
169 | | * starts a fresh one, which points R's stack check at its own stack. |
170 | | */ |
171 | | #ifndef FUZZ_R_STACK_SIZE |
172 | 78 | # define FUZZ_R_STACK_SIZE ((size_t)1 << 30) |
173 | | #endif |
174 | | |
175 | | typedef struct { |
176 | | void (*fn)(void *); |
177 | | void *arg; |
178 | | } fuzz_job_t; |
179 | | |
180 | | static struct { |
181 | | pthread_t thread; |
182 | | int started; |
183 | | pthread_mutex_t mutex; |
184 | | pthread_cond_t cond; |
185 | | fuzz_job_t *job; /* set by the caller, cleared by the thread */ |
186 | | uintptr_t stack_top; /* where the thread's frames begin */ |
187 | | } fuzz_r_thread = { |
188 | | .mutex = PTHREAD_MUTEX_INITIALIZER, |
189 | | .cond = PTHREAD_COND_INITIALIZER |
190 | | }; |
191 | | |
192 | | /* |
193 | | * Timeout diagnostics. |
194 | | * |
195 | | * With the alarm confined to the main thread, libFuzzer's timeout report |
196 | | * would show that thread waiting in fuzz_run_on_r_thread and nothing of |
197 | | * where R is. So once libFuzzer has installed its SIGALRM handler, a |
198 | | * wrapper takes its place: on a tick where libFuzzer may time the input |
199 | | * out, it first signals the R thread, which prints its own stack, and |
200 | | * then hands the alarm on to libFuzzer, which prints its report and |
201 | | * exits. The wrapper goes in after libFuzzer's startup because libFuzzer |
202 | | * leaves an already-installed SIGALRM handler alone. |
203 | | * |
204 | | * libFuzzer's clock for the input is not visible, but it is bracketed: |
205 | | * it starts after the main thread last went idle (armed) and before the |
206 | | * R thread took the input (started). Every tick (timeout/2+1 s apart) |
207 | | * comes through here. One that finds the input within a second of the |
208 | | * timeout by the armed clock, so possibly out of time by libFuzzer's |
209 | | * after whatever delays this handler, holds until the input is out of |
210 | | * time by the started clock too, which means by libFuzzer's as well; |
211 | | * then the dump is requested and waited for, and the tick goes on to |
212 | | * libFuzzer, which reports the timeout. A tick that finds the input |
213 | | * younger goes straight on, and only one delayed by over a second |
214 | | * between reading the armed clock and libFuzzer reading its own can |
215 | | * still leave a timeout without its dump. The dump pauses the R |
216 | | * thread, so it is taken only for an input already out of time, never |
217 | | * for one that may still finish. |
218 | | * |
219 | | * An input that finishes while a tick is held is not handed to libFuzzer |
220 | | * at all, nor is any tick that queued up meanwhile: it finished within |
221 | | * its time by its own clock, and the hold would be blamed for it. Inputs |
222 | | * are numbered so a dump outstanding from one cannot stand in for the |
223 | | * next's, and the R thread itself announces when an input is running, so |
224 | | * a tick during the handoff finds nothing to dump. |
225 | | */ |
226 | | #ifdef SIGRTMIN |
227 | 19 | # define FUZZ_DUMP_SIGNAL SIGRTMIN /* untouched by libFuzzer, glibc and R */ |
228 | | #else |
229 | | # define FUZZ_DUMP_SIGNAL SIGUSR2 /* macOS: displaces libFuzzer's graceful exit */ |
230 | | #endif |
231 | | |
232 | | extern void __sanitizer_print_stack_trace(void) __attribute__((weak)); |
233 | | |
234 | | static struct { |
235 | | int timeout; /* -timeout=N, seconds */ |
236 | | long poll_ns; /* between looks while holding or waiting */ |
237 | | int wrapped; |
238 | | struct sigaction chain; /* libFuzzer's SIGALRM action */ |
239 | | struct timespec armed; /* main thread idle; libFuzzer's clock starts later */ |
240 | | struct timespec started; /* the R thread took the input; libFuzzer's clock started earlier */ |
241 | | atomic_int running; /* the R thread is inside an input */ |
242 | | atomic_int finishing; /* a held tick saw the input finish */ |
243 | | atomic_uint input; /* numbers the inputs from 1; 0 is none */ |
244 | | atomic_uint requested; /* input whose dump was requested */ |
245 | | atomic_uint done; /* input whose dump has been printed */ |
246 | | } fuzz_alarm = { .timeout = 1200, .poll_ns = 1000 * 1000 }; /* libFuzzer's default */ |
247 | | |
248 | | static void fuzz_write_stderr(const char *s) |
249 | 0 | { |
250 | 0 | ssize_t rc = write(STDERR_FILENO, s, strlen(s)); |
251 | 0 | (void)rc; |
252 | 0 | } Unexecuted instantiation: io.c:fuzz_write_stderr Unexecuted instantiation: dcf.c:fuzz_write_stderr Unexecuted instantiation: character.c:fuzz_write_stderr Unexecuted instantiation: encoding.c:fuzz_write_stderr Unexecuted instantiation: sort.c:fuzz_write_stderr Unexecuted instantiation: connections.c:fuzz_write_stderr Unexecuted instantiation: unserialize.c:fuzz_write_stderr Unexecuted instantiation: decompress.c:fuzz_write_stderr Unexecuted instantiation: readtable.c:fuzz_write_stderr Unexecuted instantiation: format.c:fuzz_write_stderr Unexecuted instantiation: datetime.c:fuzz_write_stderr Unexecuted instantiation: coerce.c:fuzz_write_stderr Unexecuted instantiation: load.c:fuzz_write_stderr Unexecuted instantiation: scan.c:fuzz_write_stderr Unexecuted instantiation: colors.c:fuzz_write_stderr Unexecuted instantiation: parse.c:fuzz_write_stderr Unexecuted instantiation: sockets.c:fuzz_write_stderr Unexecuted instantiation: sprintf.c:fuzz_write_stderr Unexecuted instantiation: eval.c:fuzz_write_stderr Unexecuted instantiation: zip.c:fuzz_write_stderr |
253 | | |
254 | | /* |
255 | | * Slot labels for the timeout dump. |
256 | | * |
257 | | * The R thread's stack is mostly the byte-code interpreter, which says |
258 | | * little about which of a target's calls was running. A harness |
259 | | * registers its calls once with fuzz_label_calls(), which deparses each |
260 | | * while its placeholders still hold their initial values, and the dump |
261 | | * prints the one last entered by fuzz_eval_silent() or fuzz_do_eval() in |
262 | | * the current input. Harnesses that evaluate a registered call another |
263 | | * way note it with fuzz_label_enter(). The text is formatted up front, |
264 | | * so the dump handler only writes it. |
265 | | */ |
266 | 599 | #define FUZZ_MAX_LABELS 128 |
267 | 4.01k | #define FUZZ_LABEL_MAX 4096 |
268 | | |
269 | | static struct { |
270 | | SEXP call; |
271 | | char *text; |
272 | | } fuzz_labels[FUZZ_MAX_LABELS]; |
273 | | static int fuzz_n_labels; |
274 | | static atomic_int fuzz_label_current = -1; /* index into fuzz_labels */ |
275 | | |
276 | | typedef struct { |
277 | | SEXP call; |
278 | | char *buf; /* FUZZ_LABEL_MAX bytes, holding the header */ |
279 | | size_t len; |
280 | | } fuzz_deparse_job_t; |
281 | | |
282 | | /* Append one deparsed line, indented; false if it does not fit with |
283 | | * room left for the closing "...". */ |
284 | | static int fuzz_label_append_line(fuzz_deparse_job_t *job, const char *line) |
285 | 2.81k | { |
286 | 2.81k | size_t n = strlen(line); |
287 | 2.81k | if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof " ...\n") |
288 | 0 | return 0; |
289 | 2.81k | memcpy(job->buf + job->len, " ", 4); |
290 | 2.81k | memcpy(job->buf + job->len + 4, line, n); |
291 | 2.81k | job->buf[job->len + 4 + n] = '\n'; |
292 | 2.81k | job->len += 4 + n + 1; |
293 | 2.81k | job->buf[job->len] = '\0'; |
294 | 2.81k | return 1; |
295 | 2.81k | } io.c:fuzz_label_append_line Line | Count | Source | 285 | 130 | { | 286 | 130 | size_t n = strlen(line); | 287 | 130 | if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof " ...\n") | 288 | 0 | return 0; | 289 | 130 | memcpy(job->buf + job->len, " ", 4); | 290 | 130 | memcpy(job->buf + job->len + 4, line, n); | 291 | 130 | job->buf[job->len + 4 + n] = '\n'; | 292 | 130 | job->len += 4 + n + 1; | 293 | 130 | job->buf[job->len] = '\0'; | 294 | 130 | return 1; | 295 | 130 | } |
dcf.c:fuzz_label_append_line Line | Count | Source | 285 | 24 | { | 286 | 24 | size_t n = strlen(line); | 287 | 24 | if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof " ...\n") | 288 | 0 | return 0; | 289 | 24 | memcpy(job->buf + job->len, " ", 4); | 290 | 24 | memcpy(job->buf + job->len + 4, line, n); | 291 | 24 | job->buf[job->len + 4 + n] = '\n'; | 292 | 24 | job->len += 4 + n + 1; | 293 | 24 | job->buf[job->len] = '\0'; | 294 | 24 | return 1; | 295 | 24 | } |
character.c:fuzz_label_append_line Line | Count | Source | 285 | 68 | { | 286 | 68 | size_t n = strlen(line); | 287 | 68 | if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof " ...\n") | 288 | 0 | return 0; | 289 | 68 | memcpy(job->buf + job->len, " ", 4); | 290 | 68 | memcpy(job->buf + job->len + 4, line, n); | 291 | 68 | job->buf[job->len + 4 + n] = '\n'; | 292 | 68 | job->len += 4 + n + 1; | 293 | 68 | job->buf[job->len] = '\0'; | 294 | 68 | return 1; | 295 | 68 | } |
encoding.c:fuzz_label_append_line Line | Count | Source | 285 | 70 | { | 286 | 70 | size_t n = strlen(line); | 287 | 70 | if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof " ...\n") | 288 | 0 | return 0; | 289 | 70 | memcpy(job->buf + job->len, " ", 4); | 290 | 70 | memcpy(job->buf + job->len + 4, line, n); | 291 | 70 | job->buf[job->len + 4 + n] = '\n'; | 292 | 70 | job->len += 4 + n + 1; | 293 | 70 | job->buf[job->len] = '\0'; | 294 | 70 | return 1; | 295 | 70 | } |
sort.c:fuzz_label_append_line Line | Count | Source | 285 | 360 | { | 286 | 360 | size_t n = strlen(line); | 287 | 360 | if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof " ...\n") | 288 | 0 | return 0; | 289 | 360 | memcpy(job->buf + job->len, " ", 4); | 290 | 360 | memcpy(job->buf + job->len + 4, line, n); | 291 | 360 | job->buf[job->len + 4 + n] = '\n'; | 292 | 360 | job->len += 4 + n + 1; | 293 | 360 | job->buf[job->len] = '\0'; | 294 | 360 | return 1; | 295 | 360 | } |
connections.c:fuzz_label_append_line Line | Count | Source | 285 | 1.01k | { | 286 | 1.01k | size_t n = strlen(line); | 287 | 1.01k | if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof " ...\n") | 288 | 0 | return 0; | 289 | 1.01k | memcpy(job->buf + job->len, " ", 4); | 290 | 1.01k | memcpy(job->buf + job->len + 4, line, n); | 291 | 1.01k | job->buf[job->len + 4 + n] = '\n'; | 292 | 1.01k | job->len += 4 + n + 1; | 293 | 1.01k | job->buf[job->len] = '\0'; | 294 | 1.01k | return 1; | 295 | 1.01k | } |
unserialize.c:fuzz_label_append_line Line | Count | Source | 285 | 40 | { | 286 | 40 | size_t n = strlen(line); | 287 | 40 | if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof " ...\n") | 288 | 0 | return 0; | 289 | 40 | memcpy(job->buf + job->len, " ", 4); | 290 | 40 | memcpy(job->buf + job->len + 4, line, n); | 291 | 40 | job->buf[job->len + 4 + n] = '\n'; | 292 | 40 | job->len += 4 + n + 1; | 293 | 40 | job->buf[job->len] = '\0'; | 294 | 40 | return 1; | 295 | 40 | } |
decompress.c:fuzz_label_append_line Line | Count | Source | 285 | 8 | { | 286 | 8 | size_t n = strlen(line); | 287 | 8 | if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof " ...\n") | 288 | 0 | return 0; | 289 | 8 | memcpy(job->buf + job->len, " ", 4); | 290 | 8 | memcpy(job->buf + job->len + 4, line, n); | 291 | 8 | job->buf[job->len + 4 + n] = '\n'; | 292 | 8 | job->len += 4 + n + 1; | 293 | 8 | job->buf[job->len] = '\0'; | 294 | 8 | return 1; | 295 | 8 | } |
readtable.c:fuzz_label_append_line Line | Count | Source | 285 | 146 | { | 286 | 146 | size_t n = strlen(line); | 287 | 146 | if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof " ...\n") | 288 | 0 | return 0; | 289 | 146 | memcpy(job->buf + job->len, " ", 4); | 290 | 146 | memcpy(job->buf + job->len + 4, line, n); | 291 | 146 | job->buf[job->len + 4 + n] = '\n'; | 292 | 146 | job->len += 4 + n + 1; | 293 | 146 | job->buf[job->len] = '\0'; | 294 | 146 | return 1; | 295 | 146 | } |
format.c:fuzz_label_append_line Line | Count | Source | 285 | 408 | { | 286 | 408 | size_t n = strlen(line); | 287 | 408 | if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof " ...\n") | 288 | 0 | return 0; | 289 | 408 | memcpy(job->buf + job->len, " ", 4); | 290 | 408 | memcpy(job->buf + job->len + 4, line, n); | 291 | 408 | job->buf[job->len + 4 + n] = '\n'; | 292 | 408 | job->len += 4 + n + 1; | 293 | 408 | job->buf[job->len] = '\0'; | 294 | 408 | return 1; | 295 | 408 | } |
datetime.c:fuzz_label_append_line Line | Count | Source | 285 | 82 | { | 286 | 82 | size_t n = strlen(line); | 287 | 82 | if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof " ...\n") | 288 | 0 | return 0; | 289 | 82 | memcpy(job->buf + job->len, " ", 4); | 290 | 82 | memcpy(job->buf + job->len + 4, line, n); | 291 | 82 | job->buf[job->len + 4 + n] = '\n'; | 292 | 82 | job->len += 4 + n + 1; | 293 | 82 | job->buf[job->len] = '\0'; | 294 | 82 | return 1; | 295 | 82 | } |
coerce.c:fuzz_label_append_line Line | Count | Source | 285 | 8 | { | 286 | 8 | size_t n = strlen(line); | 287 | 8 | if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof " ...\n") | 288 | 0 | return 0; | 289 | 8 | memcpy(job->buf + job->len, " ", 4); | 290 | 8 | memcpy(job->buf + job->len + 4, line, n); | 291 | 8 | job->buf[job->len + 4 + n] = '\n'; | 292 | 8 | job->len += 4 + n + 1; | 293 | 8 | job->buf[job->len] = '\0'; | 294 | 8 | return 1; | 295 | 8 | } |
load.c:fuzz_label_append_line Line | Count | Source | 285 | 8 | { | 286 | 8 | size_t n = strlen(line); | 287 | 8 | if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof " ...\n") | 288 | 0 | return 0; | 289 | 8 | memcpy(job->buf + job->len, " ", 4); | 290 | 8 | memcpy(job->buf + job->len + 4, line, n); | 291 | 8 | job->buf[job->len + 4 + n] = '\n'; | 292 | 8 | job->len += 4 + n + 1; | 293 | 8 | job->buf[job->len] = '\0'; | 294 | 8 | return 1; | 295 | 8 | } |
scan.c:fuzz_label_append_line Line | Count | Source | 285 | 76 | { | 286 | 76 | size_t n = strlen(line); | 287 | 76 | if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof " ...\n") | 288 | 0 | return 0; | 289 | 76 | memcpy(job->buf + job->len, " ", 4); | 290 | 76 | memcpy(job->buf + job->len + 4, line, n); | 291 | 76 | job->buf[job->len + 4 + n] = '\n'; | 292 | 76 | job->len += 4 + n + 1; | 293 | 76 | job->buf[job->len] = '\0'; | 294 | 76 | return 1; | 295 | 76 | } |
colors.c:fuzz_label_append_line Line | Count | Source | 285 | 226 | { | 286 | 226 | size_t n = strlen(line); | 287 | 226 | if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof " ...\n") | 288 | 0 | return 0; | 289 | 226 | memcpy(job->buf + job->len, " ", 4); | 290 | 226 | memcpy(job->buf + job->len + 4, line, n); | 291 | 226 | job->buf[job->len + 4 + n] = '\n'; | 292 | 226 | job->len += 4 + n + 1; | 293 | 226 | job->buf[job->len] = '\0'; | 294 | 226 | return 1; | 295 | 226 | } |
parse.c:fuzz_label_append_line Line | Count | Source | 285 | 64 | { | 286 | 64 | size_t n = strlen(line); | 287 | 64 | if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof " ...\n") | 288 | 0 | return 0; | 289 | 64 | memcpy(job->buf + job->len, " ", 4); | 290 | 64 | memcpy(job->buf + job->len + 4, line, n); | 291 | 64 | job->buf[job->len + 4 + n] = '\n'; | 292 | 64 | job->len += 4 + n + 1; | 293 | 64 | job->buf[job->len] = '\0'; | 294 | 64 | return 1; | 295 | 64 | } |
sockets.c:fuzz_label_append_line Line | Count | Source | 285 | 13 | { | 286 | 13 | size_t n = strlen(line); | 287 | 13 | if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof " ...\n") | 288 | 0 | return 0; | 289 | 13 | memcpy(job->buf + job->len, " ", 4); | 290 | 13 | memcpy(job->buf + job->len + 4, line, n); | 291 | 13 | job->buf[job->len + 4 + n] = '\n'; | 292 | 13 | job->len += 4 + n + 1; | 293 | 13 | job->buf[job->len] = '\0'; | 294 | 13 | return 1; | 295 | 13 | } |
sprintf.c:fuzz_label_append_line Line | Count | Source | 285 | 8 | { | 286 | 8 | size_t n = strlen(line); | 287 | 8 | if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof " ...\n") | 288 | 0 | return 0; | 289 | 8 | memcpy(job->buf + job->len, " ", 4); | 290 | 8 | memcpy(job->buf + job->len + 4, line, n); | 291 | 8 | job->buf[job->len + 4 + n] = '\n'; | 292 | 8 | job->len += 4 + n + 1; | 293 | 8 | job->buf[job->len] = '\0'; | 294 | 8 | return 1; | 295 | 8 | } |
Unexecuted instantiation: eval.c:fuzz_label_append_line zip.c:fuzz_label_append_line Line | Count | Source | 285 | 60 | { | 286 | 60 | size_t n = strlen(line); | 287 | 60 | if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof " ...\n") | 288 | 0 | return 0; | 289 | 60 | memcpy(job->buf + job->len, " ", 4); | 290 | 60 | memcpy(job->buf + job->len + 4, line, n); | 291 | 60 | job->buf[job->len + 4 + n] = '\n'; | 292 | 60 | job->len += 4 + n + 1; | 293 | 60 | job->buf[job->len] = '\0'; | 294 | 60 | return 1; | 295 | 60 | } |
|
296 | | |
297 | | static void fuzz_do_deparse(void *data) |
298 | 599 | { |
299 | 599 | fuzz_deparse_job_t *job = data; |
300 | 599 | SEXP quoted, expr, lines; |
301 | 599 | Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call)); |
302 | 599 | Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted)); |
303 | 599 | Rf_protect(lines = Rf_eval(expr, R_BaseEnv)); |
304 | 3.41k | for (R_xlen_t i = 0; i < XLENGTH(lines); i++) { |
305 | 2.81k | if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) { |
306 | 0 | memcpy(job->buf + job->len, " ...\n", sizeof " ...\n"); |
307 | 0 | break; |
308 | 0 | } |
309 | 2.81k | } |
310 | 599 | Rf_unprotect(3); |
311 | 599 | } Line | Count | Source | 298 | 52 | { | 299 | 52 | fuzz_deparse_job_t *job = data; | 300 | 52 | SEXP quoted, expr, lines; | 301 | 52 | Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call)); | 302 | 52 | Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted)); | 303 | 52 | Rf_protect(lines = Rf_eval(expr, R_BaseEnv)); | 304 | 182 | for (R_xlen_t i = 0; i < XLENGTH(lines); i++) { | 305 | 130 | if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) { | 306 | 0 | memcpy(job->buf + job->len, " ...\n", sizeof " ...\n"); | 307 | 0 | break; | 308 | 0 | } | 309 | 130 | } | 310 | 52 | Rf_unprotect(3); | 311 | 52 | } |
Line | Count | Source | 298 | 4 | { | 299 | 4 | fuzz_deparse_job_t *job = data; | 300 | 4 | SEXP quoted, expr, lines; | 301 | 4 | Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call)); | 302 | 4 | Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted)); | 303 | 4 | Rf_protect(lines = Rf_eval(expr, R_BaseEnv)); | 304 | 28 | for (R_xlen_t i = 0; i < XLENGTH(lines); i++) { | 305 | 24 | if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) { | 306 | 0 | memcpy(job->buf + job->len, " ...\n", sizeof " ...\n"); | 307 | 0 | break; | 308 | 0 | } | 309 | 24 | } | 310 | 4 | Rf_unprotect(3); | 311 | 4 | } |
character.c:fuzz_do_deparse Line | Count | Source | 298 | 68 | { | 299 | 68 | fuzz_deparse_job_t *job = data; | 300 | 68 | SEXP quoted, expr, lines; | 301 | 68 | Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call)); | 302 | 68 | Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted)); | 303 | 68 | Rf_protect(lines = Rf_eval(expr, R_BaseEnv)); | 304 | 136 | for (R_xlen_t i = 0; i < XLENGTH(lines); i++) { | 305 | 68 | if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) { | 306 | 0 | memcpy(job->buf + job->len, " ...\n", sizeof " ...\n"); | 307 | 0 | break; | 308 | 0 | } | 309 | 68 | } | 310 | 68 | Rf_unprotect(3); | 311 | 68 | } |
encoding.c:fuzz_do_deparse Line | Count | Source | 298 | 56 | { | 299 | 56 | fuzz_deparse_job_t *job = data; | 300 | 56 | SEXP quoted, expr, lines; | 301 | 56 | Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call)); | 302 | 56 | Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted)); | 303 | 56 | Rf_protect(lines = Rf_eval(expr, R_BaseEnv)); | 304 | 126 | for (R_xlen_t i = 0; i < XLENGTH(lines); i++) { | 305 | 70 | if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) { | 306 | 0 | memcpy(job->buf + job->len, " ...\n", sizeof " ...\n"); | 307 | 0 | break; | 308 | 0 | } | 309 | 70 | } | 310 | 56 | Rf_unprotect(3); | 311 | 56 | } |
Line | Count | Source | 298 | 44 | { | 299 | 44 | fuzz_deparse_job_t *job = data; | 300 | 44 | SEXP quoted, expr, lines; | 301 | 44 | Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call)); | 302 | 44 | Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted)); | 303 | 44 | Rf_protect(lines = Rf_eval(expr, R_BaseEnv)); | 304 | 404 | for (R_xlen_t i = 0; i < XLENGTH(lines); i++) { | 305 | 360 | if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) { | 306 | 0 | memcpy(job->buf + job->len, " ...\n", sizeof " ...\n"); | 307 | 0 | break; | 308 | 0 | } | 309 | 360 | } | 310 | 44 | Rf_unprotect(3); | 311 | 44 | } |
connections.c:fuzz_do_deparse Line | Count | Source | 298 | 132 | { | 299 | 132 | fuzz_deparse_job_t *job = data; | 300 | 132 | SEXP quoted, expr, lines; | 301 | 132 | Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call)); | 302 | 132 | Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted)); | 303 | 132 | Rf_protect(lines = Rf_eval(expr, R_BaseEnv)); | 304 | 1.14k | for (R_xlen_t i = 0; i < XLENGTH(lines); i++) { | 305 | 1.01k | if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) { | 306 | 0 | memcpy(job->buf + job->len, " ...\n", sizeof " ...\n"); | 307 | 0 | break; | 308 | 0 | } | 309 | 1.01k | } | 310 | 132 | Rf_unprotect(3); | 311 | 132 | } |
unserialize.c:fuzz_do_deparse Line | Count | Source | 298 | 8 | { | 299 | 8 | fuzz_deparse_job_t *job = data; | 300 | 8 | SEXP quoted, expr, lines; | 301 | 8 | Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call)); | 302 | 8 | Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted)); | 303 | 8 | Rf_protect(lines = Rf_eval(expr, R_BaseEnv)); | 304 | 48 | for (R_xlen_t i = 0; i < XLENGTH(lines); i++) { | 305 | 40 | if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) { | 306 | 0 | memcpy(job->buf + job->len, " ...\n", sizeof " ...\n"); | 307 | 0 | break; | 308 | 0 | } | 309 | 40 | } | 310 | 8 | Rf_unprotect(3); | 311 | 8 | } |
decompress.c:fuzz_do_deparse Line | Count | Source | 298 | 8 | { | 299 | 8 | fuzz_deparse_job_t *job = data; | 300 | 8 | SEXP quoted, expr, lines; | 301 | 8 | Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call)); | 302 | 8 | Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted)); | 303 | 8 | Rf_protect(lines = Rf_eval(expr, R_BaseEnv)); | 304 | 16 | for (R_xlen_t i = 0; i < XLENGTH(lines); i++) { | 305 | 8 | if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) { | 306 | 0 | memcpy(job->buf + job->len, " ...\n", sizeof " ...\n"); | 307 | 0 | break; | 308 | 0 | } | 309 | 8 | } | 310 | 8 | Rf_unprotect(3); | 311 | 8 | } |
readtable.c:fuzz_do_deparse Line | Count | Source | 298 | 40 | { | 299 | 40 | fuzz_deparse_job_t *job = data; | 300 | 40 | SEXP quoted, expr, lines; | 301 | 40 | Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call)); | 302 | 40 | Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted)); | 303 | 40 | Rf_protect(lines = Rf_eval(expr, R_BaseEnv)); | 304 | 186 | for (R_xlen_t i = 0; i < XLENGTH(lines); i++) { | 305 | 146 | if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) { | 306 | 0 | memcpy(job->buf + job->len, " ...\n", sizeof " ...\n"); | 307 | 0 | break; | 308 | 0 | } | 309 | 146 | } | 310 | 40 | Rf_unprotect(3); | 311 | 40 | } |
Line | Count | Source | 298 | 48 | { | 299 | 48 | fuzz_deparse_job_t *job = data; | 300 | 48 | SEXP quoted, expr, lines; | 301 | 48 | Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call)); | 302 | 48 | Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted)); | 303 | 48 | Rf_protect(lines = Rf_eval(expr, R_BaseEnv)); | 304 | 456 | for (R_xlen_t i = 0; i < XLENGTH(lines); i++) { | 305 | 408 | if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) { | 306 | 0 | memcpy(job->buf + job->len, " ...\n", sizeof " ...\n"); | 307 | 0 | break; | 308 | 0 | } | 309 | 408 | } | 310 | 48 | Rf_unprotect(3); | 311 | 48 | } |
datetime.c:fuzz_do_deparse Line | Count | Source | 298 | 30 | { | 299 | 30 | fuzz_deparse_job_t *job = data; | 300 | 30 | SEXP quoted, expr, lines; | 301 | 30 | Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call)); | 302 | 30 | Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted)); | 303 | 30 | Rf_protect(lines = Rf_eval(expr, R_BaseEnv)); | 304 | 112 | for (R_xlen_t i = 0; i < XLENGTH(lines); i++) { | 305 | 82 | if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) { | 306 | 0 | memcpy(job->buf + job->len, " ...\n", sizeof " ...\n"); | 307 | 0 | break; | 308 | 0 | } | 309 | 82 | } | 310 | 30 | Rf_unprotect(3); | 311 | 30 | } |
Line | Count | Source | 298 | 8 | { | 299 | 8 | fuzz_deparse_job_t *job = data; | 300 | 8 | SEXP quoted, expr, lines; | 301 | 8 | Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call)); | 302 | 8 | Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted)); | 303 | 8 | Rf_protect(lines = Rf_eval(expr, R_BaseEnv)); | 304 | 16 | for (R_xlen_t i = 0; i < XLENGTH(lines); i++) { | 305 | 8 | if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) { | 306 | 0 | memcpy(job->buf + job->len, " ...\n", sizeof " ...\n"); | 307 | 0 | break; | 308 | 0 | } | 309 | 8 | } | 310 | 8 | Rf_unprotect(3); | 311 | 8 | } |
Line | Count | Source | 298 | 4 | { | 299 | 4 | fuzz_deparse_job_t *job = data; | 300 | 4 | SEXP quoted, expr, lines; | 301 | 4 | Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call)); | 302 | 4 | Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted)); | 303 | 4 | Rf_protect(lines = Rf_eval(expr, R_BaseEnv)); | 304 | 12 | for (R_xlen_t i = 0; i < XLENGTH(lines); i++) { | 305 | 8 | if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) { | 306 | 0 | memcpy(job->buf + job->len, " ...\n", sizeof " ...\n"); | 307 | 0 | break; | 308 | 0 | } | 309 | 8 | } | 310 | 4 | Rf_unprotect(3); | 311 | 4 | } |
Line | Count | Source | 298 | 36 | { | 299 | 36 | fuzz_deparse_job_t *job = data; | 300 | 36 | SEXP quoted, expr, lines; | 301 | 36 | Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call)); | 302 | 36 | Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted)); | 303 | 36 | Rf_protect(lines = Rf_eval(expr, R_BaseEnv)); | 304 | 112 | for (R_xlen_t i = 0; i < XLENGTH(lines); i++) { | 305 | 76 | if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) { | 306 | 0 | memcpy(job->buf + job->len, " ...\n", sizeof " ...\n"); | 307 | 0 | break; | 308 | 0 | } | 309 | 76 | } | 310 | 36 | Rf_unprotect(3); | 311 | 36 | } |
Line | Count | Source | 298 | 32 | { | 299 | 32 | fuzz_deparse_job_t *job = data; | 300 | 32 | SEXP quoted, expr, lines; | 301 | 32 | Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call)); | 302 | 32 | Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted)); | 303 | 32 | Rf_protect(lines = Rf_eval(expr, R_BaseEnv)); | 304 | 258 | for (R_xlen_t i = 0; i < XLENGTH(lines); i++) { | 305 | 226 | if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) { | 306 | 0 | memcpy(job->buf + job->len, " ...\n", sizeof " ...\n"); | 307 | 0 | break; | 308 | 0 | } | 309 | 226 | } | 310 | 32 | Rf_unprotect(3); | 311 | 32 | } |
Line | Count | Source | 298 | 12 | { | 299 | 12 | fuzz_deparse_job_t *job = data; | 300 | 12 | SEXP quoted, expr, lines; | 301 | 12 | Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call)); | 302 | 12 | Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted)); | 303 | 12 | Rf_protect(lines = Rf_eval(expr, R_BaseEnv)); | 304 | 76 | for (R_xlen_t i = 0; i < XLENGTH(lines); i++) { | 305 | 64 | if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) { | 306 | 0 | memcpy(job->buf + job->len, " ...\n", sizeof " ...\n"); | 307 | 0 | break; | 308 | 0 | } | 309 | 64 | } | 310 | 12 | Rf_unprotect(3); | 311 | 12 | } |
sockets.c:fuzz_do_deparse Line | Count | Source | 298 | 1 | { | 299 | 1 | fuzz_deparse_job_t *job = data; | 300 | 1 | SEXP quoted, expr, lines; | 301 | 1 | Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call)); | 302 | 1 | Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted)); | 303 | 1 | Rf_protect(lines = Rf_eval(expr, R_BaseEnv)); | 304 | 14 | for (R_xlen_t i = 0; i < XLENGTH(lines); i++) { | 305 | 13 | if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) { | 306 | 0 | memcpy(job->buf + job->len, " ...\n", sizeof " ...\n"); | 307 | 0 | break; | 308 | 0 | } | 309 | 13 | } | 310 | 1 | Rf_unprotect(3); | 311 | 1 | } |
sprintf.c:fuzz_do_deparse Line | Count | Source | 298 | 8 | { | 299 | 8 | fuzz_deparse_job_t *job = data; | 300 | 8 | SEXP quoted, expr, lines; | 301 | 8 | Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call)); | 302 | 8 | Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted)); | 303 | 8 | Rf_protect(lines = Rf_eval(expr, R_BaseEnv)); | 304 | 16 | for (R_xlen_t i = 0; i < XLENGTH(lines); i++) { | 305 | 8 | if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) { | 306 | 0 | memcpy(job->buf + job->len, " ...\n", sizeof " ...\n"); | 307 | 0 | break; | 308 | 0 | } | 309 | 8 | } | 310 | 8 | Rf_unprotect(3); | 311 | 8 | } |
Unexecuted instantiation: eval.c:fuzz_do_deparse Line | Count | Source | 298 | 8 | { | 299 | 8 | fuzz_deparse_job_t *job = data; | 300 | 8 | SEXP quoted, expr, lines; | 301 | 8 | Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call)); | 302 | 8 | Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted)); | 303 | 8 | Rf_protect(lines = Rf_eval(expr, R_BaseEnv)); | 304 | 68 | for (R_xlen_t i = 0; i < XLENGTH(lines); i++) { | 305 | 60 | if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) { | 306 | 0 | memcpy(job->buf + job->len, " ...\n", sizeof " ...\n"); | 307 | 0 | break; | 308 | 0 | } | 309 | 60 | } | 310 | 8 | Rf_unprotect(3); | 311 | 8 | } |
|
312 | | |
313 | | static void fuzz_label_call(SEXP call, int slot, int n_slots) |
314 | 605 | { |
315 | 605 | if (call == NULL || call == R_NilValue) |
316 | 2 | return; |
317 | | |
318 | | /* A call shared by several slots (run under different settings, say) |
319 | | * keeps one label naming them all. */ |
320 | 9.70k | for (int i = 0; i < fuzz_n_labels; i++) { |
321 | 9.10k | if (fuzz_labels[i].call != call) |
322 | 9.10k | continue; |
323 | 4 | char *old = fuzz_labels[i].text; |
324 | 4 | char *of = strstr(old, " of "); /* "==fuzz== slot 7 of 9:" */ |
325 | 4 | size_t size = strlen(old) + 32; |
326 | 4 | char *buf = malloc(size); |
327 | 4 | if (of == NULL || buf == NULL) { |
328 | 0 | free(buf); |
329 | 0 | return; |
330 | 0 | } |
331 | 4 | snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of); |
332 | 4 | fuzz_labels[i].text = buf; |
333 | 4 | free(old); |
334 | 4 | return; |
335 | 4 | } |
336 | 599 | if (fuzz_n_labels == FUZZ_MAX_LABELS) |
337 | 0 | return; |
338 | | |
339 | 599 | char *buf = malloc(FUZZ_LABEL_MAX); |
340 | 599 | if (buf == NULL) |
341 | 0 | return; |
342 | 599 | int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots); |
343 | | |
344 | | /* A failed deparse leaves the header alone. */ |
345 | 599 | fuzz_deparse_job_t job = { call, buf, (size_t)n }; |
346 | 599 | R_ToplevelExec(fuzz_do_deparse, &job); |
347 | | |
348 | 599 | fuzz_labels[fuzz_n_labels].call = call; |
349 | 599 | fuzz_labels[fuzz_n_labels].text = buf; |
350 | 599 | fuzz_n_labels++; |
351 | 599 | } Line | Count | Source | 314 | 52 | { | 315 | 52 | if (call == NULL || call == R_NilValue) | 316 | 0 | return; | 317 | | | 318 | | /* A call shared by several slots (run under different settings, say) | 319 | | * keeps one label naming them all. */ | 320 | 702 | for (int i = 0; i < fuzz_n_labels; i++) { | 321 | 650 | if (fuzz_labels[i].call != call) | 322 | 650 | continue; | 323 | 0 | char *old = fuzz_labels[i].text; | 324 | 0 | char *of = strstr(old, " of "); /* "==fuzz== slot 7 of 9:" */ | 325 | 0 | size_t size = strlen(old) + 32; | 326 | 0 | char *buf = malloc(size); | 327 | 0 | if (of == NULL || buf == NULL) { | 328 | 0 | free(buf); | 329 | 0 | return; | 330 | 0 | } | 331 | 0 | snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of); | 332 | 0 | fuzz_labels[i].text = buf; | 333 | 0 | free(old); | 334 | 0 | return; | 335 | 0 | } | 336 | 52 | if (fuzz_n_labels == FUZZ_MAX_LABELS) | 337 | 0 | return; | 338 | | | 339 | 52 | char *buf = malloc(FUZZ_LABEL_MAX); | 340 | 52 | if (buf == NULL) | 341 | 0 | return; | 342 | 52 | int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots); | 343 | | | 344 | | /* A failed deparse leaves the header alone. */ | 345 | 52 | fuzz_deparse_job_t job = { call, buf, (size_t)n }; | 346 | 52 | R_ToplevelExec(fuzz_do_deparse, &job); | 347 | | | 348 | 52 | fuzz_labels[fuzz_n_labels].call = call; | 349 | 52 | fuzz_labels[fuzz_n_labels].text = buf; | 350 | 52 | fuzz_n_labels++; | 351 | 52 | } |
Line | Count | Source | 314 | 4 | { | 315 | 4 | if (call == NULL || call == R_NilValue) | 316 | 0 | return; | 317 | | | 318 | | /* A call shared by several slots (run under different settings, say) | 319 | | * keeps one label naming them all. */ | 320 | 6 | for (int i = 0; i < fuzz_n_labels; i++) { | 321 | 2 | if (fuzz_labels[i].call != call) | 322 | 2 | continue; | 323 | 0 | char *old = fuzz_labels[i].text; | 324 | 0 | char *of = strstr(old, " of "); /* "==fuzz== slot 7 of 9:" */ | 325 | 0 | size_t size = strlen(old) + 32; | 326 | 0 | char *buf = malloc(size); | 327 | 0 | if (of == NULL || buf == NULL) { | 328 | 0 | free(buf); | 329 | 0 | return; | 330 | 0 | } | 331 | 0 | snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of); | 332 | 0 | fuzz_labels[i].text = buf; | 333 | 0 | free(old); | 334 | 0 | return; | 335 | 0 | } | 336 | 4 | if (fuzz_n_labels == FUZZ_MAX_LABELS) | 337 | 0 | return; | 338 | | | 339 | 4 | char *buf = malloc(FUZZ_LABEL_MAX); | 340 | 4 | if (buf == NULL) | 341 | 0 | return; | 342 | 4 | int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots); | 343 | | | 344 | | /* A failed deparse leaves the header alone. */ | 345 | 4 | fuzz_deparse_job_t job = { call, buf, (size_t)n }; | 346 | 4 | R_ToplevelExec(fuzz_do_deparse, &job); | 347 | | | 348 | 4 | fuzz_labels[fuzz_n_labels].call = call; | 349 | 4 | fuzz_labels[fuzz_n_labels].text = buf; | 350 | 4 | fuzz_n_labels++; | 351 | 4 | } |
character.c:fuzz_label_call Line | Count | Source | 314 | 68 | { | 315 | 68 | if (call == NULL || call == R_NilValue) | 316 | 0 | return; | 317 | | | 318 | | /* A call shared by several slots (run under different settings, say) | 319 | | * keeps one label naming them all. */ | 320 | 1.19k | for (int i = 0; i < fuzz_n_labels; i++) { | 321 | 1.12k | if (fuzz_labels[i].call != call) | 322 | 1.12k | continue; | 323 | 0 | char *old = fuzz_labels[i].text; | 324 | 0 | char *of = strstr(old, " of "); /* "==fuzz== slot 7 of 9:" */ | 325 | 0 | size_t size = strlen(old) + 32; | 326 | 0 | char *buf = malloc(size); | 327 | 0 | if (of == NULL || buf == NULL) { | 328 | 0 | free(buf); | 329 | 0 | return; | 330 | 0 | } | 331 | 0 | snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of); | 332 | 0 | fuzz_labels[i].text = buf; | 333 | 0 | free(old); | 334 | 0 | return; | 335 | 0 | } | 336 | 68 | if (fuzz_n_labels == FUZZ_MAX_LABELS) | 337 | 0 | return; | 338 | | | 339 | 68 | char *buf = malloc(FUZZ_LABEL_MAX); | 340 | 68 | if (buf == NULL) | 341 | 0 | return; | 342 | 68 | int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots); | 343 | | | 344 | | /* A failed deparse leaves the header alone. */ | 345 | 68 | fuzz_deparse_job_t job = { call, buf, (size_t)n }; | 346 | 68 | R_ToplevelExec(fuzz_do_deparse, &job); | 347 | | | 348 | 68 | fuzz_labels[fuzz_n_labels].call = call; | 349 | 68 | fuzz_labels[fuzz_n_labels].text = buf; | 350 | 68 | fuzz_n_labels++; | 351 | 68 | } |
encoding.c:fuzz_label_call Line | Count | Source | 314 | 56 | { | 315 | 56 | if (call == NULL || call == R_NilValue) | 316 | 0 | return; | 317 | | | 318 | | /* A call shared by several slots (run under different settings, say) | 319 | | * keeps one label naming them all. */ | 320 | 812 | for (int i = 0; i < fuzz_n_labels; i++) { | 321 | 756 | if (fuzz_labels[i].call != call) | 322 | 756 | continue; | 323 | 0 | char *old = fuzz_labels[i].text; | 324 | 0 | char *of = strstr(old, " of "); /* "==fuzz== slot 7 of 9:" */ | 325 | 0 | size_t size = strlen(old) + 32; | 326 | 0 | char *buf = malloc(size); | 327 | 0 | if (of == NULL || buf == NULL) { | 328 | 0 | free(buf); | 329 | 0 | return; | 330 | 0 | } | 331 | 0 | snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of); | 332 | 0 | fuzz_labels[i].text = buf; | 333 | 0 | free(old); | 334 | 0 | return; | 335 | 0 | } | 336 | 56 | if (fuzz_n_labels == FUZZ_MAX_LABELS) | 337 | 0 | return; | 338 | | | 339 | 56 | char *buf = malloc(FUZZ_LABEL_MAX); | 340 | 56 | if (buf == NULL) | 341 | 0 | return; | 342 | 56 | int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots); | 343 | | | 344 | | /* A failed deparse leaves the header alone. */ | 345 | 56 | fuzz_deparse_job_t job = { call, buf, (size_t)n }; | 346 | 56 | R_ToplevelExec(fuzz_do_deparse, &job); | 347 | | | 348 | 56 | fuzz_labels[fuzz_n_labels].call = call; | 349 | 56 | fuzz_labels[fuzz_n_labels].text = buf; | 350 | 56 | fuzz_n_labels++; | 351 | 56 | } |
Line | Count | Source | 314 | 44 | { | 315 | 44 | if (call == NULL || call == R_NilValue) | 316 | 0 | return; | 317 | | | 318 | | /* A call shared by several slots (run under different settings, say) | 319 | | * keeps one label naming them all. */ | 320 | 506 | for (int i = 0; i < fuzz_n_labels; i++) { | 321 | 462 | if (fuzz_labels[i].call != call) | 322 | 462 | continue; | 323 | 0 | char *old = fuzz_labels[i].text; | 324 | 0 | char *of = strstr(old, " of "); /* "==fuzz== slot 7 of 9:" */ | 325 | 0 | size_t size = strlen(old) + 32; | 326 | 0 | char *buf = malloc(size); | 327 | 0 | if (of == NULL || buf == NULL) { | 328 | 0 | free(buf); | 329 | 0 | return; | 330 | 0 | } | 331 | 0 | snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of); | 332 | 0 | fuzz_labels[i].text = buf; | 333 | 0 | free(old); | 334 | 0 | return; | 335 | 0 | } | 336 | 44 | if (fuzz_n_labels == FUZZ_MAX_LABELS) | 337 | 0 | return; | 338 | | | 339 | 44 | char *buf = malloc(FUZZ_LABEL_MAX); | 340 | 44 | if (buf == NULL) | 341 | 0 | return; | 342 | 44 | int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots); | 343 | | | 344 | | /* A failed deparse leaves the header alone. */ | 345 | 44 | fuzz_deparse_job_t job = { call, buf, (size_t)n }; | 346 | 44 | R_ToplevelExec(fuzz_do_deparse, &job); | 347 | | | 348 | 44 | fuzz_labels[fuzz_n_labels].call = call; | 349 | 44 | fuzz_labels[fuzz_n_labels].text = buf; | 350 | 44 | fuzz_n_labels++; | 351 | 44 | } |
connections.c:fuzz_label_call Line | Count | Source | 314 | 132 | { | 315 | 132 | if (call == NULL || call == R_NilValue) | 316 | 0 | return; | 317 | | | 318 | | /* A call shared by several slots (run under different settings, say) | 319 | | * keeps one label naming them all. */ | 320 | 4.42k | for (int i = 0; i < fuzz_n_labels; i++) { | 321 | 4.29k | if (fuzz_labels[i].call != call) | 322 | 4.29k | continue; | 323 | 0 | char *old = fuzz_labels[i].text; | 324 | 0 | char *of = strstr(old, " of "); /* "==fuzz== slot 7 of 9:" */ | 325 | 0 | size_t size = strlen(old) + 32; | 326 | 0 | char *buf = malloc(size); | 327 | 0 | if (of == NULL || buf == NULL) { | 328 | 0 | free(buf); | 329 | 0 | return; | 330 | 0 | } | 331 | 0 | snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of); | 332 | 0 | fuzz_labels[i].text = buf; | 333 | 0 | free(old); | 334 | 0 | return; | 335 | 0 | } | 336 | 132 | if (fuzz_n_labels == FUZZ_MAX_LABELS) | 337 | 0 | return; | 338 | | | 339 | 132 | char *buf = malloc(FUZZ_LABEL_MAX); | 340 | 132 | if (buf == NULL) | 341 | 0 | return; | 342 | 132 | int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots); | 343 | | | 344 | | /* A failed deparse leaves the header alone. */ | 345 | 132 | fuzz_deparse_job_t job = { call, buf, (size_t)n }; | 346 | 132 | R_ToplevelExec(fuzz_do_deparse, &job); | 347 | | | 348 | 132 | fuzz_labels[fuzz_n_labels].call = call; | 349 | 132 | fuzz_labels[fuzz_n_labels].text = buf; | 350 | 132 | fuzz_n_labels++; | 351 | 132 | } |
unserialize.c:fuzz_label_call Line | Count | Source | 314 | 8 | { | 315 | 8 | if (call == NULL || call == R_NilValue) | 316 | 0 | return; | 317 | | | 318 | | /* A call shared by several slots (run under different settings, say) | 319 | | * keeps one label naming them all. */ | 320 | 20 | for (int i = 0; i < fuzz_n_labels; i++) { | 321 | 12 | if (fuzz_labels[i].call != call) | 322 | 12 | continue; | 323 | 0 | char *old = fuzz_labels[i].text; | 324 | 0 | char *of = strstr(old, " of "); /* "==fuzz== slot 7 of 9:" */ | 325 | 0 | size_t size = strlen(old) + 32; | 326 | 0 | char *buf = malloc(size); | 327 | 0 | if (of == NULL || buf == NULL) { | 328 | 0 | free(buf); | 329 | 0 | return; | 330 | 0 | } | 331 | 0 | snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of); | 332 | 0 | fuzz_labels[i].text = buf; | 333 | 0 | free(old); | 334 | 0 | return; | 335 | 0 | } | 336 | 8 | if (fuzz_n_labels == FUZZ_MAX_LABELS) | 337 | 0 | return; | 338 | | | 339 | 8 | char *buf = malloc(FUZZ_LABEL_MAX); | 340 | 8 | if (buf == NULL) | 341 | 0 | return; | 342 | 8 | int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots); | 343 | | | 344 | | /* A failed deparse leaves the header alone. */ | 345 | 8 | fuzz_deparse_job_t job = { call, buf, (size_t)n }; | 346 | 8 | R_ToplevelExec(fuzz_do_deparse, &job); | 347 | | | 348 | 8 | fuzz_labels[fuzz_n_labels].call = call; | 349 | 8 | fuzz_labels[fuzz_n_labels].text = buf; | 350 | 8 | fuzz_n_labels++; | 351 | 8 | } |
decompress.c:fuzz_label_call Line | Count | Source | 314 | 8 | { | 315 | 8 | if (call == NULL || call == R_NilValue) | 316 | 0 | return; | 317 | | | 318 | | /* A call shared by several slots (run under different settings, say) | 319 | | * keeps one label naming them all. */ | 320 | 20 | for (int i = 0; i < fuzz_n_labels; i++) { | 321 | 12 | if (fuzz_labels[i].call != call) | 322 | 12 | continue; | 323 | 0 | char *old = fuzz_labels[i].text; | 324 | 0 | char *of = strstr(old, " of "); /* "==fuzz== slot 7 of 9:" */ | 325 | 0 | size_t size = strlen(old) + 32; | 326 | 0 | char *buf = malloc(size); | 327 | 0 | if (of == NULL || buf == NULL) { | 328 | 0 | free(buf); | 329 | 0 | return; | 330 | 0 | } | 331 | 0 | snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of); | 332 | 0 | fuzz_labels[i].text = buf; | 333 | 0 | free(old); | 334 | 0 | return; | 335 | 0 | } | 336 | 8 | if (fuzz_n_labels == FUZZ_MAX_LABELS) | 337 | 0 | return; | 338 | | | 339 | 8 | char *buf = malloc(FUZZ_LABEL_MAX); | 340 | 8 | if (buf == NULL) | 341 | 0 | return; | 342 | 8 | int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots); | 343 | | | 344 | | /* A failed deparse leaves the header alone. */ | 345 | 8 | fuzz_deparse_job_t job = { call, buf, (size_t)n }; | 346 | 8 | R_ToplevelExec(fuzz_do_deparse, &job); | 347 | | | 348 | 8 | fuzz_labels[fuzz_n_labels].call = call; | 349 | 8 | fuzz_labels[fuzz_n_labels].text = buf; | 350 | 8 | fuzz_n_labels++; | 351 | 8 | } |
readtable.c:fuzz_label_call Line | Count | Source | 314 | 40 | { | 315 | 40 | if (call == NULL || call == R_NilValue) | 316 | 0 | return; | 317 | | | 318 | | /* A call shared by several slots (run under different settings, say) | 319 | | * keeps one label naming them all. */ | 320 | 420 | for (int i = 0; i < fuzz_n_labels; i++) { | 321 | 380 | if (fuzz_labels[i].call != call) | 322 | 380 | continue; | 323 | 0 | char *old = fuzz_labels[i].text; | 324 | 0 | char *of = strstr(old, " of "); /* "==fuzz== slot 7 of 9:" */ | 325 | 0 | size_t size = strlen(old) + 32; | 326 | 0 | char *buf = malloc(size); | 327 | 0 | if (of == NULL || buf == NULL) { | 328 | 0 | free(buf); | 329 | 0 | return; | 330 | 0 | } | 331 | 0 | snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of); | 332 | 0 | fuzz_labels[i].text = buf; | 333 | 0 | free(old); | 334 | 0 | return; | 335 | 0 | } | 336 | 40 | if (fuzz_n_labels == FUZZ_MAX_LABELS) | 337 | 0 | return; | 338 | | | 339 | 40 | char *buf = malloc(FUZZ_LABEL_MAX); | 340 | 40 | if (buf == NULL) | 341 | 0 | return; | 342 | 40 | int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots); | 343 | | | 344 | | /* A failed deparse leaves the header alone. */ | 345 | 40 | fuzz_deparse_job_t job = { call, buf, (size_t)n }; | 346 | 40 | R_ToplevelExec(fuzz_do_deparse, &job); | 347 | | | 348 | 40 | fuzz_labels[fuzz_n_labels].call = call; | 349 | 40 | fuzz_labels[fuzz_n_labels].text = buf; | 350 | 40 | fuzz_n_labels++; | 351 | 40 | } |
Line | Count | Source | 314 | 48 | { | 315 | 48 | if (call == NULL || call == R_NilValue) | 316 | 0 | return; | 317 | | | 318 | | /* A call shared by several slots (run under different settings, say) | 319 | | * keeps one label naming them all. */ | 320 | 600 | for (int i = 0; i < fuzz_n_labels; i++) { | 321 | 552 | if (fuzz_labels[i].call != call) | 322 | 552 | continue; | 323 | 0 | char *old = fuzz_labels[i].text; | 324 | 0 | char *of = strstr(old, " of "); /* "==fuzz== slot 7 of 9:" */ | 325 | 0 | size_t size = strlen(old) + 32; | 326 | 0 | char *buf = malloc(size); | 327 | 0 | if (of == NULL || buf == NULL) { | 328 | 0 | free(buf); | 329 | 0 | return; | 330 | 0 | } | 331 | 0 | snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of); | 332 | 0 | fuzz_labels[i].text = buf; | 333 | 0 | free(old); | 334 | 0 | return; | 335 | 0 | } | 336 | 48 | if (fuzz_n_labels == FUZZ_MAX_LABELS) | 337 | 0 | return; | 338 | | | 339 | 48 | char *buf = malloc(FUZZ_LABEL_MAX); | 340 | 48 | if (buf == NULL) | 341 | 0 | return; | 342 | 48 | int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots); | 343 | | | 344 | | /* A failed deparse leaves the header alone. */ | 345 | 48 | fuzz_deparse_job_t job = { call, buf, (size_t)n }; | 346 | 48 | R_ToplevelExec(fuzz_do_deparse, &job); | 347 | | | 348 | 48 | fuzz_labels[fuzz_n_labels].call = call; | 349 | 48 | fuzz_labels[fuzz_n_labels].text = buf; | 350 | 48 | fuzz_n_labels++; | 351 | 48 | } |
datetime.c:fuzz_label_call Line | Count | Source | 314 | 34 | { | 315 | 34 | if (call == NULL || call == R_NilValue) | 316 | 0 | return; | 317 | | | 318 | | /* A call shared by several slots (run under different settings, say) | 319 | | * keeps one label naming them all. */ | 320 | 282 | for (int i = 0; i < fuzz_n_labels; i++) { | 321 | 252 | if (fuzz_labels[i].call != call) | 322 | 248 | continue; | 323 | 4 | char *old = fuzz_labels[i].text; | 324 | 4 | char *of = strstr(old, " of "); /* "==fuzz== slot 7 of 9:" */ | 325 | 4 | size_t size = strlen(old) + 32; | 326 | 4 | char *buf = malloc(size); | 327 | 4 | if (of == NULL || buf == NULL) { | 328 | 0 | free(buf); | 329 | 0 | return; | 330 | 0 | } | 331 | 4 | snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of); | 332 | 4 | fuzz_labels[i].text = buf; | 333 | 4 | free(old); | 334 | 4 | return; | 335 | 4 | } | 336 | 30 | if (fuzz_n_labels == FUZZ_MAX_LABELS) | 337 | 0 | return; | 338 | | | 339 | 30 | char *buf = malloc(FUZZ_LABEL_MAX); | 340 | 30 | if (buf == NULL) | 341 | 0 | return; | 342 | 30 | int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots); | 343 | | | 344 | | /* A failed deparse leaves the header alone. */ | 345 | 30 | fuzz_deparse_job_t job = { call, buf, (size_t)n }; | 346 | 30 | R_ToplevelExec(fuzz_do_deparse, &job); | 347 | | | 348 | 30 | fuzz_labels[fuzz_n_labels].call = call; | 349 | 30 | fuzz_labels[fuzz_n_labels].text = buf; | 350 | 30 | fuzz_n_labels++; | 351 | 30 | } |
Line | Count | Source | 314 | 8 | { | 315 | 8 | if (call == NULL || call == R_NilValue) | 316 | 0 | return; | 317 | | | 318 | | /* A call shared by several slots (run under different settings, say) | 319 | | * keeps one label naming them all. */ | 320 | 20 | for (int i = 0; i < fuzz_n_labels; i++) { | 321 | 12 | if (fuzz_labels[i].call != call) | 322 | 12 | continue; | 323 | 0 | char *old = fuzz_labels[i].text; | 324 | 0 | char *of = strstr(old, " of "); /* "==fuzz== slot 7 of 9:" */ | 325 | 0 | size_t size = strlen(old) + 32; | 326 | 0 | char *buf = malloc(size); | 327 | 0 | if (of == NULL || buf == NULL) { | 328 | 0 | free(buf); | 329 | 0 | return; | 330 | 0 | } | 331 | 0 | snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of); | 332 | 0 | fuzz_labels[i].text = buf; | 333 | 0 | free(old); | 334 | 0 | return; | 335 | 0 | } | 336 | 8 | if (fuzz_n_labels == FUZZ_MAX_LABELS) | 337 | 0 | return; | 338 | | | 339 | 8 | char *buf = malloc(FUZZ_LABEL_MAX); | 340 | 8 | if (buf == NULL) | 341 | 0 | return; | 342 | 8 | int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots); | 343 | | | 344 | | /* A failed deparse leaves the header alone. */ | 345 | 8 | fuzz_deparse_job_t job = { call, buf, (size_t)n }; | 346 | 8 | R_ToplevelExec(fuzz_do_deparse, &job); | 347 | | | 348 | 8 | fuzz_labels[fuzz_n_labels].call = call; | 349 | 8 | fuzz_labels[fuzz_n_labels].text = buf; | 350 | 8 | fuzz_n_labels++; | 351 | 8 | } |
Line | Count | Source | 314 | 4 | { | 315 | 4 | if (call == NULL || call == R_NilValue) | 316 | 0 | return; | 317 | | | 318 | | /* A call shared by several slots (run under different settings, say) | 319 | | * keeps one label naming them all. */ | 320 | 6 | for (int i = 0; i < fuzz_n_labels; i++) { | 321 | 2 | if (fuzz_labels[i].call != call) | 322 | 2 | continue; | 323 | 0 | char *old = fuzz_labels[i].text; | 324 | 0 | char *of = strstr(old, " of "); /* "==fuzz== slot 7 of 9:" */ | 325 | 0 | size_t size = strlen(old) + 32; | 326 | 0 | char *buf = malloc(size); | 327 | 0 | if (of == NULL || buf == NULL) { | 328 | 0 | free(buf); | 329 | 0 | return; | 330 | 0 | } | 331 | 0 | snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of); | 332 | 0 | fuzz_labels[i].text = buf; | 333 | 0 | free(old); | 334 | 0 | return; | 335 | 0 | } | 336 | 4 | if (fuzz_n_labels == FUZZ_MAX_LABELS) | 337 | 0 | return; | 338 | | | 339 | 4 | char *buf = malloc(FUZZ_LABEL_MAX); | 340 | 4 | if (buf == NULL) | 341 | 0 | return; | 342 | 4 | int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots); | 343 | | | 344 | | /* A failed deparse leaves the header alone. */ | 345 | 4 | fuzz_deparse_job_t job = { call, buf, (size_t)n }; | 346 | 4 | R_ToplevelExec(fuzz_do_deparse, &job); | 347 | | | 348 | 4 | fuzz_labels[fuzz_n_labels].call = call; | 349 | 4 | fuzz_labels[fuzz_n_labels].text = buf; | 350 | 4 | fuzz_n_labels++; | 351 | 4 | } |
Line | Count | Source | 314 | 36 | { | 315 | 36 | if (call == NULL || call == R_NilValue) | 316 | 0 | return; | 317 | | | 318 | | /* A call shared by several slots (run under different settings, say) | 319 | | * keeps one label naming them all. */ | 320 | 342 | for (int i = 0; i < fuzz_n_labels; i++) { | 321 | 306 | if (fuzz_labels[i].call != call) | 322 | 306 | continue; | 323 | 0 | char *old = fuzz_labels[i].text; | 324 | 0 | char *of = strstr(old, " of "); /* "==fuzz== slot 7 of 9:" */ | 325 | 0 | size_t size = strlen(old) + 32; | 326 | 0 | char *buf = malloc(size); | 327 | 0 | if (of == NULL || buf == NULL) { | 328 | 0 | free(buf); | 329 | 0 | return; | 330 | 0 | } | 331 | 0 | snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of); | 332 | 0 | fuzz_labels[i].text = buf; | 333 | 0 | free(old); | 334 | 0 | return; | 335 | 0 | } | 336 | 36 | if (fuzz_n_labels == FUZZ_MAX_LABELS) | 337 | 0 | return; | 338 | | | 339 | 36 | char *buf = malloc(FUZZ_LABEL_MAX); | 340 | 36 | if (buf == NULL) | 341 | 0 | return; | 342 | 36 | int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots); | 343 | | | 344 | | /* A failed deparse leaves the header alone. */ | 345 | 36 | fuzz_deparse_job_t job = { call, buf, (size_t)n }; | 346 | 36 | R_ToplevelExec(fuzz_do_deparse, &job); | 347 | | | 348 | 36 | fuzz_labels[fuzz_n_labels].call = call; | 349 | 36 | fuzz_labels[fuzz_n_labels].text = buf; | 350 | 36 | fuzz_n_labels++; | 351 | 36 | } |
Line | Count | Source | 314 | 32 | { | 315 | 32 | if (call == NULL || call == R_NilValue) | 316 | 0 | return; | 317 | | | 318 | | /* A call shared by several slots (run under different settings, say) | 319 | | * keeps one label naming them all. */ | 320 | 272 | for (int i = 0; i < fuzz_n_labels; i++) { | 321 | 240 | if (fuzz_labels[i].call != call) | 322 | 240 | continue; | 323 | 0 | char *old = fuzz_labels[i].text; | 324 | 0 | char *of = strstr(old, " of "); /* "==fuzz== slot 7 of 9:" */ | 325 | 0 | size_t size = strlen(old) + 32; | 326 | 0 | char *buf = malloc(size); | 327 | 0 | if (of == NULL || buf == NULL) { | 328 | 0 | free(buf); | 329 | 0 | return; | 330 | 0 | } | 331 | 0 | snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of); | 332 | 0 | fuzz_labels[i].text = buf; | 333 | 0 | free(old); | 334 | 0 | return; | 335 | 0 | } | 336 | 32 | if (fuzz_n_labels == FUZZ_MAX_LABELS) | 337 | 0 | return; | 338 | | | 339 | 32 | char *buf = malloc(FUZZ_LABEL_MAX); | 340 | 32 | if (buf == NULL) | 341 | 0 | return; | 342 | 32 | int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots); | 343 | | | 344 | | /* A failed deparse leaves the header alone. */ | 345 | 32 | fuzz_deparse_job_t job = { call, buf, (size_t)n }; | 346 | 32 | R_ToplevelExec(fuzz_do_deparse, &job); | 347 | | | 348 | 32 | fuzz_labels[fuzz_n_labels].call = call; | 349 | 32 | fuzz_labels[fuzz_n_labels].text = buf; | 350 | 32 | fuzz_n_labels++; | 351 | 32 | } |
Line | Count | Source | 314 | 14 | { | 315 | 14 | if (call == NULL || call == R_NilValue) | 316 | 2 | return; | 317 | | | 318 | | /* A call shared by several slots (run under different settings, say) | 319 | | * keeps one label naming them all. */ | 320 | 42 | for (int i = 0; i < fuzz_n_labels; i++) { | 321 | 30 | if (fuzz_labels[i].call != call) | 322 | 30 | continue; | 323 | 0 | char *old = fuzz_labels[i].text; | 324 | 0 | char *of = strstr(old, " of "); /* "==fuzz== slot 7 of 9:" */ | 325 | 0 | size_t size = strlen(old) + 32; | 326 | 0 | char *buf = malloc(size); | 327 | 0 | if (of == NULL || buf == NULL) { | 328 | 0 | free(buf); | 329 | 0 | return; | 330 | 0 | } | 331 | 0 | snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of); | 332 | 0 | fuzz_labels[i].text = buf; | 333 | 0 | free(old); | 334 | 0 | return; | 335 | 0 | } | 336 | 12 | if (fuzz_n_labels == FUZZ_MAX_LABELS) | 337 | 0 | return; | 338 | | | 339 | 12 | char *buf = malloc(FUZZ_LABEL_MAX); | 340 | 12 | if (buf == NULL) | 341 | 0 | return; | 342 | 12 | int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots); | 343 | | | 344 | | /* A failed deparse leaves the header alone. */ | 345 | 12 | fuzz_deparse_job_t job = { call, buf, (size_t)n }; | 346 | 12 | R_ToplevelExec(fuzz_do_deparse, &job); | 347 | | | 348 | 12 | fuzz_labels[fuzz_n_labels].call = call; | 349 | 12 | fuzz_labels[fuzz_n_labels].text = buf; | 350 | 12 | fuzz_n_labels++; | 351 | 12 | } |
sockets.c:fuzz_label_call Line | Count | Source | 314 | 1 | { | 315 | 1 | if (call == NULL || call == R_NilValue) | 316 | 0 | return; | 317 | | | 318 | | /* A call shared by several slots (run under different settings, say) | 319 | | * keeps one label naming them all. */ | 320 | 1 | for (int i = 0; i < fuzz_n_labels; i++) { | 321 | 0 | if (fuzz_labels[i].call != call) | 322 | 0 | continue; | 323 | 0 | char *old = fuzz_labels[i].text; | 324 | 0 | char *of = strstr(old, " of "); /* "==fuzz== slot 7 of 9:" */ | 325 | 0 | size_t size = strlen(old) + 32; | 326 | 0 | char *buf = malloc(size); | 327 | 0 | if (of == NULL || buf == NULL) { | 328 | 0 | free(buf); | 329 | 0 | return; | 330 | 0 | } | 331 | 0 | snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of); | 332 | 0 | fuzz_labels[i].text = buf; | 333 | 0 | free(old); | 334 | 0 | return; | 335 | 0 | } | 336 | 1 | if (fuzz_n_labels == FUZZ_MAX_LABELS) | 337 | 0 | return; | 338 | | | 339 | 1 | char *buf = malloc(FUZZ_LABEL_MAX); | 340 | 1 | if (buf == NULL) | 341 | 0 | return; | 342 | 1 | int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots); | 343 | | | 344 | | /* A failed deparse leaves the header alone. */ | 345 | 1 | fuzz_deparse_job_t job = { call, buf, (size_t)n }; | 346 | 1 | R_ToplevelExec(fuzz_do_deparse, &job); | 347 | | | 348 | 1 | fuzz_labels[fuzz_n_labels].call = call; | 349 | 1 | fuzz_labels[fuzz_n_labels].text = buf; | 350 | 1 | fuzz_n_labels++; | 351 | 1 | } |
sprintf.c:fuzz_label_call Line | Count | Source | 314 | 8 | { | 315 | 8 | if (call == NULL || call == R_NilValue) | 316 | 0 | return; | 317 | | | 318 | | /* A call shared by several slots (run under different settings, say) | 319 | | * keeps one label naming them all. */ | 320 | 20 | for (int i = 0; i < fuzz_n_labels; i++) { | 321 | 12 | if (fuzz_labels[i].call != call) | 322 | 12 | continue; | 323 | 0 | char *old = fuzz_labels[i].text; | 324 | 0 | char *of = strstr(old, " of "); /* "==fuzz== slot 7 of 9:" */ | 325 | 0 | size_t size = strlen(old) + 32; | 326 | 0 | char *buf = malloc(size); | 327 | 0 | if (of == NULL || buf == NULL) { | 328 | 0 | free(buf); | 329 | 0 | return; | 330 | 0 | } | 331 | 0 | snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of); | 332 | 0 | fuzz_labels[i].text = buf; | 333 | 0 | free(old); | 334 | 0 | return; | 335 | 0 | } | 336 | 8 | if (fuzz_n_labels == FUZZ_MAX_LABELS) | 337 | 0 | return; | 338 | | | 339 | 8 | char *buf = malloc(FUZZ_LABEL_MAX); | 340 | 8 | if (buf == NULL) | 341 | 0 | return; | 342 | 8 | int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots); | 343 | | | 344 | | /* A failed deparse leaves the header alone. */ | 345 | 8 | fuzz_deparse_job_t job = { call, buf, (size_t)n }; | 346 | 8 | R_ToplevelExec(fuzz_do_deparse, &job); | 347 | | | 348 | 8 | fuzz_labels[fuzz_n_labels].call = call; | 349 | 8 | fuzz_labels[fuzz_n_labels].text = buf; | 350 | 8 | fuzz_n_labels++; | 351 | 8 | } |
Unexecuted instantiation: eval.c:fuzz_label_call Line | Count | Source | 314 | 8 | { | 315 | 8 | if (call == NULL || call == R_NilValue) | 316 | 0 | return; | 317 | | | 318 | | /* A call shared by several slots (run under different settings, say) | 319 | | * keeps one label naming them all. */ | 320 | 20 | for (int i = 0; i < fuzz_n_labels; i++) { | 321 | 12 | if (fuzz_labels[i].call != call) | 322 | 12 | continue; | 323 | 0 | char *old = fuzz_labels[i].text; | 324 | 0 | char *of = strstr(old, " of "); /* "==fuzz== slot 7 of 9:" */ | 325 | 0 | size_t size = strlen(old) + 32; | 326 | 0 | char *buf = malloc(size); | 327 | 0 | if (of == NULL || buf == NULL) { | 328 | 0 | free(buf); | 329 | 0 | return; | 330 | 0 | } | 331 | 0 | snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of); | 332 | 0 | fuzz_labels[i].text = buf; | 333 | 0 | free(old); | 334 | 0 | return; | 335 | 0 | } | 336 | 8 | if (fuzz_n_labels == FUZZ_MAX_LABELS) | 337 | 0 | return; | 338 | | | 339 | 8 | char *buf = malloc(FUZZ_LABEL_MAX); | 340 | 8 | if (buf == NULL) | 341 | 0 | return; | 342 | 8 | int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots); | 343 | | | 344 | | /* A failed deparse leaves the header alone. */ | 345 | 8 | fuzz_deparse_job_t job = { call, buf, (size_t)n }; | 346 | 8 | R_ToplevelExec(fuzz_do_deparse, &job); | 347 | | | 348 | 8 | fuzz_labels[fuzz_n_labels].call = call; | 349 | 8 | fuzz_labels[fuzz_n_labels].text = buf; | 350 | 8 | fuzz_n_labels++; | 351 | 8 | } |
|
352 | | |
353 | | /* Label calls[0..n-1] as slots 0..n-1; NULL entries (slots run in C) |
354 | | * are skipped. */ |
355 | | static void fuzz_label_calls(const SEXP *calls, int n) |
356 | 35 | { |
357 | 588 | for (int i = 0; i < n; i++) |
358 | 553 | fuzz_label_call(calls[i], i, n); |
359 | 35 | } Unexecuted instantiation: io.c:fuzz_label_calls Line | Count | Source | 356 | 2 | { | 357 | 6 | for (int i = 0; i < n; i++) | 358 | 4 | fuzz_label_call(calls[i], i, n); | 359 | 2 | } |
character.c:fuzz_label_calls Line | Count | Source | 356 | 2 | { | 357 | 70 | for (int i = 0; i < n; i++) | 358 | 68 | fuzz_label_call(calls[i], i, n); | 359 | 2 | } |
encoding.c:fuzz_label_calls Line | Count | Source | 356 | 2 | { | 357 | 58 | for (int i = 0; i < n; i++) | 358 | 56 | fuzz_label_call(calls[i], i, n); | 359 | 2 | } |
Line | Count | Source | 356 | 2 | { | 357 | 46 | for (int i = 0; i < n; i++) | 358 | 44 | fuzz_label_call(calls[i], i, n); | 359 | 2 | } |
connections.c:fuzz_label_calls Line | Count | Source | 356 | 2 | { | 357 | 134 | for (int i = 0; i < n; i++) | 358 | 132 | fuzz_label_call(calls[i], i, n); | 359 | 2 | } |
unserialize.c:fuzz_label_calls Line | Count | Source | 356 | 2 | { | 357 | 10 | for (int i = 0; i < n; i++) | 358 | 8 | fuzz_label_call(calls[i], i, n); | 359 | 2 | } |
decompress.c:fuzz_label_calls Line | Count | Source | 356 | 2 | { | 357 | 10 | for (int i = 0; i < n; i++) | 358 | 8 | fuzz_label_call(calls[i], i, n); | 359 | 2 | } |
readtable.c:fuzz_label_calls Line | Count | Source | 356 | 2 | { | 357 | 42 | for (int i = 0; i < n; i++) | 358 | 40 | fuzz_label_call(calls[i], i, n); | 359 | 2 | } |
format.c:fuzz_label_calls Line | Count | Source | 356 | 2 | { | 357 | 50 | for (int i = 0; i < n; i++) | 358 | 48 | fuzz_label_call(calls[i], i, n); | 359 | 2 | } |
datetime.c:fuzz_label_calls Line | Count | Source | 356 | 2 | { | 357 | 36 | for (int i = 0; i < n; i++) | 358 | 34 | fuzz_label_call(calls[i], i, n); | 359 | 2 | } |
coerce.c:fuzz_label_calls Line | Count | Source | 356 | 2 | { | 357 | 10 | for (int i = 0; i < n; i++) | 358 | 8 | fuzz_label_call(calls[i], i, n); | 359 | 2 | } |
Line | Count | Source | 356 | 2 | { | 357 | 6 | for (int i = 0; i < n; i++) | 358 | 4 | fuzz_label_call(calls[i], i, n); | 359 | 2 | } |
Line | Count | Source | 356 | 2 | { | 357 | 38 | for (int i = 0; i < n; i++) | 358 | 36 | fuzz_label_call(calls[i], i, n); | 359 | 2 | } |
colors.c:fuzz_label_calls Line | Count | Source | 356 | 2 | { | 357 | 34 | for (int i = 0; i < n; i++) | 358 | 32 | fuzz_label_call(calls[i], i, n); | 359 | 2 | } |
Line | Count | Source | 356 | 2 | { | 357 | 16 | for (int i = 0; i < n; i++) | 358 | 14 | fuzz_label_call(calls[i], i, n); | 359 | 2 | } |
sockets.c:fuzz_label_calls Line | Count | Source | 356 | 1 | { | 357 | 2 | for (int i = 0; i < n; i++) | 358 | 1 | fuzz_label_call(calls[i], i, n); | 359 | 1 | } |
sprintf.c:fuzz_label_calls Line | Count | Source | 356 | 2 | { | 357 | 10 | for (int i = 0; i < n; i++) | 358 | 8 | fuzz_label_call(calls[i], i, n); | 359 | 2 | } |
Unexecuted instantiation: eval.c:fuzz_label_calls Line | Count | Source | 356 | 2 | { | 357 | 10 | for (int i = 0; i < n; i++) | 358 | 8 | fuzz_label_call(calls[i], i, n); | 359 | 2 | } |
|
360 | | |
361 | | /* Note the call about to be evaluated; an unregistered one clears it. */ |
362 | | static void fuzz_label_enter(SEXP call) |
363 | 88.8k | { |
364 | 88.8k | int found = -1; |
365 | 991k | for (int i = 0; i < fuzz_n_labels; i++) { |
366 | 986k | if (fuzz_labels[i].call == call) { |
367 | 84.0k | found = i; |
368 | 84.0k | break; |
369 | 84.0k | } |
370 | 986k | } |
371 | 88.8k | atomic_store(&fuzz_label_current, found); |
372 | 88.8k | } Line | Count | Source | 363 | 2.20k | { | 364 | 2.20k | int found = -1; | 365 | 33.6k | for (int i = 0; i < fuzz_n_labels; i++) { | 366 | 33.6k | if (fuzz_labels[i].call == call) { | 367 | 2.20k | found = i; | 368 | 2.20k | break; | 369 | 2.20k | } | 370 | 33.6k | } | 371 | | atomic_store(&fuzz_label_current, found); | 372 | 2.20k | } |
Line | Count | Source | 363 | 4.99k | { | 364 | 4.99k | int found = -1; | 365 | 9.16k | for (int i = 0; i < fuzz_n_labels; i++) { | 366 | 9.16k | if (fuzz_labels[i].call == call) { | 367 | 4.99k | found = i; | 368 | 4.99k | break; | 369 | 4.99k | } | 370 | 9.16k | } | 371 | | atomic_store(&fuzz_label_current, found); | 372 | 4.99k | } |
character.c:fuzz_label_enter Line | Count | Source | 363 | 4.42k | { | 364 | 4.42k | int found = -1; | 365 | 93.2k | for (int i = 0; i < fuzz_n_labels; i++) { | 366 | 93.2k | if (fuzz_labels[i].call == call) { | 367 | 4.42k | found = i; | 368 | 4.42k | break; | 369 | 4.42k | } | 370 | 93.2k | } | 371 | | atomic_store(&fuzz_label_current, found); | 372 | 4.42k | } |
encoding.c:fuzz_label_enter Line | Count | Source | 363 | 1.74k | { | 364 | 1.74k | int found = -1; | 365 | 31.0k | for (int i = 0; i < fuzz_n_labels; i++) { | 366 | 31.0k | if (fuzz_labels[i].call == call) { | 367 | 1.74k | found = i; | 368 | 1.74k | break; | 369 | 1.74k | } | 370 | 31.0k | } | 371 | | atomic_store(&fuzz_label_current, found); | 372 | 1.74k | } |
Line | Count | Source | 363 | 6.73k | { | 364 | 6.73k | int found = -1; | 365 | 74.8k | for (int i = 0; i < fuzz_n_labels; i++) { | 366 | 74.8k | if (fuzz_labels[i].call == call) { | 367 | 6.73k | found = i; | 368 | 6.73k | break; | 369 | 6.73k | } | 370 | 74.8k | } | 371 | | atomic_store(&fuzz_label_current, found); | 372 | 6.73k | } |
connections.c:fuzz_label_enter Line | Count | Source | 363 | 7.60k | { | 364 | 7.60k | int found = -1; | 365 | 393k | for (int i = 0; i < fuzz_n_labels; i++) { | 366 | 391k | if (fuzz_labels[i].call == call) { | 367 | 5.92k | found = i; | 368 | 5.92k | break; | 369 | 5.92k | } | 370 | 391k | } | 371 | | atomic_store(&fuzz_label_current, found); | 372 | 7.60k | } |
unserialize.c:fuzz_label_enter Line | Count | Source | 363 | 5.61k | { | 364 | 5.61k | int found = -1; | 365 | 13.4k | for (int i = 0; i < fuzz_n_labels; i++) { | 366 | 13.4k | if (fuzz_labels[i].call == call) { | 367 | 5.61k | found = i; | 368 | 5.61k | break; | 369 | 5.61k | } | 370 | 13.4k | } | 371 | | atomic_store(&fuzz_label_current, found); | 372 | 5.61k | } |
decompress.c:fuzz_label_enter Line | Count | Source | 363 | 6.74k | { | 364 | 6.74k | int found = -1; | 365 | 24.5k | for (int i = 0; i < fuzz_n_labels; i++) { | 366 | 24.5k | if (fuzz_labels[i].call == call) { | 367 | 6.74k | found = i; | 368 | 6.74k | break; | 369 | 6.74k | } | 370 | 24.5k | } | 371 | | atomic_store(&fuzz_label_current, found); | 372 | 6.74k | } |
readtable.c:fuzz_label_enter Line | Count | Source | 363 | 361 | { | 364 | 361 | int found = -1; | 365 | 4.53k | for (int i = 0; i < fuzz_n_labels; i++) { | 366 | 4.53k | if (fuzz_labels[i].call == call) { | 367 | 361 | found = i; | 368 | 361 | break; | 369 | 361 | } | 370 | 4.53k | } | 371 | | atomic_store(&fuzz_label_current, found); | 372 | 361 | } |
format.c:fuzz_label_enter Line | Count | Source | 363 | 5.51k | { | 364 | 5.51k | int found = -1; | 365 | 65.3k | for (int i = 0; i < fuzz_n_labels; i++) { | 366 | 65.3k | if (fuzz_labels[i].call == call) { | 367 | 5.51k | found = i; | 368 | 5.51k | break; | 369 | 5.51k | } | 370 | 65.3k | } | 371 | | atomic_store(&fuzz_label_current, found); | 372 | 5.51k | } |
datetime.c:fuzz_label_enter Line | Count | Source | 363 | 10.0k | { | 364 | 10.0k | int found = -1; | 365 | 127k | for (int i = 0; i < fuzz_n_labels; i++) { | 366 | 123k | if (fuzz_labels[i].call == call) { | 367 | 6.94k | found = i; | 368 | 6.94k | break; | 369 | 6.94k | } | 370 | 123k | } | 371 | | atomic_store(&fuzz_label_current, found); | 372 | 10.0k | } |
coerce.c:fuzz_label_enter Line | Count | Source | 363 | 7.55k | { | 364 | 7.55k | int found = -1; | 365 | 18.8k | for (int i = 0; i < fuzz_n_labels; i++) { | 366 | 18.8k | if (fuzz_labels[i].call == call) { | 367 | 7.55k | found = i; | 368 | 7.55k | break; | 369 | 7.55k | } | 370 | 18.8k | } | 371 | | atomic_store(&fuzz_label_current, found); | 372 | 7.55k | } |
Line | Count | Source | 363 | 8.49k | { | 364 | 8.49k | int found = -1; | 365 | 12.3k | for (int i = 0; i < fuzz_n_labels; i++) { | 366 | 12.3k | if (fuzz_labels[i].call == call) { | 367 | 8.49k | found = i; | 368 | 8.49k | break; | 369 | 8.49k | } | 370 | 12.3k | } | 371 | | atomic_store(&fuzz_label_current, found); | 372 | 8.49k | } |
Line | Count | Source | 363 | 3.15k | { | 364 | 3.15k | int found = -1; | 365 | 29.3k | for (int i = 0; i < fuzz_n_labels; i++) { | 366 | 29.3k | if (fuzz_labels[i].call == call) { | 367 | 3.15k | found = i; | 368 | 3.15k | break; | 369 | 3.15k | } | 370 | 29.3k | } | 371 | | atomic_store(&fuzz_label_current, found); | 372 | 3.15k | } |
colors.c:fuzz_label_enter Line | Count | Source | 363 | 1.87k | { | 364 | 1.87k | int found = -1; | 365 | 21.0k | for (int i = 0; i < fuzz_n_labels; i++) { | 366 | 21.0k | if (fuzz_labels[i].call == call) { | 367 | 1.87k | found = i; | 368 | 1.87k | break; | 369 | 1.87k | } | 370 | 21.0k | } | 371 | | atomic_store(&fuzz_label_current, found); | 372 | 1.87k | } |
Line | Count | Source | 363 | 7.25k | { | 364 | 7.25k | int found = -1; | 365 | 26.0k | for (int i = 0; i < fuzz_n_labels; i++) { | 366 | 26.0k | if (fuzz_labels[i].call == call) { | 367 | 7.25k | found = i; | 368 | 7.25k | break; | 369 | 7.25k | } | 370 | 26.0k | } | 371 | | atomic_store(&fuzz_label_current, found); | 372 | 7.25k | } |
Unexecuted instantiation: sockets.c:fuzz_label_enter sprintf.c:fuzz_label_enter Line | Count | Source | 363 | 2.17k | { | 364 | 2.17k | int found = -1; | 365 | 6.92k | for (int i = 0; i < fuzz_n_labels; i++) { | 366 | 6.92k | if (fuzz_labels[i].call == call) { | 367 | 2.17k | found = i; | 368 | 2.17k | break; | 369 | 2.17k | } | 370 | 6.92k | } | 371 | | atomic_store(&fuzz_label_current, found); | 372 | 2.17k | } |
Unexecuted instantiation: eval.c:fuzz_label_enter Line | Count | Source | 363 | 2.33k | { | 364 | 2.33k | int found = -1; | 365 | 6.42k | for (int i = 0; i < fuzz_n_labels; i++) { | 366 | 6.42k | if (fuzz_labels[i].call == call) { | 367 | 2.33k | found = i; | 368 | 2.33k | break; | 369 | 2.33k | } | 370 | 6.42k | } | 371 | | atomic_store(&fuzz_label_current, found); | 372 | 2.33k | } |
|
373 | | |
374 | | /* Runs on the R thread, interrupting whatever the input is doing. */ |
375 | | static void fuzz_dump_handler(int sig, siginfo_t *info, void *context) |
376 | 0 | { |
377 | 0 | (void)sig; |
378 | 0 | (void)info; |
379 | 0 | (void)context; |
380 | 0 | unsigned input = atomic_load(&fuzz_alarm.requested); |
381 | 0 | int label = atomic_load(&fuzz_label_current); |
382 | 0 | if (label >= 0) |
383 | 0 | fuzz_write_stderr(fuzz_labels[label].text); |
384 | 0 | if (__sanitizer_print_stack_trace) |
385 | 0 | __sanitizer_print_stack_trace(); |
386 | 0 | else |
387 | 0 | fuzz_write_stderr(" (no sanitizer runtime to print it)\n"); |
388 | 0 | atomic_store(&fuzz_alarm.done, input); |
389 | 0 | } Unexecuted instantiation: io.c:fuzz_dump_handler Unexecuted instantiation: dcf.c:fuzz_dump_handler Unexecuted instantiation: character.c:fuzz_dump_handler Unexecuted instantiation: encoding.c:fuzz_dump_handler Unexecuted instantiation: sort.c:fuzz_dump_handler Unexecuted instantiation: connections.c:fuzz_dump_handler Unexecuted instantiation: unserialize.c:fuzz_dump_handler Unexecuted instantiation: decompress.c:fuzz_dump_handler Unexecuted instantiation: readtable.c:fuzz_dump_handler Unexecuted instantiation: format.c:fuzz_dump_handler Unexecuted instantiation: datetime.c:fuzz_dump_handler Unexecuted instantiation: coerce.c:fuzz_dump_handler Unexecuted instantiation: load.c:fuzz_dump_handler Unexecuted instantiation: scan.c:fuzz_dump_handler Unexecuted instantiation: colors.c:fuzz_dump_handler Unexecuted instantiation: parse.c:fuzz_dump_handler Unexecuted instantiation: sockets.c:fuzz_dump_handler Unexecuted instantiation: sprintf.c:fuzz_dump_handler Unexecuted instantiation: eval.c:fuzz_dump_handler Unexecuted instantiation: zip.c:fuzz_dump_handler |
390 | | |
391 | | /* Whole seconds since a moment. */ |
392 | | static long fuzz_seconds_since(const struct timespec *then) |
393 | 23 | { |
394 | 23 | struct timespec now; |
395 | 23 | clock_gettime(CLOCK_REALTIME, &now); |
396 | | |
397 | 23 | long seconds = now.tv_sec - then->tv_sec; |
398 | 23 | if (now.tv_nsec < then->tv_nsec) |
399 | 2 | seconds--; |
400 | 23 | return seconds; |
401 | 23 | } Unexecuted instantiation: io.c:fuzz_seconds_since Line | Count | Source | 393 | 3 | { | 394 | 3 | struct timespec now; | 395 | 3 | clock_gettime(CLOCK_REALTIME, &now); | 396 | | | 397 | 3 | long seconds = now.tv_sec - then->tv_sec; | 398 | 3 | if (now.tv_nsec < then->tv_nsec) | 399 | 0 | seconds--; | 400 | 3 | return seconds; | 401 | 3 | } |
character.c:fuzz_seconds_since Line | Count | Source | 393 | 2 | { | 394 | 2 | struct timespec now; | 395 | 2 | clock_gettime(CLOCK_REALTIME, &now); | 396 | | | 397 | 2 | long seconds = now.tv_sec - then->tv_sec; | 398 | 2 | if (now.tv_nsec < then->tv_nsec) | 399 | 0 | seconds--; | 400 | 2 | return seconds; | 401 | 2 | } |
Unexecuted instantiation: encoding.c:fuzz_seconds_since sort.c:fuzz_seconds_since Line | Count | Source | 393 | 2 | { | 394 | 2 | struct timespec now; | 395 | 2 | clock_gettime(CLOCK_REALTIME, &now); | 396 | | | 397 | 2 | long seconds = now.tv_sec - then->tv_sec; | 398 | 2 | if (now.tv_nsec < then->tv_nsec) | 399 | 2 | seconds--; | 400 | 2 | return seconds; | 401 | 2 | } |
Unexecuted instantiation: connections.c:fuzz_seconds_since unserialize.c:fuzz_seconds_since Line | Count | Source | 393 | 2 | { | 394 | 2 | struct timespec now; | 395 | 2 | clock_gettime(CLOCK_REALTIME, &now); | 396 | | | 397 | 2 | long seconds = now.tv_sec - then->tv_sec; | 398 | 2 | if (now.tv_nsec < then->tv_nsec) | 399 | 0 | seconds--; | 400 | 2 | return seconds; | 401 | 2 | } |
decompress.c:fuzz_seconds_since Line | Count | Source | 393 | 1 | { | 394 | 1 | struct timespec now; | 395 | 1 | clock_gettime(CLOCK_REALTIME, &now); | 396 | | | 397 | 1 | long seconds = now.tv_sec - then->tv_sec; | 398 | 1 | if (now.tv_nsec < then->tv_nsec) | 399 | 0 | seconds--; | 400 | 1 | return seconds; | 401 | 1 | } |
Unexecuted instantiation: readtable.c:fuzz_seconds_since format.c:fuzz_seconds_since Line | Count | Source | 393 | 2 | { | 394 | 2 | struct timespec now; | 395 | 2 | clock_gettime(CLOCK_REALTIME, &now); | 396 | | | 397 | 2 | long seconds = now.tv_sec - then->tv_sec; | 398 | 2 | if (now.tv_nsec < then->tv_nsec) | 399 | 0 | seconds--; | 400 | 2 | return seconds; | 401 | 2 | } |
Unexecuted instantiation: datetime.c:fuzz_seconds_since Unexecuted instantiation: coerce.c:fuzz_seconds_since load.c:fuzz_seconds_since Line | Count | Source | 393 | 2 | { | 394 | 2 | struct timespec now; | 395 | 2 | clock_gettime(CLOCK_REALTIME, &now); | 396 | | | 397 | 2 | long seconds = now.tv_sec - then->tv_sec; | 398 | 2 | if (now.tv_nsec < then->tv_nsec) | 399 | 0 | seconds--; | 400 | 2 | return seconds; | 401 | 2 | } |
Unexecuted instantiation: scan.c:fuzz_seconds_since colors.c:fuzz_seconds_since Line | Count | Source | 393 | 1 | { | 394 | 1 | struct timespec now; | 395 | 1 | clock_gettime(CLOCK_REALTIME, &now); | 396 | | | 397 | 1 | long seconds = now.tv_sec - then->tv_sec; | 398 | 1 | if (now.tv_nsec < then->tv_nsec) | 399 | 0 | seconds--; | 400 | 1 | return seconds; | 401 | 1 | } |
parse.c:fuzz_seconds_since Line | Count | Source | 393 | 1 | { | 394 | 1 | struct timespec now; | 395 | 1 | clock_gettime(CLOCK_REALTIME, &now); | 396 | | | 397 | 1 | long seconds = now.tv_sec - then->tv_sec; | 398 | 1 | if (now.tv_nsec < then->tv_nsec) | 399 | 0 | seconds--; | 400 | 1 | return seconds; | 401 | 1 | } |
Unexecuted instantiation: sockets.c:fuzz_seconds_since Unexecuted instantiation: sprintf.c:fuzz_seconds_since eval.c:fuzz_seconds_since Line | Count | Source | 393 | 7 | { | 394 | 7 | struct timespec now; | 395 | 7 | clock_gettime(CLOCK_REALTIME, &now); | 396 | | | 397 | 7 | long seconds = now.tv_sec - then->tv_sec; | 398 | 7 | if (now.tv_nsec < then->tv_nsec) | 399 | 0 | seconds--; | 400 | 7 | return seconds; | 401 | 7 | } |
Unexecuted instantiation: zip.c:fuzz_seconds_since |
402 | | |
403 | | /* Runs on the main thread, where libFuzzer's alarm lands. */ |
404 | | static void fuzz_alarm_handler(int sig, siginfo_t *info, void *context) |
405 | 23 | { |
406 | 23 | if (atomic_load(&fuzz_alarm.finishing)) |
407 | 0 | return; |
408 | | |
409 | 23 | if (atomic_load(&fuzz_alarm.running) && |
410 | 23 | fuzz_seconds_since(&fuzz_alarm.armed) >= fuzz_alarm.timeout - 1) { |
411 | 0 | struct timespec tick = { 0, fuzz_alarm.poll_ns }; |
412 | | |
413 | | /* Hold until the input is out of time by its own clock as well; |
414 | | * one that finishes first, even in the last sleep, was within |
415 | | * its time. The clock is read before the input is looked at, so |
416 | | * an input seen running was running at a moment past the |
417 | | * timeout, whatever delay falls between the two. */ |
418 | 0 | for (;;) { |
419 | 0 | long age = fuzz_seconds_since(&fuzz_alarm.started); |
420 | 0 | if (!atomic_load(&fuzz_alarm.running)) { |
421 | 0 | atomic_store(&fuzz_alarm.finishing, 1); |
422 | 0 | return; |
423 | 0 | } |
424 | 0 | if (age >= fuzz_alarm.timeout) |
425 | 0 | break; |
426 | 0 | nanosleep(&tick, NULL); |
427 | 0 | } |
428 | | |
429 | 0 | unsigned input = atomic_load(&fuzz_alarm.input); |
430 | 0 | if (atomic_load(&fuzz_alarm.requested) != input) { |
431 | 0 | atomic_store(&fuzz_alarm.requested, input); |
432 | 0 | fuzz_write_stderr("==fuzz== R thread, where the input is running:\n"); |
433 | 0 | if (pthread_kill(fuzz_r_thread.thread, FUZZ_DUMP_SIGNAL) != 0) |
434 | 0 | atomic_store(&fuzz_alarm.done, input); |
435 | 0 | } |
436 | | |
437 | | /* Symbolizing takes a moment; a thread that never answers (stuck |
438 | | * in the allocator, say) must not hold up the report, and an |
439 | | * input finishing now is reported all the same: it was out of |
440 | | * time already. */ |
441 | 0 | for (int i = 0; i < 5000; i++) { |
442 | 0 | if (atomic_load(&fuzz_alarm.done) == input || |
443 | 0 | !atomic_load(&fuzz_alarm.running)) |
444 | 0 | break; |
445 | 0 | nanosleep(&tick, NULL); |
446 | 0 | } |
447 | 0 | } |
448 | 23 | fuzz_alarm.chain.sa_sigaction(sig, info, context); |
449 | 23 | } Unexecuted instantiation: io.c:fuzz_alarm_handler Line | Count | Source | 405 | 3 | { | 406 | 3 | if (atomic_load(&fuzz_alarm.finishing)) | 407 | 0 | return; | 408 | | | 409 | 3 | if (atomic_load(&fuzz_alarm.running) && | 410 | 3 | fuzz_seconds_since(&fuzz_alarm.armed) >= fuzz_alarm.timeout - 1) { | 411 | 0 | struct timespec tick = { 0, fuzz_alarm.poll_ns }; | 412 | | | 413 | | /* Hold until the input is out of time by its own clock as well; | 414 | | * one that finishes first, even in the last sleep, was within | 415 | | * its time. The clock is read before the input is looked at, so | 416 | | * an input seen running was running at a moment past the | 417 | | * timeout, whatever delay falls between the two. */ | 418 | 0 | for (;;) { | 419 | 0 | long age = fuzz_seconds_since(&fuzz_alarm.started); | 420 | 0 | if (!atomic_load(&fuzz_alarm.running)) { | 421 | 0 | atomic_store(&fuzz_alarm.finishing, 1); | 422 | 0 | return; | 423 | 0 | } | 424 | 0 | if (age >= fuzz_alarm.timeout) | 425 | 0 | break; | 426 | 0 | nanosleep(&tick, NULL); | 427 | 0 | } | 428 | | | 429 | 0 | unsigned input = atomic_load(&fuzz_alarm.input); | 430 | 0 | if (atomic_load(&fuzz_alarm.requested) != input) { | 431 | 0 | atomic_store(&fuzz_alarm.requested, input); | 432 | 0 | fuzz_write_stderr("==fuzz== R thread, where the input is running:\n"); | 433 | 0 | if (pthread_kill(fuzz_r_thread.thread, FUZZ_DUMP_SIGNAL) != 0) | 434 | 0 | atomic_store(&fuzz_alarm.done, input); | 435 | 0 | } | 436 | | | 437 | | /* Symbolizing takes a moment; a thread that never answers (stuck | 438 | | * in the allocator, say) must not hold up the report, and an | 439 | | * input finishing now is reported all the same: it was out of | 440 | | * time already. */ | 441 | 0 | for (int i = 0; i < 5000; i++) { | 442 | 0 | if (atomic_load(&fuzz_alarm.done) == input || | 443 | 0 | !atomic_load(&fuzz_alarm.running)) | 444 | 0 | break; | 445 | 0 | nanosleep(&tick, NULL); | 446 | 0 | } | 447 | 0 | } | 448 | 3 | fuzz_alarm.chain.sa_sigaction(sig, info, context); | 449 | 3 | } |
character.c:fuzz_alarm_handler Line | Count | Source | 405 | 2 | { | 406 | 2 | if (atomic_load(&fuzz_alarm.finishing)) | 407 | 0 | return; | 408 | | | 409 | 2 | if (atomic_load(&fuzz_alarm.running) && | 410 | 2 | fuzz_seconds_since(&fuzz_alarm.armed) >= fuzz_alarm.timeout - 1) { | 411 | 0 | struct timespec tick = { 0, fuzz_alarm.poll_ns }; | 412 | | | 413 | | /* Hold until the input is out of time by its own clock as well; | 414 | | * one that finishes first, even in the last sleep, was within | 415 | | * its time. The clock is read before the input is looked at, so | 416 | | * an input seen running was running at a moment past the | 417 | | * timeout, whatever delay falls between the two. */ | 418 | 0 | for (;;) { | 419 | 0 | long age = fuzz_seconds_since(&fuzz_alarm.started); | 420 | 0 | if (!atomic_load(&fuzz_alarm.running)) { | 421 | 0 | atomic_store(&fuzz_alarm.finishing, 1); | 422 | 0 | return; | 423 | 0 | } | 424 | 0 | if (age >= fuzz_alarm.timeout) | 425 | 0 | break; | 426 | 0 | nanosleep(&tick, NULL); | 427 | 0 | } | 428 | | | 429 | 0 | unsigned input = atomic_load(&fuzz_alarm.input); | 430 | 0 | if (atomic_load(&fuzz_alarm.requested) != input) { | 431 | 0 | atomic_store(&fuzz_alarm.requested, input); | 432 | 0 | fuzz_write_stderr("==fuzz== R thread, where the input is running:\n"); | 433 | 0 | if (pthread_kill(fuzz_r_thread.thread, FUZZ_DUMP_SIGNAL) != 0) | 434 | 0 | atomic_store(&fuzz_alarm.done, input); | 435 | 0 | } | 436 | | | 437 | | /* Symbolizing takes a moment; a thread that never answers (stuck | 438 | | * in the allocator, say) must not hold up the report, and an | 439 | | * input finishing now is reported all the same: it was out of | 440 | | * time already. */ | 441 | 0 | for (int i = 0; i < 5000; i++) { | 442 | 0 | if (atomic_load(&fuzz_alarm.done) == input || | 443 | 0 | !atomic_load(&fuzz_alarm.running)) | 444 | 0 | break; | 445 | 0 | nanosleep(&tick, NULL); | 446 | 0 | } | 447 | 0 | } | 448 | 2 | fuzz_alarm.chain.sa_sigaction(sig, info, context); | 449 | 2 | } |
Unexecuted instantiation: encoding.c:fuzz_alarm_handler sort.c:fuzz_alarm_handler Line | Count | Source | 405 | 2 | { | 406 | 2 | if (atomic_load(&fuzz_alarm.finishing)) | 407 | 0 | return; | 408 | | | 409 | 2 | if (atomic_load(&fuzz_alarm.running) && | 410 | 2 | fuzz_seconds_since(&fuzz_alarm.armed) >= fuzz_alarm.timeout - 1) { | 411 | 0 | struct timespec tick = { 0, fuzz_alarm.poll_ns }; | 412 | | | 413 | | /* Hold until the input is out of time by its own clock as well; | 414 | | * one that finishes first, even in the last sleep, was within | 415 | | * its time. The clock is read before the input is looked at, so | 416 | | * an input seen running was running at a moment past the | 417 | | * timeout, whatever delay falls between the two. */ | 418 | 0 | for (;;) { | 419 | 0 | long age = fuzz_seconds_since(&fuzz_alarm.started); | 420 | 0 | if (!atomic_load(&fuzz_alarm.running)) { | 421 | 0 | atomic_store(&fuzz_alarm.finishing, 1); | 422 | 0 | return; | 423 | 0 | } | 424 | 0 | if (age >= fuzz_alarm.timeout) | 425 | 0 | break; | 426 | 0 | nanosleep(&tick, NULL); | 427 | 0 | } | 428 | | | 429 | 0 | unsigned input = atomic_load(&fuzz_alarm.input); | 430 | 0 | if (atomic_load(&fuzz_alarm.requested) != input) { | 431 | 0 | atomic_store(&fuzz_alarm.requested, input); | 432 | 0 | fuzz_write_stderr("==fuzz== R thread, where the input is running:\n"); | 433 | 0 | if (pthread_kill(fuzz_r_thread.thread, FUZZ_DUMP_SIGNAL) != 0) | 434 | 0 | atomic_store(&fuzz_alarm.done, input); | 435 | 0 | } | 436 | | | 437 | | /* Symbolizing takes a moment; a thread that never answers (stuck | 438 | | * in the allocator, say) must not hold up the report, and an | 439 | | * input finishing now is reported all the same: it was out of | 440 | | * time already. */ | 441 | 0 | for (int i = 0; i < 5000; i++) { | 442 | 0 | if (atomic_load(&fuzz_alarm.done) == input || | 443 | 0 | !atomic_load(&fuzz_alarm.running)) | 444 | 0 | break; | 445 | 0 | nanosleep(&tick, NULL); | 446 | 0 | } | 447 | 0 | } | 448 | 2 | fuzz_alarm.chain.sa_sigaction(sig, info, context); | 449 | 2 | } |
Unexecuted instantiation: connections.c:fuzz_alarm_handler unserialize.c:fuzz_alarm_handler Line | Count | Source | 405 | 2 | { | 406 | 2 | if (atomic_load(&fuzz_alarm.finishing)) | 407 | 0 | return; | 408 | | | 409 | 2 | if (atomic_load(&fuzz_alarm.running) && | 410 | 2 | fuzz_seconds_since(&fuzz_alarm.armed) >= fuzz_alarm.timeout - 1) { | 411 | 0 | struct timespec tick = { 0, fuzz_alarm.poll_ns }; | 412 | | | 413 | | /* Hold until the input is out of time by its own clock as well; | 414 | | * one that finishes first, even in the last sleep, was within | 415 | | * its time. The clock is read before the input is looked at, so | 416 | | * an input seen running was running at a moment past the | 417 | | * timeout, whatever delay falls between the two. */ | 418 | 0 | for (;;) { | 419 | 0 | long age = fuzz_seconds_since(&fuzz_alarm.started); | 420 | 0 | if (!atomic_load(&fuzz_alarm.running)) { | 421 | 0 | atomic_store(&fuzz_alarm.finishing, 1); | 422 | 0 | return; | 423 | 0 | } | 424 | 0 | if (age >= fuzz_alarm.timeout) | 425 | 0 | break; | 426 | 0 | nanosleep(&tick, NULL); | 427 | 0 | } | 428 | | | 429 | 0 | unsigned input = atomic_load(&fuzz_alarm.input); | 430 | 0 | if (atomic_load(&fuzz_alarm.requested) != input) { | 431 | 0 | atomic_store(&fuzz_alarm.requested, input); | 432 | 0 | fuzz_write_stderr("==fuzz== R thread, where the input is running:\n"); | 433 | 0 | if (pthread_kill(fuzz_r_thread.thread, FUZZ_DUMP_SIGNAL) != 0) | 434 | 0 | atomic_store(&fuzz_alarm.done, input); | 435 | 0 | } | 436 | | | 437 | | /* Symbolizing takes a moment; a thread that never answers (stuck | 438 | | * in the allocator, say) must not hold up the report, and an | 439 | | * input finishing now is reported all the same: it was out of | 440 | | * time already. */ | 441 | 0 | for (int i = 0; i < 5000; i++) { | 442 | 0 | if (atomic_load(&fuzz_alarm.done) == input || | 443 | 0 | !atomic_load(&fuzz_alarm.running)) | 444 | 0 | break; | 445 | 0 | nanosleep(&tick, NULL); | 446 | 0 | } | 447 | 0 | } | 448 | 2 | fuzz_alarm.chain.sa_sigaction(sig, info, context); | 449 | 2 | } |
decompress.c:fuzz_alarm_handler Line | Count | Source | 405 | 1 | { | 406 | 1 | if (atomic_load(&fuzz_alarm.finishing)) | 407 | 0 | return; | 408 | | | 409 | 1 | if (atomic_load(&fuzz_alarm.running) && | 410 | 1 | fuzz_seconds_since(&fuzz_alarm.armed) >= fuzz_alarm.timeout - 1) { | 411 | 0 | struct timespec tick = { 0, fuzz_alarm.poll_ns }; | 412 | | | 413 | | /* Hold until the input is out of time by its own clock as well; | 414 | | * one that finishes first, even in the last sleep, was within | 415 | | * its time. The clock is read before the input is looked at, so | 416 | | * an input seen running was running at a moment past the | 417 | | * timeout, whatever delay falls between the two. */ | 418 | 0 | for (;;) { | 419 | 0 | long age = fuzz_seconds_since(&fuzz_alarm.started); | 420 | 0 | if (!atomic_load(&fuzz_alarm.running)) { | 421 | 0 | atomic_store(&fuzz_alarm.finishing, 1); | 422 | 0 | return; | 423 | 0 | } | 424 | 0 | if (age >= fuzz_alarm.timeout) | 425 | 0 | break; | 426 | 0 | nanosleep(&tick, NULL); | 427 | 0 | } | 428 | | | 429 | 0 | unsigned input = atomic_load(&fuzz_alarm.input); | 430 | 0 | if (atomic_load(&fuzz_alarm.requested) != input) { | 431 | 0 | atomic_store(&fuzz_alarm.requested, input); | 432 | 0 | fuzz_write_stderr("==fuzz== R thread, where the input is running:\n"); | 433 | 0 | if (pthread_kill(fuzz_r_thread.thread, FUZZ_DUMP_SIGNAL) != 0) | 434 | 0 | atomic_store(&fuzz_alarm.done, input); | 435 | 0 | } | 436 | | | 437 | | /* Symbolizing takes a moment; a thread that never answers (stuck | 438 | | * in the allocator, say) must not hold up the report, and an | 439 | | * input finishing now is reported all the same: it was out of | 440 | | * time already. */ | 441 | 0 | for (int i = 0; i < 5000; i++) { | 442 | 0 | if (atomic_load(&fuzz_alarm.done) == input || | 443 | 0 | !atomic_load(&fuzz_alarm.running)) | 444 | 0 | break; | 445 | 0 | nanosleep(&tick, NULL); | 446 | 0 | } | 447 | 0 | } | 448 | 1 | fuzz_alarm.chain.sa_sigaction(sig, info, context); | 449 | 1 | } |
Unexecuted instantiation: readtable.c:fuzz_alarm_handler format.c:fuzz_alarm_handler Line | Count | Source | 405 | 2 | { | 406 | 2 | if (atomic_load(&fuzz_alarm.finishing)) | 407 | 0 | return; | 408 | | | 409 | 2 | if (atomic_load(&fuzz_alarm.running) && | 410 | 2 | fuzz_seconds_since(&fuzz_alarm.armed) >= fuzz_alarm.timeout - 1) { | 411 | 0 | struct timespec tick = { 0, fuzz_alarm.poll_ns }; | 412 | | | 413 | | /* Hold until the input is out of time by its own clock as well; | 414 | | * one that finishes first, even in the last sleep, was within | 415 | | * its time. The clock is read before the input is looked at, so | 416 | | * an input seen running was running at a moment past the | 417 | | * timeout, whatever delay falls between the two. */ | 418 | 0 | for (;;) { | 419 | 0 | long age = fuzz_seconds_since(&fuzz_alarm.started); | 420 | 0 | if (!atomic_load(&fuzz_alarm.running)) { | 421 | 0 | atomic_store(&fuzz_alarm.finishing, 1); | 422 | 0 | return; | 423 | 0 | } | 424 | 0 | if (age >= fuzz_alarm.timeout) | 425 | 0 | break; | 426 | 0 | nanosleep(&tick, NULL); | 427 | 0 | } | 428 | | | 429 | 0 | unsigned input = atomic_load(&fuzz_alarm.input); | 430 | 0 | if (atomic_load(&fuzz_alarm.requested) != input) { | 431 | 0 | atomic_store(&fuzz_alarm.requested, input); | 432 | 0 | fuzz_write_stderr("==fuzz== R thread, where the input is running:\n"); | 433 | 0 | if (pthread_kill(fuzz_r_thread.thread, FUZZ_DUMP_SIGNAL) != 0) | 434 | 0 | atomic_store(&fuzz_alarm.done, input); | 435 | 0 | } | 436 | | | 437 | | /* Symbolizing takes a moment; a thread that never answers (stuck | 438 | | * in the allocator, say) must not hold up the report, and an | 439 | | * input finishing now is reported all the same: it was out of | 440 | | * time already. */ | 441 | 0 | for (int i = 0; i < 5000; i++) { | 442 | 0 | if (atomic_load(&fuzz_alarm.done) == input || | 443 | 0 | !atomic_load(&fuzz_alarm.running)) | 444 | 0 | break; | 445 | 0 | nanosleep(&tick, NULL); | 446 | 0 | } | 447 | 0 | } | 448 | 2 | fuzz_alarm.chain.sa_sigaction(sig, info, context); | 449 | 2 | } |
Unexecuted instantiation: datetime.c:fuzz_alarm_handler Unexecuted instantiation: coerce.c:fuzz_alarm_handler load.c:fuzz_alarm_handler Line | Count | Source | 405 | 2 | { | 406 | 2 | if (atomic_load(&fuzz_alarm.finishing)) | 407 | 0 | return; | 408 | | | 409 | 2 | if (atomic_load(&fuzz_alarm.running) && | 410 | 2 | fuzz_seconds_since(&fuzz_alarm.armed) >= fuzz_alarm.timeout - 1) { | 411 | 0 | struct timespec tick = { 0, fuzz_alarm.poll_ns }; | 412 | | | 413 | | /* Hold until the input is out of time by its own clock as well; | 414 | | * one that finishes first, even in the last sleep, was within | 415 | | * its time. The clock is read before the input is looked at, so | 416 | | * an input seen running was running at a moment past the | 417 | | * timeout, whatever delay falls between the two. */ | 418 | 0 | for (;;) { | 419 | 0 | long age = fuzz_seconds_since(&fuzz_alarm.started); | 420 | 0 | if (!atomic_load(&fuzz_alarm.running)) { | 421 | 0 | atomic_store(&fuzz_alarm.finishing, 1); | 422 | 0 | return; | 423 | 0 | } | 424 | 0 | if (age >= fuzz_alarm.timeout) | 425 | 0 | break; | 426 | 0 | nanosleep(&tick, NULL); | 427 | 0 | } | 428 | | | 429 | 0 | unsigned input = atomic_load(&fuzz_alarm.input); | 430 | 0 | if (atomic_load(&fuzz_alarm.requested) != input) { | 431 | 0 | atomic_store(&fuzz_alarm.requested, input); | 432 | 0 | fuzz_write_stderr("==fuzz== R thread, where the input is running:\n"); | 433 | 0 | if (pthread_kill(fuzz_r_thread.thread, FUZZ_DUMP_SIGNAL) != 0) | 434 | 0 | atomic_store(&fuzz_alarm.done, input); | 435 | 0 | } | 436 | | | 437 | | /* Symbolizing takes a moment; a thread that never answers (stuck | 438 | | * in the allocator, say) must not hold up the report, and an | 439 | | * input finishing now is reported all the same: it was out of | 440 | | * time already. */ | 441 | 0 | for (int i = 0; i < 5000; i++) { | 442 | 0 | if (atomic_load(&fuzz_alarm.done) == input || | 443 | 0 | !atomic_load(&fuzz_alarm.running)) | 444 | 0 | break; | 445 | 0 | nanosleep(&tick, NULL); | 446 | 0 | } | 447 | 0 | } | 448 | 2 | fuzz_alarm.chain.sa_sigaction(sig, info, context); | 449 | 2 | } |
Unexecuted instantiation: scan.c:fuzz_alarm_handler colors.c:fuzz_alarm_handler Line | Count | Source | 405 | 1 | { | 406 | 1 | if (atomic_load(&fuzz_alarm.finishing)) | 407 | 0 | return; | 408 | | | 409 | 1 | if (atomic_load(&fuzz_alarm.running) && | 410 | 1 | fuzz_seconds_since(&fuzz_alarm.armed) >= fuzz_alarm.timeout - 1) { | 411 | 0 | struct timespec tick = { 0, fuzz_alarm.poll_ns }; | 412 | | | 413 | | /* Hold until the input is out of time by its own clock as well; | 414 | | * one that finishes first, even in the last sleep, was within | 415 | | * its time. The clock is read before the input is looked at, so | 416 | | * an input seen running was running at a moment past the | 417 | | * timeout, whatever delay falls between the two. */ | 418 | 0 | for (;;) { | 419 | 0 | long age = fuzz_seconds_since(&fuzz_alarm.started); | 420 | 0 | if (!atomic_load(&fuzz_alarm.running)) { | 421 | 0 | atomic_store(&fuzz_alarm.finishing, 1); | 422 | 0 | return; | 423 | 0 | } | 424 | 0 | if (age >= fuzz_alarm.timeout) | 425 | 0 | break; | 426 | 0 | nanosleep(&tick, NULL); | 427 | 0 | } | 428 | | | 429 | 0 | unsigned input = atomic_load(&fuzz_alarm.input); | 430 | 0 | if (atomic_load(&fuzz_alarm.requested) != input) { | 431 | 0 | atomic_store(&fuzz_alarm.requested, input); | 432 | 0 | fuzz_write_stderr("==fuzz== R thread, where the input is running:\n"); | 433 | 0 | if (pthread_kill(fuzz_r_thread.thread, FUZZ_DUMP_SIGNAL) != 0) | 434 | 0 | atomic_store(&fuzz_alarm.done, input); | 435 | 0 | } | 436 | | | 437 | | /* Symbolizing takes a moment; a thread that never answers (stuck | 438 | | * in the allocator, say) must not hold up the report, and an | 439 | | * input finishing now is reported all the same: it was out of | 440 | | * time already. */ | 441 | 0 | for (int i = 0; i < 5000; i++) { | 442 | 0 | if (atomic_load(&fuzz_alarm.done) == input || | 443 | 0 | !atomic_load(&fuzz_alarm.running)) | 444 | 0 | break; | 445 | 0 | nanosleep(&tick, NULL); | 446 | 0 | } | 447 | 0 | } | 448 | 1 | fuzz_alarm.chain.sa_sigaction(sig, info, context); | 449 | 1 | } |
parse.c:fuzz_alarm_handler Line | Count | Source | 405 | 1 | { | 406 | 1 | if (atomic_load(&fuzz_alarm.finishing)) | 407 | 0 | return; | 408 | | | 409 | 1 | if (atomic_load(&fuzz_alarm.running) && | 410 | 1 | fuzz_seconds_since(&fuzz_alarm.armed) >= fuzz_alarm.timeout - 1) { | 411 | 0 | struct timespec tick = { 0, fuzz_alarm.poll_ns }; | 412 | | | 413 | | /* Hold until the input is out of time by its own clock as well; | 414 | | * one that finishes first, even in the last sleep, was within | 415 | | * its time. The clock is read before the input is looked at, so | 416 | | * an input seen running was running at a moment past the | 417 | | * timeout, whatever delay falls between the two. */ | 418 | 0 | for (;;) { | 419 | 0 | long age = fuzz_seconds_since(&fuzz_alarm.started); | 420 | 0 | if (!atomic_load(&fuzz_alarm.running)) { | 421 | 0 | atomic_store(&fuzz_alarm.finishing, 1); | 422 | 0 | return; | 423 | 0 | } | 424 | 0 | if (age >= fuzz_alarm.timeout) | 425 | 0 | break; | 426 | 0 | nanosleep(&tick, NULL); | 427 | 0 | } | 428 | | | 429 | 0 | unsigned input = atomic_load(&fuzz_alarm.input); | 430 | 0 | if (atomic_load(&fuzz_alarm.requested) != input) { | 431 | 0 | atomic_store(&fuzz_alarm.requested, input); | 432 | 0 | fuzz_write_stderr("==fuzz== R thread, where the input is running:\n"); | 433 | 0 | if (pthread_kill(fuzz_r_thread.thread, FUZZ_DUMP_SIGNAL) != 0) | 434 | 0 | atomic_store(&fuzz_alarm.done, input); | 435 | 0 | } | 436 | | | 437 | | /* Symbolizing takes a moment; a thread that never answers (stuck | 438 | | * in the allocator, say) must not hold up the report, and an | 439 | | * input finishing now is reported all the same: it was out of | 440 | | * time already. */ | 441 | 0 | for (int i = 0; i < 5000; i++) { | 442 | 0 | if (atomic_load(&fuzz_alarm.done) == input || | 443 | 0 | !atomic_load(&fuzz_alarm.running)) | 444 | 0 | break; | 445 | 0 | nanosleep(&tick, NULL); | 446 | 0 | } | 447 | 0 | } | 448 | 1 | fuzz_alarm.chain.sa_sigaction(sig, info, context); | 449 | 1 | } |
Unexecuted instantiation: sockets.c:fuzz_alarm_handler Unexecuted instantiation: sprintf.c:fuzz_alarm_handler eval.c:fuzz_alarm_handler Line | Count | Source | 405 | 7 | { | 406 | 7 | if (atomic_load(&fuzz_alarm.finishing)) | 407 | 0 | return; | 408 | | | 409 | 7 | if (atomic_load(&fuzz_alarm.running) && | 410 | 7 | fuzz_seconds_since(&fuzz_alarm.armed) >= fuzz_alarm.timeout - 1) { | 411 | 0 | struct timespec tick = { 0, fuzz_alarm.poll_ns }; | 412 | | | 413 | | /* Hold until the input is out of time by its own clock as well; | 414 | | * one that finishes first, even in the last sleep, was within | 415 | | * its time. The clock is read before the input is looked at, so | 416 | | * an input seen running was running at a moment past the | 417 | | * timeout, whatever delay falls between the two. */ | 418 | 0 | for (;;) { | 419 | 0 | long age = fuzz_seconds_since(&fuzz_alarm.started); | 420 | 0 | if (!atomic_load(&fuzz_alarm.running)) { | 421 | 0 | atomic_store(&fuzz_alarm.finishing, 1); | 422 | 0 | return; | 423 | 0 | } | 424 | 0 | if (age >= fuzz_alarm.timeout) | 425 | 0 | break; | 426 | 0 | nanosleep(&tick, NULL); | 427 | 0 | } | 428 | | | 429 | 0 | unsigned input = atomic_load(&fuzz_alarm.input); | 430 | 0 | if (atomic_load(&fuzz_alarm.requested) != input) { | 431 | 0 | atomic_store(&fuzz_alarm.requested, input); | 432 | 0 | fuzz_write_stderr("==fuzz== R thread, where the input is running:\n"); | 433 | 0 | if (pthread_kill(fuzz_r_thread.thread, FUZZ_DUMP_SIGNAL) != 0) | 434 | 0 | atomic_store(&fuzz_alarm.done, input); | 435 | 0 | } | 436 | | | 437 | | /* Symbolizing takes a moment; a thread that never answers (stuck | 438 | | * in the allocator, say) must not hold up the report, and an | 439 | | * input finishing now is reported all the same: it was out of | 440 | | * time already. */ | 441 | 0 | for (int i = 0; i < 5000; i++) { | 442 | 0 | if (atomic_load(&fuzz_alarm.done) == input || | 443 | 0 | !atomic_load(&fuzz_alarm.running)) | 444 | 0 | break; | 445 | 0 | nanosleep(&tick, NULL); | 446 | 0 | } | 447 | 0 | } | 448 | 7 | fuzz_alarm.chain.sa_sigaction(sig, info, context); | 449 | 7 | } |
Unexecuted instantiation: zip.c:fuzz_alarm_handler |
450 | | |
451 | | /* Wrap libFuzzer's SIGALRM handler, once it exists. Called before each |
452 | | * input; the first call after libFuzzer's startup sees the handler. */ |
453 | | static void fuzz_alarm_wrap(void) |
454 | 90.8k | { |
455 | 90.8k | if (fuzz_alarm.wrapped) |
456 | 90.8k | return; |
457 | 19 | fuzz_alarm.wrapped = 1; |
458 | | |
459 | 19 | struct sigaction current; |
460 | 19 | if (sigaction(SIGALRM, NULL, ¤t) != 0 || |
461 | 19 | !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL) |
462 | 0 | return; /* no alarm: AFL++'s driver, -timeout=0, tests */ |
463 | | |
464 | 19 | struct sigaction dump; |
465 | 19 | memset(&dump, 0, sizeof dump); |
466 | 19 | dump.sa_sigaction = fuzz_dump_handler; |
467 | 19 | dump.sa_flags = SA_SIGINFO; |
468 | 19 | sigemptyset(&dump.sa_mask); |
469 | 19 | if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0) |
470 | 0 | return; |
471 | | |
472 | 19 | fuzz_alarm.chain = current; |
473 | 19 | struct sigaction wrapper = current; |
474 | 19 | wrapper.sa_sigaction = fuzz_alarm_handler; |
475 | 19 | if (sigaction(SIGALRM, &wrapper, NULL) != 0) |
476 | 0 | sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL); |
477 | 19 | } Line | Count | Source | 454 | 1.50k | { | 455 | 1.50k | if (fuzz_alarm.wrapped) | 456 | 1.50k | return; | 457 | 1 | fuzz_alarm.wrapped = 1; | 458 | | | 459 | 1 | struct sigaction current; | 460 | 1 | if (sigaction(SIGALRM, NULL, ¤t) != 0 || | 461 | 1 | !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL) | 462 | 0 | return; /* no alarm: AFL++'s driver, -timeout=0, tests */ | 463 | | | 464 | 1 | struct sigaction dump; | 465 | 1 | memset(&dump, 0, sizeof dump); | 466 | 1 | dump.sa_sigaction = fuzz_dump_handler; | 467 | 1 | dump.sa_flags = SA_SIGINFO; | 468 | 1 | sigemptyset(&dump.sa_mask); | 469 | 1 | if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0) | 470 | 0 | return; | 471 | | | 472 | 1 | fuzz_alarm.chain = current; | 473 | 1 | struct sigaction wrapper = current; | 474 | 1 | wrapper.sa_sigaction = fuzz_alarm_handler; | 475 | 1 | if (sigaction(SIGALRM, &wrapper, NULL) != 0) | 476 | 0 | sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL); | 477 | 1 | } |
Line | Count | Source | 454 | 5.00k | { | 455 | 5.00k | if (fuzz_alarm.wrapped) | 456 | 5.00k | return; | 457 | 1 | fuzz_alarm.wrapped = 1; | 458 | | | 459 | 1 | struct sigaction current; | 460 | 1 | if (sigaction(SIGALRM, NULL, ¤t) != 0 || | 461 | 1 | !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL) | 462 | 0 | return; /* no alarm: AFL++'s driver, -timeout=0, tests */ | 463 | | | 464 | 1 | struct sigaction dump; | 465 | 1 | memset(&dump, 0, sizeof dump); | 466 | 1 | dump.sa_sigaction = fuzz_dump_handler; | 467 | 1 | dump.sa_flags = SA_SIGINFO; | 468 | 1 | sigemptyset(&dump.sa_mask); | 469 | 1 | if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0) | 470 | 0 | return; | 471 | | | 472 | 1 | fuzz_alarm.chain = current; | 473 | 1 | struct sigaction wrapper = current; | 474 | 1 | wrapper.sa_sigaction = fuzz_alarm_handler; | 475 | 1 | if (sigaction(SIGALRM, &wrapper, NULL) != 0) | 476 | 0 | sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL); | 477 | 1 | } |
character.c:fuzz_alarm_wrap Line | Count | Source | 454 | 4.46k | { | 455 | 4.46k | if (fuzz_alarm.wrapped) | 456 | 4.46k | return; | 457 | 1 | fuzz_alarm.wrapped = 1; | 458 | | | 459 | 1 | struct sigaction current; | 460 | 1 | if (sigaction(SIGALRM, NULL, ¤t) != 0 || | 461 | 1 | !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL) | 462 | 0 | return; /* no alarm: AFL++'s driver, -timeout=0, tests */ | 463 | | | 464 | 1 | struct sigaction dump; | 465 | 1 | memset(&dump, 0, sizeof dump); | 466 | 1 | dump.sa_sigaction = fuzz_dump_handler; | 467 | 1 | dump.sa_flags = SA_SIGINFO; | 468 | 1 | sigemptyset(&dump.sa_mask); | 469 | 1 | if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0) | 470 | 0 | return; | 471 | | | 472 | 1 | fuzz_alarm.chain = current; | 473 | 1 | struct sigaction wrapper = current; | 474 | 1 | wrapper.sa_sigaction = fuzz_alarm_handler; | 475 | 1 | if (sigaction(SIGALRM, &wrapper, NULL) != 0) | 476 | 0 | sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL); | 477 | 1 | } |
encoding.c:fuzz_alarm_wrap Line | Count | Source | 454 | 1.75k | { | 455 | 1.75k | if (fuzz_alarm.wrapped) | 456 | 1.75k | return; | 457 | 1 | fuzz_alarm.wrapped = 1; | 458 | | | 459 | 1 | struct sigaction current; | 460 | 1 | if (sigaction(SIGALRM, NULL, ¤t) != 0 || | 461 | 1 | !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL) | 462 | 0 | return; /* no alarm: AFL++'s driver, -timeout=0, tests */ | 463 | | | 464 | 1 | struct sigaction dump; | 465 | 1 | memset(&dump, 0, sizeof dump); | 466 | 1 | dump.sa_sigaction = fuzz_dump_handler; | 467 | 1 | dump.sa_flags = SA_SIGINFO; | 468 | 1 | sigemptyset(&dump.sa_mask); | 469 | 1 | if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0) | 470 | 0 | return; | 471 | | | 472 | 1 | fuzz_alarm.chain = current; | 473 | 1 | struct sigaction wrapper = current; | 474 | 1 | wrapper.sa_sigaction = fuzz_alarm_handler; | 475 | 1 | if (sigaction(SIGALRM, &wrapper, NULL) != 0) | 476 | 0 | sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL); | 477 | 1 | } |
Line | Count | Source | 454 | 6.75k | { | 455 | 6.75k | if (fuzz_alarm.wrapped) | 456 | 6.75k | return; | 457 | 1 | fuzz_alarm.wrapped = 1; | 458 | | | 459 | 1 | struct sigaction current; | 460 | 1 | if (sigaction(SIGALRM, NULL, ¤t) != 0 || | 461 | 1 | !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL) | 462 | 0 | return; /* no alarm: AFL++'s driver, -timeout=0, tests */ | 463 | | | 464 | 1 | struct sigaction dump; | 465 | 1 | memset(&dump, 0, sizeof dump); | 466 | 1 | dump.sa_sigaction = fuzz_dump_handler; | 467 | 1 | dump.sa_flags = SA_SIGINFO; | 468 | 1 | sigemptyset(&dump.sa_mask); | 469 | 1 | if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0) | 470 | 0 | return; | 471 | | | 472 | 1 | fuzz_alarm.chain = current; | 473 | 1 | struct sigaction wrapper = current; | 474 | 1 | wrapper.sa_sigaction = fuzz_alarm_handler; | 475 | 1 | if (sigaction(SIGALRM, &wrapper, NULL) != 0) | 476 | 0 | sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL); | 477 | 1 | } |
connections.c:fuzz_alarm_wrap Line | Count | Source | 454 | 5.98k | { | 455 | 5.98k | if (fuzz_alarm.wrapped) | 456 | 5.98k | return; | 457 | 1 | fuzz_alarm.wrapped = 1; | 458 | | | 459 | 1 | struct sigaction current; | 460 | 1 | if (sigaction(SIGALRM, NULL, ¤t) != 0 || | 461 | 1 | !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL) | 462 | 0 | return; /* no alarm: AFL++'s driver, -timeout=0, tests */ | 463 | | | 464 | 1 | struct sigaction dump; | 465 | 1 | memset(&dump, 0, sizeof dump); | 466 | 1 | dump.sa_sigaction = fuzz_dump_handler; | 467 | 1 | dump.sa_flags = SA_SIGINFO; | 468 | 1 | sigemptyset(&dump.sa_mask); | 469 | 1 | if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0) | 470 | 0 | return; | 471 | | | 472 | 1 | fuzz_alarm.chain = current; | 473 | 1 | struct sigaction wrapper = current; | 474 | 1 | wrapper.sa_sigaction = fuzz_alarm_handler; | 475 | 1 | if (sigaction(SIGALRM, &wrapper, NULL) != 0) | 476 | 0 | sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL); | 477 | 1 | } |
unserialize.c:fuzz_alarm_wrap Line | Count | Source | 454 | 5.61k | { | 455 | 5.61k | if (fuzz_alarm.wrapped) | 456 | 5.61k | return; | 457 | 1 | fuzz_alarm.wrapped = 1; | 458 | | | 459 | 1 | struct sigaction current; | 460 | 1 | if (sigaction(SIGALRM, NULL, ¤t) != 0 || | 461 | 1 | !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL) | 462 | 0 | return; /* no alarm: AFL++'s driver, -timeout=0, tests */ | 463 | | | 464 | 1 | struct sigaction dump; | 465 | 1 | memset(&dump, 0, sizeof dump); | 466 | 1 | dump.sa_sigaction = fuzz_dump_handler; | 467 | 1 | dump.sa_flags = SA_SIGINFO; | 468 | 1 | sigemptyset(&dump.sa_mask); | 469 | 1 | if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0) | 470 | 0 | return; | 471 | | | 472 | 1 | fuzz_alarm.chain = current; | 473 | 1 | struct sigaction wrapper = current; | 474 | 1 | wrapper.sa_sigaction = fuzz_alarm_handler; | 475 | 1 | if (sigaction(SIGALRM, &wrapper, NULL) != 0) | 476 | 0 | sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL); | 477 | 1 | } |
decompress.c:fuzz_alarm_wrap Line | Count | Source | 454 | 6.75k | { | 455 | 6.75k | if (fuzz_alarm.wrapped) | 456 | 6.75k | return; | 457 | 1 | fuzz_alarm.wrapped = 1; | 458 | | | 459 | 1 | struct sigaction current; | 460 | 1 | if (sigaction(SIGALRM, NULL, ¤t) != 0 || | 461 | 1 | !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL) | 462 | 0 | return; /* no alarm: AFL++'s driver, -timeout=0, tests */ | 463 | | | 464 | 1 | struct sigaction dump; | 465 | 1 | memset(&dump, 0, sizeof dump); | 466 | 1 | dump.sa_sigaction = fuzz_dump_handler; | 467 | 1 | dump.sa_flags = SA_SIGINFO; | 468 | 1 | sigemptyset(&dump.sa_mask); | 469 | 1 | if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0) | 470 | 0 | return; | 471 | | | 472 | 1 | fuzz_alarm.chain = current; | 473 | 1 | struct sigaction wrapper = current; | 474 | 1 | wrapper.sa_sigaction = fuzz_alarm_handler; | 475 | 1 | if (sigaction(SIGALRM, &wrapper, NULL) != 0) | 476 | 0 | sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL); | 477 | 1 | } |
readtable.c:fuzz_alarm_wrap Line | Count | Source | 454 | 346 | { | 455 | 346 | if (fuzz_alarm.wrapped) | 456 | 345 | return; | 457 | 1 | fuzz_alarm.wrapped = 1; | 458 | | | 459 | 1 | struct sigaction current; | 460 | 1 | if (sigaction(SIGALRM, NULL, ¤t) != 0 || | 461 | 1 | !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL) | 462 | 0 | return; /* no alarm: AFL++'s driver, -timeout=0, tests */ | 463 | | | 464 | 1 | struct sigaction dump; | 465 | 1 | memset(&dump, 0, sizeof dump); | 466 | 1 | dump.sa_sigaction = fuzz_dump_handler; | 467 | 1 | dump.sa_flags = SA_SIGINFO; | 468 | 1 | sigemptyset(&dump.sa_mask); | 469 | 1 | if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0) | 470 | 0 | return; | 471 | | | 472 | 1 | fuzz_alarm.chain = current; | 473 | 1 | struct sigaction wrapper = current; | 474 | 1 | wrapper.sa_sigaction = fuzz_alarm_handler; | 475 | 1 | if (sigaction(SIGALRM, &wrapper, NULL) != 0) | 476 | 0 | sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL); | 477 | 1 | } |
Line | Count | Source | 454 | 5.53k | { | 455 | 5.53k | if (fuzz_alarm.wrapped) | 456 | 5.53k | return; | 457 | 1 | fuzz_alarm.wrapped = 1; | 458 | | | 459 | 1 | struct sigaction current; | 460 | 1 | if (sigaction(SIGALRM, NULL, ¤t) != 0 || | 461 | 1 | !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL) | 462 | 0 | return; /* no alarm: AFL++'s driver, -timeout=0, tests */ | 463 | | | 464 | 1 | struct sigaction dump; | 465 | 1 | memset(&dump, 0, sizeof dump); | 466 | 1 | dump.sa_sigaction = fuzz_dump_handler; | 467 | 1 | dump.sa_flags = SA_SIGINFO; | 468 | 1 | sigemptyset(&dump.sa_mask); | 469 | 1 | if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0) | 470 | 0 | return; | 471 | | | 472 | 1 | fuzz_alarm.chain = current; | 473 | 1 | struct sigaction wrapper = current; | 474 | 1 | wrapper.sa_sigaction = fuzz_alarm_handler; | 475 | 1 | if (sigaction(SIGALRM, &wrapper, NULL) != 0) | 476 | 0 | sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL); | 477 | 1 | } |
datetime.c:fuzz_alarm_wrap Line | Count | Source | 454 | 6.95k | { | 455 | 6.95k | if (fuzz_alarm.wrapped) | 456 | 6.95k | return; | 457 | 1 | fuzz_alarm.wrapped = 1; | 458 | | | 459 | 1 | struct sigaction current; | 460 | 1 | if (sigaction(SIGALRM, NULL, ¤t) != 0 || | 461 | 1 | !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL) | 462 | 0 | return; /* no alarm: AFL++'s driver, -timeout=0, tests */ | 463 | | | 464 | 1 | struct sigaction dump; | 465 | 1 | memset(&dump, 0, sizeof dump); | 466 | 1 | dump.sa_sigaction = fuzz_dump_handler; | 467 | 1 | dump.sa_flags = SA_SIGINFO; | 468 | 1 | sigemptyset(&dump.sa_mask); | 469 | 1 | if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0) | 470 | 0 | return; | 471 | | | 472 | 1 | fuzz_alarm.chain = current; | 473 | 1 | struct sigaction wrapper = current; | 474 | 1 | wrapper.sa_sigaction = fuzz_alarm_handler; | 475 | 1 | if (sigaction(SIGALRM, &wrapper, NULL) != 0) | 476 | 0 | sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL); | 477 | 1 | } |
Line | Count | Source | 454 | 1.89k | { | 455 | 1.89k | if (fuzz_alarm.wrapped) | 456 | 1.89k | return; | 457 | 1 | fuzz_alarm.wrapped = 1; | 458 | | | 459 | 1 | struct sigaction current; | 460 | 1 | if (sigaction(SIGALRM, NULL, ¤t) != 0 || | 461 | 1 | !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL) | 462 | 0 | return; /* no alarm: AFL++'s driver, -timeout=0, tests */ | 463 | | | 464 | 1 | struct sigaction dump; | 465 | 1 | memset(&dump, 0, sizeof dump); | 466 | 1 | dump.sa_sigaction = fuzz_dump_handler; | 467 | 1 | dump.sa_flags = SA_SIGINFO; | 468 | 1 | sigemptyset(&dump.sa_mask); | 469 | 1 | if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0) | 470 | 0 | return; | 471 | | | 472 | 1 | fuzz_alarm.chain = current; | 473 | 1 | struct sigaction wrapper = current; | 474 | 1 | wrapper.sa_sigaction = fuzz_alarm_handler; | 475 | 1 | if (sigaction(SIGALRM, &wrapper, NULL) != 0) | 476 | 0 | sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL); | 477 | 1 | } |
Line | Count | Source | 454 | 8.50k | { | 455 | 8.50k | if (fuzz_alarm.wrapped) | 456 | 8.50k | return; | 457 | 1 | fuzz_alarm.wrapped = 1; | 458 | | | 459 | 1 | struct sigaction current; | 460 | 1 | if (sigaction(SIGALRM, NULL, ¤t) != 0 || | 461 | 1 | !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL) | 462 | 0 | return; /* no alarm: AFL++'s driver, -timeout=0, tests */ | 463 | | | 464 | 1 | struct sigaction dump; | 465 | 1 | memset(&dump, 0, sizeof dump); | 466 | 1 | dump.sa_sigaction = fuzz_dump_handler; | 467 | 1 | dump.sa_flags = SA_SIGINFO; | 468 | 1 | sigemptyset(&dump.sa_mask); | 469 | 1 | if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0) | 470 | 0 | return; | 471 | | | 472 | 1 | fuzz_alarm.chain = current; | 473 | 1 | struct sigaction wrapper = current; | 474 | 1 | wrapper.sa_sigaction = fuzz_alarm_handler; | 475 | 1 | if (sigaction(SIGALRM, &wrapper, NULL) != 0) | 476 | 0 | sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL); | 477 | 1 | } |
Line | Count | Source | 454 | 3.13k | { | 455 | 3.13k | if (fuzz_alarm.wrapped) | 456 | 3.13k | return; | 457 | 1 | fuzz_alarm.wrapped = 1; | 458 | | | 459 | 1 | struct sigaction current; | 460 | 1 | if (sigaction(SIGALRM, NULL, ¤t) != 0 || | 461 | 1 | !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL) | 462 | 0 | return; /* no alarm: AFL++'s driver, -timeout=0, tests */ | 463 | | | 464 | 1 | struct sigaction dump; | 465 | 1 | memset(&dump, 0, sizeof dump); | 466 | 1 | dump.sa_sigaction = fuzz_dump_handler; | 467 | 1 | dump.sa_flags = SA_SIGINFO; | 468 | 1 | sigemptyset(&dump.sa_mask); | 469 | 1 | if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0) | 470 | 0 | return; | 471 | | | 472 | 1 | fuzz_alarm.chain = current; | 473 | 1 | struct sigaction wrapper = current; | 474 | 1 | wrapper.sa_sigaction = fuzz_alarm_handler; | 475 | 1 | if (sigaction(SIGALRM, &wrapper, NULL) != 0) | 476 | 0 | sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL); | 477 | 1 | } |
Line | Count | Source | 454 | 1.85k | { | 455 | 1.85k | if (fuzz_alarm.wrapped) | 456 | 1.85k | return; | 457 | 1 | fuzz_alarm.wrapped = 1; | 458 | | | 459 | 1 | struct sigaction current; | 460 | 1 | if (sigaction(SIGALRM, NULL, ¤t) != 0 || | 461 | 1 | !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL) | 462 | 0 | return; /* no alarm: AFL++'s driver, -timeout=0, tests */ | 463 | | | 464 | 1 | struct sigaction dump; | 465 | 1 | memset(&dump, 0, sizeof dump); | 466 | 1 | dump.sa_sigaction = fuzz_dump_handler; | 467 | 1 | dump.sa_flags = SA_SIGINFO; | 468 | 1 | sigemptyset(&dump.sa_mask); | 469 | 1 | if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0) | 470 | 0 | return; | 471 | | | 472 | 1 | fuzz_alarm.chain = current; | 473 | 1 | struct sigaction wrapper = current; | 474 | 1 | wrapper.sa_sigaction = fuzz_alarm_handler; | 475 | 1 | if (sigaction(SIGALRM, &wrapper, NULL) != 0) | 476 | 0 | sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL); | 477 | 1 | } |
Line | Count | Source | 454 | 8.04k | { | 455 | 8.04k | if (fuzz_alarm.wrapped) | 456 | 8.03k | return; | 457 | 1 | fuzz_alarm.wrapped = 1; | 458 | | | 459 | 1 | struct sigaction current; | 460 | 1 | if (sigaction(SIGALRM, NULL, ¤t) != 0 || | 461 | 1 | !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL) | 462 | 0 | return; /* no alarm: AFL++'s driver, -timeout=0, tests */ | 463 | | | 464 | 1 | struct sigaction dump; | 465 | 1 | memset(&dump, 0, sizeof dump); | 466 | 1 | dump.sa_sigaction = fuzz_dump_handler; | 467 | 1 | dump.sa_flags = SA_SIGINFO; | 468 | 1 | sigemptyset(&dump.sa_mask); | 469 | 1 | if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0) | 470 | 0 | return; | 471 | | | 472 | 1 | fuzz_alarm.chain = current; | 473 | 1 | struct sigaction wrapper = current; | 474 | 1 | wrapper.sa_sigaction = fuzz_alarm_handler; | 475 | 1 | if (sigaction(SIGALRM, &wrapper, NULL) != 0) | 476 | 0 | sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL); | 477 | 1 | } |
Unexecuted instantiation: sockets.c:fuzz_alarm_wrap sprintf.c:fuzz_alarm_wrap Line | Count | Source | 454 | 2.20k | { | 455 | 2.20k | if (fuzz_alarm.wrapped) | 456 | 2.20k | return; | 457 | 1 | fuzz_alarm.wrapped = 1; | 458 | | | 459 | 1 | struct sigaction current; | 460 | 1 | if (sigaction(SIGALRM, NULL, ¤t) != 0 || | 461 | 1 | !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL) | 462 | 0 | return; /* no alarm: AFL++'s driver, -timeout=0, tests */ | 463 | | | 464 | 1 | struct sigaction dump; | 465 | 1 | memset(&dump, 0, sizeof dump); | 466 | 1 | dump.sa_sigaction = fuzz_dump_handler; | 467 | 1 | dump.sa_flags = SA_SIGINFO; | 468 | 1 | sigemptyset(&dump.sa_mask); | 469 | 1 | if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0) | 470 | 0 | return; | 471 | | | 472 | 1 | fuzz_alarm.chain = current; | 473 | 1 | struct sigaction wrapper = current; | 474 | 1 | wrapper.sa_sigaction = fuzz_alarm_handler; | 475 | 1 | if (sigaction(SIGALRM, &wrapper, NULL) != 0) | 476 | 0 | sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL); | 477 | 1 | } |
Line | Count | Source | 454 | 12.1k | { | 455 | 12.1k | if (fuzz_alarm.wrapped) | 456 | 12.1k | return; | 457 | 1 | fuzz_alarm.wrapped = 1; | 458 | | | 459 | 1 | struct sigaction current; | 460 | 1 | if (sigaction(SIGALRM, NULL, ¤t) != 0 || | 461 | 1 | !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL) | 462 | 0 | return; /* no alarm: AFL++'s driver, -timeout=0, tests */ | 463 | | | 464 | 1 | struct sigaction dump; | 465 | 1 | memset(&dump, 0, sizeof dump); | 466 | 1 | dump.sa_sigaction = fuzz_dump_handler; | 467 | 1 | dump.sa_flags = SA_SIGINFO; | 468 | 1 | sigemptyset(&dump.sa_mask); | 469 | 1 | if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0) | 470 | 0 | return; | 471 | | | 472 | 1 | fuzz_alarm.chain = current; | 473 | 1 | struct sigaction wrapper = current; | 474 | 1 | wrapper.sa_sigaction = fuzz_alarm_handler; | 475 | 1 | if (sigaction(SIGALRM, &wrapper, NULL) != 0) | 476 | 0 | sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL); | 477 | 1 | } |
Line | Count | Source | 454 | 2.34k | { | 455 | 2.34k | if (fuzz_alarm.wrapped) | 456 | 2.34k | return; | 457 | 1 | fuzz_alarm.wrapped = 1; | 458 | | | 459 | 1 | struct sigaction current; | 460 | 1 | if (sigaction(SIGALRM, NULL, ¤t) != 0 || | 461 | 1 | !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL) | 462 | 0 | return; /* no alarm: AFL++'s driver, -timeout=0, tests */ | 463 | | | 464 | 1 | struct sigaction dump; | 465 | 1 | memset(&dump, 0, sizeof dump); | 466 | 1 | dump.sa_sigaction = fuzz_dump_handler; | 467 | 1 | dump.sa_flags = SA_SIGINFO; | 468 | 1 | sigemptyset(&dump.sa_mask); | 469 | 1 | if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0) | 470 | 0 | return; | 471 | | | 472 | 1 | fuzz_alarm.chain = current; | 473 | 1 | struct sigaction wrapper = current; | 474 | 1 | wrapper.sa_sigaction = fuzz_alarm_handler; | 475 | 1 | if (sigaction(SIGALRM, &wrapper, NULL) != 0) | 476 | 0 | sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL); | 477 | 1 | } |
|
478 | | |
479 | | static void *fuzz_r_thread_main(void *unused) |
480 | 39 | { |
481 | 39 | (void)unused; |
482 | | /* The frame address rather than a local's: under ASAN an address-taken |
483 | | * local may sit on the fake stack, nowhere near this thread's stack. |
484 | | * R_CStackStart matters only once R is initialized; fuzz_init_r() |
485 | | * sets it again after Rf_initialize_R has overwritten it. */ |
486 | 39 | fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0); |
487 | 39 | R_CStackStart = fuzz_r_thread.stack_top; |
488 | | |
489 | | /* libFuzzer's -timeout alarm is acted on only by the thread running |
490 | | * its loop (the main thread); delivered here it would be ignored and |
491 | | * the input would run on. Block it so the kernel cannot pick this |
492 | | * thread; fuzz_alarm_handler below gets this thread's stack into the |
493 | | * timeout report instead. */ |
494 | 39 | sigset_t alarm; |
495 | 39 | sigemptyset(&alarm); |
496 | 39 | sigaddset(&alarm, SIGALRM); |
497 | 39 | pthread_sigmask(SIG_BLOCK, &alarm, NULL); |
498 | | |
499 | 39 | pthread_mutex_lock(&fuzz_r_thread.mutex); |
500 | 90.9k | for (;;) { |
501 | 181k | while (fuzz_r_thread.job == NULL) |
502 | 90.8k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); |
503 | 90.9k | fuzz_job_t *job = fuzz_r_thread.job; |
504 | 90.9k | pthread_mutex_unlock(&fuzz_r_thread.mutex); |
505 | | |
506 | 90.9k | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started); |
507 | 90.9k | atomic_store(&fuzz_alarm.running, 1); |
508 | 90.9k | job->fn(job->arg); |
509 | 90.9k | atomic_store(&fuzz_alarm.running, 0); |
510 | | |
511 | 90.9k | pthread_mutex_lock(&fuzz_r_thread.mutex); |
512 | 90.9k | fuzz_r_thread.job = NULL; |
513 | 90.9k | pthread_cond_broadcast(&fuzz_r_thread.cond); |
514 | 90.9k | } |
515 | 39 | return NULL; |
516 | 39 | } Line | Count | Source | 480 | 2 | { | 481 | 2 | (void)unused; | 482 | | /* The frame address rather than a local's: under ASAN an address-taken | 483 | | * local may sit on the fake stack, nowhere near this thread's stack. | 484 | | * R_CStackStart matters only once R is initialized; fuzz_init_r() | 485 | | * sets it again after Rf_initialize_R has overwritten it. */ | 486 | 2 | fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0); | 487 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 488 | | | 489 | | /* libFuzzer's -timeout alarm is acted on only by the thread running | 490 | | * its loop (the main thread); delivered here it would be ignored and | 491 | | * the input would run on. Block it so the kernel cannot pick this | 492 | | * thread; fuzz_alarm_handler below gets this thread's stack into the | 493 | | * timeout report instead. */ | 494 | 2 | sigset_t alarm; | 495 | 2 | sigemptyset(&alarm); | 496 | 2 | sigaddset(&alarm, SIGALRM); | 497 | 2 | pthread_sigmask(SIG_BLOCK, &alarm, NULL); | 498 | | | 499 | 2 | pthread_mutex_lock(&fuzz_r_thread.mutex); | 500 | 1.50k | for (;;) { | 501 | 3.01k | while (fuzz_r_thread.job == NULL) | 502 | 1.50k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 503 | 1.50k | fuzz_job_t *job = fuzz_r_thread.job; | 504 | 1.50k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 505 | | | 506 | 1.50k | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started); | 507 | 1.50k | atomic_store(&fuzz_alarm.running, 1); | 508 | 1.50k | job->fn(job->arg); | 509 | 1.50k | atomic_store(&fuzz_alarm.running, 0); | 510 | | | 511 | 1.50k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 512 | 1.50k | fuzz_r_thread.job = NULL; | 513 | 1.50k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 514 | 1.50k | } | 515 | | return NULL; | 516 | 2 | } |
Line | Count | Source | 480 | 2 | { | 481 | 2 | (void)unused; | 482 | | /* The frame address rather than a local's: under ASAN an address-taken | 483 | | * local may sit on the fake stack, nowhere near this thread's stack. | 484 | | * R_CStackStart matters only once R is initialized; fuzz_init_r() | 485 | | * sets it again after Rf_initialize_R has overwritten it. */ | 486 | 2 | fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0); | 487 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 488 | | | 489 | | /* libFuzzer's -timeout alarm is acted on only by the thread running | 490 | | * its loop (the main thread); delivered here it would be ignored and | 491 | | * the input would run on. Block it so the kernel cannot pick this | 492 | | * thread; fuzz_alarm_handler below gets this thread's stack into the | 493 | | * timeout report instead. */ | 494 | 2 | sigset_t alarm; | 495 | 2 | sigemptyset(&alarm); | 496 | 2 | sigaddset(&alarm, SIGALRM); | 497 | 2 | pthread_sigmask(SIG_BLOCK, &alarm, NULL); | 498 | | | 499 | 2 | pthread_mutex_lock(&fuzz_r_thread.mutex); | 500 | 5.00k | for (;;) { | 501 | 10.0k | while (fuzz_r_thread.job == NULL) | 502 | 5.00k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 503 | 5.00k | fuzz_job_t *job = fuzz_r_thread.job; | 504 | 5.00k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 505 | | | 506 | 5.00k | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started); | 507 | 5.00k | atomic_store(&fuzz_alarm.running, 1); | 508 | 5.00k | job->fn(job->arg); | 509 | 5.00k | atomic_store(&fuzz_alarm.running, 0); | 510 | | | 511 | 5.00k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 512 | 5.00k | fuzz_r_thread.job = NULL; | 513 | 5.00k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 514 | 5.00k | } | 515 | | return NULL; | 516 | 2 | } |
character.c:fuzz_r_thread_main Line | Count | Source | 480 | 2 | { | 481 | 2 | (void)unused; | 482 | | /* The frame address rather than a local's: under ASAN an address-taken | 483 | | * local may sit on the fake stack, nowhere near this thread's stack. | 484 | | * R_CStackStart matters only once R is initialized; fuzz_init_r() | 485 | | * sets it again after Rf_initialize_R has overwritten it. */ | 486 | 2 | fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0); | 487 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 488 | | | 489 | | /* libFuzzer's -timeout alarm is acted on only by the thread running | 490 | | * its loop (the main thread); delivered here it would be ignored and | 491 | | * the input would run on. Block it so the kernel cannot pick this | 492 | | * thread; fuzz_alarm_handler below gets this thread's stack into the | 493 | | * timeout report instead. */ | 494 | 2 | sigset_t alarm; | 495 | 2 | sigemptyset(&alarm); | 496 | 2 | sigaddset(&alarm, SIGALRM); | 497 | 2 | pthread_sigmask(SIG_BLOCK, &alarm, NULL); | 498 | | | 499 | 2 | pthread_mutex_lock(&fuzz_r_thread.mutex); | 500 | 4.47k | for (;;) { | 501 | 8.94k | while (fuzz_r_thread.job == NULL) | 502 | 4.46k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 503 | 4.47k | fuzz_job_t *job = fuzz_r_thread.job; | 504 | 4.47k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 505 | | | 506 | 4.47k | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started); | 507 | 4.47k | atomic_store(&fuzz_alarm.running, 1); | 508 | 4.47k | job->fn(job->arg); | 509 | 4.47k | atomic_store(&fuzz_alarm.running, 0); | 510 | | | 511 | 4.47k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 512 | 4.47k | fuzz_r_thread.job = NULL; | 513 | 4.47k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 514 | 4.47k | } | 515 | | return NULL; | 516 | 2 | } |
encoding.c:fuzz_r_thread_main Line | Count | Source | 480 | 2 | { | 481 | 2 | (void)unused; | 482 | | /* The frame address rather than a local's: under ASAN an address-taken | 483 | | * local may sit on the fake stack, nowhere near this thread's stack. | 484 | | * R_CStackStart matters only once R is initialized; fuzz_init_r() | 485 | | * sets it again after Rf_initialize_R has overwritten it. */ | 486 | 2 | fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0); | 487 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 488 | | | 489 | | /* libFuzzer's -timeout alarm is acted on only by the thread running | 490 | | * its loop (the main thread); delivered here it would be ignored and | 491 | | * the input would run on. Block it so the kernel cannot pick this | 492 | | * thread; fuzz_alarm_handler below gets this thread's stack into the | 493 | | * timeout report instead. */ | 494 | 2 | sigset_t alarm; | 495 | 2 | sigemptyset(&alarm); | 496 | 2 | sigaddset(&alarm, SIGALRM); | 497 | 2 | pthread_sigmask(SIG_BLOCK, &alarm, NULL); | 498 | | | 499 | 2 | pthread_mutex_lock(&fuzz_r_thread.mutex); | 500 | 1.76k | for (;;) { | 501 | 3.52k | while (fuzz_r_thread.job == NULL) | 502 | 1.76k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 503 | 1.76k | fuzz_job_t *job = fuzz_r_thread.job; | 504 | 1.76k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 505 | | | 506 | 1.76k | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started); | 507 | 1.76k | atomic_store(&fuzz_alarm.running, 1); | 508 | 1.76k | job->fn(job->arg); | 509 | 1.76k | atomic_store(&fuzz_alarm.running, 0); | 510 | | | 511 | 1.76k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 512 | 1.76k | fuzz_r_thread.job = NULL; | 513 | 1.76k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 514 | 1.76k | } | 515 | | return NULL; | 516 | 2 | } |
sort.c:fuzz_r_thread_main Line | Count | Source | 480 | 2 | { | 481 | 2 | (void)unused; | 482 | | /* The frame address rather than a local's: under ASAN an address-taken | 483 | | * local may sit on the fake stack, nowhere near this thread's stack. | 484 | | * R_CStackStart matters only once R is initialized; fuzz_init_r() | 485 | | * sets it again after Rf_initialize_R has overwritten it. */ | 486 | 2 | fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0); | 487 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 488 | | | 489 | | /* libFuzzer's -timeout alarm is acted on only by the thread running | 490 | | * its loop (the main thread); delivered here it would be ignored and | 491 | | * the input would run on. Block it so the kernel cannot pick this | 492 | | * thread; fuzz_alarm_handler below gets this thread's stack into the | 493 | | * timeout report instead. */ | 494 | 2 | sigset_t alarm; | 495 | 2 | sigemptyset(&alarm); | 496 | 2 | sigaddset(&alarm, SIGALRM); | 497 | 2 | pthread_sigmask(SIG_BLOCK, &alarm, NULL); | 498 | | | 499 | 2 | pthread_mutex_lock(&fuzz_r_thread.mutex); | 500 | 6.76k | for (;;) { | 501 | 13.5k | while (fuzz_r_thread.job == NULL) | 502 | 6.75k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 503 | 6.76k | fuzz_job_t *job = fuzz_r_thread.job; | 504 | 6.76k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 505 | | | 506 | 6.76k | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started); | 507 | 6.76k | atomic_store(&fuzz_alarm.running, 1); | 508 | 6.76k | job->fn(job->arg); | 509 | 6.76k | atomic_store(&fuzz_alarm.running, 0); | 510 | | | 511 | 6.76k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 512 | 6.76k | fuzz_r_thread.job = NULL; | 513 | 6.76k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 514 | 6.76k | } | 515 | | return NULL; | 516 | 2 | } |
connections.c:fuzz_r_thread_main Line | Count | Source | 480 | 2 | { | 481 | 2 | (void)unused; | 482 | | /* The frame address rather than a local's: under ASAN an address-taken | 483 | | * local may sit on the fake stack, nowhere near this thread's stack. | 484 | | * R_CStackStart matters only once R is initialized; fuzz_init_r() | 485 | | * sets it again after Rf_initialize_R has overwritten it. */ | 486 | 2 | fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0); | 487 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 488 | | | 489 | | /* libFuzzer's -timeout alarm is acted on only by the thread running | 490 | | * its loop (the main thread); delivered here it would be ignored and | 491 | | * the input would run on. Block it so the kernel cannot pick this | 492 | | * thread; fuzz_alarm_handler below gets this thread's stack into the | 493 | | * timeout report instead. */ | 494 | 2 | sigset_t alarm; | 495 | 2 | sigemptyset(&alarm); | 496 | 2 | sigaddset(&alarm, SIGALRM); | 497 | 2 | pthread_sigmask(SIG_BLOCK, &alarm, NULL); | 498 | | | 499 | 2 | pthread_mutex_lock(&fuzz_r_thread.mutex); | 500 | 5.99k | for (;;) { | 501 | 11.9k | while (fuzz_r_thread.job == NULL) | 502 | 5.99k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 503 | 5.99k | fuzz_job_t *job = fuzz_r_thread.job; | 504 | 5.99k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 505 | | | 506 | 5.99k | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started); | 507 | 5.99k | atomic_store(&fuzz_alarm.running, 1); | 508 | 5.99k | job->fn(job->arg); | 509 | 5.99k | atomic_store(&fuzz_alarm.running, 0); | 510 | | | 511 | 5.99k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 512 | 5.99k | fuzz_r_thread.job = NULL; | 513 | 5.99k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 514 | 5.99k | } | 515 | | return NULL; | 516 | 2 | } |
unserialize.c:fuzz_r_thread_main Line | Count | Source | 480 | 2 | { | 481 | 2 | (void)unused; | 482 | | /* The frame address rather than a local's: under ASAN an address-taken | 483 | | * local may sit on the fake stack, nowhere near this thread's stack. | 484 | | * R_CStackStart matters only once R is initialized; fuzz_init_r() | 485 | | * sets it again after Rf_initialize_R has overwritten it. */ | 486 | 2 | fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0); | 487 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 488 | | | 489 | | /* libFuzzer's -timeout alarm is acted on only by the thread running | 490 | | * its loop (the main thread); delivered here it would be ignored and | 491 | | * the input would run on. Block it so the kernel cannot pick this | 492 | | * thread; fuzz_alarm_handler below gets this thread's stack into the | 493 | | * timeout report instead. */ | 494 | 2 | sigset_t alarm; | 495 | 2 | sigemptyset(&alarm); | 496 | 2 | sigaddset(&alarm, SIGALRM); | 497 | 2 | pthread_sigmask(SIG_BLOCK, &alarm, NULL); | 498 | | | 499 | 2 | pthread_mutex_lock(&fuzz_r_thread.mutex); | 500 | 5.62k | for (;;) { | 501 | 11.2k | while (fuzz_r_thread.job == NULL) | 502 | 5.61k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 503 | 5.62k | fuzz_job_t *job = fuzz_r_thread.job; | 504 | 5.62k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 505 | | | 506 | 5.62k | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started); | 507 | 5.62k | atomic_store(&fuzz_alarm.running, 1); | 508 | 5.62k | job->fn(job->arg); | 509 | 5.62k | atomic_store(&fuzz_alarm.running, 0); | 510 | | | 511 | 5.62k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 512 | 5.62k | fuzz_r_thread.job = NULL; | 513 | 5.62k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 514 | 5.62k | } | 515 | | return NULL; | 516 | 2 | } |
decompress.c:fuzz_r_thread_main Line | Count | Source | 480 | 2 | { | 481 | 2 | (void)unused; | 482 | | /* The frame address rather than a local's: under ASAN an address-taken | 483 | | * local may sit on the fake stack, nowhere near this thread's stack. | 484 | | * R_CStackStart matters only once R is initialized; fuzz_init_r() | 485 | | * sets it again after Rf_initialize_R has overwritten it. */ | 486 | 2 | fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0); | 487 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 488 | | | 489 | | /* libFuzzer's -timeout alarm is acted on only by the thread running | 490 | | * its loop (the main thread); delivered here it would be ignored and | 491 | | * the input would run on. Block it so the kernel cannot pick this | 492 | | * thread; fuzz_alarm_handler below gets this thread's stack into the | 493 | | * timeout report instead. */ | 494 | 2 | sigset_t alarm; | 495 | 2 | sigemptyset(&alarm); | 496 | 2 | sigaddset(&alarm, SIGALRM); | 497 | 2 | pthread_sigmask(SIG_BLOCK, &alarm, NULL); | 498 | | | 499 | 2 | pthread_mutex_lock(&fuzz_r_thread.mutex); | 500 | 6.75k | for (;;) { | 501 | 13.5k | while (fuzz_r_thread.job == NULL) | 502 | 6.75k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 503 | 6.75k | fuzz_job_t *job = fuzz_r_thread.job; | 504 | 6.75k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 505 | | | 506 | 6.75k | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started); | 507 | 6.75k | atomic_store(&fuzz_alarm.running, 1); | 508 | 6.75k | job->fn(job->arg); | 509 | 6.75k | atomic_store(&fuzz_alarm.running, 0); | 510 | | | 511 | 6.75k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 512 | 6.75k | fuzz_r_thread.job = NULL; | 513 | 6.75k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 514 | 6.75k | } | 515 | | return NULL; | 516 | 2 | } |
readtable.c:fuzz_r_thread_main Line | Count | Source | 480 | 2 | { | 481 | 2 | (void)unused; | 482 | | /* The frame address rather than a local's: under ASAN an address-taken | 483 | | * local may sit on the fake stack, nowhere near this thread's stack. | 484 | | * R_CStackStart matters only once R is initialized; fuzz_init_r() | 485 | | * sets it again after Rf_initialize_R has overwritten it. */ | 486 | 2 | fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0); | 487 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 488 | | | 489 | | /* libFuzzer's -timeout alarm is acted on only by the thread running | 490 | | * its loop (the main thread); delivered here it would be ignored and | 491 | | * the input would run on. Block it so the kernel cannot pick this | 492 | | * thread; fuzz_alarm_handler below gets this thread's stack into the | 493 | | * timeout report instead. */ | 494 | 2 | sigset_t alarm; | 495 | 2 | sigemptyset(&alarm); | 496 | 2 | sigaddset(&alarm, SIGALRM); | 497 | 2 | pthread_sigmask(SIG_BLOCK, &alarm, NULL); | 498 | | | 499 | 2 | pthread_mutex_lock(&fuzz_r_thread.mutex); | 500 | 350 | for (;;) { | 501 | 698 | while (fuzz_r_thread.job == NULL) | 502 | 348 | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 503 | 350 | fuzz_job_t *job = fuzz_r_thread.job; | 504 | 350 | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 505 | | | 506 | 350 | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started); | 507 | 350 | atomic_store(&fuzz_alarm.running, 1); | 508 | 350 | job->fn(job->arg); | 509 | 350 | atomic_store(&fuzz_alarm.running, 0); | 510 | | | 511 | 350 | pthread_mutex_lock(&fuzz_r_thread.mutex); | 512 | 350 | fuzz_r_thread.job = NULL; | 513 | 350 | pthread_cond_broadcast(&fuzz_r_thread.cond); | 514 | 350 | } | 515 | | return NULL; | 516 | 2 | } |
format.c:fuzz_r_thread_main Line | Count | Source | 480 | 2 | { | 481 | 2 | (void)unused; | 482 | | /* The frame address rather than a local's: under ASAN an address-taken | 483 | | * local may sit on the fake stack, nowhere near this thread's stack. | 484 | | * R_CStackStart matters only once R is initialized; fuzz_init_r() | 485 | | * sets it again after Rf_initialize_R has overwritten it. */ | 486 | 2 | fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0); | 487 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 488 | | | 489 | | /* libFuzzer's -timeout alarm is acted on only by the thread running | 490 | | * its loop (the main thread); delivered here it would be ignored and | 491 | | * the input would run on. Block it so the kernel cannot pick this | 492 | | * thread; fuzz_alarm_handler below gets this thread's stack into the | 493 | | * timeout report instead. */ | 494 | 2 | sigset_t alarm; | 495 | 2 | sigemptyset(&alarm); | 496 | 2 | sigaddset(&alarm, SIGALRM); | 497 | 2 | pthread_sigmask(SIG_BLOCK, &alarm, NULL); | 498 | | | 499 | 2 | pthread_mutex_lock(&fuzz_r_thread.mutex); | 500 | 5.54k | for (;;) { | 501 | 11.0k | while (fuzz_r_thread.job == NULL) | 502 | 5.54k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 503 | 5.54k | fuzz_job_t *job = fuzz_r_thread.job; | 504 | 5.54k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 505 | | | 506 | 5.54k | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started); | 507 | 5.54k | atomic_store(&fuzz_alarm.running, 1); | 508 | 5.54k | job->fn(job->arg); | 509 | 5.54k | atomic_store(&fuzz_alarm.running, 0); | 510 | | | 511 | 5.54k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 512 | 5.54k | fuzz_r_thread.job = NULL; | 513 | 5.54k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 514 | 5.54k | } | 515 | | return NULL; | 516 | 2 | } |
datetime.c:fuzz_r_thread_main Line | Count | Source | 480 | 2 | { | 481 | 2 | (void)unused; | 482 | | /* The frame address rather than a local's: under ASAN an address-taken | 483 | | * local may sit on the fake stack, nowhere near this thread's stack. | 484 | | * R_CStackStart matters only once R is initialized; fuzz_init_r() | 485 | | * sets it again after Rf_initialize_R has overwritten it. */ | 486 | 2 | fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0); | 487 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 488 | | | 489 | | /* libFuzzer's -timeout alarm is acted on only by the thread running | 490 | | * its loop (the main thread); delivered here it would be ignored and | 491 | | * the input would run on. Block it so the kernel cannot pick this | 492 | | * thread; fuzz_alarm_handler below gets this thread's stack into the | 493 | | * timeout report instead. */ | 494 | 2 | sigset_t alarm; | 495 | 2 | sigemptyset(&alarm); | 496 | 2 | sigaddset(&alarm, SIGALRM); | 497 | 2 | pthread_sigmask(SIG_BLOCK, &alarm, NULL); | 498 | | | 499 | 2 | pthread_mutex_lock(&fuzz_r_thread.mutex); | 500 | 6.96k | for (;;) { | 501 | 13.9k | while (fuzz_r_thread.job == NULL) | 502 | 6.95k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 503 | 6.96k | fuzz_job_t *job = fuzz_r_thread.job; | 504 | 6.96k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 505 | | | 506 | 6.96k | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started); | 507 | 6.96k | atomic_store(&fuzz_alarm.running, 1); | 508 | 6.96k | job->fn(job->arg); | 509 | 6.96k | atomic_store(&fuzz_alarm.running, 0); | 510 | | | 511 | 6.96k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 512 | 6.96k | fuzz_r_thread.job = NULL; | 513 | 6.96k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 514 | 6.96k | } | 515 | | return NULL; | 516 | 2 | } |
coerce.c:fuzz_r_thread_main Line | Count | Source | 480 | 2 | { | 481 | 2 | (void)unused; | 482 | | /* The frame address rather than a local's: under ASAN an address-taken | 483 | | * local may sit on the fake stack, nowhere near this thread's stack. | 484 | | * R_CStackStart matters only once R is initialized; fuzz_init_r() | 485 | | * sets it again after Rf_initialize_R has overwritten it. */ | 486 | 2 | fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0); | 487 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 488 | | | 489 | | /* libFuzzer's -timeout alarm is acted on only by the thread running | 490 | | * its loop (the main thread); delivered here it would be ignored and | 491 | | * the input would run on. Block it so the kernel cannot pick this | 492 | | * thread; fuzz_alarm_handler below gets this thread's stack into the | 493 | | * timeout report instead. */ | 494 | 2 | sigset_t alarm; | 495 | 2 | sigemptyset(&alarm); | 496 | 2 | sigaddset(&alarm, SIGALRM); | 497 | 2 | pthread_sigmask(SIG_BLOCK, &alarm, NULL); | 498 | | | 499 | 2 | pthread_mutex_lock(&fuzz_r_thread.mutex); | 500 | 1.89k | for (;;) { | 501 | 3.79k | while (fuzz_r_thread.job == NULL) | 502 | 1.89k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 503 | 1.89k | fuzz_job_t *job = fuzz_r_thread.job; | 504 | 1.89k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 505 | | | 506 | 1.89k | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started); | 507 | 1.89k | atomic_store(&fuzz_alarm.running, 1); | 508 | 1.89k | job->fn(job->arg); | 509 | 1.89k | atomic_store(&fuzz_alarm.running, 0); | 510 | | | 511 | 1.89k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 512 | 1.89k | fuzz_r_thread.job = NULL; | 513 | 1.89k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 514 | 1.89k | } | 515 | | return NULL; | 516 | 2 | } |
load.c:fuzz_r_thread_main Line | Count | Source | 480 | 2 | { | 481 | 2 | (void)unused; | 482 | | /* The frame address rather than a local's: under ASAN an address-taken | 483 | | * local may sit on the fake stack, nowhere near this thread's stack. | 484 | | * R_CStackStart matters only once R is initialized; fuzz_init_r() | 485 | | * sets it again after Rf_initialize_R has overwritten it. */ | 486 | 2 | fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0); | 487 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 488 | | | 489 | | /* libFuzzer's -timeout alarm is acted on only by the thread running | 490 | | * its loop (the main thread); delivered here it would be ignored and | 491 | | * the input would run on. Block it so the kernel cannot pick this | 492 | | * thread; fuzz_alarm_handler below gets this thread's stack into the | 493 | | * timeout report instead. */ | 494 | 2 | sigset_t alarm; | 495 | 2 | sigemptyset(&alarm); | 496 | 2 | sigaddset(&alarm, SIGALRM); | 497 | 2 | pthread_sigmask(SIG_BLOCK, &alarm, NULL); | 498 | | | 499 | 2 | pthread_mutex_lock(&fuzz_r_thread.mutex); | 500 | 8.51k | for (;;) { | 501 | 17.0k | while (fuzz_r_thread.job == NULL) | 502 | 8.51k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 503 | 8.51k | fuzz_job_t *job = fuzz_r_thread.job; | 504 | 8.51k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 505 | | | 506 | 8.51k | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started); | 507 | 8.51k | atomic_store(&fuzz_alarm.running, 1); | 508 | 8.51k | job->fn(job->arg); | 509 | 8.51k | atomic_store(&fuzz_alarm.running, 0); | 510 | | | 511 | 8.51k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 512 | 8.51k | fuzz_r_thread.job = NULL; | 513 | 8.51k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 514 | 8.51k | } | 515 | | return NULL; | 516 | 2 | } |
scan.c:fuzz_r_thread_main Line | Count | Source | 480 | 2 | { | 481 | 2 | (void)unused; | 482 | | /* The frame address rather than a local's: under ASAN an address-taken | 483 | | * local may sit on the fake stack, nowhere near this thread's stack. | 484 | | * R_CStackStart matters only once R is initialized; fuzz_init_r() | 485 | | * sets it again after Rf_initialize_R has overwritten it. */ | 486 | 2 | fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0); | 487 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 488 | | | 489 | | /* libFuzzer's -timeout alarm is acted on only by the thread running | 490 | | * its loop (the main thread); delivered here it would be ignored and | 491 | | * the input would run on. Block it so the kernel cannot pick this | 492 | | * thread; fuzz_alarm_handler below gets this thread's stack into the | 493 | | * timeout report instead. */ | 494 | 2 | sigset_t alarm; | 495 | 2 | sigemptyset(&alarm); | 496 | 2 | sigaddset(&alarm, SIGALRM); | 497 | 2 | pthread_sigmask(SIG_BLOCK, &alarm, NULL); | 498 | | | 499 | 2 | pthread_mutex_lock(&fuzz_r_thread.mutex); | 500 | 3.13k | for (;;) { | 501 | 6.26k | while (fuzz_r_thread.job == NULL) | 502 | 3.13k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 503 | 3.13k | fuzz_job_t *job = fuzz_r_thread.job; | 504 | 3.13k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 505 | | | 506 | 3.13k | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started); | 507 | 3.13k | atomic_store(&fuzz_alarm.running, 1); | 508 | 3.13k | job->fn(job->arg); | 509 | 3.13k | atomic_store(&fuzz_alarm.running, 0); | 510 | | | 511 | 3.13k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 512 | 3.13k | fuzz_r_thread.job = NULL; | 513 | 3.13k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 514 | 3.13k | } | 515 | | return NULL; | 516 | 2 | } |
colors.c:fuzz_r_thread_main Line | Count | Source | 480 | 2 | { | 481 | 2 | (void)unused; | 482 | | /* The frame address rather than a local's: under ASAN an address-taken | 483 | | * local may sit on the fake stack, nowhere near this thread's stack. | 484 | | * R_CStackStart matters only once R is initialized; fuzz_init_r() | 485 | | * sets it again after Rf_initialize_R has overwritten it. */ | 486 | 2 | fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0); | 487 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 488 | | | 489 | | /* libFuzzer's -timeout alarm is acted on only by the thread running | 490 | | * its loop (the main thread); delivered here it would be ignored and | 491 | | * the input would run on. Block it so the kernel cannot pick this | 492 | | * thread; fuzz_alarm_handler below gets this thread's stack into the | 493 | | * timeout report instead. */ | 494 | 2 | sigset_t alarm; | 495 | 2 | sigemptyset(&alarm); | 496 | 2 | sigaddset(&alarm, SIGALRM); | 497 | 2 | pthread_sigmask(SIG_BLOCK, &alarm, NULL); | 498 | | | 499 | 2 | pthread_mutex_lock(&fuzz_r_thread.mutex); | 500 | 1.86k | for (;;) { | 501 | 3.72k | while (fuzz_r_thread.job == NULL) | 502 | 1.85k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 503 | 1.86k | fuzz_job_t *job = fuzz_r_thread.job; | 504 | 1.86k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 505 | | | 506 | 1.86k | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started); | 507 | 1.86k | atomic_store(&fuzz_alarm.running, 1); | 508 | 1.86k | job->fn(job->arg); | 509 | 1.86k | atomic_store(&fuzz_alarm.running, 0); | 510 | | | 511 | 1.86k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 512 | 1.86k | fuzz_r_thread.job = NULL; | 513 | 1.86k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 514 | 1.86k | } | 515 | | return NULL; | 516 | 2 | } |
parse.c:fuzz_r_thread_main Line | Count | Source | 480 | 2 | { | 481 | 2 | (void)unused; | 482 | | /* The frame address rather than a local's: under ASAN an address-taken | 483 | | * local may sit on the fake stack, nowhere near this thread's stack. | 484 | | * R_CStackStart matters only once R is initialized; fuzz_init_r() | 485 | | * sets it again after Rf_initialize_R has overwritten it. */ | 486 | 2 | fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0); | 487 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 488 | | | 489 | | /* libFuzzer's -timeout alarm is acted on only by the thread running | 490 | | * its loop (the main thread); delivered here it would be ignored and | 491 | | * the input would run on. Block it so the kernel cannot pick this | 492 | | * thread; fuzz_alarm_handler below gets this thread's stack into the | 493 | | * timeout report instead. */ | 494 | 2 | sigset_t alarm; | 495 | 2 | sigemptyset(&alarm); | 496 | 2 | sigaddset(&alarm, SIGALRM); | 497 | 2 | pthread_sigmask(SIG_BLOCK, &alarm, NULL); | 498 | | | 499 | 2 | pthread_mutex_lock(&fuzz_r_thread.mutex); | 500 | 8.04k | for (;;) { | 501 | 16.0k | while (fuzz_r_thread.job == NULL) | 502 | 8.04k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 503 | 8.04k | fuzz_job_t *job = fuzz_r_thread.job; | 504 | 8.04k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 505 | | | 506 | 8.04k | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started); | 507 | 8.04k | atomic_store(&fuzz_alarm.running, 1); | 508 | 8.04k | job->fn(job->arg); | 509 | 8.04k | atomic_store(&fuzz_alarm.running, 0); | 510 | | | 511 | 8.04k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 512 | 8.04k | fuzz_r_thread.job = NULL; | 513 | 8.04k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 514 | 8.04k | } | 515 | | return NULL; | 516 | 2 | } |
sockets.c:fuzz_r_thread_main Line | Count | Source | 480 | 1 | { | 481 | 1 | (void)unused; | 482 | | /* The frame address rather than a local's: under ASAN an address-taken | 483 | | * local may sit on the fake stack, nowhere near this thread's stack. | 484 | | * R_CStackStart matters only once R is initialized; fuzz_init_r() | 485 | | * sets it again after Rf_initialize_R has overwritten it. */ | 486 | 1 | fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0); | 487 | 1 | R_CStackStart = fuzz_r_thread.stack_top; | 488 | | | 489 | | /* libFuzzer's -timeout alarm is acted on only by the thread running | 490 | | * its loop (the main thread); delivered here it would be ignored and | 491 | | * the input would run on. Block it so the kernel cannot pick this | 492 | | * thread; fuzz_alarm_handler below gets this thread's stack into the | 493 | | * timeout report instead. */ | 494 | 1 | sigset_t alarm; | 495 | 1 | sigemptyset(&alarm); | 496 | 1 | sigaddset(&alarm, SIGALRM); | 497 | 1 | pthread_sigmask(SIG_BLOCK, &alarm, NULL); | 498 | | | 499 | 1 | pthread_mutex_lock(&fuzz_r_thread.mutex); | 500 | 2 | for (;;) { | 501 | 3 | while (fuzz_r_thread.job == NULL) | 502 | 1 | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 503 | 2 | fuzz_job_t *job = fuzz_r_thread.job; | 504 | 2 | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 505 | | | 506 | 2 | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started); | 507 | 2 | atomic_store(&fuzz_alarm.running, 1); | 508 | 2 | job->fn(job->arg); | 509 | 2 | atomic_store(&fuzz_alarm.running, 0); | 510 | | | 511 | 2 | pthread_mutex_lock(&fuzz_r_thread.mutex); | 512 | 2 | fuzz_r_thread.job = NULL; | 513 | 2 | pthread_cond_broadcast(&fuzz_r_thread.cond); | 514 | 2 | } | 515 | | return NULL; | 516 | 1 | } |
sprintf.c:fuzz_r_thread_main Line | Count | Source | 480 | 2 | { | 481 | 2 | (void)unused; | 482 | | /* The frame address rather than a local's: under ASAN an address-taken | 483 | | * local may sit on the fake stack, nowhere near this thread's stack. | 484 | | * R_CStackStart matters only once R is initialized; fuzz_init_r() | 485 | | * sets it again after Rf_initialize_R has overwritten it. */ | 486 | 2 | fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0); | 487 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 488 | | | 489 | | /* libFuzzer's -timeout alarm is acted on only by the thread running | 490 | | * its loop (the main thread); delivered here it would be ignored and | 491 | | * the input would run on. Block it so the kernel cannot pick this | 492 | | * thread; fuzz_alarm_handler below gets this thread's stack into the | 493 | | * timeout report instead. */ | 494 | 2 | sigset_t alarm; | 495 | 2 | sigemptyset(&alarm); | 496 | 2 | sigaddset(&alarm, SIGALRM); | 497 | 2 | pthread_sigmask(SIG_BLOCK, &alarm, NULL); | 498 | | | 499 | 2 | pthread_mutex_lock(&fuzz_r_thread.mutex); | 500 | 2.20k | for (;;) { | 501 | 4.41k | while (fuzz_r_thread.job == NULL) | 502 | 2.20k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 503 | 2.20k | fuzz_job_t *job = fuzz_r_thread.job; | 504 | 2.20k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 505 | | | 506 | 2.20k | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started); | 507 | 2.20k | atomic_store(&fuzz_alarm.running, 1); | 508 | 2.20k | job->fn(job->arg); | 509 | 2.20k | atomic_store(&fuzz_alarm.running, 0); | 510 | | | 511 | 2.20k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 512 | 2.20k | fuzz_r_thread.job = NULL; | 513 | 2.20k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 514 | 2.20k | } | 515 | | return NULL; | 516 | 2 | } |
eval.c:fuzz_r_thread_main Line | Count | Source | 480 | 2 | { | 481 | 2 | (void)unused; | 482 | | /* The frame address rather than a local's: under ASAN an address-taken | 483 | | * local may sit on the fake stack, nowhere near this thread's stack. | 484 | | * R_CStackStart matters only once R is initialized; fuzz_init_r() | 485 | | * sets it again after Rf_initialize_R has overwritten it. */ | 486 | 2 | fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0); | 487 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 488 | | | 489 | | /* libFuzzer's -timeout alarm is acted on only by the thread running | 490 | | * its loop (the main thread); delivered here it would be ignored and | 491 | | * the input would run on. Block it so the kernel cannot pick this | 492 | | * thread; fuzz_alarm_handler below gets this thread's stack into the | 493 | | * timeout report instead. */ | 494 | 2 | sigset_t alarm; | 495 | 2 | sigemptyset(&alarm); | 496 | 2 | sigaddset(&alarm, SIGALRM); | 497 | 2 | pthread_sigmask(SIG_BLOCK, &alarm, NULL); | 498 | | | 499 | 2 | pthread_mutex_lock(&fuzz_r_thread.mutex); | 500 | 12.1k | for (;;) { | 501 | 24.3k | while (fuzz_r_thread.job == NULL) | 502 | 12.1k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 503 | 12.1k | fuzz_job_t *job = fuzz_r_thread.job; | 504 | 12.1k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 505 | | | 506 | 12.1k | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started); | 507 | 12.1k | atomic_store(&fuzz_alarm.running, 1); | 508 | 12.1k | job->fn(job->arg); | 509 | 12.1k | atomic_store(&fuzz_alarm.running, 0); | 510 | | | 511 | 12.1k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 512 | 12.1k | fuzz_r_thread.job = NULL; | 513 | 12.1k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 514 | 12.1k | } | 515 | | return NULL; | 516 | 2 | } |
Line | Count | Source | 480 | 2 | { | 481 | 2 | (void)unused; | 482 | | /* The frame address rather than a local's: under ASAN an address-taken | 483 | | * local may sit on the fake stack, nowhere near this thread's stack. | 484 | | * R_CStackStart matters only once R is initialized; fuzz_init_r() | 485 | | * sets it again after Rf_initialize_R has overwritten it. */ | 486 | 2 | fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0); | 487 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 488 | | | 489 | | /* libFuzzer's -timeout alarm is acted on only by the thread running | 490 | | * its loop (the main thread); delivered here it would be ignored and | 491 | | * the input would run on. Block it so the kernel cannot pick this | 492 | | * thread; fuzz_alarm_handler below gets this thread's stack into the | 493 | | * timeout report instead. */ | 494 | 2 | sigset_t alarm; | 495 | 2 | sigemptyset(&alarm); | 496 | 2 | sigaddset(&alarm, SIGALRM); | 497 | 2 | pthread_sigmask(SIG_BLOCK, &alarm, NULL); | 498 | | | 499 | 2 | pthread_mutex_lock(&fuzz_r_thread.mutex); | 500 | 2.34k | for (;;) { | 501 | 4.69k | while (fuzz_r_thread.job == NULL) | 502 | 2.34k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 503 | 2.34k | fuzz_job_t *job = fuzz_r_thread.job; | 504 | 2.34k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 505 | | | 506 | 2.34k | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started); | 507 | 2.34k | atomic_store(&fuzz_alarm.running, 1); | 508 | 2.34k | job->fn(job->arg); | 509 | 2.34k | atomic_store(&fuzz_alarm.running, 0); | 510 | | | 511 | 2.34k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 512 | 2.34k | fuzz_r_thread.job = NULL; | 513 | 2.34k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 514 | 2.34k | } | 515 | | return NULL; | 516 | 2 | } |
|
517 | | |
518 | | static int fuzz_on_r_thread(void) |
519 | 90.9k | { |
520 | 90.9k | return fuzz_r_thread.started && |
521 | 90.9k | pthread_equal(pthread_self(), fuzz_r_thread.thread); |
522 | 90.9k | } Line | Count | Source | 519 | 1.50k | { | 520 | 1.50k | return fuzz_r_thread.started && | 521 | 1.50k | pthread_equal(pthread_self(), fuzz_r_thread.thread); | 522 | 1.50k | } |
Line | Count | Source | 519 | 5.00k | { | 520 | 5.00k | return fuzz_r_thread.started && | 521 | 5.00k | pthread_equal(pthread_self(), fuzz_r_thread.thread); | 522 | 5.00k | } |
character.c:fuzz_on_r_thread Line | Count | Source | 519 | 4.47k | { | 520 | 4.47k | return fuzz_r_thread.started && | 521 | 4.47k | pthread_equal(pthread_self(), fuzz_r_thread.thread); | 522 | 4.47k | } |
encoding.c:fuzz_on_r_thread Line | Count | Source | 519 | 1.76k | { | 520 | 1.76k | return fuzz_r_thread.started && | 521 | 1.76k | pthread_equal(pthread_self(), fuzz_r_thread.thread); | 522 | 1.76k | } |
Line | Count | Source | 519 | 6.76k | { | 520 | 6.76k | return fuzz_r_thread.started && | 521 | 6.76k | pthread_equal(pthread_self(), fuzz_r_thread.thread); | 522 | 6.76k | } |
connections.c:fuzz_on_r_thread Line | Count | Source | 519 | 5.99k | { | 520 | 5.99k | return fuzz_r_thread.started && | 521 | 5.99k | pthread_equal(pthread_self(), fuzz_r_thread.thread); | 522 | 5.99k | } |
unserialize.c:fuzz_on_r_thread Line | Count | Source | 519 | 5.62k | { | 520 | 5.62k | return fuzz_r_thread.started && | 521 | 5.62k | pthread_equal(pthread_self(), fuzz_r_thread.thread); | 522 | 5.62k | } |
decompress.c:fuzz_on_r_thread Line | Count | Source | 519 | 6.75k | { | 520 | 6.75k | return fuzz_r_thread.started && | 521 | 6.75k | pthread_equal(pthread_self(), fuzz_r_thread.thread); | 522 | 6.75k | } |
readtable.c:fuzz_on_r_thread Line | Count | Source | 519 | 350 | { | 520 | 350 | return fuzz_r_thread.started && | 521 | 350 | pthread_equal(pthread_self(), fuzz_r_thread.thread); | 522 | 350 | } |
format.c:fuzz_on_r_thread Line | Count | Source | 519 | 5.54k | { | 520 | 5.54k | return fuzz_r_thread.started && | 521 | 5.54k | pthread_equal(pthread_self(), fuzz_r_thread.thread); | 522 | 5.54k | } |
datetime.c:fuzz_on_r_thread Line | Count | Source | 519 | 6.96k | { | 520 | 6.96k | return fuzz_r_thread.started && | 521 | 6.96k | pthread_equal(pthread_self(), fuzz_r_thread.thread); | 522 | 6.96k | } |
coerce.c:fuzz_on_r_thread Line | Count | Source | 519 | 1.89k | { | 520 | 1.89k | return fuzz_r_thread.started && | 521 | 1.89k | pthread_equal(pthread_self(), fuzz_r_thread.thread); | 522 | 1.89k | } |
Line | Count | Source | 519 | 8.51k | { | 520 | 8.51k | return fuzz_r_thread.started && | 521 | 8.51k | pthread_equal(pthread_self(), fuzz_r_thread.thread); | 522 | 8.51k | } |
Line | Count | Source | 519 | 3.13k | { | 520 | 3.13k | return fuzz_r_thread.started && | 521 | 3.13k | pthread_equal(pthread_self(), fuzz_r_thread.thread); | 522 | 3.13k | } |
colors.c:fuzz_on_r_thread Line | Count | Source | 519 | 1.86k | { | 520 | 1.86k | return fuzz_r_thread.started && | 521 | 1.86k | pthread_equal(pthread_self(), fuzz_r_thread.thread); | 522 | 1.86k | } |
Line | Count | Source | 519 | 8.04k | { | 520 | 8.04k | return fuzz_r_thread.started && | 521 | 8.04k | pthread_equal(pthread_self(), fuzz_r_thread.thread); | 522 | 8.04k | } |
sockets.c:fuzz_on_r_thread Line | Count | Source | 519 | 2 | { | 520 | 2 | return fuzz_r_thread.started && | 521 | 2 | pthread_equal(pthread_self(), fuzz_r_thread.thread); | 522 | 2 | } |
sprintf.c:fuzz_on_r_thread Line | Count | Source | 519 | 2.20k | { | 520 | 2.20k | return fuzz_r_thread.started && | 521 | 2.20k | pthread_equal(pthread_self(), fuzz_r_thread.thread); | 522 | 2.20k | } |
Line | Count | Source | 519 | 12.1k | { | 520 | 12.1k | return fuzz_r_thread.started && | 521 | 12.1k | pthread_equal(pthread_self(), fuzz_r_thread.thread); | 522 | 12.1k | } |
Line | Count | Source | 519 | 2.34k | { | 520 | 2.34k | return fuzz_r_thread.started && | 521 | 2.34k | pthread_equal(pthread_self(), fuzz_r_thread.thread); | 522 | 2.34k | } |
|
523 | | |
524 | | /* Child side of fork: only the forking thread survives, so the R thread |
525 | | * is gone, and if it was the one waiting in pthread_cond_wait the |
526 | | * condition variable still counts it. Nothing holds the mutex during a |
527 | | * fork from either side of the handoff, so resetting both is safe; |
528 | | * pthread_cond_destroy would wait for the phantom waiter instead. */ |
529 | | static void fuzz_r_thread_forget(void) |
530 | 0 | { |
531 | 0 | fuzz_r_thread.started = 0; |
532 | 0 | fuzz_r_thread.job = NULL; |
533 | 0 | fuzz_r_thread.mutex = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER; |
534 | 0 | fuzz_r_thread.cond = (pthread_cond_t)PTHREAD_COND_INITIALIZER; |
535 | 0 | } Unexecuted instantiation: io.c:fuzz_r_thread_forget Unexecuted instantiation: dcf.c:fuzz_r_thread_forget Unexecuted instantiation: character.c:fuzz_r_thread_forget Unexecuted instantiation: encoding.c:fuzz_r_thread_forget Unexecuted instantiation: sort.c:fuzz_r_thread_forget Unexecuted instantiation: connections.c:fuzz_r_thread_forget Unexecuted instantiation: unserialize.c:fuzz_r_thread_forget Unexecuted instantiation: decompress.c:fuzz_r_thread_forget Unexecuted instantiation: readtable.c:fuzz_r_thread_forget Unexecuted instantiation: format.c:fuzz_r_thread_forget Unexecuted instantiation: datetime.c:fuzz_r_thread_forget Unexecuted instantiation: coerce.c:fuzz_r_thread_forget Unexecuted instantiation: load.c:fuzz_r_thread_forget Unexecuted instantiation: scan.c:fuzz_r_thread_forget Unexecuted instantiation: colors.c:fuzz_r_thread_forget Unexecuted instantiation: parse.c:fuzz_r_thread_forget Unexecuted instantiation: sockets.c:fuzz_r_thread_forget Unexecuted instantiation: sprintf.c:fuzz_r_thread_forget Unexecuted instantiation: eval.c:fuzz_r_thread_forget Unexecuted instantiation: zip.c:fuzz_r_thread_forget |
536 | | |
537 | | /* Run fn(arg) on the R thread and wait for it to return, starting the |
538 | | * thread on first use. From the R thread itself this is a plain call. */ |
539 | | static void fuzz_run_on_r_thread(void (*fn)(void *), void *arg) |
540 | 90.8k | { |
541 | 90.8k | if (!fuzz_r_thread.started) { |
542 | 39 | static int atfork_registered = 0; |
543 | 39 | if (!atfork_registered) { |
544 | 39 | if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) { |
545 | 0 | fprintf(stderr, "fuzz: cannot register the fork handler\n"); |
546 | 0 | abort(); |
547 | 0 | } |
548 | 39 | atfork_registered = 1; |
549 | 39 | } |
550 | | |
551 | 39 | pthread_attr_t attr; |
552 | 39 | if (pthread_attr_init(&attr) != 0 || |
553 | 39 | pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 || |
554 | 39 | pthread_create(&fuzz_r_thread.thread, &attr, |
555 | 39 | fuzz_r_thread_main, NULL) != 0) { |
556 | 0 | fprintf(stderr, "fuzz: cannot start the R thread\n"); |
557 | 0 | abort(); |
558 | 0 | } |
559 | 39 | pthread_attr_destroy(&attr); |
560 | 39 | fuzz_r_thread.started = 1; |
561 | 39 | } |
562 | | |
563 | 90.8k | if (fuzz_on_r_thread()) { |
564 | 0 | fn(arg); |
565 | 0 | return; |
566 | 0 | } |
567 | | |
568 | 90.8k | fuzz_job_t job = { fn, arg }; |
569 | 90.8k | if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0) |
570 | 90.8k | atomic_fetch_add(&fuzz_alarm.input, 1); /* wrapped past 0, which is none */ |
571 | | |
572 | 90.8k | pthread_mutex_lock(&fuzz_r_thread.mutex); |
573 | 90.8k | fuzz_r_thread.job = &job; |
574 | 90.8k | pthread_cond_broadcast(&fuzz_r_thread.cond); |
575 | 181k | while (fuzz_r_thread.job != NULL) |
576 | 90.8k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); |
577 | 90.8k | pthread_mutex_unlock(&fuzz_r_thread.mutex); |
578 | | |
579 | | /* Idle again: ticks count, and libFuzzer's clock for the next input |
580 | | * starts after this. */ |
581 | 90.8k | atomic_store(&fuzz_alarm.finishing, 0); |
582 | 90.8k | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed); |
583 | 90.8k | } io.c:fuzz_run_on_r_thread Line | Count | Source | 540 | 1.50k | { | 541 | 1.50k | if (!fuzz_r_thread.started) { | 542 | 2 | static int atfork_registered = 0; | 543 | 2 | if (!atfork_registered) { | 544 | 2 | if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) { | 545 | 0 | fprintf(stderr, "fuzz: cannot register the fork handler\n"); | 546 | 0 | abort(); | 547 | 0 | } | 548 | 2 | atfork_registered = 1; | 549 | 2 | } | 550 | | | 551 | 2 | pthread_attr_t attr; | 552 | 2 | if (pthread_attr_init(&attr) != 0 || | 553 | 2 | pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 || | 554 | 2 | pthread_create(&fuzz_r_thread.thread, &attr, | 555 | 2 | fuzz_r_thread_main, NULL) != 0) { | 556 | 0 | fprintf(stderr, "fuzz: cannot start the R thread\n"); | 557 | 0 | abort(); | 558 | 0 | } | 559 | 2 | pthread_attr_destroy(&attr); | 560 | 2 | fuzz_r_thread.started = 1; | 561 | 2 | } | 562 | | | 563 | 1.50k | if (fuzz_on_r_thread()) { | 564 | 0 | fn(arg); | 565 | 0 | return; | 566 | 0 | } | 567 | | | 568 | 1.50k | fuzz_job_t job = { fn, arg }; | 569 | 1.50k | if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0) | 570 | 1.50k | atomic_fetch_add(&fuzz_alarm.input, 1); /* wrapped past 0, which is none */ | 571 | | | 572 | 1.50k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 573 | 1.50k | fuzz_r_thread.job = &job; | 574 | 1.50k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 575 | 3.01k | while (fuzz_r_thread.job != NULL) | 576 | 1.50k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 577 | 1.50k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 578 | | | 579 | | /* Idle again: ticks count, and libFuzzer's clock for the next input | 580 | | * starts after this. */ | 581 | 1.50k | atomic_store(&fuzz_alarm.finishing, 0); | 582 | | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed); | 583 | 1.50k | } |
dcf.c:fuzz_run_on_r_thread Line | Count | Source | 540 | 5.00k | { | 541 | 5.00k | if (!fuzz_r_thread.started) { | 542 | 2 | static int atfork_registered = 0; | 543 | 2 | if (!atfork_registered) { | 544 | 2 | if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) { | 545 | 0 | fprintf(stderr, "fuzz: cannot register the fork handler\n"); | 546 | 0 | abort(); | 547 | 0 | } | 548 | 2 | atfork_registered = 1; | 549 | 2 | } | 550 | | | 551 | 2 | pthread_attr_t attr; | 552 | 2 | if (pthread_attr_init(&attr) != 0 || | 553 | 2 | pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 || | 554 | 2 | pthread_create(&fuzz_r_thread.thread, &attr, | 555 | 2 | fuzz_r_thread_main, NULL) != 0) { | 556 | 0 | fprintf(stderr, "fuzz: cannot start the R thread\n"); | 557 | 0 | abort(); | 558 | 0 | } | 559 | 2 | pthread_attr_destroy(&attr); | 560 | 2 | fuzz_r_thread.started = 1; | 561 | 2 | } | 562 | | | 563 | 5.00k | if (fuzz_on_r_thread()) { | 564 | 0 | fn(arg); | 565 | 0 | return; | 566 | 0 | } | 567 | | | 568 | 5.00k | fuzz_job_t job = { fn, arg }; | 569 | 5.00k | if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0) | 570 | 5.00k | atomic_fetch_add(&fuzz_alarm.input, 1); /* wrapped past 0, which is none */ | 571 | | | 572 | 5.00k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 573 | 5.00k | fuzz_r_thread.job = &job; | 574 | 5.00k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 575 | 10.0k | while (fuzz_r_thread.job != NULL) | 576 | 5.00k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 577 | 5.00k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 578 | | | 579 | | /* Idle again: ticks count, and libFuzzer's clock for the next input | 580 | | * starts after this. */ | 581 | 5.00k | atomic_store(&fuzz_alarm.finishing, 0); | 582 | | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed); | 583 | 5.00k | } |
character.c:fuzz_run_on_r_thread Line | Count | Source | 540 | 4.46k | { | 541 | 4.46k | if (!fuzz_r_thread.started) { | 542 | 2 | static int atfork_registered = 0; | 543 | 2 | if (!atfork_registered) { | 544 | 2 | if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) { | 545 | 0 | fprintf(stderr, "fuzz: cannot register the fork handler\n"); | 546 | 0 | abort(); | 547 | 0 | } | 548 | 2 | atfork_registered = 1; | 549 | 2 | } | 550 | | | 551 | 2 | pthread_attr_t attr; | 552 | 2 | if (pthread_attr_init(&attr) != 0 || | 553 | 2 | pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 || | 554 | 2 | pthread_create(&fuzz_r_thread.thread, &attr, | 555 | 2 | fuzz_r_thread_main, NULL) != 0) { | 556 | 0 | fprintf(stderr, "fuzz: cannot start the R thread\n"); | 557 | 0 | abort(); | 558 | 0 | } | 559 | 2 | pthread_attr_destroy(&attr); | 560 | 2 | fuzz_r_thread.started = 1; | 561 | 2 | } | 562 | | | 563 | 4.46k | if (fuzz_on_r_thread()) { | 564 | 0 | fn(arg); | 565 | 0 | return; | 566 | 0 | } | 567 | | | 568 | 4.46k | fuzz_job_t job = { fn, arg }; | 569 | 4.46k | if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0) | 570 | 4.46k | atomic_fetch_add(&fuzz_alarm.input, 1); /* wrapped past 0, which is none */ | 571 | | | 572 | 4.46k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 573 | 4.46k | fuzz_r_thread.job = &job; | 574 | 4.46k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 575 | 8.93k | while (fuzz_r_thread.job != NULL) | 576 | 4.46k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 577 | 4.46k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 578 | | | 579 | | /* Idle again: ticks count, and libFuzzer's clock for the next input | 580 | | * starts after this. */ | 581 | 4.46k | atomic_store(&fuzz_alarm.finishing, 0); | 582 | | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed); | 583 | 4.46k | } |
encoding.c:fuzz_run_on_r_thread Line | Count | Source | 540 | 1.76k | { | 541 | 1.76k | if (!fuzz_r_thread.started) { | 542 | 2 | static int atfork_registered = 0; | 543 | 2 | if (!atfork_registered) { | 544 | 2 | if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) { | 545 | 0 | fprintf(stderr, "fuzz: cannot register the fork handler\n"); | 546 | 0 | abort(); | 547 | 0 | } | 548 | 2 | atfork_registered = 1; | 549 | 2 | } | 550 | | | 551 | 2 | pthread_attr_t attr; | 552 | 2 | if (pthread_attr_init(&attr) != 0 || | 553 | 2 | pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 || | 554 | 2 | pthread_create(&fuzz_r_thread.thread, &attr, | 555 | 2 | fuzz_r_thread_main, NULL) != 0) { | 556 | 0 | fprintf(stderr, "fuzz: cannot start the R thread\n"); | 557 | 0 | abort(); | 558 | 0 | } | 559 | 2 | pthread_attr_destroy(&attr); | 560 | 2 | fuzz_r_thread.started = 1; | 561 | 2 | } | 562 | | | 563 | 1.76k | if (fuzz_on_r_thread()) { | 564 | 0 | fn(arg); | 565 | 0 | return; | 566 | 0 | } | 567 | | | 568 | 1.76k | fuzz_job_t job = { fn, arg }; | 569 | 1.76k | if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0) | 570 | 1.76k | atomic_fetch_add(&fuzz_alarm.input, 1); /* wrapped past 0, which is none */ | 571 | | | 572 | 1.76k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 573 | 1.76k | fuzz_r_thread.job = &job; | 574 | 1.76k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 575 | 3.52k | while (fuzz_r_thread.job != NULL) | 576 | 1.76k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 577 | 1.76k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 578 | | | 579 | | /* Idle again: ticks count, and libFuzzer's clock for the next input | 580 | | * starts after this. */ | 581 | 1.76k | atomic_store(&fuzz_alarm.finishing, 0); | 582 | | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed); | 583 | 1.76k | } |
sort.c:fuzz_run_on_r_thread Line | Count | Source | 540 | 6.75k | { | 541 | 6.75k | if (!fuzz_r_thread.started) { | 542 | 2 | static int atfork_registered = 0; | 543 | 2 | if (!atfork_registered) { | 544 | 2 | if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) { | 545 | 0 | fprintf(stderr, "fuzz: cannot register the fork handler\n"); | 546 | 0 | abort(); | 547 | 0 | } | 548 | 2 | atfork_registered = 1; | 549 | 2 | } | 550 | | | 551 | 2 | pthread_attr_t attr; | 552 | 2 | if (pthread_attr_init(&attr) != 0 || | 553 | 2 | pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 || | 554 | 2 | pthread_create(&fuzz_r_thread.thread, &attr, | 555 | 2 | fuzz_r_thread_main, NULL) != 0) { | 556 | 0 | fprintf(stderr, "fuzz: cannot start the R thread\n"); | 557 | 0 | abort(); | 558 | 0 | } | 559 | 2 | pthread_attr_destroy(&attr); | 560 | 2 | fuzz_r_thread.started = 1; | 561 | 2 | } | 562 | | | 563 | 6.75k | if (fuzz_on_r_thread()) { | 564 | 0 | fn(arg); | 565 | 0 | return; | 566 | 0 | } | 567 | | | 568 | 6.75k | fuzz_job_t job = { fn, arg }; | 569 | 6.75k | if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0) | 570 | 6.75k | atomic_fetch_add(&fuzz_alarm.input, 1); /* wrapped past 0, which is none */ | 571 | | | 572 | 6.75k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 573 | 6.75k | fuzz_r_thread.job = &job; | 574 | 6.75k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 575 | 13.5k | while (fuzz_r_thread.job != NULL) | 576 | 6.75k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 577 | 6.75k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 578 | | | 579 | | /* Idle again: ticks count, and libFuzzer's clock for the next input | 580 | | * starts after this. */ | 581 | 6.75k | atomic_store(&fuzz_alarm.finishing, 0); | 582 | | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed); | 583 | 6.75k | } |
connections.c:fuzz_run_on_r_thread Line | Count | Source | 540 | 5.99k | { | 541 | 5.99k | if (!fuzz_r_thread.started) { | 542 | 2 | static int atfork_registered = 0; | 543 | 2 | if (!atfork_registered) { | 544 | 2 | if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) { | 545 | 0 | fprintf(stderr, "fuzz: cannot register the fork handler\n"); | 546 | 0 | abort(); | 547 | 0 | } | 548 | 2 | atfork_registered = 1; | 549 | 2 | } | 550 | | | 551 | 2 | pthread_attr_t attr; | 552 | 2 | if (pthread_attr_init(&attr) != 0 || | 553 | 2 | pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 || | 554 | 2 | pthread_create(&fuzz_r_thread.thread, &attr, | 555 | 2 | fuzz_r_thread_main, NULL) != 0) { | 556 | 0 | fprintf(stderr, "fuzz: cannot start the R thread\n"); | 557 | 0 | abort(); | 558 | 0 | } | 559 | 2 | pthread_attr_destroy(&attr); | 560 | 2 | fuzz_r_thread.started = 1; | 561 | 2 | } | 562 | | | 563 | 5.99k | if (fuzz_on_r_thread()) { | 564 | 0 | fn(arg); | 565 | 0 | return; | 566 | 0 | } | 567 | | | 568 | 5.99k | fuzz_job_t job = { fn, arg }; | 569 | 5.99k | if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0) | 570 | 5.99k | atomic_fetch_add(&fuzz_alarm.input, 1); /* wrapped past 0, which is none */ | 571 | | | 572 | 5.99k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 573 | 5.99k | fuzz_r_thread.job = &job; | 574 | 5.99k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 575 | 11.9k | while (fuzz_r_thread.job != NULL) | 576 | 5.99k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 577 | 5.99k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 578 | | | 579 | | /* Idle again: ticks count, and libFuzzer's clock for the next input | 580 | | * starts after this. */ | 581 | 5.99k | atomic_store(&fuzz_alarm.finishing, 0); | 582 | | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed); | 583 | 5.99k | } |
unserialize.c:fuzz_run_on_r_thread Line | Count | Source | 540 | 5.61k | { | 541 | 5.61k | if (!fuzz_r_thread.started) { | 542 | 2 | static int atfork_registered = 0; | 543 | 2 | if (!atfork_registered) { | 544 | 2 | if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) { | 545 | 0 | fprintf(stderr, "fuzz: cannot register the fork handler\n"); | 546 | 0 | abort(); | 547 | 0 | } | 548 | 2 | atfork_registered = 1; | 549 | 2 | } | 550 | | | 551 | 2 | pthread_attr_t attr; | 552 | 2 | if (pthread_attr_init(&attr) != 0 || | 553 | 2 | pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 || | 554 | 2 | pthread_create(&fuzz_r_thread.thread, &attr, | 555 | 2 | fuzz_r_thread_main, NULL) != 0) { | 556 | 0 | fprintf(stderr, "fuzz: cannot start the R thread\n"); | 557 | 0 | abort(); | 558 | 0 | } | 559 | 2 | pthread_attr_destroy(&attr); | 560 | 2 | fuzz_r_thread.started = 1; | 561 | 2 | } | 562 | | | 563 | 5.61k | if (fuzz_on_r_thread()) { | 564 | 0 | fn(arg); | 565 | 0 | return; | 566 | 0 | } | 567 | | | 568 | 5.61k | fuzz_job_t job = { fn, arg }; | 569 | 5.61k | if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0) | 570 | 5.61k | atomic_fetch_add(&fuzz_alarm.input, 1); /* wrapped past 0, which is none */ | 571 | | | 572 | 5.61k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 573 | 5.61k | fuzz_r_thread.job = &job; | 574 | 5.61k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 575 | 11.2k | while (fuzz_r_thread.job != NULL) | 576 | 5.61k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 577 | 5.61k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 578 | | | 579 | | /* Idle again: ticks count, and libFuzzer's clock for the next input | 580 | | * starts after this. */ | 581 | 5.61k | atomic_store(&fuzz_alarm.finishing, 0); | 582 | | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed); | 583 | 5.61k | } |
decompress.c:fuzz_run_on_r_thread Line | Count | Source | 540 | 6.75k | { | 541 | 6.75k | if (!fuzz_r_thread.started) { | 542 | 2 | static int atfork_registered = 0; | 543 | 2 | if (!atfork_registered) { | 544 | 2 | if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) { | 545 | 0 | fprintf(stderr, "fuzz: cannot register the fork handler\n"); | 546 | 0 | abort(); | 547 | 0 | } | 548 | 2 | atfork_registered = 1; | 549 | 2 | } | 550 | | | 551 | 2 | pthread_attr_t attr; | 552 | 2 | if (pthread_attr_init(&attr) != 0 || | 553 | 2 | pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 || | 554 | 2 | pthread_create(&fuzz_r_thread.thread, &attr, | 555 | 2 | fuzz_r_thread_main, NULL) != 0) { | 556 | 0 | fprintf(stderr, "fuzz: cannot start the R thread\n"); | 557 | 0 | abort(); | 558 | 0 | } | 559 | 2 | pthread_attr_destroy(&attr); | 560 | 2 | fuzz_r_thread.started = 1; | 561 | 2 | } | 562 | | | 563 | 6.75k | if (fuzz_on_r_thread()) { | 564 | 0 | fn(arg); | 565 | 0 | return; | 566 | 0 | } | 567 | | | 568 | 6.75k | fuzz_job_t job = { fn, arg }; | 569 | 6.75k | if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0) | 570 | 6.75k | atomic_fetch_add(&fuzz_alarm.input, 1); /* wrapped past 0, which is none */ | 571 | | | 572 | 6.75k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 573 | 6.75k | fuzz_r_thread.job = &job; | 574 | 6.75k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 575 | 13.5k | while (fuzz_r_thread.job != NULL) | 576 | 6.75k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 577 | 6.75k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 578 | | | 579 | | /* Idle again: ticks count, and libFuzzer's clock for the next input | 580 | | * starts after this. */ | 581 | 6.75k | atomic_store(&fuzz_alarm.finishing, 0); | 582 | | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed); | 583 | 6.75k | } |
readtable.c:fuzz_run_on_r_thread Line | Count | Source | 540 | 348 | { | 541 | 348 | if (!fuzz_r_thread.started) { | 542 | 2 | static int atfork_registered = 0; | 543 | 2 | if (!atfork_registered) { | 544 | 2 | if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) { | 545 | 0 | fprintf(stderr, "fuzz: cannot register the fork handler\n"); | 546 | 0 | abort(); | 547 | 0 | } | 548 | 2 | atfork_registered = 1; | 549 | 2 | } | 550 | | | 551 | 2 | pthread_attr_t attr; | 552 | 2 | if (pthread_attr_init(&attr) != 0 || | 553 | 2 | pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 || | 554 | 2 | pthread_create(&fuzz_r_thread.thread, &attr, | 555 | 2 | fuzz_r_thread_main, NULL) != 0) { | 556 | 0 | fprintf(stderr, "fuzz: cannot start the R thread\n"); | 557 | 0 | abort(); | 558 | 0 | } | 559 | 2 | pthread_attr_destroy(&attr); | 560 | 2 | fuzz_r_thread.started = 1; | 561 | 2 | } | 562 | | | 563 | 348 | if (fuzz_on_r_thread()) { | 564 | 0 | fn(arg); | 565 | 0 | return; | 566 | 0 | } | 567 | | | 568 | 348 | fuzz_job_t job = { fn, arg }; | 569 | 348 | if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0) | 570 | 348 | atomic_fetch_add(&fuzz_alarm.input, 1); /* wrapped past 0, which is none */ | 571 | | | 572 | 348 | pthread_mutex_lock(&fuzz_r_thread.mutex); | 573 | 348 | fuzz_r_thread.job = &job; | 574 | 348 | pthread_cond_broadcast(&fuzz_r_thread.cond); | 575 | 696 | while (fuzz_r_thread.job != NULL) | 576 | 348 | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 577 | 348 | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 578 | | | 579 | | /* Idle again: ticks count, and libFuzzer's clock for the next input | 580 | | * starts after this. */ | 581 | 348 | atomic_store(&fuzz_alarm.finishing, 0); | 582 | | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed); | 583 | 348 | } |
format.c:fuzz_run_on_r_thread Line | Count | Source | 540 | 5.54k | { | 541 | 5.54k | if (!fuzz_r_thread.started) { | 542 | 2 | static int atfork_registered = 0; | 543 | 2 | if (!atfork_registered) { | 544 | 2 | if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) { | 545 | 0 | fprintf(stderr, "fuzz: cannot register the fork handler\n"); | 546 | 0 | abort(); | 547 | 0 | } | 548 | 2 | atfork_registered = 1; | 549 | 2 | } | 550 | | | 551 | 2 | pthread_attr_t attr; | 552 | 2 | if (pthread_attr_init(&attr) != 0 || | 553 | 2 | pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 || | 554 | 2 | pthread_create(&fuzz_r_thread.thread, &attr, | 555 | 2 | fuzz_r_thread_main, NULL) != 0) { | 556 | 0 | fprintf(stderr, "fuzz: cannot start the R thread\n"); | 557 | 0 | abort(); | 558 | 0 | } | 559 | 2 | pthread_attr_destroy(&attr); | 560 | 2 | fuzz_r_thread.started = 1; | 561 | 2 | } | 562 | | | 563 | 5.54k | if (fuzz_on_r_thread()) { | 564 | 0 | fn(arg); | 565 | 0 | return; | 566 | 0 | } | 567 | | | 568 | 5.54k | fuzz_job_t job = { fn, arg }; | 569 | 5.54k | if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0) | 570 | 5.54k | atomic_fetch_add(&fuzz_alarm.input, 1); /* wrapped past 0, which is none */ | 571 | | | 572 | 5.54k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 573 | 5.54k | fuzz_r_thread.job = &job; | 574 | 5.54k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 575 | 11.0k | while (fuzz_r_thread.job != NULL) | 576 | 5.54k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 577 | 5.54k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 578 | | | 579 | | /* Idle again: ticks count, and libFuzzer's clock for the next input | 580 | | * starts after this. */ | 581 | 5.54k | atomic_store(&fuzz_alarm.finishing, 0); | 582 | | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed); | 583 | 5.54k | } |
datetime.c:fuzz_run_on_r_thread Line | Count | Source | 540 | 6.95k | { | 541 | 6.95k | if (!fuzz_r_thread.started) { | 542 | 2 | static int atfork_registered = 0; | 543 | 2 | if (!atfork_registered) { | 544 | 2 | if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) { | 545 | 0 | fprintf(stderr, "fuzz: cannot register the fork handler\n"); | 546 | 0 | abort(); | 547 | 0 | } | 548 | 2 | atfork_registered = 1; | 549 | 2 | } | 550 | | | 551 | 2 | pthread_attr_t attr; | 552 | 2 | if (pthread_attr_init(&attr) != 0 || | 553 | 2 | pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 || | 554 | 2 | pthread_create(&fuzz_r_thread.thread, &attr, | 555 | 2 | fuzz_r_thread_main, NULL) != 0) { | 556 | 0 | fprintf(stderr, "fuzz: cannot start the R thread\n"); | 557 | 0 | abort(); | 558 | 0 | } | 559 | 2 | pthread_attr_destroy(&attr); | 560 | 2 | fuzz_r_thread.started = 1; | 561 | 2 | } | 562 | | | 563 | 6.95k | if (fuzz_on_r_thread()) { | 564 | 0 | fn(arg); | 565 | 0 | return; | 566 | 0 | } | 567 | | | 568 | 6.95k | fuzz_job_t job = { fn, arg }; | 569 | 6.95k | if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0) | 570 | 6.95k | atomic_fetch_add(&fuzz_alarm.input, 1); /* wrapped past 0, which is none */ | 571 | | | 572 | 6.95k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 573 | 6.95k | fuzz_r_thread.job = &job; | 574 | 6.95k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 575 | 13.9k | while (fuzz_r_thread.job != NULL) | 576 | 6.95k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 577 | 6.95k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 578 | | | 579 | | /* Idle again: ticks count, and libFuzzer's clock for the next input | 580 | | * starts after this. */ | 581 | 6.95k | atomic_store(&fuzz_alarm.finishing, 0); | 582 | | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed); | 583 | 6.95k | } |
coerce.c:fuzz_run_on_r_thread Line | Count | Source | 540 | 1.89k | { | 541 | 1.89k | if (!fuzz_r_thread.started) { | 542 | 2 | static int atfork_registered = 0; | 543 | 2 | if (!atfork_registered) { | 544 | 2 | if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) { | 545 | 0 | fprintf(stderr, "fuzz: cannot register the fork handler\n"); | 546 | 0 | abort(); | 547 | 0 | } | 548 | 2 | atfork_registered = 1; | 549 | 2 | } | 550 | | | 551 | 2 | pthread_attr_t attr; | 552 | 2 | if (pthread_attr_init(&attr) != 0 || | 553 | 2 | pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 || | 554 | 2 | pthread_create(&fuzz_r_thread.thread, &attr, | 555 | 2 | fuzz_r_thread_main, NULL) != 0) { | 556 | 0 | fprintf(stderr, "fuzz: cannot start the R thread\n"); | 557 | 0 | abort(); | 558 | 0 | } | 559 | 2 | pthread_attr_destroy(&attr); | 560 | 2 | fuzz_r_thread.started = 1; | 561 | 2 | } | 562 | | | 563 | 1.89k | if (fuzz_on_r_thread()) { | 564 | 0 | fn(arg); | 565 | 0 | return; | 566 | 0 | } | 567 | | | 568 | 1.89k | fuzz_job_t job = { fn, arg }; | 569 | 1.89k | if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0) | 570 | 1.89k | atomic_fetch_add(&fuzz_alarm.input, 1); /* wrapped past 0, which is none */ | 571 | | | 572 | 1.89k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 573 | 1.89k | fuzz_r_thread.job = &job; | 574 | 1.89k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 575 | 3.79k | while (fuzz_r_thread.job != NULL) | 576 | 1.89k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 577 | 1.89k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 578 | | | 579 | | /* Idle again: ticks count, and libFuzzer's clock for the next input | 580 | | * starts after this. */ | 581 | 1.89k | atomic_store(&fuzz_alarm.finishing, 0); | 582 | | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed); | 583 | 1.89k | } |
load.c:fuzz_run_on_r_thread Line | Count | Source | 540 | 8.51k | { | 541 | 8.51k | if (!fuzz_r_thread.started) { | 542 | 2 | static int atfork_registered = 0; | 543 | 2 | if (!atfork_registered) { | 544 | 2 | if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) { | 545 | 0 | fprintf(stderr, "fuzz: cannot register the fork handler\n"); | 546 | 0 | abort(); | 547 | 0 | } | 548 | 2 | atfork_registered = 1; | 549 | 2 | } | 550 | | | 551 | 2 | pthread_attr_t attr; | 552 | 2 | if (pthread_attr_init(&attr) != 0 || | 553 | 2 | pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 || | 554 | 2 | pthread_create(&fuzz_r_thread.thread, &attr, | 555 | 2 | fuzz_r_thread_main, NULL) != 0) { | 556 | 0 | fprintf(stderr, "fuzz: cannot start the R thread\n"); | 557 | 0 | abort(); | 558 | 0 | } | 559 | 2 | pthread_attr_destroy(&attr); | 560 | 2 | fuzz_r_thread.started = 1; | 561 | 2 | } | 562 | | | 563 | 8.51k | if (fuzz_on_r_thread()) { | 564 | 0 | fn(arg); | 565 | 0 | return; | 566 | 0 | } | 567 | | | 568 | 8.51k | fuzz_job_t job = { fn, arg }; | 569 | 8.51k | if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0) | 570 | 8.51k | atomic_fetch_add(&fuzz_alarm.input, 1); /* wrapped past 0, which is none */ | 571 | | | 572 | 8.51k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 573 | 8.51k | fuzz_r_thread.job = &job; | 574 | 8.51k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 575 | 17.0k | while (fuzz_r_thread.job != NULL) | 576 | 8.51k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 577 | 8.51k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 578 | | | 579 | | /* Idle again: ticks count, and libFuzzer's clock for the next input | 580 | | * starts after this. */ | 581 | 8.51k | atomic_store(&fuzz_alarm.finishing, 0); | 582 | | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed); | 583 | 8.51k | } |
scan.c:fuzz_run_on_r_thread Line | Count | Source | 540 | 3.13k | { | 541 | 3.13k | if (!fuzz_r_thread.started) { | 542 | 2 | static int atfork_registered = 0; | 543 | 2 | if (!atfork_registered) { | 544 | 2 | if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) { | 545 | 0 | fprintf(stderr, "fuzz: cannot register the fork handler\n"); | 546 | 0 | abort(); | 547 | 0 | } | 548 | 2 | atfork_registered = 1; | 549 | 2 | } | 550 | | | 551 | 2 | pthread_attr_t attr; | 552 | 2 | if (pthread_attr_init(&attr) != 0 || | 553 | 2 | pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 || | 554 | 2 | pthread_create(&fuzz_r_thread.thread, &attr, | 555 | 2 | fuzz_r_thread_main, NULL) != 0) { | 556 | 0 | fprintf(stderr, "fuzz: cannot start the R thread\n"); | 557 | 0 | abort(); | 558 | 0 | } | 559 | 2 | pthread_attr_destroy(&attr); | 560 | 2 | fuzz_r_thread.started = 1; | 561 | 2 | } | 562 | | | 563 | 3.13k | if (fuzz_on_r_thread()) { | 564 | 0 | fn(arg); | 565 | 0 | return; | 566 | 0 | } | 567 | | | 568 | 3.13k | fuzz_job_t job = { fn, arg }; | 569 | 3.13k | if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0) | 570 | 3.13k | atomic_fetch_add(&fuzz_alarm.input, 1); /* wrapped past 0, which is none */ | 571 | | | 572 | 3.13k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 573 | 3.13k | fuzz_r_thread.job = &job; | 574 | 3.13k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 575 | 6.26k | while (fuzz_r_thread.job != NULL) | 576 | 3.13k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 577 | 3.13k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 578 | | | 579 | | /* Idle again: ticks count, and libFuzzer's clock for the next input | 580 | | * starts after this. */ | 581 | 3.13k | atomic_store(&fuzz_alarm.finishing, 0); | 582 | | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed); | 583 | 3.13k | } |
colors.c:fuzz_run_on_r_thread Line | Count | Source | 540 | 1.85k | { | 541 | 1.85k | if (!fuzz_r_thread.started) { | 542 | 2 | static int atfork_registered = 0; | 543 | 2 | if (!atfork_registered) { | 544 | 2 | if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) { | 545 | 0 | fprintf(stderr, "fuzz: cannot register the fork handler\n"); | 546 | 0 | abort(); | 547 | 0 | } | 548 | 2 | atfork_registered = 1; | 549 | 2 | } | 550 | | | 551 | 2 | pthread_attr_t attr; | 552 | 2 | if (pthread_attr_init(&attr) != 0 || | 553 | 2 | pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 || | 554 | 2 | pthread_create(&fuzz_r_thread.thread, &attr, | 555 | 2 | fuzz_r_thread_main, NULL) != 0) { | 556 | 0 | fprintf(stderr, "fuzz: cannot start the R thread\n"); | 557 | 0 | abort(); | 558 | 0 | } | 559 | 2 | pthread_attr_destroy(&attr); | 560 | 2 | fuzz_r_thread.started = 1; | 561 | 2 | } | 562 | | | 563 | 1.85k | if (fuzz_on_r_thread()) { | 564 | 0 | fn(arg); | 565 | 0 | return; | 566 | 0 | } | 567 | | | 568 | 1.85k | fuzz_job_t job = { fn, arg }; | 569 | 1.85k | if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0) | 570 | 1.85k | atomic_fetch_add(&fuzz_alarm.input, 1); /* wrapped past 0, which is none */ | 571 | | | 572 | 1.85k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 573 | 1.85k | fuzz_r_thread.job = &job; | 574 | 1.85k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 575 | 3.71k | while (fuzz_r_thread.job != NULL) | 576 | 1.85k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 577 | 1.85k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 578 | | | 579 | | /* Idle again: ticks count, and libFuzzer's clock for the next input | 580 | | * starts after this. */ | 581 | 1.85k | atomic_store(&fuzz_alarm.finishing, 0); | 582 | | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed); | 583 | 1.85k | } |
parse.c:fuzz_run_on_r_thread Line | Count | Source | 540 | 8.04k | { | 541 | 8.04k | if (!fuzz_r_thread.started) { | 542 | 2 | static int atfork_registered = 0; | 543 | 2 | if (!atfork_registered) { | 544 | 2 | if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) { | 545 | 0 | fprintf(stderr, "fuzz: cannot register the fork handler\n"); | 546 | 0 | abort(); | 547 | 0 | } | 548 | 2 | atfork_registered = 1; | 549 | 2 | } | 550 | | | 551 | 2 | pthread_attr_t attr; | 552 | 2 | if (pthread_attr_init(&attr) != 0 || | 553 | 2 | pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 || | 554 | 2 | pthread_create(&fuzz_r_thread.thread, &attr, | 555 | 2 | fuzz_r_thread_main, NULL) != 0) { | 556 | 0 | fprintf(stderr, "fuzz: cannot start the R thread\n"); | 557 | 0 | abort(); | 558 | 0 | } | 559 | 2 | pthread_attr_destroy(&attr); | 560 | 2 | fuzz_r_thread.started = 1; | 561 | 2 | } | 562 | | | 563 | 8.04k | if (fuzz_on_r_thread()) { | 564 | 0 | fn(arg); | 565 | 0 | return; | 566 | 0 | } | 567 | | | 568 | 8.04k | fuzz_job_t job = { fn, arg }; | 569 | 8.04k | if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0) | 570 | 8.04k | atomic_fetch_add(&fuzz_alarm.input, 1); /* wrapped past 0, which is none */ | 571 | | | 572 | 8.04k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 573 | 8.04k | fuzz_r_thread.job = &job; | 574 | 8.04k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 575 | 16.0k | while (fuzz_r_thread.job != NULL) | 576 | 8.04k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 577 | 8.04k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 578 | | | 579 | | /* Idle again: ticks count, and libFuzzer's clock for the next input | 580 | | * starts after this. */ | 581 | 8.04k | atomic_store(&fuzz_alarm.finishing, 0); | 582 | | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed); | 583 | 8.04k | } |
sockets.c:fuzz_run_on_r_thread Line | Count | Source | 540 | 1 | { | 541 | 1 | if (!fuzz_r_thread.started) { | 542 | 1 | static int atfork_registered = 0; | 543 | 1 | if (!atfork_registered) { | 544 | 1 | if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) { | 545 | 0 | fprintf(stderr, "fuzz: cannot register the fork handler\n"); | 546 | 0 | abort(); | 547 | 0 | } | 548 | 1 | atfork_registered = 1; | 549 | 1 | } | 550 | | | 551 | 1 | pthread_attr_t attr; | 552 | 1 | if (pthread_attr_init(&attr) != 0 || | 553 | 1 | pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 || | 554 | 1 | pthread_create(&fuzz_r_thread.thread, &attr, | 555 | 1 | fuzz_r_thread_main, NULL) != 0) { | 556 | 0 | fprintf(stderr, "fuzz: cannot start the R thread\n"); | 557 | 0 | abort(); | 558 | 0 | } | 559 | 1 | pthread_attr_destroy(&attr); | 560 | 1 | fuzz_r_thread.started = 1; | 561 | 1 | } | 562 | | | 563 | 1 | if (fuzz_on_r_thread()) { | 564 | 0 | fn(arg); | 565 | 0 | return; | 566 | 0 | } | 567 | | | 568 | 1 | fuzz_job_t job = { fn, arg }; | 569 | 1 | if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0) | 570 | 1 | atomic_fetch_add(&fuzz_alarm.input, 1); /* wrapped past 0, which is none */ | 571 | | | 572 | 1 | pthread_mutex_lock(&fuzz_r_thread.mutex); | 573 | 1 | fuzz_r_thread.job = &job; | 574 | 1 | pthread_cond_broadcast(&fuzz_r_thread.cond); | 575 | 2 | while (fuzz_r_thread.job != NULL) | 576 | 1 | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 577 | 1 | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 578 | | | 579 | | /* Idle again: ticks count, and libFuzzer's clock for the next input | 580 | | * starts after this. */ | 581 | 1 | atomic_store(&fuzz_alarm.finishing, 0); | 582 | | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed); | 583 | 1 | } |
sprintf.c:fuzz_run_on_r_thread Line | Count | Source | 540 | 2.20k | { | 541 | 2.20k | if (!fuzz_r_thread.started) { | 542 | 2 | static int atfork_registered = 0; | 543 | 2 | if (!atfork_registered) { | 544 | 2 | if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) { | 545 | 0 | fprintf(stderr, "fuzz: cannot register the fork handler\n"); | 546 | 0 | abort(); | 547 | 0 | } | 548 | 2 | atfork_registered = 1; | 549 | 2 | } | 550 | | | 551 | 2 | pthread_attr_t attr; | 552 | 2 | if (pthread_attr_init(&attr) != 0 || | 553 | 2 | pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 || | 554 | 2 | pthread_create(&fuzz_r_thread.thread, &attr, | 555 | 2 | fuzz_r_thread_main, NULL) != 0) { | 556 | 0 | fprintf(stderr, "fuzz: cannot start the R thread\n"); | 557 | 0 | abort(); | 558 | 0 | } | 559 | 2 | pthread_attr_destroy(&attr); | 560 | 2 | fuzz_r_thread.started = 1; | 561 | 2 | } | 562 | | | 563 | 2.20k | if (fuzz_on_r_thread()) { | 564 | 0 | fn(arg); | 565 | 0 | return; | 566 | 0 | } | 567 | | | 568 | 2.20k | fuzz_job_t job = { fn, arg }; | 569 | 2.20k | if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0) | 570 | 2.20k | atomic_fetch_add(&fuzz_alarm.input, 1); /* wrapped past 0, which is none */ | 571 | | | 572 | 2.20k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 573 | 2.20k | fuzz_r_thread.job = &job; | 574 | 2.20k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 575 | 4.40k | while (fuzz_r_thread.job != NULL) | 576 | 2.20k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 577 | 2.20k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 578 | | | 579 | | /* Idle again: ticks count, and libFuzzer's clock for the next input | 580 | | * starts after this. */ | 581 | 2.20k | atomic_store(&fuzz_alarm.finishing, 0); | 582 | | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed); | 583 | 2.20k | } |
eval.c:fuzz_run_on_r_thread Line | Count | Source | 540 | 12.1k | { | 541 | 12.1k | if (!fuzz_r_thread.started) { | 542 | 2 | static int atfork_registered = 0; | 543 | 2 | if (!atfork_registered) { | 544 | 2 | if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) { | 545 | 0 | fprintf(stderr, "fuzz: cannot register the fork handler\n"); | 546 | 0 | abort(); | 547 | 0 | } | 548 | 2 | atfork_registered = 1; | 549 | 2 | } | 550 | | | 551 | 2 | pthread_attr_t attr; | 552 | 2 | if (pthread_attr_init(&attr) != 0 || | 553 | 2 | pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 || | 554 | 2 | pthread_create(&fuzz_r_thread.thread, &attr, | 555 | 2 | fuzz_r_thread_main, NULL) != 0) { | 556 | 0 | fprintf(stderr, "fuzz: cannot start the R thread\n"); | 557 | 0 | abort(); | 558 | 0 | } | 559 | 2 | pthread_attr_destroy(&attr); | 560 | 2 | fuzz_r_thread.started = 1; | 561 | 2 | } | 562 | | | 563 | 12.1k | if (fuzz_on_r_thread()) { | 564 | 0 | fn(arg); | 565 | 0 | return; | 566 | 0 | } | 567 | | | 568 | 12.1k | fuzz_job_t job = { fn, arg }; | 569 | 12.1k | if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0) | 570 | 12.1k | atomic_fetch_add(&fuzz_alarm.input, 1); /* wrapped past 0, which is none */ | 571 | | | 572 | 12.1k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 573 | 12.1k | fuzz_r_thread.job = &job; | 574 | 12.1k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 575 | 24.3k | while (fuzz_r_thread.job != NULL) | 576 | 12.1k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 577 | 12.1k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 578 | | | 579 | | /* Idle again: ticks count, and libFuzzer's clock for the next input | 580 | | * starts after this. */ | 581 | 12.1k | atomic_store(&fuzz_alarm.finishing, 0); | 582 | | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed); | 583 | 12.1k | } |
zip.c:fuzz_run_on_r_thread Line | Count | Source | 540 | 2.34k | { | 541 | 2.34k | if (!fuzz_r_thread.started) { | 542 | 2 | static int atfork_registered = 0; | 543 | 2 | if (!atfork_registered) { | 544 | 2 | if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) { | 545 | 0 | fprintf(stderr, "fuzz: cannot register the fork handler\n"); | 546 | 0 | abort(); | 547 | 0 | } | 548 | 2 | atfork_registered = 1; | 549 | 2 | } | 550 | | | 551 | 2 | pthread_attr_t attr; | 552 | 2 | if (pthread_attr_init(&attr) != 0 || | 553 | 2 | pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 || | 554 | 2 | pthread_create(&fuzz_r_thread.thread, &attr, | 555 | 2 | fuzz_r_thread_main, NULL) != 0) { | 556 | 0 | fprintf(stderr, "fuzz: cannot start the R thread\n"); | 557 | 0 | abort(); | 558 | 0 | } | 559 | 2 | pthread_attr_destroy(&attr); | 560 | 2 | fuzz_r_thread.started = 1; | 561 | 2 | } | 562 | | | 563 | 2.34k | if (fuzz_on_r_thread()) { | 564 | 0 | fn(arg); | 565 | 0 | return; | 566 | 0 | } | 567 | | | 568 | 2.34k | fuzz_job_t job = { fn, arg }; | 569 | 2.34k | if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0) | 570 | 2.34k | atomic_fetch_add(&fuzz_alarm.input, 1); /* wrapped past 0, which is none */ | 571 | | | 572 | 2.34k | pthread_mutex_lock(&fuzz_r_thread.mutex); | 573 | 2.34k | fuzz_r_thread.job = &job; | 574 | 2.34k | pthread_cond_broadcast(&fuzz_r_thread.cond); | 575 | 4.69k | while (fuzz_r_thread.job != NULL) | 576 | 2.34k | pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex); | 577 | 2.34k | pthread_mutex_unlock(&fuzz_r_thread.mutex); | 578 | | | 579 | | /* Idle again: ticks count, and libFuzzer's clock for the next input | 580 | | * starts after this. */ | 581 | 2.34k | atomic_store(&fuzz_alarm.finishing, 0); | 582 | | clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed); | 583 | 2.34k | } |
|
584 | | |
585 | | /* |
586 | | * Initialize R for fuzzing. Call once from fuzz_target_init. |
587 | | * |
588 | | * Performs: |
589 | | * 1. Set R_HOME from binary location |
590 | | * 2. Cap the vector heap (must precede R's startup, which reads it) |
591 | | * 3. Initialize embedded R, without R's signal handlers |
592 | | * 4. Point R's C stack check at the R thread's stack |
593 | | * 5. Suppress warnings |
594 | | */ |
595 | | static void fuzz_init_r(void) |
596 | 39 | { |
597 | 39 | if (!fuzz_on_r_thread()) { |
598 | 0 | fprintf(stderr, "fuzz_init_r: must run on the R thread " |
599 | 0 | "(define fuzz_target_init, not LLVMFuzzerInitialize)\n"); |
600 | 0 | abort(); |
601 | 0 | } |
602 | | |
603 | 39 | fuzz_set_r_home(); |
604 | 39 | fuzz_set_vsize_limit(); |
605 | | |
606 | | /* GC consistency failures ("untraced old-to-new reference", a node |
607 | | * with a bad type) are memory corruption, not input errors. R's |
608 | | * default is to report and carry on; this makes gc_error() fatal |
609 | | * (through R_Suicide, which instrumentation/0004 turns into abort) |
610 | | * so they surface as crashes at the collection that found them. */ |
611 | 39 | if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL) |
612 | 20 | setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1); |
613 | | |
614 | | /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery |
615 | | * prompt instead of crashing, which would hang the fuzzer. Telling |
616 | | * R not to install them (rather than resetting to SIG_DFL after |
617 | | * init) keeps the sanitizers' own handlers in place, so wild-pointer |
618 | | * faults still get full ASAN reports and clean deduplication. */ |
619 | 39 | R_SignalHandlers = 0; |
620 | | |
621 | | /* The two halves of Rf_initEmbeddedR, with the C stack check fixed |
622 | | * up in between. On Linux Rf_initialize_R takes R_CStackStart from |
623 | | * __libc_stack_end, the main thread's stack, so from this thread |
624 | | * every R_CheckStack() while setup_Rmainloop loads base would see |
625 | | * terabytes of usage and R would abort ("unable to initialize the |
626 | | * JIT"). macOS never sets it when embedded, which hides this |
627 | | * locally. Switch the check off for startup, then measure against |
628 | | * this thread with R's own 5% of headroom for handling the overflow |
629 | | * error: R_CheckStack() fires as an ordinary R error at |
630 | | * 0.95 * FUZZ_R_STACK_SIZE rather than the sanitizer catching a fault. |
631 | | * setup_Rmainloop itself would turn any limit above 100 MB into |
632 | | * "unlimited", hence setting it after. */ |
633 | 39 | char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"}; |
634 | 39 | int r_argc = sizeof(r_argv) / sizeof(r_argv[0]); |
635 | 39 | Rf_initialize_R(r_argc, r_argv); |
636 | 39 | R_CStackStart = fuzz_r_thread.stack_top; |
637 | 39 | R_CStackLimit = (uintptr_t)-1; |
638 | 39 | R_Interactive = TRUE; /* as Rf_initEmbeddedR */ |
639 | 39 | setup_Rmainloop(); |
640 | 39 | R_CStackLimit = (uintptr_t)(0.95 * FUZZ_R_STACK_SIZE); |
641 | | |
642 | 39 | fuzz_suppress_warnings(); |
643 | 39 | } Line | Count | Source | 596 | 2 | { | 597 | 2 | if (!fuzz_on_r_thread()) { | 598 | 0 | fprintf(stderr, "fuzz_init_r: must run on the R thread " | 599 | 0 | "(define fuzz_target_init, not LLVMFuzzerInitialize)\n"); | 600 | 0 | abort(); | 601 | 0 | } | 602 | | | 603 | 2 | fuzz_set_r_home(); | 604 | 2 | fuzz_set_vsize_limit(); | 605 | | | 606 | | /* GC consistency failures ("untraced old-to-new reference", a node | 607 | | * with a bad type) are memory corruption, not input errors. R's | 608 | | * default is to report and carry on; this makes gc_error() fatal | 609 | | * (through R_Suicide, which instrumentation/0004 turns into abort) | 610 | | * so they surface as crashes at the collection that found them. */ | 611 | 2 | if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL) | 612 | 1 | setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1); | 613 | | | 614 | | /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery | 615 | | * prompt instead of crashing, which would hang the fuzzer. Telling | 616 | | * R not to install them (rather than resetting to SIG_DFL after | 617 | | * init) keeps the sanitizers' own handlers in place, so wild-pointer | 618 | | * faults still get full ASAN reports and clean deduplication. */ | 619 | 2 | R_SignalHandlers = 0; | 620 | | | 621 | | /* The two halves of Rf_initEmbeddedR, with the C stack check fixed | 622 | | * up in between. On Linux Rf_initialize_R takes R_CStackStart from | 623 | | * __libc_stack_end, the main thread's stack, so from this thread | 624 | | * every R_CheckStack() while setup_Rmainloop loads base would see | 625 | | * terabytes of usage and R would abort ("unable to initialize the | 626 | | * JIT"). macOS never sets it when embedded, which hides this | 627 | | * locally. Switch the check off for startup, then measure against | 628 | | * this thread with R's own 5% of headroom for handling the overflow | 629 | | * error: R_CheckStack() fires as an ordinary R error at | 630 | | * 0.95 * FUZZ_R_STACK_SIZE rather than the sanitizer catching a fault. | 631 | | * setup_Rmainloop itself would turn any limit above 100 MB into | 632 | | * "unlimited", hence setting it after. */ | 633 | 2 | char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"}; | 634 | 2 | int r_argc = sizeof(r_argv) / sizeof(r_argv[0]); | 635 | 2 | Rf_initialize_R(r_argc, r_argv); | 636 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 637 | 2 | R_CStackLimit = (uintptr_t)-1; | 638 | 2 | R_Interactive = TRUE; /* as Rf_initEmbeddedR */ | 639 | 2 | setup_Rmainloop(); | 640 | 2 | R_CStackLimit = (uintptr_t)(0.95 * FUZZ_R_STACK_SIZE); | 641 | | | 642 | 2 | fuzz_suppress_warnings(); | 643 | 2 | } |
Line | Count | Source | 596 | 2 | { | 597 | 2 | if (!fuzz_on_r_thread()) { | 598 | 0 | fprintf(stderr, "fuzz_init_r: must run on the R thread " | 599 | 0 | "(define fuzz_target_init, not LLVMFuzzerInitialize)\n"); | 600 | 0 | abort(); | 601 | 0 | } | 602 | | | 603 | 2 | fuzz_set_r_home(); | 604 | 2 | fuzz_set_vsize_limit(); | 605 | | | 606 | | /* GC consistency failures ("untraced old-to-new reference", a node | 607 | | * with a bad type) are memory corruption, not input errors. R's | 608 | | * default is to report and carry on; this makes gc_error() fatal | 609 | | * (through R_Suicide, which instrumentation/0004 turns into abort) | 610 | | * so they surface as crashes at the collection that found them. */ | 611 | 2 | if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL) | 612 | 1 | setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1); | 613 | | | 614 | | /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery | 615 | | * prompt instead of crashing, which would hang the fuzzer. Telling | 616 | | * R not to install them (rather than resetting to SIG_DFL after | 617 | | * init) keeps the sanitizers' own handlers in place, so wild-pointer | 618 | | * faults still get full ASAN reports and clean deduplication. */ | 619 | 2 | R_SignalHandlers = 0; | 620 | | | 621 | | /* The two halves of Rf_initEmbeddedR, with the C stack check fixed | 622 | | * up in between. On Linux Rf_initialize_R takes R_CStackStart from | 623 | | * __libc_stack_end, the main thread's stack, so from this thread | 624 | | * every R_CheckStack() while setup_Rmainloop loads base would see | 625 | | * terabytes of usage and R would abort ("unable to initialize the | 626 | | * JIT"). macOS never sets it when embedded, which hides this | 627 | | * locally. Switch the check off for startup, then measure against | 628 | | * this thread with R's own 5% of headroom for handling the overflow | 629 | | * error: R_CheckStack() fires as an ordinary R error at | 630 | | * 0.95 * FUZZ_R_STACK_SIZE rather than the sanitizer catching a fault. | 631 | | * setup_Rmainloop itself would turn any limit above 100 MB into | 632 | | * "unlimited", hence setting it after. */ | 633 | 2 | char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"}; | 634 | 2 | int r_argc = sizeof(r_argv) / sizeof(r_argv[0]); | 635 | 2 | Rf_initialize_R(r_argc, r_argv); | 636 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 637 | 2 | R_CStackLimit = (uintptr_t)-1; | 638 | 2 | R_Interactive = TRUE; /* as Rf_initEmbeddedR */ | 639 | 2 | setup_Rmainloop(); | 640 | 2 | R_CStackLimit = (uintptr_t)(0.95 * FUZZ_R_STACK_SIZE); | 641 | | | 642 | 2 | fuzz_suppress_warnings(); | 643 | 2 | } |
Line | Count | Source | 596 | 2 | { | 597 | 2 | if (!fuzz_on_r_thread()) { | 598 | 0 | fprintf(stderr, "fuzz_init_r: must run on the R thread " | 599 | 0 | "(define fuzz_target_init, not LLVMFuzzerInitialize)\n"); | 600 | 0 | abort(); | 601 | 0 | } | 602 | | | 603 | 2 | fuzz_set_r_home(); | 604 | 2 | fuzz_set_vsize_limit(); | 605 | | | 606 | | /* GC consistency failures ("untraced old-to-new reference", a node | 607 | | * with a bad type) are memory corruption, not input errors. R's | 608 | | * default is to report and carry on; this makes gc_error() fatal | 609 | | * (through R_Suicide, which instrumentation/0004 turns into abort) | 610 | | * so they surface as crashes at the collection that found them. */ | 611 | 2 | if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL) | 612 | 1 | setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1); | 613 | | | 614 | | /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery | 615 | | * prompt instead of crashing, which would hang the fuzzer. Telling | 616 | | * R not to install them (rather than resetting to SIG_DFL after | 617 | | * init) keeps the sanitizers' own handlers in place, so wild-pointer | 618 | | * faults still get full ASAN reports and clean deduplication. */ | 619 | 2 | R_SignalHandlers = 0; | 620 | | | 621 | | /* The two halves of Rf_initEmbeddedR, with the C stack check fixed | 622 | | * up in between. On Linux Rf_initialize_R takes R_CStackStart from | 623 | | * __libc_stack_end, the main thread's stack, so from this thread | 624 | | * every R_CheckStack() while setup_Rmainloop loads base would see | 625 | | * terabytes of usage and R would abort ("unable to initialize the | 626 | | * JIT"). macOS never sets it when embedded, which hides this | 627 | | * locally. Switch the check off for startup, then measure against | 628 | | * this thread with R's own 5% of headroom for handling the overflow | 629 | | * error: R_CheckStack() fires as an ordinary R error at | 630 | | * 0.95 * FUZZ_R_STACK_SIZE rather than the sanitizer catching a fault. | 631 | | * setup_Rmainloop itself would turn any limit above 100 MB into | 632 | | * "unlimited", hence setting it after. */ | 633 | 2 | char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"}; | 634 | 2 | int r_argc = sizeof(r_argv) / sizeof(r_argv[0]); | 635 | 2 | Rf_initialize_R(r_argc, r_argv); | 636 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 637 | 2 | R_CStackLimit = (uintptr_t)-1; | 638 | 2 | R_Interactive = TRUE; /* as Rf_initEmbeddedR */ | 639 | 2 | setup_Rmainloop(); | 640 | 2 | R_CStackLimit = (uintptr_t)(0.95 * FUZZ_R_STACK_SIZE); | 641 | | | 642 | 2 | fuzz_suppress_warnings(); | 643 | 2 | } |
Line | Count | Source | 596 | 2 | { | 597 | 2 | if (!fuzz_on_r_thread()) { | 598 | 0 | fprintf(stderr, "fuzz_init_r: must run on the R thread " | 599 | 0 | "(define fuzz_target_init, not LLVMFuzzerInitialize)\n"); | 600 | 0 | abort(); | 601 | 0 | } | 602 | | | 603 | 2 | fuzz_set_r_home(); | 604 | 2 | fuzz_set_vsize_limit(); | 605 | | | 606 | | /* GC consistency failures ("untraced old-to-new reference", a node | 607 | | * with a bad type) are memory corruption, not input errors. R's | 608 | | * default is to report and carry on; this makes gc_error() fatal | 609 | | * (through R_Suicide, which instrumentation/0004 turns into abort) | 610 | | * so they surface as crashes at the collection that found them. */ | 611 | 2 | if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL) | 612 | 1 | setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1); | 613 | | | 614 | | /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery | 615 | | * prompt instead of crashing, which would hang the fuzzer. Telling | 616 | | * R not to install them (rather than resetting to SIG_DFL after | 617 | | * init) keeps the sanitizers' own handlers in place, so wild-pointer | 618 | | * faults still get full ASAN reports and clean deduplication. */ | 619 | 2 | R_SignalHandlers = 0; | 620 | | | 621 | | /* The two halves of Rf_initEmbeddedR, with the C stack check fixed | 622 | | * up in between. On Linux Rf_initialize_R takes R_CStackStart from | 623 | | * __libc_stack_end, the main thread's stack, so from this thread | 624 | | * every R_CheckStack() while setup_Rmainloop loads base would see | 625 | | * terabytes of usage and R would abort ("unable to initialize the | 626 | | * JIT"). macOS never sets it when embedded, which hides this | 627 | | * locally. Switch the check off for startup, then measure against | 628 | | * this thread with R's own 5% of headroom for handling the overflow | 629 | | * error: R_CheckStack() fires as an ordinary R error at | 630 | | * 0.95 * FUZZ_R_STACK_SIZE rather than the sanitizer catching a fault. | 631 | | * setup_Rmainloop itself would turn any limit above 100 MB into | 632 | | * "unlimited", hence setting it after. */ | 633 | 2 | char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"}; | 634 | 2 | int r_argc = sizeof(r_argv) / sizeof(r_argv[0]); | 635 | 2 | Rf_initialize_R(r_argc, r_argv); | 636 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 637 | 2 | R_CStackLimit = (uintptr_t)-1; | 638 | 2 | R_Interactive = TRUE; /* as Rf_initEmbeddedR */ | 639 | 2 | setup_Rmainloop(); | 640 | 2 | R_CStackLimit = (uintptr_t)(0.95 * FUZZ_R_STACK_SIZE); | 641 | | | 642 | 2 | fuzz_suppress_warnings(); | 643 | 2 | } |
Line | Count | Source | 596 | 2 | { | 597 | 2 | if (!fuzz_on_r_thread()) { | 598 | 0 | fprintf(stderr, "fuzz_init_r: must run on the R thread " | 599 | 0 | "(define fuzz_target_init, not LLVMFuzzerInitialize)\n"); | 600 | 0 | abort(); | 601 | 0 | } | 602 | | | 603 | 2 | fuzz_set_r_home(); | 604 | 2 | fuzz_set_vsize_limit(); | 605 | | | 606 | | /* GC consistency failures ("untraced old-to-new reference", a node | 607 | | * with a bad type) are memory corruption, not input errors. R's | 608 | | * default is to report and carry on; this makes gc_error() fatal | 609 | | * (through R_Suicide, which instrumentation/0004 turns into abort) | 610 | | * so they surface as crashes at the collection that found them. */ | 611 | 2 | if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL) | 612 | 1 | setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1); | 613 | | | 614 | | /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery | 615 | | * prompt instead of crashing, which would hang the fuzzer. Telling | 616 | | * R not to install them (rather than resetting to SIG_DFL after | 617 | | * init) keeps the sanitizers' own handlers in place, so wild-pointer | 618 | | * faults still get full ASAN reports and clean deduplication. */ | 619 | 2 | R_SignalHandlers = 0; | 620 | | | 621 | | /* The two halves of Rf_initEmbeddedR, with the C stack check fixed | 622 | | * up in between. On Linux Rf_initialize_R takes R_CStackStart from | 623 | | * __libc_stack_end, the main thread's stack, so from this thread | 624 | | * every R_CheckStack() while setup_Rmainloop loads base would see | 625 | | * terabytes of usage and R would abort ("unable to initialize the | 626 | | * JIT"). macOS never sets it when embedded, which hides this | 627 | | * locally. Switch the check off for startup, then measure against | 628 | | * this thread with R's own 5% of headroom for handling the overflow | 629 | | * error: R_CheckStack() fires as an ordinary R error at | 630 | | * 0.95 * FUZZ_R_STACK_SIZE rather than the sanitizer catching a fault. | 631 | | * setup_Rmainloop itself would turn any limit above 100 MB into | 632 | | * "unlimited", hence setting it after. */ | 633 | 2 | char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"}; | 634 | 2 | int r_argc = sizeof(r_argv) / sizeof(r_argv[0]); | 635 | 2 | Rf_initialize_R(r_argc, r_argv); | 636 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 637 | 2 | R_CStackLimit = (uintptr_t)-1; | 638 | 2 | R_Interactive = TRUE; /* as Rf_initEmbeddedR */ | 639 | 2 | setup_Rmainloop(); | 640 | 2 | R_CStackLimit = (uintptr_t)(0.95 * FUZZ_R_STACK_SIZE); | 641 | | | 642 | 2 | fuzz_suppress_warnings(); | 643 | 2 | } |
connections.c:fuzz_init_r Line | Count | Source | 596 | 2 | { | 597 | 2 | if (!fuzz_on_r_thread()) { | 598 | 0 | fprintf(stderr, "fuzz_init_r: must run on the R thread " | 599 | 0 | "(define fuzz_target_init, not LLVMFuzzerInitialize)\n"); | 600 | 0 | abort(); | 601 | 0 | } | 602 | | | 603 | 2 | fuzz_set_r_home(); | 604 | 2 | fuzz_set_vsize_limit(); | 605 | | | 606 | | /* GC consistency failures ("untraced old-to-new reference", a node | 607 | | * with a bad type) are memory corruption, not input errors. R's | 608 | | * default is to report and carry on; this makes gc_error() fatal | 609 | | * (through R_Suicide, which instrumentation/0004 turns into abort) | 610 | | * so they surface as crashes at the collection that found them. */ | 611 | 2 | if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL) | 612 | 1 | setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1); | 613 | | | 614 | | /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery | 615 | | * prompt instead of crashing, which would hang the fuzzer. Telling | 616 | | * R not to install them (rather than resetting to SIG_DFL after | 617 | | * init) keeps the sanitizers' own handlers in place, so wild-pointer | 618 | | * faults still get full ASAN reports and clean deduplication. */ | 619 | 2 | R_SignalHandlers = 0; | 620 | | | 621 | | /* The two halves of Rf_initEmbeddedR, with the C stack check fixed | 622 | | * up in between. On Linux Rf_initialize_R takes R_CStackStart from | 623 | | * __libc_stack_end, the main thread's stack, so from this thread | 624 | | * every R_CheckStack() while setup_Rmainloop loads base would see | 625 | | * terabytes of usage and R would abort ("unable to initialize the | 626 | | * JIT"). macOS never sets it when embedded, which hides this | 627 | | * locally. Switch the check off for startup, then measure against | 628 | | * this thread with R's own 5% of headroom for handling the overflow | 629 | | * error: R_CheckStack() fires as an ordinary R error at | 630 | | * 0.95 * FUZZ_R_STACK_SIZE rather than the sanitizer catching a fault. | 631 | | * setup_Rmainloop itself would turn any limit above 100 MB into | 632 | | * "unlimited", hence setting it after. */ | 633 | 2 | char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"}; | 634 | 2 | int r_argc = sizeof(r_argv) / sizeof(r_argv[0]); | 635 | 2 | Rf_initialize_R(r_argc, r_argv); | 636 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 637 | 2 | R_CStackLimit = (uintptr_t)-1; | 638 | 2 | R_Interactive = TRUE; /* as Rf_initEmbeddedR */ | 639 | 2 | setup_Rmainloop(); | 640 | 2 | R_CStackLimit = (uintptr_t)(0.95 * FUZZ_R_STACK_SIZE); | 641 | | | 642 | 2 | fuzz_suppress_warnings(); | 643 | 2 | } |
unserialize.c:fuzz_init_r Line | Count | Source | 596 | 2 | { | 597 | 2 | if (!fuzz_on_r_thread()) { | 598 | 0 | fprintf(stderr, "fuzz_init_r: must run on the R thread " | 599 | 0 | "(define fuzz_target_init, not LLVMFuzzerInitialize)\n"); | 600 | 0 | abort(); | 601 | 0 | } | 602 | | | 603 | 2 | fuzz_set_r_home(); | 604 | 2 | fuzz_set_vsize_limit(); | 605 | | | 606 | | /* GC consistency failures ("untraced old-to-new reference", a node | 607 | | * with a bad type) are memory corruption, not input errors. R's | 608 | | * default is to report and carry on; this makes gc_error() fatal | 609 | | * (through R_Suicide, which instrumentation/0004 turns into abort) | 610 | | * so they surface as crashes at the collection that found them. */ | 611 | 2 | if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL) | 612 | 1 | setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1); | 613 | | | 614 | | /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery | 615 | | * prompt instead of crashing, which would hang the fuzzer. Telling | 616 | | * R not to install them (rather than resetting to SIG_DFL after | 617 | | * init) keeps the sanitizers' own handlers in place, so wild-pointer | 618 | | * faults still get full ASAN reports and clean deduplication. */ | 619 | 2 | R_SignalHandlers = 0; | 620 | | | 621 | | /* The two halves of Rf_initEmbeddedR, with the C stack check fixed | 622 | | * up in between. On Linux Rf_initialize_R takes R_CStackStart from | 623 | | * __libc_stack_end, the main thread's stack, so from this thread | 624 | | * every R_CheckStack() while setup_Rmainloop loads base would see | 625 | | * terabytes of usage and R would abort ("unable to initialize the | 626 | | * JIT"). macOS never sets it when embedded, which hides this | 627 | | * locally. Switch the check off for startup, then measure against | 628 | | * this thread with R's own 5% of headroom for handling the overflow | 629 | | * error: R_CheckStack() fires as an ordinary R error at | 630 | | * 0.95 * FUZZ_R_STACK_SIZE rather than the sanitizer catching a fault. | 631 | | * setup_Rmainloop itself would turn any limit above 100 MB into | 632 | | * "unlimited", hence setting it after. */ | 633 | 2 | char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"}; | 634 | 2 | int r_argc = sizeof(r_argv) / sizeof(r_argv[0]); | 635 | 2 | Rf_initialize_R(r_argc, r_argv); | 636 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 637 | 2 | R_CStackLimit = (uintptr_t)-1; | 638 | 2 | R_Interactive = TRUE; /* as Rf_initEmbeddedR */ | 639 | 2 | setup_Rmainloop(); | 640 | 2 | R_CStackLimit = (uintptr_t)(0.95 * FUZZ_R_STACK_SIZE); | 641 | | | 642 | 2 | fuzz_suppress_warnings(); | 643 | 2 | } |
Line | Count | Source | 596 | 2 | { | 597 | 2 | if (!fuzz_on_r_thread()) { | 598 | 0 | fprintf(stderr, "fuzz_init_r: must run on the R thread " | 599 | 0 | "(define fuzz_target_init, not LLVMFuzzerInitialize)\n"); | 600 | 0 | abort(); | 601 | 0 | } | 602 | | | 603 | 2 | fuzz_set_r_home(); | 604 | 2 | fuzz_set_vsize_limit(); | 605 | | | 606 | | /* GC consistency failures ("untraced old-to-new reference", a node | 607 | | * with a bad type) are memory corruption, not input errors. R's | 608 | | * default is to report and carry on; this makes gc_error() fatal | 609 | | * (through R_Suicide, which instrumentation/0004 turns into abort) | 610 | | * so they surface as crashes at the collection that found them. */ | 611 | 2 | if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL) | 612 | 1 | setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1); | 613 | | | 614 | | /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery | 615 | | * prompt instead of crashing, which would hang the fuzzer. Telling | 616 | | * R not to install them (rather than resetting to SIG_DFL after | 617 | | * init) keeps the sanitizers' own handlers in place, so wild-pointer | 618 | | * faults still get full ASAN reports and clean deduplication. */ | 619 | 2 | R_SignalHandlers = 0; | 620 | | | 621 | | /* The two halves of Rf_initEmbeddedR, with the C stack check fixed | 622 | | * up in between. On Linux Rf_initialize_R takes R_CStackStart from | 623 | | * __libc_stack_end, the main thread's stack, so from this thread | 624 | | * every R_CheckStack() while setup_Rmainloop loads base would see | 625 | | * terabytes of usage and R would abort ("unable to initialize the | 626 | | * JIT"). macOS never sets it when embedded, which hides this | 627 | | * locally. Switch the check off for startup, then measure against | 628 | | * this thread with R's own 5% of headroom for handling the overflow | 629 | | * error: R_CheckStack() fires as an ordinary R error at | 630 | | * 0.95 * FUZZ_R_STACK_SIZE rather than the sanitizer catching a fault. | 631 | | * setup_Rmainloop itself would turn any limit above 100 MB into | 632 | | * "unlimited", hence setting it after. */ | 633 | 2 | char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"}; | 634 | 2 | int r_argc = sizeof(r_argv) / sizeof(r_argv[0]); | 635 | 2 | Rf_initialize_R(r_argc, r_argv); | 636 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 637 | 2 | R_CStackLimit = (uintptr_t)-1; | 638 | 2 | R_Interactive = TRUE; /* as Rf_initEmbeddedR */ | 639 | 2 | setup_Rmainloop(); | 640 | 2 | R_CStackLimit = (uintptr_t)(0.95 * FUZZ_R_STACK_SIZE); | 641 | | | 642 | 2 | fuzz_suppress_warnings(); | 643 | 2 | } |
Line | Count | Source | 596 | 2 | { | 597 | 2 | if (!fuzz_on_r_thread()) { | 598 | 0 | fprintf(stderr, "fuzz_init_r: must run on the R thread " | 599 | 0 | "(define fuzz_target_init, not LLVMFuzzerInitialize)\n"); | 600 | 0 | abort(); | 601 | 0 | } | 602 | | | 603 | 2 | fuzz_set_r_home(); | 604 | 2 | fuzz_set_vsize_limit(); | 605 | | | 606 | | /* GC consistency failures ("untraced old-to-new reference", a node | 607 | | * with a bad type) are memory corruption, not input errors. R's | 608 | | * default is to report and carry on; this makes gc_error() fatal | 609 | | * (through R_Suicide, which instrumentation/0004 turns into abort) | 610 | | * so they surface as crashes at the collection that found them. */ | 611 | 2 | if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL) | 612 | 1 | setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1); | 613 | | | 614 | | /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery | 615 | | * prompt instead of crashing, which would hang the fuzzer. Telling | 616 | | * R not to install them (rather than resetting to SIG_DFL after | 617 | | * init) keeps the sanitizers' own handlers in place, so wild-pointer | 618 | | * faults still get full ASAN reports and clean deduplication. */ | 619 | 2 | R_SignalHandlers = 0; | 620 | | | 621 | | /* The two halves of Rf_initEmbeddedR, with the C stack check fixed | 622 | | * up in between. On Linux Rf_initialize_R takes R_CStackStart from | 623 | | * __libc_stack_end, the main thread's stack, so from this thread | 624 | | * every R_CheckStack() while setup_Rmainloop loads base would see | 625 | | * terabytes of usage and R would abort ("unable to initialize the | 626 | | * JIT"). macOS never sets it when embedded, which hides this | 627 | | * locally. Switch the check off for startup, then measure against | 628 | | * this thread with R's own 5% of headroom for handling the overflow | 629 | | * error: R_CheckStack() fires as an ordinary R error at | 630 | | * 0.95 * FUZZ_R_STACK_SIZE rather than the sanitizer catching a fault. | 631 | | * setup_Rmainloop itself would turn any limit above 100 MB into | 632 | | * "unlimited", hence setting it after. */ | 633 | 2 | char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"}; | 634 | 2 | int r_argc = sizeof(r_argv) / sizeof(r_argv[0]); | 635 | 2 | Rf_initialize_R(r_argc, r_argv); | 636 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 637 | 2 | R_CStackLimit = (uintptr_t)-1; | 638 | 2 | R_Interactive = TRUE; /* as Rf_initEmbeddedR */ | 639 | 2 | setup_Rmainloop(); | 640 | 2 | R_CStackLimit = (uintptr_t)(0.95 * FUZZ_R_STACK_SIZE); | 641 | | | 642 | 2 | fuzz_suppress_warnings(); | 643 | 2 | } |
Line | Count | Source | 596 | 2 | { | 597 | 2 | if (!fuzz_on_r_thread()) { | 598 | 0 | fprintf(stderr, "fuzz_init_r: must run on the R thread " | 599 | 0 | "(define fuzz_target_init, not LLVMFuzzerInitialize)\n"); | 600 | 0 | abort(); | 601 | 0 | } | 602 | | | 603 | 2 | fuzz_set_r_home(); | 604 | 2 | fuzz_set_vsize_limit(); | 605 | | | 606 | | /* GC consistency failures ("untraced old-to-new reference", a node | 607 | | * with a bad type) are memory corruption, not input errors. R's | 608 | | * default is to report and carry on; this makes gc_error() fatal | 609 | | * (through R_Suicide, which instrumentation/0004 turns into abort) | 610 | | * so they surface as crashes at the collection that found them. */ | 611 | 2 | if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL) | 612 | 1 | setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1); | 613 | | | 614 | | /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery | 615 | | * prompt instead of crashing, which would hang the fuzzer. Telling | 616 | | * R not to install them (rather than resetting to SIG_DFL after | 617 | | * init) keeps the sanitizers' own handlers in place, so wild-pointer | 618 | | * faults still get full ASAN reports and clean deduplication. */ | 619 | 2 | R_SignalHandlers = 0; | 620 | | | 621 | | /* The two halves of Rf_initEmbeddedR, with the C stack check fixed | 622 | | * up in between. On Linux Rf_initialize_R takes R_CStackStart from | 623 | | * __libc_stack_end, the main thread's stack, so from this thread | 624 | | * every R_CheckStack() while setup_Rmainloop loads base would see | 625 | | * terabytes of usage and R would abort ("unable to initialize the | 626 | | * JIT"). macOS never sets it when embedded, which hides this | 627 | | * locally. Switch the check off for startup, then measure against | 628 | | * this thread with R's own 5% of headroom for handling the overflow | 629 | | * error: R_CheckStack() fires as an ordinary R error at | 630 | | * 0.95 * FUZZ_R_STACK_SIZE rather than the sanitizer catching a fault. | 631 | | * setup_Rmainloop itself would turn any limit above 100 MB into | 632 | | * "unlimited", hence setting it after. */ | 633 | 2 | char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"}; | 634 | 2 | int r_argc = sizeof(r_argv) / sizeof(r_argv[0]); | 635 | 2 | Rf_initialize_R(r_argc, r_argv); | 636 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 637 | 2 | R_CStackLimit = (uintptr_t)-1; | 638 | 2 | R_Interactive = TRUE; /* as Rf_initEmbeddedR */ | 639 | 2 | setup_Rmainloop(); | 640 | 2 | R_CStackLimit = (uintptr_t)(0.95 * FUZZ_R_STACK_SIZE); | 641 | | | 642 | 2 | fuzz_suppress_warnings(); | 643 | 2 | } |
Line | Count | Source | 596 | 2 | { | 597 | 2 | if (!fuzz_on_r_thread()) { | 598 | 0 | fprintf(stderr, "fuzz_init_r: must run on the R thread " | 599 | 0 | "(define fuzz_target_init, not LLVMFuzzerInitialize)\n"); | 600 | 0 | abort(); | 601 | 0 | } | 602 | | | 603 | 2 | fuzz_set_r_home(); | 604 | 2 | fuzz_set_vsize_limit(); | 605 | | | 606 | | /* GC consistency failures ("untraced old-to-new reference", a node | 607 | | * with a bad type) are memory corruption, not input errors. R's | 608 | | * default is to report and carry on; this makes gc_error() fatal | 609 | | * (through R_Suicide, which instrumentation/0004 turns into abort) | 610 | | * so they surface as crashes at the collection that found them. */ | 611 | 2 | if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL) | 612 | 1 | setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1); | 613 | | | 614 | | /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery | 615 | | * prompt instead of crashing, which would hang the fuzzer. Telling | 616 | | * R not to install them (rather than resetting to SIG_DFL after | 617 | | * init) keeps the sanitizers' own handlers in place, so wild-pointer | 618 | | * faults still get full ASAN reports and clean deduplication. */ | 619 | 2 | R_SignalHandlers = 0; | 620 | | | 621 | | /* The two halves of Rf_initEmbeddedR, with the C stack check fixed | 622 | | * up in between. On Linux Rf_initialize_R takes R_CStackStart from | 623 | | * __libc_stack_end, the main thread's stack, so from this thread | 624 | | * every R_CheckStack() while setup_Rmainloop loads base would see | 625 | | * terabytes of usage and R would abort ("unable to initialize the | 626 | | * JIT"). macOS never sets it when embedded, which hides this | 627 | | * locally. Switch the check off for startup, then measure against | 628 | | * this thread with R's own 5% of headroom for handling the overflow | 629 | | * error: R_CheckStack() fires as an ordinary R error at | 630 | | * 0.95 * FUZZ_R_STACK_SIZE rather than the sanitizer catching a fault. | 631 | | * setup_Rmainloop itself would turn any limit above 100 MB into | 632 | | * "unlimited", hence setting it after. */ | 633 | 2 | char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"}; | 634 | 2 | int r_argc = sizeof(r_argv) / sizeof(r_argv[0]); | 635 | 2 | Rf_initialize_R(r_argc, r_argv); | 636 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 637 | 2 | R_CStackLimit = (uintptr_t)-1; | 638 | 2 | R_Interactive = TRUE; /* as Rf_initEmbeddedR */ | 639 | 2 | setup_Rmainloop(); | 640 | 2 | R_CStackLimit = (uintptr_t)(0.95 * FUZZ_R_STACK_SIZE); | 641 | | | 642 | 2 | fuzz_suppress_warnings(); | 643 | 2 | } |
Line | Count | Source | 596 | 2 | { | 597 | 2 | if (!fuzz_on_r_thread()) { | 598 | 0 | fprintf(stderr, "fuzz_init_r: must run on the R thread " | 599 | 0 | "(define fuzz_target_init, not LLVMFuzzerInitialize)\n"); | 600 | 0 | abort(); | 601 | 0 | } | 602 | | | 603 | 2 | fuzz_set_r_home(); | 604 | 2 | fuzz_set_vsize_limit(); | 605 | | | 606 | | /* GC consistency failures ("untraced old-to-new reference", a node | 607 | | * with a bad type) are memory corruption, not input errors. R's | 608 | | * default is to report and carry on; this makes gc_error() fatal | 609 | | * (through R_Suicide, which instrumentation/0004 turns into abort) | 610 | | * so they surface as crashes at the collection that found them. */ | 611 | 2 | if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL) | 612 | 1 | setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1); | 613 | | | 614 | | /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery | 615 | | * prompt instead of crashing, which would hang the fuzzer. Telling | 616 | | * R not to install them (rather than resetting to SIG_DFL after | 617 | | * init) keeps the sanitizers' own handlers in place, so wild-pointer | 618 | | * faults still get full ASAN reports and clean deduplication. */ | 619 | 2 | R_SignalHandlers = 0; | 620 | | | 621 | | /* The two halves of Rf_initEmbeddedR, with the C stack check fixed | 622 | | * up in between. On Linux Rf_initialize_R takes R_CStackStart from | 623 | | * __libc_stack_end, the main thread's stack, so from this thread | 624 | | * every R_CheckStack() while setup_Rmainloop loads base would see | 625 | | * terabytes of usage and R would abort ("unable to initialize the | 626 | | * JIT"). macOS never sets it when embedded, which hides this | 627 | | * locally. Switch the check off for startup, then measure against | 628 | | * this thread with R's own 5% of headroom for handling the overflow | 629 | | * error: R_CheckStack() fires as an ordinary R error at | 630 | | * 0.95 * FUZZ_R_STACK_SIZE rather than the sanitizer catching a fault. | 631 | | * setup_Rmainloop itself would turn any limit above 100 MB into | 632 | | * "unlimited", hence setting it after. */ | 633 | 2 | char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"}; | 634 | 2 | int r_argc = sizeof(r_argv) / sizeof(r_argv[0]); | 635 | 2 | Rf_initialize_R(r_argc, r_argv); | 636 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 637 | 2 | R_CStackLimit = (uintptr_t)-1; | 638 | 2 | R_Interactive = TRUE; /* as Rf_initEmbeddedR */ | 639 | 2 | setup_Rmainloop(); | 640 | 2 | R_CStackLimit = (uintptr_t)(0.95 * FUZZ_R_STACK_SIZE); | 641 | | | 642 | 2 | fuzz_suppress_warnings(); | 643 | 2 | } |
Line | Count | Source | 596 | 2 | { | 597 | 2 | if (!fuzz_on_r_thread()) { | 598 | 0 | fprintf(stderr, "fuzz_init_r: must run on the R thread " | 599 | 0 | "(define fuzz_target_init, not LLVMFuzzerInitialize)\n"); | 600 | 0 | abort(); | 601 | 0 | } | 602 | | | 603 | 2 | fuzz_set_r_home(); | 604 | 2 | fuzz_set_vsize_limit(); | 605 | | | 606 | | /* GC consistency failures ("untraced old-to-new reference", a node | 607 | | * with a bad type) are memory corruption, not input errors. R's | 608 | | * default is to report and carry on; this makes gc_error() fatal | 609 | | * (through R_Suicide, which instrumentation/0004 turns into abort) | 610 | | * so they surface as crashes at the collection that found them. */ | 611 | 2 | if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL) | 612 | 1 | setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1); | 613 | | | 614 | | /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery | 615 | | * prompt instead of crashing, which would hang the fuzzer. Telling | 616 | | * R not to install them (rather than resetting to SIG_DFL after | 617 | | * init) keeps the sanitizers' own handlers in place, so wild-pointer | 618 | | * faults still get full ASAN reports and clean deduplication. */ | 619 | 2 | R_SignalHandlers = 0; | 620 | | | 621 | | /* The two halves of Rf_initEmbeddedR, with the C stack check fixed | 622 | | * up in between. On Linux Rf_initialize_R takes R_CStackStart from | 623 | | * __libc_stack_end, the main thread's stack, so from this thread | 624 | | * every R_CheckStack() while setup_Rmainloop loads base would see | 625 | | * terabytes of usage and R would abort ("unable to initialize the | 626 | | * JIT"). macOS never sets it when embedded, which hides this | 627 | | * locally. Switch the check off for startup, then measure against | 628 | | * this thread with R's own 5% of headroom for handling the overflow | 629 | | * error: R_CheckStack() fires as an ordinary R error at | 630 | | * 0.95 * FUZZ_R_STACK_SIZE rather than the sanitizer catching a fault. | 631 | | * setup_Rmainloop itself would turn any limit above 100 MB into | 632 | | * "unlimited", hence setting it after. */ | 633 | 2 | char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"}; | 634 | 2 | int r_argc = sizeof(r_argv) / sizeof(r_argv[0]); | 635 | 2 | Rf_initialize_R(r_argc, r_argv); | 636 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 637 | 2 | R_CStackLimit = (uintptr_t)-1; | 638 | 2 | R_Interactive = TRUE; /* as Rf_initEmbeddedR */ | 639 | 2 | setup_Rmainloop(); | 640 | 2 | R_CStackLimit = (uintptr_t)(0.95 * FUZZ_R_STACK_SIZE); | 641 | | | 642 | 2 | fuzz_suppress_warnings(); | 643 | 2 | } |
Line | Count | Source | 596 | 2 | { | 597 | 2 | if (!fuzz_on_r_thread()) { | 598 | 0 | fprintf(stderr, "fuzz_init_r: must run on the R thread " | 599 | 0 | "(define fuzz_target_init, not LLVMFuzzerInitialize)\n"); | 600 | 0 | abort(); | 601 | 0 | } | 602 | | | 603 | 2 | fuzz_set_r_home(); | 604 | 2 | fuzz_set_vsize_limit(); | 605 | | | 606 | | /* GC consistency failures ("untraced old-to-new reference", a node | 607 | | * with a bad type) are memory corruption, not input errors. R's | 608 | | * default is to report and carry on; this makes gc_error() fatal | 609 | | * (through R_Suicide, which instrumentation/0004 turns into abort) | 610 | | * so they surface as crashes at the collection that found them. */ | 611 | 2 | if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL) | 612 | 1 | setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1); | 613 | | | 614 | | /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery | 615 | | * prompt instead of crashing, which would hang the fuzzer. Telling | 616 | | * R not to install them (rather than resetting to SIG_DFL after | 617 | | * init) keeps the sanitizers' own handlers in place, so wild-pointer | 618 | | * faults still get full ASAN reports and clean deduplication. */ | 619 | 2 | R_SignalHandlers = 0; | 620 | | | 621 | | /* The two halves of Rf_initEmbeddedR, with the C stack check fixed | 622 | | * up in between. On Linux Rf_initialize_R takes R_CStackStart from | 623 | | * __libc_stack_end, the main thread's stack, so from this thread | 624 | | * every R_CheckStack() while setup_Rmainloop loads base would see | 625 | | * terabytes of usage and R would abort ("unable to initialize the | 626 | | * JIT"). macOS never sets it when embedded, which hides this | 627 | | * locally. Switch the check off for startup, then measure against | 628 | | * this thread with R's own 5% of headroom for handling the overflow | 629 | | * error: R_CheckStack() fires as an ordinary R error at | 630 | | * 0.95 * FUZZ_R_STACK_SIZE rather than the sanitizer catching a fault. | 631 | | * setup_Rmainloop itself would turn any limit above 100 MB into | 632 | | * "unlimited", hence setting it after. */ | 633 | 2 | char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"}; | 634 | 2 | int r_argc = sizeof(r_argv) / sizeof(r_argv[0]); | 635 | 2 | Rf_initialize_R(r_argc, r_argv); | 636 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 637 | 2 | R_CStackLimit = (uintptr_t)-1; | 638 | 2 | R_Interactive = TRUE; /* as Rf_initEmbeddedR */ | 639 | 2 | setup_Rmainloop(); | 640 | 2 | R_CStackLimit = (uintptr_t)(0.95 * FUZZ_R_STACK_SIZE); | 641 | | | 642 | 2 | fuzz_suppress_warnings(); | 643 | 2 | } |
Line | Count | Source | 596 | 2 | { | 597 | 2 | if (!fuzz_on_r_thread()) { | 598 | 0 | fprintf(stderr, "fuzz_init_r: must run on the R thread " | 599 | 0 | "(define fuzz_target_init, not LLVMFuzzerInitialize)\n"); | 600 | 0 | abort(); | 601 | 0 | } | 602 | | | 603 | 2 | fuzz_set_r_home(); | 604 | 2 | fuzz_set_vsize_limit(); | 605 | | | 606 | | /* GC consistency failures ("untraced old-to-new reference", a node | 607 | | * with a bad type) are memory corruption, not input errors. R's | 608 | | * default is to report and carry on; this makes gc_error() fatal | 609 | | * (through R_Suicide, which instrumentation/0004 turns into abort) | 610 | | * so they surface as crashes at the collection that found them. */ | 611 | 2 | if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL) | 612 | 1 | setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1); | 613 | | | 614 | | /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery | 615 | | * prompt instead of crashing, which would hang the fuzzer. Telling | 616 | | * R not to install them (rather than resetting to SIG_DFL after | 617 | | * init) keeps the sanitizers' own handlers in place, so wild-pointer | 618 | | * faults still get full ASAN reports and clean deduplication. */ | 619 | 2 | R_SignalHandlers = 0; | 620 | | | 621 | | /* The two halves of Rf_initEmbeddedR, with the C stack check fixed | 622 | | * up in between. On Linux Rf_initialize_R takes R_CStackStart from | 623 | | * __libc_stack_end, the main thread's stack, so from this thread | 624 | | * every R_CheckStack() while setup_Rmainloop loads base would see | 625 | | * terabytes of usage and R would abort ("unable to initialize the | 626 | | * JIT"). macOS never sets it when embedded, which hides this | 627 | | * locally. Switch the check off for startup, then measure against | 628 | | * this thread with R's own 5% of headroom for handling the overflow | 629 | | * error: R_CheckStack() fires as an ordinary R error at | 630 | | * 0.95 * FUZZ_R_STACK_SIZE rather than the sanitizer catching a fault. | 631 | | * setup_Rmainloop itself would turn any limit above 100 MB into | 632 | | * "unlimited", hence setting it after. */ | 633 | 2 | char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"}; | 634 | 2 | int r_argc = sizeof(r_argv) / sizeof(r_argv[0]); | 635 | 2 | Rf_initialize_R(r_argc, r_argv); | 636 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 637 | 2 | R_CStackLimit = (uintptr_t)-1; | 638 | 2 | R_Interactive = TRUE; /* as Rf_initEmbeddedR */ | 639 | 2 | setup_Rmainloop(); | 640 | 2 | R_CStackLimit = (uintptr_t)(0.95 * FUZZ_R_STACK_SIZE); | 641 | | | 642 | 2 | fuzz_suppress_warnings(); | 643 | 2 | } |
Line | Count | Source | 596 | 2 | { | 597 | 2 | if (!fuzz_on_r_thread()) { | 598 | 0 | fprintf(stderr, "fuzz_init_r: must run on the R thread " | 599 | 0 | "(define fuzz_target_init, not LLVMFuzzerInitialize)\n"); | 600 | 0 | abort(); | 601 | 0 | } | 602 | | | 603 | 2 | fuzz_set_r_home(); | 604 | 2 | fuzz_set_vsize_limit(); | 605 | | | 606 | | /* GC consistency failures ("untraced old-to-new reference", a node | 607 | | * with a bad type) are memory corruption, not input errors. R's | 608 | | * default is to report and carry on; this makes gc_error() fatal | 609 | | * (through R_Suicide, which instrumentation/0004 turns into abort) | 610 | | * so they surface as crashes at the collection that found them. */ | 611 | 2 | if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL) | 612 | 1 | setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1); | 613 | | | 614 | | /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery | 615 | | * prompt instead of crashing, which would hang the fuzzer. Telling | 616 | | * R not to install them (rather than resetting to SIG_DFL after | 617 | | * init) keeps the sanitizers' own handlers in place, so wild-pointer | 618 | | * faults still get full ASAN reports and clean deduplication. */ | 619 | 2 | R_SignalHandlers = 0; | 620 | | | 621 | | /* The two halves of Rf_initEmbeddedR, with the C stack check fixed | 622 | | * up in between. On Linux Rf_initialize_R takes R_CStackStart from | 623 | | * __libc_stack_end, the main thread's stack, so from this thread | 624 | | * every R_CheckStack() while setup_Rmainloop loads base would see | 625 | | * terabytes of usage and R would abort ("unable to initialize the | 626 | | * JIT"). macOS never sets it when embedded, which hides this | 627 | | * locally. Switch the check off for startup, then measure against | 628 | | * this thread with R's own 5% of headroom for handling the overflow | 629 | | * error: R_CheckStack() fires as an ordinary R error at | 630 | | * 0.95 * FUZZ_R_STACK_SIZE rather than the sanitizer catching a fault. | 631 | | * setup_Rmainloop itself would turn any limit above 100 MB into | 632 | | * "unlimited", hence setting it after. */ | 633 | 2 | char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"}; | 634 | 2 | int r_argc = sizeof(r_argv) / sizeof(r_argv[0]); | 635 | 2 | Rf_initialize_R(r_argc, r_argv); | 636 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 637 | 2 | R_CStackLimit = (uintptr_t)-1; | 638 | 2 | R_Interactive = TRUE; /* as Rf_initEmbeddedR */ | 639 | 2 | setup_Rmainloop(); | 640 | 2 | R_CStackLimit = (uintptr_t)(0.95 * FUZZ_R_STACK_SIZE); | 641 | | | 642 | 2 | fuzz_suppress_warnings(); | 643 | 2 | } |
Line | Count | Source | 596 | 1 | { | 597 | 1 | if (!fuzz_on_r_thread()) { | 598 | 0 | fprintf(stderr, "fuzz_init_r: must run on the R thread " | 599 | 0 | "(define fuzz_target_init, not LLVMFuzzerInitialize)\n"); | 600 | 0 | abort(); | 601 | 0 | } | 602 | | | 603 | 1 | fuzz_set_r_home(); | 604 | 1 | fuzz_set_vsize_limit(); | 605 | | | 606 | | /* GC consistency failures ("untraced old-to-new reference", a node | 607 | | * with a bad type) are memory corruption, not input errors. R's | 608 | | * default is to report and carry on; this makes gc_error() fatal | 609 | | * (through R_Suicide, which instrumentation/0004 turns into abort) | 610 | | * so they surface as crashes at the collection that found them. */ | 611 | 1 | if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL) | 612 | 1 | setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1); | 613 | | | 614 | | /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery | 615 | | * prompt instead of crashing, which would hang the fuzzer. Telling | 616 | | * R not to install them (rather than resetting to SIG_DFL after | 617 | | * init) keeps the sanitizers' own handlers in place, so wild-pointer | 618 | | * faults still get full ASAN reports and clean deduplication. */ | 619 | 1 | R_SignalHandlers = 0; | 620 | | | 621 | | /* The two halves of Rf_initEmbeddedR, with the C stack check fixed | 622 | | * up in between. On Linux Rf_initialize_R takes R_CStackStart from | 623 | | * __libc_stack_end, the main thread's stack, so from this thread | 624 | | * every R_CheckStack() while setup_Rmainloop loads base would see | 625 | | * terabytes of usage and R would abort ("unable to initialize the | 626 | | * JIT"). macOS never sets it when embedded, which hides this | 627 | | * locally. Switch the check off for startup, then measure against | 628 | | * this thread with R's own 5% of headroom for handling the overflow | 629 | | * error: R_CheckStack() fires as an ordinary R error at | 630 | | * 0.95 * FUZZ_R_STACK_SIZE rather than the sanitizer catching a fault. | 631 | | * setup_Rmainloop itself would turn any limit above 100 MB into | 632 | | * "unlimited", hence setting it after. */ | 633 | 1 | char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"}; | 634 | 1 | int r_argc = sizeof(r_argv) / sizeof(r_argv[0]); | 635 | 1 | Rf_initialize_R(r_argc, r_argv); | 636 | 1 | R_CStackStart = fuzz_r_thread.stack_top; | 637 | 1 | R_CStackLimit = (uintptr_t)-1; | 638 | 1 | R_Interactive = TRUE; /* as Rf_initEmbeddedR */ | 639 | 1 | setup_Rmainloop(); | 640 | 1 | R_CStackLimit = (uintptr_t)(0.95 * FUZZ_R_STACK_SIZE); | 641 | | | 642 | 1 | fuzz_suppress_warnings(); | 643 | 1 | } |
Line | Count | Source | 596 | 2 | { | 597 | 2 | if (!fuzz_on_r_thread()) { | 598 | 0 | fprintf(stderr, "fuzz_init_r: must run on the R thread " | 599 | 0 | "(define fuzz_target_init, not LLVMFuzzerInitialize)\n"); | 600 | 0 | abort(); | 601 | 0 | } | 602 | | | 603 | 2 | fuzz_set_r_home(); | 604 | 2 | fuzz_set_vsize_limit(); | 605 | | | 606 | | /* GC consistency failures ("untraced old-to-new reference", a node | 607 | | * with a bad type) are memory corruption, not input errors. R's | 608 | | * default is to report and carry on; this makes gc_error() fatal | 609 | | * (through R_Suicide, which instrumentation/0004 turns into abort) | 610 | | * so they surface as crashes at the collection that found them. */ | 611 | 2 | if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL) | 612 | 1 | setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1); | 613 | | | 614 | | /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery | 615 | | * prompt instead of crashing, which would hang the fuzzer. Telling | 616 | | * R not to install them (rather than resetting to SIG_DFL after | 617 | | * init) keeps the sanitizers' own handlers in place, so wild-pointer | 618 | | * faults still get full ASAN reports and clean deduplication. */ | 619 | 2 | R_SignalHandlers = 0; | 620 | | | 621 | | /* The two halves of Rf_initEmbeddedR, with the C stack check fixed | 622 | | * up in between. On Linux Rf_initialize_R takes R_CStackStart from | 623 | | * __libc_stack_end, the main thread's stack, so from this thread | 624 | | * every R_CheckStack() while setup_Rmainloop loads base would see | 625 | | * terabytes of usage and R would abort ("unable to initialize the | 626 | | * JIT"). macOS never sets it when embedded, which hides this | 627 | | * locally. Switch the check off for startup, then measure against | 628 | | * this thread with R's own 5% of headroom for handling the overflow | 629 | | * error: R_CheckStack() fires as an ordinary R error at | 630 | | * 0.95 * FUZZ_R_STACK_SIZE rather than the sanitizer catching a fault. | 631 | | * setup_Rmainloop itself would turn any limit above 100 MB into | 632 | | * "unlimited", hence setting it after. */ | 633 | 2 | char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"}; | 634 | 2 | int r_argc = sizeof(r_argv) / sizeof(r_argv[0]); | 635 | 2 | Rf_initialize_R(r_argc, r_argv); | 636 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 637 | 2 | R_CStackLimit = (uintptr_t)-1; | 638 | 2 | R_Interactive = TRUE; /* as Rf_initEmbeddedR */ | 639 | 2 | setup_Rmainloop(); | 640 | 2 | R_CStackLimit = (uintptr_t)(0.95 * FUZZ_R_STACK_SIZE); | 641 | | | 642 | 2 | fuzz_suppress_warnings(); | 643 | 2 | } |
Line | Count | Source | 596 | 2 | { | 597 | 2 | if (!fuzz_on_r_thread()) { | 598 | 0 | fprintf(stderr, "fuzz_init_r: must run on the R thread " | 599 | 0 | "(define fuzz_target_init, not LLVMFuzzerInitialize)\n"); | 600 | 0 | abort(); | 601 | 0 | } | 602 | | | 603 | 2 | fuzz_set_r_home(); | 604 | 2 | fuzz_set_vsize_limit(); | 605 | | | 606 | | /* GC consistency failures ("untraced old-to-new reference", a node | 607 | | * with a bad type) are memory corruption, not input errors. R's | 608 | | * default is to report and carry on; this makes gc_error() fatal | 609 | | * (through R_Suicide, which instrumentation/0004 turns into abort) | 610 | | * so they surface as crashes at the collection that found them. */ | 611 | 2 | if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL) | 612 | 1 | setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1); | 613 | | | 614 | | /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery | 615 | | * prompt instead of crashing, which would hang the fuzzer. Telling | 616 | | * R not to install them (rather than resetting to SIG_DFL after | 617 | | * init) keeps the sanitizers' own handlers in place, so wild-pointer | 618 | | * faults still get full ASAN reports and clean deduplication. */ | 619 | 2 | R_SignalHandlers = 0; | 620 | | | 621 | | /* The two halves of Rf_initEmbeddedR, with the C stack check fixed | 622 | | * up in between. On Linux Rf_initialize_R takes R_CStackStart from | 623 | | * __libc_stack_end, the main thread's stack, so from this thread | 624 | | * every R_CheckStack() while setup_Rmainloop loads base would see | 625 | | * terabytes of usage and R would abort ("unable to initialize the | 626 | | * JIT"). macOS never sets it when embedded, which hides this | 627 | | * locally. Switch the check off for startup, then measure against | 628 | | * this thread with R's own 5% of headroom for handling the overflow | 629 | | * error: R_CheckStack() fires as an ordinary R error at | 630 | | * 0.95 * FUZZ_R_STACK_SIZE rather than the sanitizer catching a fault. | 631 | | * setup_Rmainloop itself would turn any limit above 100 MB into | 632 | | * "unlimited", hence setting it after. */ | 633 | 2 | char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"}; | 634 | 2 | int r_argc = sizeof(r_argv) / sizeof(r_argv[0]); | 635 | 2 | Rf_initialize_R(r_argc, r_argv); | 636 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 637 | 2 | R_CStackLimit = (uintptr_t)-1; | 638 | 2 | R_Interactive = TRUE; /* as Rf_initEmbeddedR */ | 639 | 2 | setup_Rmainloop(); | 640 | 2 | R_CStackLimit = (uintptr_t)(0.95 * FUZZ_R_STACK_SIZE); | 641 | | | 642 | 2 | fuzz_suppress_warnings(); | 643 | 2 | } |
Line | Count | Source | 596 | 2 | { | 597 | 2 | if (!fuzz_on_r_thread()) { | 598 | 0 | fprintf(stderr, "fuzz_init_r: must run on the R thread " | 599 | 0 | "(define fuzz_target_init, not LLVMFuzzerInitialize)\n"); | 600 | 0 | abort(); | 601 | 0 | } | 602 | | | 603 | 2 | fuzz_set_r_home(); | 604 | 2 | fuzz_set_vsize_limit(); | 605 | | | 606 | | /* GC consistency failures ("untraced old-to-new reference", a node | 607 | | * with a bad type) are memory corruption, not input errors. R's | 608 | | * default is to report and carry on; this makes gc_error() fatal | 609 | | * (through R_Suicide, which instrumentation/0004 turns into abort) | 610 | | * so they surface as crashes at the collection that found them. */ | 611 | 2 | if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL) | 612 | 1 | setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1); | 613 | | | 614 | | /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery | 615 | | * prompt instead of crashing, which would hang the fuzzer. Telling | 616 | | * R not to install them (rather than resetting to SIG_DFL after | 617 | | * init) keeps the sanitizers' own handlers in place, so wild-pointer | 618 | | * faults still get full ASAN reports and clean deduplication. */ | 619 | 2 | R_SignalHandlers = 0; | 620 | | | 621 | | /* The two halves of Rf_initEmbeddedR, with the C stack check fixed | 622 | | * up in between. On Linux Rf_initialize_R takes R_CStackStart from | 623 | | * __libc_stack_end, the main thread's stack, so from this thread | 624 | | * every R_CheckStack() while setup_Rmainloop loads base would see | 625 | | * terabytes of usage and R would abort ("unable to initialize the | 626 | | * JIT"). macOS never sets it when embedded, which hides this | 627 | | * locally. Switch the check off for startup, then measure against | 628 | | * this thread with R's own 5% of headroom for handling the overflow | 629 | | * error: R_CheckStack() fires as an ordinary R error at | 630 | | * 0.95 * FUZZ_R_STACK_SIZE rather than the sanitizer catching a fault. | 631 | | * setup_Rmainloop itself would turn any limit above 100 MB into | 632 | | * "unlimited", hence setting it after. */ | 633 | 2 | char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"}; | 634 | 2 | int r_argc = sizeof(r_argv) / sizeof(r_argv[0]); | 635 | 2 | Rf_initialize_R(r_argc, r_argv); | 636 | 2 | R_CStackStart = fuzz_r_thread.stack_top; | 637 | 2 | R_CStackLimit = (uintptr_t)-1; | 638 | 2 | R_Interactive = TRUE; /* as Rf_initEmbeddedR */ | 639 | 2 | setup_Rmainloop(); | 640 | 2 | R_CStackLimit = (uintptr_t)(0.95 * FUZZ_R_STACK_SIZE); | 641 | | | 642 | 2 | fuzz_suppress_warnings(); | 643 | 2 | } |
|
644 | | |
645 | | /* |
646 | | * Helper for protected evaluation via R_ToplevelExec. |
647 | | * |
648 | | * R API calls that touch R objects can longjmp on error. Without a |
649 | | * top-level context, R's error handler crashes. Wrapping calls in |
650 | | * R_ToplevelExec catches the longjmp cleanly. |
651 | | */ |
652 | | typedef struct { |
653 | | SEXP call; |
654 | | SEXP env; |
655 | | } fuzz_eval_data_t; |
656 | | |
657 | | static void fuzz_do_eval(void *data) |
658 | 21.2k | { |
659 | 21.2k | fuzz_eval_data_t *ed = (fuzz_eval_data_t *)data; |
660 | 21.2k | fuzz_label_enter(ed->call); |
661 | 21.2k | Rf_eval(ed->call, ed->env); |
662 | 21.2k | } Unexecuted instantiation: io.c:fuzz_do_eval Unexecuted instantiation: dcf.c:fuzz_do_eval Unexecuted instantiation: character.c:fuzz_do_eval Unexecuted instantiation: encoding.c:fuzz_do_eval Unexecuted instantiation: sort.c:fuzz_do_eval Unexecuted instantiation: connections.c:fuzz_do_eval Unexecuted instantiation: unserialize.c:fuzz_do_eval decompress.c:fuzz_do_eval Line | Count | Source | 658 | 6.74k | { | 659 | 6.74k | fuzz_eval_data_t *ed = (fuzz_eval_data_t *)data; | 660 | 6.74k | fuzz_label_enter(ed->call); | 661 | 6.74k | Rf_eval(ed->call, ed->env); | 662 | 6.74k | } |
Unexecuted instantiation: readtable.c:fuzz_do_eval Unexecuted instantiation: format.c:fuzz_do_eval Line | Count | Source | 658 | 6.94k | { | 659 | 6.94k | fuzz_eval_data_t *ed = (fuzz_eval_data_t *)data; | 660 | 6.94k | fuzz_label_enter(ed->call); | 661 | 6.94k | Rf_eval(ed->call, ed->env); | 662 | 6.94k | } |
Line | Count | Source | 658 | 7.55k | { | 659 | 7.55k | fuzz_eval_data_t *ed = (fuzz_eval_data_t *)data; | 660 | 7.55k | fuzz_label_enter(ed->call); | 661 | 7.55k | Rf_eval(ed->call, ed->env); | 662 | 7.55k | } |
Unexecuted instantiation: load.c:fuzz_do_eval Unexecuted instantiation: scan.c:fuzz_do_eval Unexecuted instantiation: colors.c:fuzz_do_eval Unexecuted instantiation: parse.c:fuzz_do_eval Unexecuted instantiation: sockets.c:fuzz_do_eval Unexecuted instantiation: sprintf.c:fuzz_do_eval Unexecuted instantiation: eval.c:fuzz_do_eval Unexecuted instantiation: zip.c:fuzz_do_eval |
663 | | |
664 | | /* Evaluate malformed-input-heavy targets without printing each expected |
665 | | * R error. R_tryEvalSilent installs its own top-level error context. */ |
666 | | static void fuzz_eval_silent(SEXP call, SEXP env) |
667 | 64.8k | { |
668 | 64.8k | int error = 0; |
669 | 64.8k | fuzz_label_enter(call); |
670 | 64.8k | R_tryEvalSilent(call, env, &error); |
671 | 64.8k | } Line | Count | Source | 667 | 1.13k | { | 668 | 1.13k | int error = 0; | 669 | 1.13k | fuzz_label_enter(call); | 670 | 1.13k | R_tryEvalSilent(call, env, &error); | 671 | 1.13k | } |
Line | Count | Source | 667 | 4.99k | { | 668 | 4.99k | int error = 0; | 669 | 4.99k | fuzz_label_enter(call); | 670 | 4.99k | R_tryEvalSilent(call, env, &error); | 671 | 4.99k | } |
character.c:fuzz_eval_silent Line | Count | Source | 667 | 4.42k | { | 668 | 4.42k | int error = 0; | 669 | 4.42k | fuzz_label_enter(call); | 670 | 4.42k | R_tryEvalSilent(call, env, &error); | 671 | 4.42k | } |
encoding.c:fuzz_eval_silent Line | Count | Source | 667 | 1.74k | { | 668 | 1.74k | int error = 0; | 669 | 1.74k | fuzz_label_enter(call); | 670 | 1.74k | R_tryEvalSilent(call, env, &error); | 671 | 1.74k | } |
Line | Count | Source | 667 | 6.73k | { | 668 | 6.73k | int error = 0; | 669 | 6.73k | fuzz_label_enter(call); | 670 | 6.73k | R_tryEvalSilent(call, env, &error); | 671 | 6.73k | } |
connections.c:fuzz_eval_silent Line | Count | Source | 667 | 5.92k | { | 668 | 5.92k | int error = 0; | 669 | 5.92k | fuzz_label_enter(call); | 670 | 5.92k | R_tryEvalSilent(call, env, &error); | 671 | 5.92k | } |
unserialize.c:fuzz_eval_silent Line | Count | Source | 667 | 5.61k | { | 668 | 5.61k | int error = 0; | 669 | 5.61k | fuzz_label_enter(call); | 670 | 5.61k | R_tryEvalSilent(call, env, &error); | 671 | 5.61k | } |
Unexecuted instantiation: decompress.c:fuzz_eval_silent readtable.c:fuzz_eval_silent Line | Count | Source | 667 | 361 | { | 668 | 361 | int error = 0; | 669 | 361 | fuzz_label_enter(call); | 670 | 361 | R_tryEvalSilent(call, env, &error); | 671 | 361 | } |
format.c:fuzz_eval_silent Line | Count | Source | 667 | 5.51k | { | 668 | 5.51k | int error = 0; | 669 | 5.51k | fuzz_label_enter(call); | 670 | 5.51k | R_tryEvalSilent(call, env, &error); | 671 | 5.51k | } |
datetime.c:fuzz_eval_silent Line | Count | Source | 667 | 3.11k | { | 668 | 3.11k | int error = 0; | 669 | 3.11k | fuzz_label_enter(call); | 670 | 3.11k | R_tryEvalSilent(call, env, &error); | 671 | 3.11k | } |
Unexecuted instantiation: coerce.c:fuzz_eval_silent Line | Count | Source | 667 | 8.49k | { | 668 | 8.49k | int error = 0; | 669 | 8.49k | fuzz_label_enter(call); | 670 | 8.49k | R_tryEvalSilent(call, env, &error); | 671 | 8.49k | } |
Line | Count | Source | 667 | 3.15k | { | 668 | 3.15k | int error = 0; | 669 | 3.15k | fuzz_label_enter(call); | 670 | 3.15k | R_tryEvalSilent(call, env, &error); | 671 | 3.15k | } |
colors.c:fuzz_eval_silent Line | Count | Source | 667 | 1.87k | { | 668 | 1.87k | int error = 0; | 669 | 1.87k | fuzz_label_enter(call); | 670 | 1.87k | R_tryEvalSilent(call, env, &error); | 671 | 1.87k | } |
Line | Count | Source | 667 | 7.25k | { | 668 | 7.25k | int error = 0; | 669 | 7.25k | fuzz_label_enter(call); | 670 | 7.25k | R_tryEvalSilent(call, env, &error); | 671 | 7.25k | } |
Unexecuted instantiation: sockets.c:fuzz_eval_silent sprintf.c:fuzz_eval_silent Line | Count | Source | 667 | 2.17k | { | 668 | 2.17k | int error = 0; | 669 | 2.17k | fuzz_label_enter(call); | 670 | 2.17k | R_tryEvalSilent(call, env, &error); | 671 | 2.17k | } |
Unexecuted instantiation: eval.c:fuzz_eval_silent Line | Count | Source | 667 | 2.33k | { | 668 | 2.33k | int error = 0; | 669 | 2.33k | fuzz_label_enter(call); | 670 | 2.33k | R_tryEvalSilent(call, env, &error); | 671 | 2.33k | } |
|
672 | | |
673 | | /* |
674 | | * Stage per-iteration inputs under a toplevel context. |
675 | | * |
676 | | * Rf_mkChar and Rf_allocVector can themselves signal the vector-limit |
677 | | * error. Outside a toplevel context that error longjmps into a stack |
678 | | * frame that returned during Rf_initEmbeddedR -- undefined behaviour -- |
679 | | * so input staging must be wrapped just like evaluation. Both helpers |
680 | | * return FALSE when the allocation failed; skip the iteration then. |
681 | | */ |
682 | | typedef struct { |
683 | | SEXP vec; |
684 | | const char *str; |
685 | | } fuzz_string_data_t; |
686 | | |
687 | | static void fuzz_do_set_string(void *data) |
688 | 45.6k | { |
689 | 45.6k | fuzz_string_data_t *sd = (fuzz_string_data_t *)data; |
690 | 45.6k | SET_STRING_ELT(sd->vec, 0, Rf_mkChar(sd->str)); |
691 | 45.6k | } Unexecuted instantiation: io.c:fuzz_do_set_string Line | Count | Source | 688 | 4.99k | { | 689 | 4.99k | fuzz_string_data_t *sd = (fuzz_string_data_t *)data; | 690 | 4.99k | SET_STRING_ELT(sd->vec, 0, Rf_mkChar(sd->str)); | 691 | 4.99k | } |
character.c:fuzz_do_set_string Line | Count | Source | 688 | 3.15k | { | 689 | 3.15k | fuzz_string_data_t *sd = (fuzz_string_data_t *)data; | 690 | 3.15k | SET_STRING_ELT(sd->vec, 0, Rf_mkChar(sd->str)); | 691 | 3.15k | } |
encoding.c:fuzz_do_set_string Line | Count | Source | 688 | 769 | { | 689 | 769 | fuzz_string_data_t *sd = (fuzz_string_data_t *)data; | 690 | 769 | SET_STRING_ELT(sd->vec, 0, Rf_mkChar(sd->str)); | 691 | 769 | } |
Unexecuted instantiation: sort.c:fuzz_do_set_string Unexecuted instantiation: connections.c:fuzz_do_set_string Unexecuted instantiation: unserialize.c:fuzz_do_set_string Unexecuted instantiation: decompress.c:fuzz_do_set_string readtable.c:fuzz_do_set_string Line | Count | Source | 688 | 321 | { | 689 | 321 | fuzz_string_data_t *sd = (fuzz_string_data_t *)data; | 690 | 321 | SET_STRING_ELT(sd->vec, 0, Rf_mkChar(sd->str)); | 691 | 321 | } |
format.c:fuzz_do_set_string Line | Count | Source | 688 | 5.51k | { | 689 | 5.51k | fuzz_string_data_t *sd = (fuzz_string_data_t *)data; | 690 | 5.51k | SET_STRING_ELT(sd->vec, 0, Rf_mkChar(sd->str)); | 691 | 5.51k | } |
datetime.c:fuzz_do_set_string Line | Count | Source | 688 | 13.8k | { | 689 | 13.8k | fuzz_string_data_t *sd = (fuzz_string_data_t *)data; | 690 | 13.8k | SET_STRING_ELT(sd->vec, 0, Rf_mkChar(sd->str)); | 691 | 13.8k | } |
coerce.c:fuzz_do_set_string Line | Count | Source | 688 | 1.88k | { | 689 | 1.88k | fuzz_string_data_t *sd = (fuzz_string_data_t *)data; | 690 | 1.88k | SET_STRING_ELT(sd->vec, 0, Rf_mkChar(sd->str)); | 691 | 1.88k | } |
Unexecuted instantiation: load.c:fuzz_do_set_string scan.c:fuzz_do_set_string Line | Count | Source | 688 | 3.11k | { | 689 | 3.11k | fuzz_string_data_t *sd = (fuzz_string_data_t *)data; | 690 | 3.11k | SET_STRING_ELT(sd->vec, 0, Rf_mkChar(sd->str)); | 691 | 3.11k | } |
colors.c:fuzz_do_set_string Line | Count | Source | 688 | 1.84k | { | 689 | 1.84k | fuzz_string_data_t *sd = (fuzz_string_data_t *)data; | 690 | 1.84k | SET_STRING_ELT(sd->vec, 0, Rf_mkChar(sd->str)); | 691 | 1.84k | } |
parse.c:fuzz_do_set_string Line | Count | Source | 688 | 8.02k | { | 689 | 8.02k | fuzz_string_data_t *sd = (fuzz_string_data_t *)data; | 690 | 8.02k | SET_STRING_ELT(sd->vec, 0, Rf_mkChar(sd->str)); | 691 | 8.02k | } |
Unexecuted instantiation: sockets.c:fuzz_do_set_string sprintf.c:fuzz_do_set_string Line | Count | Source | 688 | 2.17k | { | 689 | 2.17k | fuzz_string_data_t *sd = (fuzz_string_data_t *)data; | 690 | 2.17k | SET_STRING_ELT(sd->vec, 0, Rf_mkChar(sd->str)); | 691 | 2.17k | } |
Unexecuted instantiation: eval.c:fuzz_do_set_string Unexecuted instantiation: zip.c:fuzz_do_set_string |
692 | | |
693 | | static Rboolean fuzz_set_string(SEXP vec, const char *str) |
694 | 45.6k | { |
695 | 45.6k | fuzz_string_data_t sd = { vec, str }; |
696 | 45.6k | return R_ToplevelExec(fuzz_do_set_string, &sd); |
697 | 45.6k | } Unexecuted instantiation: io.c:fuzz_set_string Line | Count | Source | 694 | 4.99k | { | 695 | 4.99k | fuzz_string_data_t sd = { vec, str }; | 696 | 4.99k | return R_ToplevelExec(fuzz_do_set_string, &sd); | 697 | 4.99k | } |
character.c:fuzz_set_string Line | Count | Source | 694 | 3.15k | { | 695 | 3.15k | fuzz_string_data_t sd = { vec, str }; | 696 | 3.15k | return R_ToplevelExec(fuzz_do_set_string, &sd); | 697 | 3.15k | } |
encoding.c:fuzz_set_string Line | Count | Source | 694 | 769 | { | 695 | 769 | fuzz_string_data_t sd = { vec, str }; | 696 | 769 | return R_ToplevelExec(fuzz_do_set_string, &sd); | 697 | 769 | } |
Unexecuted instantiation: sort.c:fuzz_set_string Unexecuted instantiation: connections.c:fuzz_set_string Unexecuted instantiation: unserialize.c:fuzz_set_string Unexecuted instantiation: decompress.c:fuzz_set_string readtable.c:fuzz_set_string Line | Count | Source | 694 | 321 | { | 695 | 321 | fuzz_string_data_t sd = { vec, str }; | 696 | 321 | return R_ToplevelExec(fuzz_do_set_string, &sd); | 697 | 321 | } |
Line | Count | Source | 694 | 5.51k | { | 695 | 5.51k | fuzz_string_data_t sd = { vec, str }; | 696 | 5.51k | return R_ToplevelExec(fuzz_do_set_string, &sd); | 697 | 5.51k | } |
datetime.c:fuzz_set_string Line | Count | Source | 694 | 13.8k | { | 695 | 13.8k | fuzz_string_data_t sd = { vec, str }; | 696 | 13.8k | return R_ToplevelExec(fuzz_do_set_string, &sd); | 697 | 13.8k | } |
Line | Count | Source | 694 | 1.88k | { | 695 | 1.88k | fuzz_string_data_t sd = { vec, str }; | 696 | 1.88k | return R_ToplevelExec(fuzz_do_set_string, &sd); | 697 | 1.88k | } |
Unexecuted instantiation: load.c:fuzz_set_string Line | Count | Source | 694 | 3.11k | { | 695 | 3.11k | fuzz_string_data_t sd = { vec, str }; | 696 | 3.11k | return R_ToplevelExec(fuzz_do_set_string, &sd); | 697 | 3.11k | } |
Line | Count | Source | 694 | 1.84k | { | 695 | 1.84k | fuzz_string_data_t sd = { vec, str }; | 696 | 1.84k | return R_ToplevelExec(fuzz_do_set_string, &sd); | 697 | 1.84k | } |
Line | Count | Source | 694 | 8.02k | { | 695 | 8.02k | fuzz_string_data_t sd = { vec, str }; | 696 | 8.02k | return R_ToplevelExec(fuzz_do_set_string, &sd); | 697 | 8.02k | } |
Unexecuted instantiation: sockets.c:fuzz_set_string sprintf.c:fuzz_set_string Line | Count | Source | 694 | 2.17k | { | 695 | 2.17k | fuzz_string_data_t sd = { vec, str }; | 696 | 2.17k | return R_ToplevelExec(fuzz_do_set_string, &sd); | 697 | 2.17k | } |
Unexecuted instantiation: eval.c:fuzz_set_string Unexecuted instantiation: zip.c:fuzz_set_string |
698 | | |
699 | | /* |
700 | | * Parse and evaluate one R function literal, once, at initialization. |
701 | | * |
702 | | * Harnesses whose calls need named arguments, on.exit(close(con)) or a |
703 | | * few R-level steps around the entry point express each slot as an R |
704 | | * closure and call it with Rf_lang*; that keeps the C side free of |
705 | | * argument plumbing. The source is harness-authored (never fuzz |
706 | | * input), so a parse or evaluation failure is a harness bug: abort. |
707 | | */ |
708 | | static SEXP fuzz_make_wrapper(const char *source) |
709 | 278 | { |
710 | 278 | ParseStatus status; |
711 | 278 | SEXP text, parsed, wrapper; |
712 | 278 | Rf_protect(text = Rf_mkString(source)); |
713 | 278 | Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue)); |
714 | 278 | if (status != PARSE_OK || XLENGTH(parsed) != 1) |
715 | 0 | abort(); |
716 | | |
717 | 278 | wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_BaseEnv); |
718 | 278 | Rf_unprotect(2); |
719 | 278 | return wrapper; |
720 | 278 | } Line | Count | Source | 709 | 20 | { | 710 | 20 | ParseStatus status; | 711 | 20 | SEXP text, parsed, wrapper; | 712 | 20 | Rf_protect(text = Rf_mkString(source)); | 713 | 20 | Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue)); | 714 | 20 | if (status != PARSE_OK || XLENGTH(parsed) != 1) | 715 | 0 | abort(); | 716 | | | 717 | 20 | wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_BaseEnv); | 718 | 20 | Rf_unprotect(2); | 719 | 20 | return wrapper; | 720 | 20 | } |
Unexecuted instantiation: dcf.c:fuzz_make_wrapper Unexecuted instantiation: character.c:fuzz_make_wrapper Unexecuted instantiation: encoding.c:fuzz_make_wrapper Line | Count | Source | 709 | 44 | { | 710 | 44 | ParseStatus status; | 711 | 44 | SEXP text, parsed, wrapper; | 712 | 44 | Rf_protect(text = Rf_mkString(source)); | 713 | 44 | Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue)); | 714 | 44 | if (status != PARSE_OK || XLENGTH(parsed) != 1) | 715 | 0 | abort(); | 716 | | | 717 | 44 | wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_BaseEnv); | 718 | 44 | Rf_unprotect(2); | 719 | 44 | return wrapper; | 720 | 44 | } |
connections.c:fuzz_make_wrapper Line | Count | Source | 709 | 22 | { | 710 | 22 | ParseStatus status; | 711 | 22 | SEXP text, parsed, wrapper; | 712 | 22 | Rf_protect(text = Rf_mkString(source)); | 713 | 22 | Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue)); | 714 | 22 | if (status != PARSE_OK || XLENGTH(parsed) != 1) | 715 | 0 | abort(); | 716 | | | 717 | 22 | wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_BaseEnv); | 718 | 22 | Rf_unprotect(2); | 719 | 22 | return wrapper; | 720 | 22 | } |
unserialize.c:fuzz_make_wrapper Line | Count | Source | 709 | 8 | { | 710 | 8 | ParseStatus status; | 711 | 8 | SEXP text, parsed, wrapper; | 712 | 8 | Rf_protect(text = Rf_mkString(source)); | 713 | 8 | Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue)); | 714 | 8 | if (status != PARSE_OK || XLENGTH(parsed) != 1) | 715 | 0 | abort(); | 716 | | | 717 | 8 | wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_BaseEnv); | 718 | 8 | Rf_unprotect(2); | 719 | 8 | return wrapper; | 720 | 8 | } |
Unexecuted instantiation: decompress.c:fuzz_make_wrapper readtable.c:fuzz_make_wrapper Line | Count | Source | 709 | 40 | { | 710 | 40 | ParseStatus status; | 711 | 40 | SEXP text, parsed, wrapper; | 712 | 40 | Rf_protect(text = Rf_mkString(source)); | 713 | 40 | Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue)); | 714 | 40 | if (status != PARSE_OK || XLENGTH(parsed) != 1) | 715 | 0 | abort(); | 716 | | | 717 | 40 | wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_BaseEnv); | 718 | 40 | Rf_unprotect(2); | 719 | 40 | return wrapper; | 720 | 40 | } |
format.c:fuzz_make_wrapper Line | Count | Source | 709 | 48 | { | 710 | 48 | ParseStatus status; | 711 | 48 | SEXP text, parsed, wrapper; | 712 | 48 | Rf_protect(text = Rf_mkString(source)); | 713 | 48 | Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue)); | 714 | 48 | if (status != PARSE_OK || XLENGTH(parsed) != 1) | 715 | 0 | abort(); | 716 | | | 717 | 48 | wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_BaseEnv); | 718 | 48 | Rf_unprotect(2); | 719 | 48 | return wrapper; | 720 | 48 | } |
datetime.c:fuzz_make_wrapper Line | Count | Source | 709 | 2 | { | 710 | 2 | ParseStatus status; | 711 | 2 | SEXP text, parsed, wrapper; | 712 | 2 | Rf_protect(text = Rf_mkString(source)); | 713 | 2 | Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue)); | 714 | 2 | if (status != PARSE_OK || XLENGTH(parsed) != 1) | 715 | 0 | abort(); | 716 | | | 717 | 2 | wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_BaseEnv); | 718 | 2 | Rf_unprotect(2); | 719 | 2 | return wrapper; | 720 | 2 | } |
Unexecuted instantiation: coerce.c:fuzz_make_wrapper Line | Count | Source | 709 | 4 | { | 710 | 4 | ParseStatus status; | 711 | 4 | SEXP text, parsed, wrapper; | 712 | 4 | Rf_protect(text = Rf_mkString(source)); | 713 | 4 | Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue)); | 714 | 4 | if (status != PARSE_OK || XLENGTH(parsed) != 1) | 715 | 0 | abort(); | 716 | | | 717 | 4 | wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_BaseEnv); | 718 | 4 | Rf_unprotect(2); | 719 | 4 | return wrapper; | 720 | 4 | } |
Line | Count | Source | 709 | 36 | { | 710 | 36 | ParseStatus status; | 711 | 36 | SEXP text, parsed, wrapper; | 712 | 36 | Rf_protect(text = Rf_mkString(source)); | 713 | 36 | Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue)); | 714 | 36 | if (status != PARSE_OK || XLENGTH(parsed) != 1) | 715 | 0 | abort(); | 716 | | | 717 | 36 | wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_BaseEnv); | 718 | 36 | Rf_unprotect(2); | 719 | 36 | return wrapper; | 720 | 36 | } |
colors.c:fuzz_make_wrapper Line | Count | Source | 709 | 32 | { | 710 | 32 | ParseStatus status; | 711 | 32 | SEXP text, parsed, wrapper; | 712 | 32 | Rf_protect(text = Rf_mkString(source)); | 713 | 32 | Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue)); | 714 | 32 | if (status != PARSE_OK || XLENGTH(parsed) != 1) | 715 | 0 | abort(); | 716 | | | 717 | 32 | wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_BaseEnv); | 718 | 32 | Rf_unprotect(2); | 719 | 32 | return wrapper; | 720 | 32 | } |
parse.c:fuzz_make_wrapper Line | Count | Source | 709 | 12 | { | 710 | 12 | ParseStatus status; | 711 | 12 | SEXP text, parsed, wrapper; | 712 | 12 | Rf_protect(text = Rf_mkString(source)); | 713 | 12 | Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue)); | 714 | 12 | if (status != PARSE_OK || XLENGTH(parsed) != 1) | 715 | 0 | abort(); | 716 | | | 717 | 12 | wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_BaseEnv); | 718 | 12 | Rf_unprotect(2); | 719 | 12 | return wrapper; | 720 | 12 | } |
sockets.c:fuzz_make_wrapper Line | Count | Source | 709 | 2 | { | 710 | 2 | ParseStatus status; | 711 | 2 | SEXP text, parsed, wrapper; | 712 | 2 | Rf_protect(text = Rf_mkString(source)); | 713 | 2 | Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue)); | 714 | 2 | if (status != PARSE_OK || XLENGTH(parsed) != 1) | 715 | 0 | abort(); | 716 | | | 717 | 2 | wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_BaseEnv); | 718 | 2 | Rf_unprotect(2); | 719 | 2 | return wrapper; | 720 | 2 | } |
Unexecuted instantiation: sprintf.c:fuzz_make_wrapper Unexecuted instantiation: eval.c:fuzz_make_wrapper Line | Count | Source | 709 | 8 | { | 710 | 8 | ParseStatus status; | 711 | 8 | SEXP text, parsed, wrapper; | 712 | 8 | Rf_protect(text = Rf_mkString(source)); | 713 | 8 | Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue)); | 714 | 8 | if (status != PARSE_OK || XLENGTH(parsed) != 1) | 715 | 0 | abort(); | 716 | | | 717 | 8 | wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_BaseEnv); | 718 | 8 | Rf_unprotect(2); | 719 | 8 | return wrapper; | 720 | 8 | } |
|
721 | | |
722 | | /* |
723 | | * fuzz_set_string with an explicit encoding mark. |
724 | | * |
725 | | * R does not validate the mark (Encoding<- lets users set it on any |
726 | | * bytes), so handing the same payload over as UTF-8 or latin1 reaches |
727 | | * the multibyte branches and their handling of invalid sequences |
728 | | * without touching the process locale. |
729 | | */ |
730 | | typedef struct { |
731 | | SEXP vec; |
732 | | const char *str; |
733 | | cetype_t ce; |
734 | | } fuzz_ce_string_data_t; |
735 | | |
736 | | static void fuzz_do_set_string_ce(void *data) |
737 | 3.29k | { |
738 | 3.29k | fuzz_ce_string_data_t *sd = (fuzz_ce_string_data_t *)data; |
739 | 3.29k | SET_STRING_ELT(sd->vec, 0, Rf_mkCharCE(sd->str, sd->ce)); |
740 | 3.29k | } Unexecuted instantiation: io.c:fuzz_do_set_string_ce Unexecuted instantiation: dcf.c:fuzz_do_set_string_ce character.c:fuzz_do_set_string_ce Line | Count | Source | 737 | 3.08k | { | 738 | 3.08k | fuzz_ce_string_data_t *sd = (fuzz_ce_string_data_t *)data; | 739 | 3.08k | SET_STRING_ELT(sd->vec, 0, Rf_mkCharCE(sd->str, sd->ce)); | 740 | 3.08k | } |
encoding.c:fuzz_do_set_string_ce Line | Count | Source | 737 | 212 | { | 738 | 212 | fuzz_ce_string_data_t *sd = (fuzz_ce_string_data_t *)data; | 739 | 212 | SET_STRING_ELT(sd->vec, 0, Rf_mkCharCE(sd->str, sd->ce)); | 740 | 212 | } |
Unexecuted instantiation: sort.c:fuzz_do_set_string_ce Unexecuted instantiation: connections.c:fuzz_do_set_string_ce Unexecuted instantiation: unserialize.c:fuzz_do_set_string_ce Unexecuted instantiation: decompress.c:fuzz_do_set_string_ce Unexecuted instantiation: readtable.c:fuzz_do_set_string_ce Unexecuted instantiation: format.c:fuzz_do_set_string_ce Unexecuted instantiation: datetime.c:fuzz_do_set_string_ce Unexecuted instantiation: coerce.c:fuzz_do_set_string_ce Unexecuted instantiation: load.c:fuzz_do_set_string_ce Unexecuted instantiation: scan.c:fuzz_do_set_string_ce Unexecuted instantiation: colors.c:fuzz_do_set_string_ce Unexecuted instantiation: parse.c:fuzz_do_set_string_ce Unexecuted instantiation: sockets.c:fuzz_do_set_string_ce Unexecuted instantiation: sprintf.c:fuzz_do_set_string_ce Unexecuted instantiation: eval.c:fuzz_do_set_string_ce Unexecuted instantiation: zip.c:fuzz_do_set_string_ce |
741 | | |
742 | | static Rboolean fuzz_set_string_ce(SEXP vec, const char *str, cetype_t ce) |
743 | 3.29k | { |
744 | 3.29k | fuzz_ce_string_data_t sd = { vec, str, ce }; |
745 | 3.29k | return R_ToplevelExec(fuzz_do_set_string_ce, &sd); |
746 | 3.29k | } Unexecuted instantiation: io.c:fuzz_set_string_ce Unexecuted instantiation: dcf.c:fuzz_set_string_ce character.c:fuzz_set_string_ce Line | Count | Source | 743 | 3.08k | { | 744 | 3.08k | fuzz_ce_string_data_t sd = { vec, str, ce }; | 745 | 3.08k | return R_ToplevelExec(fuzz_do_set_string_ce, &sd); | 746 | 3.08k | } |
encoding.c:fuzz_set_string_ce Line | Count | Source | 743 | 212 | { | 744 | 212 | fuzz_ce_string_data_t sd = { vec, str, ce }; | 745 | 212 | return R_ToplevelExec(fuzz_do_set_string_ce, &sd); | 746 | 212 | } |
Unexecuted instantiation: sort.c:fuzz_set_string_ce Unexecuted instantiation: connections.c:fuzz_set_string_ce Unexecuted instantiation: unserialize.c:fuzz_set_string_ce Unexecuted instantiation: decompress.c:fuzz_set_string_ce Unexecuted instantiation: readtable.c:fuzz_set_string_ce Unexecuted instantiation: format.c:fuzz_set_string_ce Unexecuted instantiation: datetime.c:fuzz_set_string_ce Unexecuted instantiation: coerce.c:fuzz_set_string_ce Unexecuted instantiation: load.c:fuzz_set_string_ce Unexecuted instantiation: scan.c:fuzz_set_string_ce Unexecuted instantiation: colors.c:fuzz_set_string_ce Unexecuted instantiation: parse.c:fuzz_set_string_ce Unexecuted instantiation: sockets.c:fuzz_set_string_ce Unexecuted instantiation: sprintf.c:fuzz_set_string_ce Unexecuted instantiation: eval.c:fuzz_set_string_ce Unexecuted instantiation: zip.c:fuzz_set_string_ce |
747 | | |
748 | | typedef struct { |
749 | | SEXP call; |
750 | | const uint8_t *data; |
751 | | size_t size; |
752 | | } fuzz_raw_data_t; |
753 | | |
754 | | static void fuzz_do_set_raw(void *data) |
755 | 19.4k | { |
756 | 19.4k | fuzz_raw_data_t *rd = (fuzz_raw_data_t *)data; |
757 | | |
758 | | /* The raw vector is reachable from the (protected) call as soon as |
759 | | * SETCADR runs, and nothing allocates before the memcpy completes, |
760 | | * so no extra protection is needed. */ |
761 | 19.4k | SEXP raw = Rf_allocVector(RAWSXP, (R_xlen_t)rd->size); |
762 | 19.4k | SETCADR(rd->call, raw); |
763 | 19.4k | memcpy(RAW(raw), rd->data, rd->size); |
764 | 19.4k | } Line | Count | Source | 755 | 1.13k | { | 756 | 1.13k | fuzz_raw_data_t *rd = (fuzz_raw_data_t *)data; | 757 | | | 758 | | /* The raw vector is reachable from the (protected) call as soon as | 759 | | * SETCADR runs, and nothing allocates before the memcpy completes, | 760 | | * so no extra protection is needed. */ | 761 | 1.13k | SEXP raw = Rf_allocVector(RAWSXP, (R_xlen_t)rd->size); | 762 | 1.13k | SETCADR(rd->call, raw); | 763 | 1.13k | memcpy(RAW(raw), rd->data, rd->size); | 764 | 1.13k | } |
Unexecuted instantiation: dcf.c:fuzz_do_set_raw Unexecuted instantiation: character.c:fuzz_do_set_raw Unexecuted instantiation: encoding.c:fuzz_do_set_raw Unexecuted instantiation: sort.c:fuzz_do_set_raw connections.c:fuzz_do_set_raw Line | Count | Source | 755 | 5.92k | { | 756 | 5.92k | fuzz_raw_data_t *rd = (fuzz_raw_data_t *)data; | 757 | | | 758 | | /* The raw vector is reachable from the (protected) call as soon as | 759 | | * SETCADR runs, and nothing allocates before the memcpy completes, | 760 | | * so no extra protection is needed. */ | 761 | 5.92k | SEXP raw = Rf_allocVector(RAWSXP, (R_xlen_t)rd->size); | 762 | 5.92k | SETCADR(rd->call, raw); | 763 | 5.92k | memcpy(RAW(raw), rd->data, rd->size); | 764 | 5.92k | } |
unserialize.c:fuzz_do_set_raw Line | Count | Source | 755 | 5.60k | { | 756 | 5.60k | fuzz_raw_data_t *rd = (fuzz_raw_data_t *)data; | 757 | | | 758 | | /* The raw vector is reachable from the (protected) call as soon as | 759 | | * SETCADR runs, and nothing allocates before the memcpy completes, | 760 | | * so no extra protection is needed. */ | 761 | 5.60k | SEXP raw = Rf_allocVector(RAWSXP, (R_xlen_t)rd->size); | 762 | 5.60k | SETCADR(rd->call, raw); | 763 | 5.60k | memcpy(RAW(raw), rd->data, rd->size); | 764 | 5.60k | } |
decompress.c:fuzz_do_set_raw Line | Count | Source | 755 | 6.74k | { | 756 | 6.74k | fuzz_raw_data_t *rd = (fuzz_raw_data_t *)data; | 757 | | | 758 | | /* The raw vector is reachable from the (protected) call as soon as | 759 | | * SETCADR runs, and nothing allocates before the memcpy completes, | 760 | | * so no extra protection is needed. */ | 761 | 6.74k | SEXP raw = Rf_allocVector(RAWSXP, (R_xlen_t)rd->size); | 762 | 6.74k | SETCADR(rd->call, raw); | 763 | 6.74k | memcpy(RAW(raw), rd->data, rd->size); | 764 | 6.74k | } |
Unexecuted instantiation: readtable.c:fuzz_do_set_raw Unexecuted instantiation: format.c:fuzz_do_set_raw Unexecuted instantiation: datetime.c:fuzz_do_set_raw Unexecuted instantiation: coerce.c:fuzz_do_set_raw Unexecuted instantiation: load.c:fuzz_do_set_raw Unexecuted instantiation: scan.c:fuzz_do_set_raw Unexecuted instantiation: colors.c:fuzz_do_set_raw Unexecuted instantiation: parse.c:fuzz_do_set_raw Unexecuted instantiation: sockets.c:fuzz_do_set_raw Unexecuted instantiation: sprintf.c:fuzz_do_set_raw Unexecuted instantiation: eval.c:fuzz_do_set_raw Unexecuted instantiation: zip.c:fuzz_do_set_raw |
765 | | |
766 | | static Rboolean fuzz_set_raw_arg(SEXP call, const uint8_t *data, size_t size) |
767 | 19.4k | { |
768 | 19.4k | fuzz_raw_data_t rd = { call, data, size }; |
769 | 19.4k | return R_ToplevelExec(fuzz_do_set_raw, &rd); |
770 | 19.4k | } Line | Count | Source | 767 | 1.13k | { | 768 | 1.13k | fuzz_raw_data_t rd = { call, data, size }; | 769 | 1.13k | return R_ToplevelExec(fuzz_do_set_raw, &rd); | 770 | 1.13k | } |
Unexecuted instantiation: dcf.c:fuzz_set_raw_arg Unexecuted instantiation: character.c:fuzz_set_raw_arg Unexecuted instantiation: encoding.c:fuzz_set_raw_arg Unexecuted instantiation: sort.c:fuzz_set_raw_arg connections.c:fuzz_set_raw_arg Line | Count | Source | 767 | 5.92k | { | 768 | 5.92k | fuzz_raw_data_t rd = { call, data, size }; | 769 | 5.92k | return R_ToplevelExec(fuzz_do_set_raw, &rd); | 770 | 5.92k | } |
unserialize.c:fuzz_set_raw_arg Line | Count | Source | 767 | 5.60k | { | 768 | 5.60k | fuzz_raw_data_t rd = { call, data, size }; | 769 | 5.60k | return R_ToplevelExec(fuzz_do_set_raw, &rd); | 770 | 5.60k | } |
decompress.c:fuzz_set_raw_arg Line | Count | Source | 767 | 6.74k | { | 768 | 6.74k | fuzz_raw_data_t rd = { call, data, size }; | 769 | 6.74k | return R_ToplevelExec(fuzz_do_set_raw, &rd); | 770 | 6.74k | } |
Unexecuted instantiation: readtable.c:fuzz_set_raw_arg Unexecuted instantiation: format.c:fuzz_set_raw_arg Unexecuted instantiation: datetime.c:fuzz_set_raw_arg Unexecuted instantiation: coerce.c:fuzz_set_raw_arg Unexecuted instantiation: load.c:fuzz_set_raw_arg Unexecuted instantiation: scan.c:fuzz_set_raw_arg Unexecuted instantiation: colors.c:fuzz_set_raw_arg Unexecuted instantiation: parse.c:fuzz_set_raw_arg Unexecuted instantiation: sockets.c:fuzz_set_raw_arg Unexecuted instantiation: sprintf.c:fuzz_set_raw_arg Unexecuted instantiation: eval.c:fuzz_set_raw_arg Unexecuted instantiation: zip.c:fuzz_set_raw_arg |
771 | | |
772 | | /* |
773 | | * Stage the input in a scratch file. |
774 | | * |
775 | | * Some R entry points only take a path (load() of a pre-1.4 save file, |
776 | | * unzip(), file(encoding=)), so those targets rewrite one per-process |
777 | | * file each iteration instead of handing R a raw vector. The file lives |
778 | | * in the system temp directory, which OSS-Fuzz runners allow writes to, |
779 | | * and is created once in fuzz_target_init so fuzzing never pays a |
780 | | * mkstemp per input. Returns a malloc'd path, or NULL on failure. |
781 | | */ |
782 | | static char *fuzz_scratch_file(const char *name) |
783 | 6 | { |
784 | 6 | const char *tmpdir = getenv("TMPDIR"); |
785 | 6 | if (tmpdir == NULL || *tmpdir == '\0') |
786 | 6 | tmpdir = "/tmp"; |
787 | | |
788 | 6 | char *path = malloc(PATH_MAX); |
789 | 6 | if (path == NULL) |
790 | 0 | return NULL; |
791 | 6 | snprintf(path, PATH_MAX, "%s/fuzz-%s-XXXXXX", tmpdir, name); |
792 | | |
793 | 6 | int fd = mkstemp(path); |
794 | 6 | if (fd < 0) { |
795 | 0 | free(path); |
796 | 0 | return NULL; |
797 | 0 | } |
798 | 6 | close(fd); |
799 | 6 | return path; |
800 | 6 | } Unexecuted instantiation: io.c:fuzz_scratch_file Unexecuted instantiation: dcf.c:fuzz_scratch_file Unexecuted instantiation: character.c:fuzz_scratch_file Unexecuted instantiation: encoding.c:fuzz_scratch_file Unexecuted instantiation: sort.c:fuzz_scratch_file connections.c:fuzz_scratch_file Line | Count | Source | 783 | 2 | { | 784 | 2 | const char *tmpdir = getenv("TMPDIR"); | 785 | 2 | if (tmpdir == NULL || *tmpdir == '\0') | 786 | 2 | tmpdir = "/tmp"; | 787 | | | 788 | 2 | char *path = malloc(PATH_MAX); | 789 | 2 | if (path == NULL) | 790 | 0 | return NULL; | 791 | 2 | snprintf(path, PATH_MAX, "%s/fuzz-%s-XXXXXX", tmpdir, name); | 792 | | | 793 | 2 | int fd = mkstemp(path); | 794 | 2 | if (fd < 0) { | 795 | 0 | free(path); | 796 | 0 | return NULL; | 797 | 0 | } | 798 | 2 | close(fd); | 799 | 2 | return path; | 800 | 2 | } |
Unexecuted instantiation: unserialize.c:fuzz_scratch_file Unexecuted instantiation: decompress.c:fuzz_scratch_file Unexecuted instantiation: readtable.c:fuzz_scratch_file Unexecuted instantiation: format.c:fuzz_scratch_file Unexecuted instantiation: datetime.c:fuzz_scratch_file Unexecuted instantiation: coerce.c:fuzz_scratch_file Line | Count | Source | 783 | 2 | { | 784 | 2 | const char *tmpdir = getenv("TMPDIR"); | 785 | 2 | if (tmpdir == NULL || *tmpdir == '\0') | 786 | 2 | tmpdir = "/tmp"; | 787 | | | 788 | 2 | char *path = malloc(PATH_MAX); | 789 | 2 | if (path == NULL) | 790 | 0 | return NULL; | 791 | 2 | snprintf(path, PATH_MAX, "%s/fuzz-%s-XXXXXX", tmpdir, name); | 792 | | | 793 | 2 | int fd = mkstemp(path); | 794 | 2 | if (fd < 0) { | 795 | 0 | free(path); | 796 | 0 | return NULL; | 797 | 0 | } | 798 | 2 | close(fd); | 799 | 2 | return path; | 800 | 2 | } |
Unexecuted instantiation: scan.c:fuzz_scratch_file Unexecuted instantiation: colors.c:fuzz_scratch_file Unexecuted instantiation: parse.c:fuzz_scratch_file Unexecuted instantiation: sockets.c:fuzz_scratch_file Unexecuted instantiation: sprintf.c:fuzz_scratch_file Unexecuted instantiation: eval.c:fuzz_scratch_file Line | Count | Source | 783 | 2 | { | 784 | 2 | const char *tmpdir = getenv("TMPDIR"); | 785 | 2 | if (tmpdir == NULL || *tmpdir == '\0') | 786 | 2 | tmpdir = "/tmp"; | 787 | | | 788 | 2 | char *path = malloc(PATH_MAX); | 789 | 2 | if (path == NULL) | 790 | 0 | return NULL; | 791 | 2 | snprintf(path, PATH_MAX, "%s/fuzz-%s-XXXXXX", tmpdir, name); | 792 | | | 793 | 2 | int fd = mkstemp(path); | 794 | 2 | if (fd < 0) { | 795 | 0 | free(path); | 796 | 0 | return NULL; | 797 | 0 | } | 798 | 2 | close(fd); | 799 | 2 | return path; | 800 | 2 | } |
|
801 | | |
802 | | /* Replace the scratch file's contents. Returns FALSE on any I/O error so |
803 | | * the iteration can be skipped rather than fuzzing a stale file. */ |
804 | | static Rboolean fuzz_write_scratch(const char *path, const uint8_t *data, |
805 | | size_t size) |
806 | 16.8k | { |
807 | 16.8k | FILE *fp = fopen(path, "wb"); |
808 | 16.8k | if (fp == NULL) |
809 | 0 | return FALSE; |
810 | | |
811 | 16.8k | size_t written = size > 0 ? fwrite(data, 1, size, fp) : 0; |
812 | 16.8k | int rc = fclose(fp); |
813 | 16.8k | return written == size && rc == 0; |
814 | 16.8k | } Unexecuted instantiation: io.c:fuzz_write_scratch Unexecuted instantiation: dcf.c:fuzz_write_scratch Unexecuted instantiation: character.c:fuzz_write_scratch Unexecuted instantiation: encoding.c:fuzz_write_scratch Unexecuted instantiation: sort.c:fuzz_write_scratch connections.c:fuzz_write_scratch Line | Count | Source | 806 | 5.97k | { | 807 | 5.97k | FILE *fp = fopen(path, "wb"); | 808 | 5.97k | if (fp == NULL) | 809 | 0 | return FALSE; | 810 | | | 811 | 5.97k | size_t written = size > 0 ? fwrite(data, 1, size, fp) : 0; | 812 | 5.97k | int rc = fclose(fp); | 813 | 5.97k | return written == size && rc == 0; | 814 | 5.97k | } |
Unexecuted instantiation: unserialize.c:fuzz_write_scratch Unexecuted instantiation: decompress.c:fuzz_write_scratch Unexecuted instantiation: readtable.c:fuzz_write_scratch Unexecuted instantiation: format.c:fuzz_write_scratch Unexecuted instantiation: datetime.c:fuzz_write_scratch Unexecuted instantiation: coerce.c:fuzz_write_scratch load.c:fuzz_write_scratch Line | Count | Source | 806 | 8.49k | { | 807 | 8.49k | FILE *fp = fopen(path, "wb"); | 808 | 8.49k | if (fp == NULL) | 809 | 0 | return FALSE; | 810 | | | 811 | 8.49k | size_t written = size > 0 ? fwrite(data, 1, size, fp) : 0; | 812 | 8.49k | int rc = fclose(fp); | 813 | 8.49k | return written == size && rc == 0; | 814 | 8.49k | } |
Unexecuted instantiation: scan.c:fuzz_write_scratch Unexecuted instantiation: colors.c:fuzz_write_scratch Unexecuted instantiation: parse.c:fuzz_write_scratch Unexecuted instantiation: sockets.c:fuzz_write_scratch Unexecuted instantiation: sprintf.c:fuzz_write_scratch Unexecuted instantiation: eval.c:fuzz_write_scratch Line | Count | Source | 806 | 2.33k | { | 807 | 2.33k | FILE *fp = fopen(path, "wb"); | 808 | 2.33k | if (fp == NULL) | 809 | 0 | return FALSE; | 810 | | | 811 | 2.33k | size_t written = size > 0 ? fwrite(data, 1, size, fp) : 0; | 812 | 2.33k | int rc = fclose(fp); | 813 | 2.33k | return written == size && rc == 0; | 814 | 2.33k | } |
|
815 | | |
816 | | /* |
817 | | * Guard against TRE's bounded-repeat blowup. |
818 | | * |
819 | | * TRE compiles bounded repeats by duplicating the pattern AST, so nested |
820 | | * counted repeats multiply: a 36-byte pattern like |
821 | | * (?:a{2,101,})(?:a{2,101,}){100}{100} expands to ~10^8 nodes and >8GB of |
822 | | * allocations at compile time. Those allocations are malloc, not R's |
823 | | * vector heap, so R_MAX_VSIZE cannot bound them; reject the pattern |
824 | | * before it reaches R instead. |
825 | | * |
826 | | * The product of all repeat bounds is a deliberate over-estimate -- |
827 | | * sequential (non-nested) repeats add rather than multiply -- trading a |
828 | | * little coverage of repeat-heavy patterns for a hard bound on compile |
829 | | * cost. |
830 | | */ |
831 | 758 | #define FUZZ_MAX_REPEAT_PRODUCT 1000000.0 |
832 | | |
833 | | static int fuzz_repeat_product_excessive(const char *pattern) |
834 | 338 | { |
835 | 338 | double product = 1.0; |
836 | | |
837 | 42.4k | for (const char *p = pattern; *p != '\0'; p++) { |
838 | 42.0k | if (*p != '{') |
839 | 40.4k | continue; |
840 | | |
841 | | /* The largest number inside the braces bounds this repeat. */ |
842 | 1.65k | unsigned long bound = 0, cur = 0; |
843 | 1.65k | int counted = 0; |
844 | 1.65k | const char *q = p + 1; |
845 | 5.68k | for (; *q != '\0' && *q != '}'; q++) { |
846 | 4.78k | if (*q >= '0' && *q <= '9') { |
847 | 2.93k | cur = cur * 10 + (unsigned long)(*q - '0'); |
848 | 2.93k | if (cur > 10000000) |
849 | 419 | cur = 10000000; /* saturate; already over any budget */ |
850 | 2.93k | counted = 1; |
851 | 2.93k | } else if (*q == ',') { |
852 | 1.09k | if (cur > bound) |
853 | 403 | bound = cur; |
854 | 1.09k | cur = 0; |
855 | 1.09k | } else { |
856 | 751 | counted = 0; /* not a counted repeat, e.g. "{a}" */ |
857 | 751 | break; |
858 | 751 | } |
859 | 4.78k | } |
860 | 1.65k | if (!counted || *q != '}') |
861 | 900 | continue; |
862 | | |
863 | 758 | if (cur > bound) |
864 | 306 | bound = cur; |
865 | 758 | if (bound > 1) |
866 | 265 | product *= (double)bound; |
867 | 758 | if (product > FUZZ_MAX_REPEAT_PRODUCT) |
868 | 17 | return 1; |
869 | | |
870 | 741 | p = q; |
871 | 741 | } |
872 | | |
873 | 321 | return 0; |
874 | 338 | } Unexecuted instantiation: io.c:fuzz_repeat_product_excessive Unexecuted instantiation: dcf.c:fuzz_repeat_product_excessive character.c:fuzz_repeat_product_excessive Line | Count | Source | 834 | 338 | { | 835 | 338 | double product = 1.0; | 836 | | | 837 | 42.4k | for (const char *p = pattern; *p != '\0'; p++) { | 838 | 42.0k | if (*p != '{') | 839 | 40.4k | continue; | 840 | | | 841 | | /* The largest number inside the braces bounds this repeat. */ | 842 | 1.65k | unsigned long bound = 0, cur = 0; | 843 | 1.65k | int counted = 0; | 844 | 1.65k | const char *q = p + 1; | 845 | 5.68k | for (; *q != '\0' && *q != '}'; q++) { | 846 | 4.78k | if (*q >= '0' && *q <= '9') { | 847 | 2.93k | cur = cur * 10 + (unsigned long)(*q - '0'); | 848 | 2.93k | if (cur > 10000000) | 849 | 419 | cur = 10000000; /* saturate; already over any budget */ | 850 | 2.93k | counted = 1; | 851 | 2.93k | } else if (*q == ',') { | 852 | 1.09k | if (cur > bound) | 853 | 403 | bound = cur; | 854 | 1.09k | cur = 0; | 855 | 1.09k | } else { | 856 | 751 | counted = 0; /* not a counted repeat, e.g. "{a}" */ | 857 | 751 | break; | 858 | 751 | } | 859 | 4.78k | } | 860 | 1.65k | if (!counted || *q != '}') | 861 | 900 | continue; | 862 | | | 863 | 758 | if (cur > bound) | 864 | 306 | bound = cur; | 865 | 758 | if (bound > 1) | 866 | 265 | product *= (double)bound; | 867 | 758 | if (product > FUZZ_MAX_REPEAT_PRODUCT) | 868 | 17 | return 1; | 869 | | | 870 | 741 | p = q; | 871 | 741 | } | 872 | | | 873 | 321 | return 0; | 874 | 338 | } |
Unexecuted instantiation: encoding.c:fuzz_repeat_product_excessive Unexecuted instantiation: sort.c:fuzz_repeat_product_excessive Unexecuted instantiation: connections.c:fuzz_repeat_product_excessive Unexecuted instantiation: unserialize.c:fuzz_repeat_product_excessive Unexecuted instantiation: decompress.c:fuzz_repeat_product_excessive Unexecuted instantiation: readtable.c:fuzz_repeat_product_excessive Unexecuted instantiation: format.c:fuzz_repeat_product_excessive Unexecuted instantiation: datetime.c:fuzz_repeat_product_excessive Unexecuted instantiation: coerce.c:fuzz_repeat_product_excessive Unexecuted instantiation: load.c:fuzz_repeat_product_excessive Unexecuted instantiation: scan.c:fuzz_repeat_product_excessive Unexecuted instantiation: colors.c:fuzz_repeat_product_excessive Unexecuted instantiation: parse.c:fuzz_repeat_product_excessive Unexecuted instantiation: sockets.c:fuzz_repeat_product_excessive Unexecuted instantiation: sprintf.c:fuzz_repeat_product_excessive Unexecuted instantiation: eval.c:fuzz_repeat_product_excessive Unexecuted instantiation: zip.c:fuzz_repeat_product_excessive |
875 | | |
876 | | /* |
877 | | * libFuzzer entry points. |
878 | | * |
879 | | * A harness defines fuzz_target_init and fuzz_target_run with the |
880 | | * LLVMFuzzerInitialize / LLVMFuzzerTestOneInput signatures; these run |
881 | | * them on the R thread, one condition-variable handoff each way per input. |
882 | | */ |
883 | | int fuzz_target_init(int *argc, char ***argv); |
884 | | int fuzz_target_run(const uint8_t *data, size_t size); |
885 | | |
886 | | typedef struct { |
887 | | int *argc; |
888 | | char ***argv; |
889 | | int result; |
890 | | } fuzz_init_job_t; |
891 | | |
892 | | static void fuzz_do_target_init(void *data) |
893 | 39 | { |
894 | 39 | fuzz_init_job_t *job = data; |
895 | 39 | job->result = fuzz_target_init(job->argc, job->argv); |
896 | 39 | } Line | Count | Source | 893 | 2 | { | 894 | 2 | fuzz_init_job_t *job = data; | 895 | 2 | job->result = fuzz_target_init(job->argc, job->argv); | 896 | 2 | } |
dcf.c:fuzz_do_target_init Line | Count | Source | 893 | 2 | { | 894 | 2 | fuzz_init_job_t *job = data; | 895 | 2 | job->result = fuzz_target_init(job->argc, job->argv); | 896 | 2 | } |
character.c:fuzz_do_target_init Line | Count | Source | 893 | 2 | { | 894 | 2 | fuzz_init_job_t *job = data; | 895 | 2 | job->result = fuzz_target_init(job->argc, job->argv); | 896 | 2 | } |
encoding.c:fuzz_do_target_init Line | Count | Source | 893 | 2 | { | 894 | 2 | fuzz_init_job_t *job = data; | 895 | 2 | job->result = fuzz_target_init(job->argc, job->argv); | 896 | 2 | } |
sort.c:fuzz_do_target_init Line | Count | Source | 893 | 2 | { | 894 | 2 | fuzz_init_job_t *job = data; | 895 | 2 | job->result = fuzz_target_init(job->argc, job->argv); | 896 | 2 | } |
connections.c:fuzz_do_target_init Line | Count | Source | 893 | 2 | { | 894 | 2 | fuzz_init_job_t *job = data; | 895 | 2 | job->result = fuzz_target_init(job->argc, job->argv); | 896 | 2 | } |
unserialize.c:fuzz_do_target_init Line | Count | Source | 893 | 2 | { | 894 | 2 | fuzz_init_job_t *job = data; | 895 | 2 | job->result = fuzz_target_init(job->argc, job->argv); | 896 | 2 | } |
decompress.c:fuzz_do_target_init Line | Count | Source | 893 | 2 | { | 894 | 2 | fuzz_init_job_t *job = data; | 895 | 2 | job->result = fuzz_target_init(job->argc, job->argv); | 896 | 2 | } |
readtable.c:fuzz_do_target_init Line | Count | Source | 893 | 2 | { | 894 | 2 | fuzz_init_job_t *job = data; | 895 | 2 | job->result = fuzz_target_init(job->argc, job->argv); | 896 | 2 | } |
format.c:fuzz_do_target_init Line | Count | Source | 893 | 2 | { | 894 | 2 | fuzz_init_job_t *job = data; | 895 | 2 | job->result = fuzz_target_init(job->argc, job->argv); | 896 | 2 | } |
datetime.c:fuzz_do_target_init Line | Count | Source | 893 | 2 | { | 894 | 2 | fuzz_init_job_t *job = data; | 895 | 2 | job->result = fuzz_target_init(job->argc, job->argv); | 896 | 2 | } |
coerce.c:fuzz_do_target_init Line | Count | Source | 893 | 2 | { | 894 | 2 | fuzz_init_job_t *job = data; | 895 | 2 | job->result = fuzz_target_init(job->argc, job->argv); | 896 | 2 | } |
load.c:fuzz_do_target_init Line | Count | Source | 893 | 2 | { | 894 | 2 | fuzz_init_job_t *job = data; | 895 | 2 | job->result = fuzz_target_init(job->argc, job->argv); | 896 | 2 | } |
scan.c:fuzz_do_target_init Line | Count | Source | 893 | 2 | { | 894 | 2 | fuzz_init_job_t *job = data; | 895 | 2 | job->result = fuzz_target_init(job->argc, job->argv); | 896 | 2 | } |
colors.c:fuzz_do_target_init Line | Count | Source | 893 | 2 | { | 894 | 2 | fuzz_init_job_t *job = data; | 895 | 2 | job->result = fuzz_target_init(job->argc, job->argv); | 896 | 2 | } |
parse.c:fuzz_do_target_init Line | Count | Source | 893 | 2 | { | 894 | 2 | fuzz_init_job_t *job = data; | 895 | 2 | job->result = fuzz_target_init(job->argc, job->argv); | 896 | 2 | } |
sockets.c:fuzz_do_target_init Line | Count | Source | 893 | 1 | { | 894 | 1 | fuzz_init_job_t *job = data; | 895 | 1 | job->result = fuzz_target_init(job->argc, job->argv); | 896 | 1 | } |
sprintf.c:fuzz_do_target_init Line | Count | Source | 893 | 2 | { | 894 | 2 | fuzz_init_job_t *job = data; | 895 | 2 | job->result = fuzz_target_init(job->argc, job->argv); | 896 | 2 | } |
eval.c:fuzz_do_target_init Line | Count | Source | 893 | 2 | { | 894 | 2 | fuzz_init_job_t *job = data; | 895 | 2 | job->result = fuzz_target_init(job->argc, job->argv); | 896 | 2 | } |
zip.c:fuzz_do_target_init Line | Count | Source | 893 | 2 | { | 894 | 2 | fuzz_init_job_t *job = data; | 895 | 2 | job->result = fuzz_target_init(job->argc, job->argv); | 896 | 2 | } |
|
897 | | |
898 | | typedef struct { |
899 | | const uint8_t *data; |
900 | | size_t size; |
901 | | int result; |
902 | | } fuzz_run_job_t; |
903 | | |
904 | | static void fuzz_do_target_run(void *data) |
905 | 90.8k | { |
906 | 90.8k | fuzz_run_job_t *job = data; |
907 | 90.8k | atomic_store(&fuzz_label_current, -1); |
908 | 90.8k | job->result = fuzz_target_run(job->data, job->size); |
909 | 90.8k | atomic_store(&fuzz_label_current, -1); |
910 | 90.8k | } Line | Count | Source | 905 | 1.50k | { | 906 | 1.50k | fuzz_run_job_t *job = data; | 907 | 1.50k | atomic_store(&fuzz_label_current, -1); | 908 | 1.50k | job->result = fuzz_target_run(job->data, job->size); | 909 | | atomic_store(&fuzz_label_current, -1); | 910 | 1.50k | } |
Line | Count | Source | 905 | 5.00k | { | 906 | 5.00k | fuzz_run_job_t *job = data; | 907 | 5.00k | atomic_store(&fuzz_label_current, -1); | 908 | 5.00k | job->result = fuzz_target_run(job->data, job->size); | 909 | | atomic_store(&fuzz_label_current, -1); | 910 | 5.00k | } |
character.c:fuzz_do_target_run Line | Count | Source | 905 | 4.46k | { | 906 | 4.46k | fuzz_run_job_t *job = data; | 907 | 4.46k | atomic_store(&fuzz_label_current, -1); | 908 | 4.46k | job->result = fuzz_target_run(job->data, job->size); | 909 | | atomic_store(&fuzz_label_current, -1); | 910 | 4.46k | } |
encoding.c:fuzz_do_target_run Line | Count | Source | 905 | 1.75k | { | 906 | 1.75k | fuzz_run_job_t *job = data; | 907 | 1.75k | atomic_store(&fuzz_label_current, -1); | 908 | 1.75k | job->result = fuzz_target_run(job->data, job->size); | 909 | | atomic_store(&fuzz_label_current, -1); | 910 | 1.75k | } |
sort.c:fuzz_do_target_run Line | Count | Source | 905 | 6.75k | { | 906 | 6.75k | fuzz_run_job_t *job = data; | 907 | 6.75k | atomic_store(&fuzz_label_current, -1); | 908 | 6.75k | job->result = fuzz_target_run(job->data, job->size); | 909 | | atomic_store(&fuzz_label_current, -1); | 910 | 6.75k | } |
connections.c:fuzz_do_target_run Line | Count | Source | 905 | 5.98k | { | 906 | 5.98k | fuzz_run_job_t *job = data; | 907 | 5.98k | atomic_store(&fuzz_label_current, -1); | 908 | 5.98k | job->result = fuzz_target_run(job->data, job->size); | 909 | | atomic_store(&fuzz_label_current, -1); | 910 | 5.98k | } |
unserialize.c:fuzz_do_target_run Line | Count | Source | 905 | 5.61k | { | 906 | 5.61k | fuzz_run_job_t *job = data; | 907 | 5.61k | atomic_store(&fuzz_label_current, -1); | 908 | 5.61k | job->result = fuzz_target_run(job->data, job->size); | 909 | | atomic_store(&fuzz_label_current, -1); | 910 | 5.61k | } |
decompress.c:fuzz_do_target_run Line | Count | Source | 905 | 6.75k | { | 906 | 6.75k | fuzz_run_job_t *job = data; | 907 | 6.75k | atomic_store(&fuzz_label_current, -1); | 908 | 6.75k | job->result = fuzz_target_run(job->data, job->size); | 909 | | atomic_store(&fuzz_label_current, -1); | 910 | 6.75k | } |
readtable.c:fuzz_do_target_run Line | Count | Source | 905 | 346 | { | 906 | 346 | fuzz_run_job_t *job = data; | 907 | 346 | atomic_store(&fuzz_label_current, -1); | 908 | 346 | job->result = fuzz_target_run(job->data, job->size); | 909 | | atomic_store(&fuzz_label_current, -1); | 910 | 346 | } |
format.c:fuzz_do_target_run Line | Count | Source | 905 | 5.53k | { | 906 | 5.53k | fuzz_run_job_t *job = data; | 907 | 5.53k | atomic_store(&fuzz_label_current, -1); | 908 | 5.53k | job->result = fuzz_target_run(job->data, job->size); | 909 | | atomic_store(&fuzz_label_current, -1); | 910 | 5.53k | } |
datetime.c:fuzz_do_target_run Line | Count | Source | 905 | 6.95k | { | 906 | 6.95k | fuzz_run_job_t *job = data; | 907 | 6.95k | atomic_store(&fuzz_label_current, -1); | 908 | 6.95k | job->result = fuzz_target_run(job->data, job->size); | 909 | | atomic_store(&fuzz_label_current, -1); | 910 | 6.95k | } |
coerce.c:fuzz_do_target_run Line | Count | Source | 905 | 1.89k | { | 906 | 1.89k | fuzz_run_job_t *job = data; | 907 | 1.89k | atomic_store(&fuzz_label_current, -1); | 908 | 1.89k | job->result = fuzz_target_run(job->data, job->size); | 909 | | atomic_store(&fuzz_label_current, -1); | 910 | 1.89k | } |
load.c:fuzz_do_target_run Line | Count | Source | 905 | 8.50k | { | 906 | 8.50k | fuzz_run_job_t *job = data; | 907 | 8.50k | atomic_store(&fuzz_label_current, -1); | 908 | 8.50k | job->result = fuzz_target_run(job->data, job->size); | 909 | | atomic_store(&fuzz_label_current, -1); | 910 | 8.50k | } |
scan.c:fuzz_do_target_run Line | Count | Source | 905 | 3.13k | { | 906 | 3.13k | fuzz_run_job_t *job = data; | 907 | 3.13k | atomic_store(&fuzz_label_current, -1); | 908 | 3.13k | job->result = fuzz_target_run(job->data, job->size); | 909 | | atomic_store(&fuzz_label_current, -1); | 910 | 3.13k | } |
colors.c:fuzz_do_target_run Line | Count | Source | 905 | 1.85k | { | 906 | 1.85k | fuzz_run_job_t *job = data; | 907 | 1.85k | atomic_store(&fuzz_label_current, -1); | 908 | 1.85k | job->result = fuzz_target_run(job->data, job->size); | 909 | | atomic_store(&fuzz_label_current, -1); | 910 | 1.85k | } |
parse.c:fuzz_do_target_run Line | Count | Source | 905 | 8.04k | { | 906 | 8.04k | fuzz_run_job_t *job = data; | 907 | 8.04k | atomic_store(&fuzz_label_current, -1); | 908 | 8.04k | job->result = fuzz_target_run(job->data, job->size); | 909 | | atomic_store(&fuzz_label_current, -1); | 910 | 8.04k | } |
Unexecuted instantiation: sockets.c:fuzz_do_target_run sprintf.c:fuzz_do_target_run Line | Count | Source | 905 | 2.20k | { | 906 | 2.20k | fuzz_run_job_t *job = data; | 907 | 2.20k | atomic_store(&fuzz_label_current, -1); | 908 | 2.20k | job->result = fuzz_target_run(job->data, job->size); | 909 | | atomic_store(&fuzz_label_current, -1); | 910 | 2.20k | } |
eval.c:fuzz_do_target_run Line | Count | Source | 905 | 12.1k | { | 906 | 12.1k | fuzz_run_job_t *job = data; | 907 | 12.1k | atomic_store(&fuzz_label_current, -1); | 908 | 12.1k | job->result = fuzz_target_run(job->data, job->size); | 909 | | atomic_store(&fuzz_label_current, -1); | 910 | 12.1k | } |
Line | Count | Source | 905 | 2.34k | { | 906 | 2.34k | fuzz_run_job_t *job = data; | 907 | 2.34k | atomic_store(&fuzz_label_current, -1); | 908 | 2.34k | job->result = fuzz_target_run(job->data, job->size); | 909 | | atomic_store(&fuzz_label_current, -1); | 910 | 2.34k | } |
|
911 | | |
912 | | int LLVMFuzzerInitialize(int *argc, char ***argv) |
913 | 39 | { |
914 | | /* libFuzzer parses this itself; the alarm wrapper needs the value. */ |
915 | 214 | for (int i = 1; i < *argc; i++) { |
916 | 175 | const char *arg = (*argv)[i]; |
917 | 175 | if (strncmp(arg, "-timeout=", 9) == 0) |
918 | 39 | fuzz_alarm.timeout = atoi(arg + 9); |
919 | 175 | } |
920 | | |
921 | 39 | fuzz_init_job_t job = { argc, argv, 0 }; |
922 | 39 | fuzz_run_on_r_thread(fuzz_do_target_init, &job); |
923 | 39 | return job.result; |
924 | 39 | } |
925 | | |
926 | | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) |
927 | 90.8k | { |
928 | 90.8k | fuzz_alarm_wrap(); |
929 | | |
930 | 90.8k | fuzz_run_job_t job = { data, size, 0 }; |
931 | 90.8k | fuzz_run_on_r_thread(fuzz_do_target_run, &job); |
932 | 90.8k | return job.result; |
933 | 90.8k | } |
934 | | |
935 | | #endif /* FUZZ_COMMON_H */ |