Coverage Report

Created: 2026-11-30 07:09

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/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
48
{
54
48
    int error = 0;
55
48
    SEXP warn_call;
56
48
    Rf_protect(warn_call = Rf_lang2(Rf_install("options"),
57
48
                                    Rf_ScalarInteger(-1)));
58
48
    SET_TAG(CDR(warn_call), Rf_install("warn"));
59
48
    R_tryEval(warn_call, R_GlobalEnv, &error);
60
48
    Rf_unprotect(1);
61
48
}
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
}
formula.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
}
grep.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
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
}
rd.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
}
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
}
nmath.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
48
{
72
    /* Skip if R_HOME is already set (e.g., for local testing) */
73
48
    if (getenv("R_HOME") != NULL)
74
24
        return;
75
76
24
    char exe[PATH_MAX];
77
24
    ssize_t len = readlink("/proc/self/exe", exe, sizeof(exe) - 1);
78
24
    if (len <= 0)
79
0
        return;
80
24
    exe[len] = '\0';
81
82
    /* Find the directory containing the binary */
83
24
    char *slash = strrchr(exe, '/');
84
24
    if (slash == NULL)
85
0
        return;
86
24
    *slash = '\0';
87
88
24
    char r_home[PATH_MAX];
89
24
    snprintf(r_home, sizeof(r_home), "%s/r-install/lib/R", exe);
90
24
    setenv("R_HOME", r_home, 1);
91
24
}
io.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
}
dcf.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
}
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
}
sort.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
}
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
}
formula.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
}
format.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
}
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
}
coerce.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
}
load.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
}
scan.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
}
colors.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
}
grep.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
}
parse.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
}
sockets.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
}
rd.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
}
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
}
eval.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
}
zip.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
}
nmath.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
}
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, load 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
21
# define FUZZ_R_MAX_VSIZE "1Gb"
132
#endif
133
134
static void fuzz_set_vsize_limit(void)
135
48
{
136
48
    if (getenv("R_MAX_VSIZE") == NULL)
137
24
        setenv("R_MAX_VSIZE", FUZZ_R_MAX_VSIZE, 1);
138
48
}
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
}
formula.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
}
grep.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
2
{
136
2
    if (getenv("R_MAX_VSIZE") == NULL)
137
1
        setenv("R_MAX_VSIZE", FUZZ_R_MAX_VSIZE, 1);
138
2
}
rd.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
}
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
}
nmath.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
 * Strict barrier's thread check would reject that new thread wherever
171
 * it gets a new pthread_t; instrumentation/0008 lets it in.
172
 */
173
#ifndef FUZZ_R_STACK_SIZE
174
48
# define FUZZ_R_STACK_SIZE ((size_t)1 << 30)
175
#endif
176
177
/*
178
 * R_CheckStack()'s limit, far below the stack it guards.  When an R error
179
 * longjmps out of more than 64 MiB of stack, ASAN does not unpoison the
180
 * frames it abandons -- a fixed cap in __asan_handle_no_return, which
181
 * says "ASan is ignoring requested __asan_handle_no_return" -- and the
182
 * next code to reuse that stack trips over their stale redzones: a
183
 * stack-buffer-overflow in whatever runs after the error, with no bug
184
 * behind it.  R's check is what ends recursion that goes through C
185
 * (UseMethod dispatch, the AST interpreter, deparse through the poll of
186
 * instrumentation/0005), and R handles the overflow error with another
187
 * 5% of stack, so a limit of 48 MiB keeps those errors inside ASAN's
188
 * cleanup.  The walkers that never check still have the whole stack.
189
 */
190
#ifndef FUZZ_R_CSTACK_LIMIT
191
48
# define FUZZ_R_CSTACK_LIMIT ((uintptr_t)48 << 20)
192
#endif
193
194
typedef struct {
195
    void (*fn)(void *);
196
    void *arg;
197
} fuzz_job_t;
198
199
static struct {
200
    pthread_t thread;
201
    int started;
202
    pthread_mutex_t mutex;
203
    pthread_cond_t cond;
204
    fuzz_job_t *job;        /* set by the caller, cleared by the thread */
205
    uintptr_t stack_top;    /* where the thread's frames begin */
206
} fuzz_r_thread = {
207
    .mutex = PTHREAD_MUTEX_INITIALIZER,
208
    .cond = PTHREAD_COND_INITIALIZER
209
};
210
211
/*
212
 * Timeout diagnostics.
213
 *
214
 * With the alarm confined to the main thread, libFuzzer's timeout report
215
 * would show that thread waiting in fuzz_run_on_r_thread and nothing of
216
 * where R is.  So once libFuzzer has installed its SIGALRM handler, a
217
 * wrapper takes its place: on a tick where libFuzzer may time the input
218
 * out, it first signals the R thread, which prints its own stack, and
219
 * then hands the alarm on to libFuzzer, which prints its report and
220
 * exits.  The wrapper goes in after libFuzzer's startup because libFuzzer
221
 * leaves an already-installed SIGALRM handler alone.
222
 *
223
 * libFuzzer's clock for the input is not visible, but it is bracketed:
224
 * it starts after the main thread last went idle (armed) and before the
225
 * R thread took the input (started).  Every tick (timeout/2+1 s apart)
226
 * comes through here.  One that finds the input within a second of the
227
 * timeout by the armed clock, so possibly out of time by libFuzzer's
228
 * after whatever delays this handler, holds until the input is out of
229
 * time by the started clock too, which means by libFuzzer's as well;
230
 * then the dump is requested and waited for, and the tick goes on to
231
 * libFuzzer, which reports the timeout.  A tick that finds the input
232
 * younger goes straight on, and only one delayed by over a second
233
 * between reading the armed clock and libFuzzer reading its own can
234
 * still leave a timeout without its dump.  The dump pauses the R
235
 * thread, so it is taken only for an input already out of time, never
236
 * for one that may still finish.
237
 *
238
 * An input that finishes while a tick is held is not handed to libFuzzer
239
 * at all, nor is any tick that queued up meanwhile: it finished within
240
 * its time by its own clock, and the hold would be blamed for it.  Inputs
241
 * are numbered so a dump outstanding from one cannot stand in for the
242
 * next's, and the R thread itself announces when an input is running, so
243
 * a tick during the handoff finds nothing to dump.
244
 */
245
#ifdef SIGRTMIN
246
24
# define FUZZ_DUMP_SIGNAL SIGRTMIN   /* untouched by libFuzzer, glibc and R */
247
#else
248
# define FUZZ_DUMP_SIGNAL SIGUSR2    /* macOS: displaces libFuzzer's graceful exit */
249
#endif
250
251
extern void __sanitizer_print_stack_trace(void) __attribute__((weak));
252
253
static struct {
254
    int timeout;                 /* -timeout=N, seconds */
255
    long poll_ns;                /* between looks while holding or waiting */
256
    int wrapped;
257
    struct sigaction chain;      /* libFuzzer's SIGALRM action */
258
    struct timespec armed;       /* main thread idle; libFuzzer's clock starts later */
259
    struct timespec started;     /* the R thread took the input; libFuzzer's clock started earlier */
260
    atomic_int running;          /* the R thread is inside an input */
261
    atomic_int finishing;        /* a held tick saw the input finish */
262
    atomic_uint input;           /* numbers the inputs from 1; 0 is none */
263
    atomic_uint requested;       /* input whose dump was requested */
264
    atomic_uint done;            /* input whose dump has been printed */
265
} fuzz_alarm = { .timeout = 1200, .poll_ns = 1000 * 1000 };  /* libFuzzer's default */
266
267
static void fuzz_write_stderr(const char *s)
268
0
{
269
0
    ssize_t rc = write(STDERR_FILENO, s, strlen(s));
270
0
    (void)rc;
271
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: formula.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: grep.c:fuzz_write_stderr
Unexecuted instantiation: parse.c:fuzz_write_stderr
Unexecuted instantiation: sockets.c:fuzz_write_stderr
Unexecuted instantiation: rd.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
Unexecuted instantiation: nmath.c:fuzz_write_stderr
272
273
/*
274
 * Slot labels for the timeout dump.
275
 *
276
 * The R thread's stack is mostly the byte-code interpreter, which says
277
 * little about which of a target's calls was running.  A harness
278
 * registers its calls once with fuzz_label_calls(), which deparses each
279
 * while its placeholders still hold their initial values, and the dump
280
 * prints the one last entered by fuzz_eval_silent() or fuzz_do_eval() in
281
 * the current input.  Harnesses that evaluate a registered call another
282
 * way note it with fuzz_label_enter().  The text is formatted up front,
283
 * so the dump handler only writes it.
284
 */
285
646
#define FUZZ_MAX_LABELS 128
286
4.61k
#define FUZZ_LABEL_MAX 4096
287
288
static struct {
289
    SEXP call;
290
    char *text;
291
} fuzz_labels[FUZZ_MAX_LABELS];
292
static int fuzz_n_labels;
293
static atomic_int fuzz_label_current = -1;  /* index into fuzz_labels */
294
295
typedef struct {
296
    SEXP call;
297
    char *buf;      /* FUZZ_LABEL_MAX bytes, holding the header */
298
    size_t len;
299
} fuzz_deparse_job_t;
300
301
/* Append one deparsed line, indented; false if it does not fit with
302
 * room left for the closing "...". */
303
static int fuzz_label_append_line(fuzz_deparse_job_t *job, const char *line)
304
3.31k
{
305
3.31k
    size_t n = strlen(line);
306
3.31k
    if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof "    ...\n")
307
0
        return 0;
308
3.31k
    memcpy(job->buf + job->len, "    ", 4);
309
3.31k
    memcpy(job->buf + job->len + 4, line, n);
310
3.31k
    job->buf[job->len + 4 + n] = '\n';
311
3.31k
    job->len += 4 + n + 1;
312
3.31k
    job->buf[job->len] = '\0';
313
3.31k
    return 1;
314
3.31k
}
io.c:fuzz_label_append_line
Line
Count
Source
304
130
{
305
130
    size_t n = strlen(line);
306
130
    if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof "    ...\n")
307
0
        return 0;
308
130
    memcpy(job->buf + job->len, "    ", 4);
309
130
    memcpy(job->buf + job->len + 4, line, n);
310
130
    job->buf[job->len + 4 + n] = '\n';
311
130
    job->len += 4 + n + 1;
312
130
    job->buf[job->len] = '\0';
313
130
    return 1;
314
130
}
dcf.c:fuzz_label_append_line
Line
Count
Source
304
24
{
305
24
    size_t n = strlen(line);
306
24
    if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof "    ...\n")
307
0
        return 0;
308
24
    memcpy(job->buf + job->len, "    ", 4);
309
24
    memcpy(job->buf + job->len + 4, line, n);
310
24
    job->buf[job->len + 4 + n] = '\n';
311
24
    job->len += 4 + n + 1;
312
24
    job->buf[job->len] = '\0';
313
24
    return 1;
314
24
}
character.c:fuzz_label_append_line
Line
Count
Source
304
68
{
305
68
    size_t n = strlen(line);
306
68
    if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof "    ...\n")
307
0
        return 0;
308
68
    memcpy(job->buf + job->len, "    ", 4);
309
68
    memcpy(job->buf + job->len + 4, line, n);
310
68
    job->buf[job->len + 4 + n] = '\n';
311
68
    job->len += 4 + n + 1;
312
68
    job->buf[job->len] = '\0';
313
68
    return 1;
314
68
}
encoding.c:fuzz_label_append_line
Line
Count
Source
304
70
{
305
70
    size_t n = strlen(line);
306
70
    if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof "    ...\n")
307
0
        return 0;
308
70
    memcpy(job->buf + job->len, "    ", 4);
309
70
    memcpy(job->buf + job->len + 4, line, n);
310
70
    job->buf[job->len + 4 + n] = '\n';
311
70
    job->len += 4 + n + 1;
312
70
    job->buf[job->len] = '\0';
313
70
    return 1;
314
70
}
sort.c:fuzz_label_append_line
Line
Count
Source
304
360
{
305
360
    size_t n = strlen(line);
306
360
    if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof "    ...\n")
307
0
        return 0;
308
360
    memcpy(job->buf + job->len, "    ", 4);
309
360
    memcpy(job->buf + job->len + 4, line, n);
310
360
    job->buf[job->len + 4 + n] = '\n';
311
360
    job->len += 4 + n + 1;
312
360
    job->buf[job->len] = '\0';
313
360
    return 1;
314
360
}
connections.c:fuzz_label_append_line
Line
Count
Source
304
1.01k
{
305
1.01k
    size_t n = strlen(line);
306
1.01k
    if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof "    ...\n")
307
0
        return 0;
308
1.01k
    memcpy(job->buf + job->len, "    ", 4);
309
1.01k
    memcpy(job->buf + job->len + 4, line, n);
310
1.01k
    job->buf[job->len + 4 + n] = '\n';
311
1.01k
    job->len += 4 + n + 1;
312
1.01k
    job->buf[job->len] = '\0';
313
1.01k
    return 1;
314
1.01k
}
unserialize.c:fuzz_label_append_line
Line
Count
Source
304
40
{
305
40
    size_t n = strlen(line);
306
40
    if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof "    ...\n")
307
0
        return 0;
308
40
    memcpy(job->buf + job->len, "    ", 4);
309
40
    memcpy(job->buf + job->len + 4, line, n);
310
40
    job->buf[job->len + 4 + n] = '\n';
311
40
    job->len += 4 + n + 1;
312
40
    job->buf[job->len] = '\0';
313
40
    return 1;
314
40
}
formula.c:fuzz_label_append_line
Line
Count
Source
304
252
{
305
252
    size_t n = strlen(line);
306
252
    if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof "    ...\n")
307
0
        return 0;
308
252
    memcpy(job->buf + job->len, "    ", 4);
309
252
    memcpy(job->buf + job->len + 4, line, n);
310
252
    job->buf[job->len + 4 + n] = '\n';
311
252
    job->len += 4 + n + 1;
312
252
    job->buf[job->len] = '\0';
313
252
    return 1;
314
252
}
decompress.c:fuzz_label_append_line
Line
Count
Source
304
8
{
305
8
    size_t n = strlen(line);
306
8
    if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof "    ...\n")
307
0
        return 0;
308
8
    memcpy(job->buf + job->len, "    ", 4);
309
8
    memcpy(job->buf + job->len + 4, line, n);
310
8
    job->buf[job->len + 4 + n] = '\n';
311
8
    job->len += 4 + n + 1;
312
8
    job->buf[job->len] = '\0';
313
8
    return 1;
314
8
}
readtable.c:fuzz_label_append_line
Line
Count
Source
304
146
{
305
146
    size_t n = strlen(line);
306
146
    if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof "    ...\n")
307
0
        return 0;
308
146
    memcpy(job->buf + job->len, "    ", 4);
309
146
    memcpy(job->buf + job->len + 4, line, n);
310
146
    job->buf[job->len + 4 + n] = '\n';
311
146
    job->len += 4 + n + 1;
312
146
    job->buf[job->len] = '\0';
313
146
    return 1;
314
146
}
format.c:fuzz_label_append_line
Line
Count
Source
304
408
{
305
408
    size_t n = strlen(line);
306
408
    if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof "    ...\n")
307
0
        return 0;
308
408
    memcpy(job->buf + job->len, "    ", 4);
309
408
    memcpy(job->buf + job->len + 4, line, n);
310
408
    job->buf[job->len + 4 + n] = '\n';
311
408
    job->len += 4 + n + 1;
312
408
    job->buf[job->len] = '\0';
313
408
    return 1;
314
408
}
datetime.c:fuzz_label_append_line
Line
Count
Source
304
82
{
305
82
    size_t n = strlen(line);
306
82
    if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof "    ...\n")
307
0
        return 0;
308
82
    memcpy(job->buf + job->len, "    ", 4);
309
82
    memcpy(job->buf + job->len + 4, line, n);
310
82
    job->buf[job->len + 4 + n] = '\n';
311
82
    job->len += 4 + n + 1;
312
82
    job->buf[job->len] = '\0';
313
82
    return 1;
314
82
}
coerce.c:fuzz_label_append_line
Line
Count
Source
304
8
{
305
8
    size_t n = strlen(line);
306
8
    if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof "    ...\n")
307
0
        return 0;
308
8
    memcpy(job->buf + job->len, "    ", 4);
309
8
    memcpy(job->buf + job->len + 4, line, n);
310
8
    job->buf[job->len + 4 + n] = '\n';
311
8
    job->len += 4 + n + 1;
312
8
    job->buf[job->len] = '\0';
313
8
    return 1;
314
8
}
load.c:fuzz_label_append_line
Line
Count
Source
304
8
{
305
8
    size_t n = strlen(line);
306
8
    if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof "    ...\n")
307
0
        return 0;
308
8
    memcpy(job->buf + job->len, "    ", 4);
309
8
    memcpy(job->buf + job->len + 4, line, n);
310
8
    job->buf[job->len + 4 + n] = '\n';
311
8
    job->len += 4 + n + 1;
312
8
    job->buf[job->len] = '\0';
313
8
    return 1;
314
8
}
scan.c:fuzz_label_append_line
Line
Count
Source
304
76
{
305
76
    size_t n = strlen(line);
306
76
    if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof "    ...\n")
307
0
        return 0;
308
76
    memcpy(job->buf + job->len, "    ", 4);
309
76
    memcpy(job->buf + job->len + 4, line, n);
310
76
    job->buf[job->len + 4 + n] = '\n';
311
76
    job->len += 4 + n + 1;
312
76
    job->buf[job->len] = '\0';
313
76
    return 1;
314
76
}
colors.c:fuzz_label_append_line
Line
Count
Source
304
226
{
305
226
    size_t n = strlen(line);
306
226
    if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof "    ...\n")
307
0
        return 0;
308
226
    memcpy(job->buf + job->len, "    ", 4);
309
226
    memcpy(job->buf + job->len + 4, line, n);
310
226
    job->buf[job->len + 4 + n] = '\n';
311
226
    job->len += 4 + n + 1;
312
226
    job->buf[job->len] = '\0';
313
226
    return 1;
314
226
}
grep.c:fuzz_label_append_line
Line
Count
Source
304
128
{
305
128
    size_t n = strlen(line);
306
128
    if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof "    ...\n")
307
0
        return 0;
308
128
    memcpy(job->buf + job->len, "    ", 4);
309
128
    memcpy(job->buf + job->len + 4, line, n);
310
128
    job->buf[job->len + 4 + n] = '\n';
311
128
    job->len += 4 + n + 1;
312
128
    job->buf[job->len] = '\0';
313
128
    return 1;
314
128
}
parse.c:fuzz_label_append_line
Line
Count
Source
304
64
{
305
64
    size_t n = strlen(line);
306
64
    if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof "    ...\n")
307
0
        return 0;
308
64
    memcpy(job->buf + job->len, "    ", 4);
309
64
    memcpy(job->buf + job->len + 4, line, n);
310
64
    job->buf[job->len + 4 + n] = '\n';
311
64
    job->len += 4 + n + 1;
312
64
    job->buf[job->len] = '\0';
313
64
    return 1;
314
64
}
sockets.c:fuzz_label_append_line
Line
Count
Source
304
26
{
305
26
    size_t n = strlen(line);
306
26
    if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof "    ...\n")
307
0
        return 0;
308
26
    memcpy(job->buf + job->len, "    ", 4);
309
26
    memcpy(job->buf + job->len + 4, line, n);
310
26
    job->buf[job->len + 4 + n] = '\n';
311
26
    job->len += 4 + n + 1;
312
26
    job->buf[job->len] = '\0';
313
26
    return 1;
314
26
}
rd.c:fuzz_label_append_line
Line
Count
Source
304
24
{
305
24
    size_t n = strlen(line);
306
24
    if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof "    ...\n")
307
0
        return 0;
308
24
    memcpy(job->buf + job->len, "    ", 4);
309
24
    memcpy(job->buf + job->len + 4, line, n);
310
24
    job->buf[job->len + 4 + n] = '\n';
311
24
    job->len += 4 + n + 1;
312
24
    job->buf[job->len] = '\0';
313
24
    return 1;
314
24
}
sprintf.c:fuzz_label_append_line
Line
Count
Source
304
8
{
305
8
    size_t n = strlen(line);
306
8
    if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof "    ...\n")
307
0
        return 0;
308
8
    memcpy(job->buf + job->len, "    ", 4);
309
8
    memcpy(job->buf + job->len + 4, line, n);
310
8
    job->buf[job->len + 4 + n] = '\n';
311
8
    job->len += 4 + n + 1;
312
8
    job->buf[job->len] = '\0';
313
8
    return 1;
314
8
}
Unexecuted instantiation: eval.c:fuzz_label_append_line
zip.c:fuzz_label_append_line
Line
Count
Source
304
60
{
305
60
    size_t n = strlen(line);
306
60
    if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof "    ...\n")
307
0
        return 0;
308
60
    memcpy(job->buf + job->len, "    ", 4);
309
60
    memcpy(job->buf + job->len + 4, line, n);
310
60
    job->buf[job->len + 4 + n] = '\n';
311
60
    job->len += 4 + n + 1;
312
60
    job->buf[job->len] = '\0';
313
60
    return 1;
314
60
}
nmath.c:fuzz_label_append_line
Line
Count
Source
304
86
{
305
86
    size_t n = strlen(line);
306
86
    if (job->len + 4 + n + 1 >= FUZZ_LABEL_MAX - sizeof "    ...\n")
307
0
        return 0;
308
86
    memcpy(job->buf + job->len, "    ", 4);
309
86
    memcpy(job->buf + job->len + 4, line, n);
310
86
    job->buf[job->len + 4 + n] = '\n';
311
86
    job->len += 4 + n + 1;
312
86
    job->buf[job->len] = '\0';
313
86
    return 1;
314
86
}
315
316
static void fuzz_do_deparse(void *data)
317
646
{
318
646
    fuzz_deparse_job_t *job = data;
319
646
    SEXP quoted, expr, lines;
320
646
    Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call));
321
646
    Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted));
322
646
    Rf_protect(lines = Rf_eval(expr, R_BaseEnv));
323
3.96k
    for (R_xlen_t i = 0; i < XLENGTH(lines); i++) {
324
3.31k
        if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) {
325
0
            memcpy(job->buf + job->len, "    ...\n", sizeof "    ...\n");
326
0
            break;
327
0
        }
328
3.31k
    }
329
646
    Rf_unprotect(3);
330
646
}
io.c:fuzz_do_deparse
Line
Count
Source
317
52
{
318
52
    fuzz_deparse_job_t *job = data;
319
52
    SEXP quoted, expr, lines;
320
52
    Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call));
321
52
    Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted));
322
52
    Rf_protect(lines = Rf_eval(expr, R_BaseEnv));
323
182
    for (R_xlen_t i = 0; i < XLENGTH(lines); i++) {
324
130
        if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) {
325
0
            memcpy(job->buf + job->len, "    ...\n", sizeof "    ...\n");
326
0
            break;
327
0
        }
328
130
    }
329
52
    Rf_unprotect(3);
330
52
}
dcf.c:fuzz_do_deparse
Line
Count
Source
317
4
{
318
4
    fuzz_deparse_job_t *job = data;
319
4
    SEXP quoted, expr, lines;
320
4
    Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call));
321
4
    Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted));
322
4
    Rf_protect(lines = Rf_eval(expr, R_BaseEnv));
323
28
    for (R_xlen_t i = 0; i < XLENGTH(lines); i++) {
324
24
        if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) {
325
0
            memcpy(job->buf + job->len, "    ...\n", sizeof "    ...\n");
326
0
            break;
327
0
        }
328
24
    }
329
4
    Rf_unprotect(3);
330
4
}
character.c:fuzz_do_deparse
Line
Count
Source
317
68
{
318
68
    fuzz_deparse_job_t *job = data;
319
68
    SEXP quoted, expr, lines;
320
68
    Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call));
321
68
    Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted));
322
68
    Rf_protect(lines = Rf_eval(expr, R_BaseEnv));
323
136
    for (R_xlen_t i = 0; i < XLENGTH(lines); i++) {
324
68
        if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) {
325
0
            memcpy(job->buf + job->len, "    ...\n", sizeof "    ...\n");
326
0
            break;
327
0
        }
328
68
    }
329
68
    Rf_unprotect(3);
330
68
}
encoding.c:fuzz_do_deparse
Line
Count
Source
317
56
{
318
56
    fuzz_deparse_job_t *job = data;
319
56
    SEXP quoted, expr, lines;
320
56
    Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call));
321
56
    Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted));
322
56
    Rf_protect(lines = Rf_eval(expr, R_BaseEnv));
323
126
    for (R_xlen_t i = 0; i < XLENGTH(lines); i++) {
324
70
        if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) {
325
0
            memcpy(job->buf + job->len, "    ...\n", sizeof "    ...\n");
326
0
            break;
327
0
        }
328
70
    }
329
56
    Rf_unprotect(3);
330
56
}
sort.c:fuzz_do_deparse
Line
Count
Source
317
44
{
318
44
    fuzz_deparse_job_t *job = data;
319
44
    SEXP quoted, expr, lines;
320
44
    Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call));
321
44
    Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted));
322
44
    Rf_protect(lines = Rf_eval(expr, R_BaseEnv));
323
404
    for (R_xlen_t i = 0; i < XLENGTH(lines); i++) {
324
360
        if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) {
325
0
            memcpy(job->buf + job->len, "    ...\n", sizeof "    ...\n");
326
0
            break;
327
0
        }
328
360
    }
329
44
    Rf_unprotect(3);
330
44
}
connections.c:fuzz_do_deparse
Line
Count
Source
317
132
{
318
132
    fuzz_deparse_job_t *job = data;
319
132
    SEXP quoted, expr, lines;
320
132
    Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call));
321
132
    Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted));
322
132
    Rf_protect(lines = Rf_eval(expr, R_BaseEnv));
323
1.14k
    for (R_xlen_t i = 0; i < XLENGTH(lines); i++) {
324
1.01k
        if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) {
325
0
            memcpy(job->buf + job->len, "    ...\n", sizeof "    ...\n");
326
0
            break;
327
0
        }
328
1.01k
    }
329
132
    Rf_unprotect(3);
330
132
}
unserialize.c:fuzz_do_deparse
Line
Count
Source
317
8
{
318
8
    fuzz_deparse_job_t *job = data;
319
8
    SEXP quoted, expr, lines;
320
8
    Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call));
321
8
    Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted));
322
8
    Rf_protect(lines = Rf_eval(expr, R_BaseEnv));
323
48
    for (R_xlen_t i = 0; i < XLENGTH(lines); i++) {
324
40
        if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) {
325
0
            memcpy(job->buf + job->len, "    ...\n", sizeof "    ...\n");
326
0
            break;
327
0
        }
328
40
    }
329
8
    Rf_unprotect(3);
330
8
}
formula.c:fuzz_do_deparse
Line
Count
Source
317
8
{
318
8
    fuzz_deparse_job_t *job = data;
319
8
    SEXP quoted, expr, lines;
320
8
    Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call));
321
8
    Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted));
322
8
    Rf_protect(lines = Rf_eval(expr, R_BaseEnv));
323
260
    for (R_xlen_t i = 0; i < XLENGTH(lines); i++) {
324
252
        if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) {
325
0
            memcpy(job->buf + job->len, "    ...\n", sizeof "    ...\n");
326
0
            break;
327
0
        }
328
252
    }
329
8
    Rf_unprotect(3);
330
8
}
decompress.c:fuzz_do_deparse
Line
Count
Source
317
8
{
318
8
    fuzz_deparse_job_t *job = data;
319
8
    SEXP quoted, expr, lines;
320
8
    Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call));
321
8
    Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted));
322
8
    Rf_protect(lines = Rf_eval(expr, R_BaseEnv));
323
16
    for (R_xlen_t i = 0; i < XLENGTH(lines); i++) {
324
8
        if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) {
325
0
            memcpy(job->buf + job->len, "    ...\n", sizeof "    ...\n");
326
0
            break;
327
0
        }
328
8
    }
329
8
    Rf_unprotect(3);
330
8
}
readtable.c:fuzz_do_deparse
Line
Count
Source
317
40
{
318
40
    fuzz_deparse_job_t *job = data;
319
40
    SEXP quoted, expr, lines;
320
40
    Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call));
321
40
    Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted));
322
40
    Rf_protect(lines = Rf_eval(expr, R_BaseEnv));
323
186
    for (R_xlen_t i = 0; i < XLENGTH(lines); i++) {
324
146
        if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) {
325
0
            memcpy(job->buf + job->len, "    ...\n", sizeof "    ...\n");
326
0
            break;
327
0
        }
328
146
    }
329
40
    Rf_unprotect(3);
330
40
}
format.c:fuzz_do_deparse
Line
Count
Source
317
48
{
318
48
    fuzz_deparse_job_t *job = data;
319
48
    SEXP quoted, expr, lines;
320
48
    Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call));
321
48
    Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted));
322
48
    Rf_protect(lines = Rf_eval(expr, R_BaseEnv));
323
456
    for (R_xlen_t i = 0; i < XLENGTH(lines); i++) {
324
408
        if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) {
325
0
            memcpy(job->buf + job->len, "    ...\n", sizeof "    ...\n");
326
0
            break;
327
0
        }
328
408
    }
329
48
    Rf_unprotect(3);
330
48
}
datetime.c:fuzz_do_deparse
Line
Count
Source
317
30
{
318
30
    fuzz_deparse_job_t *job = data;
319
30
    SEXP quoted, expr, lines;
320
30
    Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call));
321
30
    Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted));
322
30
    Rf_protect(lines = Rf_eval(expr, R_BaseEnv));
323
112
    for (R_xlen_t i = 0; i < XLENGTH(lines); i++) {
324
82
        if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) {
325
0
            memcpy(job->buf + job->len, "    ...\n", sizeof "    ...\n");
326
0
            break;
327
0
        }
328
82
    }
329
30
    Rf_unprotect(3);
330
30
}
coerce.c:fuzz_do_deparse
Line
Count
Source
317
8
{
318
8
    fuzz_deparse_job_t *job = data;
319
8
    SEXP quoted, expr, lines;
320
8
    Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call));
321
8
    Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted));
322
8
    Rf_protect(lines = Rf_eval(expr, R_BaseEnv));
323
16
    for (R_xlen_t i = 0; i < XLENGTH(lines); i++) {
324
8
        if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) {
325
0
            memcpy(job->buf + job->len, "    ...\n", sizeof "    ...\n");
326
0
            break;
327
0
        }
328
8
    }
329
8
    Rf_unprotect(3);
330
8
}
load.c:fuzz_do_deparse
Line
Count
Source
317
4
{
318
4
    fuzz_deparse_job_t *job = data;
319
4
    SEXP quoted, expr, lines;
320
4
    Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call));
321
4
    Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted));
322
4
    Rf_protect(lines = Rf_eval(expr, R_BaseEnv));
323
12
    for (R_xlen_t i = 0; i < XLENGTH(lines); i++) {
324
8
        if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) {
325
0
            memcpy(job->buf + job->len, "    ...\n", sizeof "    ...\n");
326
0
            break;
327
0
        }
328
8
    }
329
4
    Rf_unprotect(3);
330
4
}
scan.c:fuzz_do_deparse
Line
Count
Source
317
36
{
318
36
    fuzz_deparse_job_t *job = data;
319
36
    SEXP quoted, expr, lines;
320
36
    Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call));
321
36
    Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted));
322
36
    Rf_protect(lines = Rf_eval(expr, R_BaseEnv));
323
112
    for (R_xlen_t i = 0; i < XLENGTH(lines); i++) {
324
76
        if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) {
325
0
            memcpy(job->buf + job->len, "    ...\n", sizeof "    ...\n");
326
0
            break;
327
0
        }
328
76
    }
329
36
    Rf_unprotect(3);
330
36
}
colors.c:fuzz_do_deparse
Line
Count
Source
317
32
{
318
32
    fuzz_deparse_job_t *job = data;
319
32
    SEXP quoted, expr, lines;
320
32
    Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call));
321
32
    Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted));
322
32
    Rf_protect(lines = Rf_eval(expr, R_BaseEnv));
323
258
    for (R_xlen_t i = 0; i < XLENGTH(lines); i++) {
324
226
        if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) {
325
0
            memcpy(job->buf + job->len, "    ...\n", sizeof "    ...\n");
326
0
            break;
327
0
        }
328
226
    }
329
32
    Rf_unprotect(3);
330
32
}
grep.c:fuzz_do_deparse
Line
Count
Source
317
32
{
318
32
    fuzz_deparse_job_t *job = data;
319
32
    SEXP quoted, expr, lines;
320
32
    Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call));
321
32
    Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted));
322
32
    Rf_protect(lines = Rf_eval(expr, R_BaseEnv));
323
160
    for (R_xlen_t i = 0; i < XLENGTH(lines); i++) {
324
128
        if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) {
325
0
            memcpy(job->buf + job->len, "    ...\n", sizeof "    ...\n");
326
0
            break;
327
0
        }
328
128
    }
329
32
    Rf_unprotect(3);
330
32
}
parse.c:fuzz_do_deparse
Line
Count
Source
317
12
{
318
12
    fuzz_deparse_job_t *job = data;
319
12
    SEXP quoted, expr, lines;
320
12
    Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call));
321
12
    Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted));
322
12
    Rf_protect(lines = Rf_eval(expr, R_BaseEnv));
323
76
    for (R_xlen_t i = 0; i < XLENGTH(lines); i++) {
324
64
        if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) {
325
0
            memcpy(job->buf + job->len, "    ...\n", sizeof "    ...\n");
326
0
            break;
327
0
        }
328
64
    }
329
12
    Rf_unprotect(3);
330
12
}
sockets.c:fuzz_do_deparse
Line
Count
Source
317
2
{
318
2
    fuzz_deparse_job_t *job = data;
319
2
    SEXP quoted, expr, lines;
320
2
    Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call));
321
2
    Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted));
322
2
    Rf_protect(lines = Rf_eval(expr, R_BaseEnv));
323
28
    for (R_xlen_t i = 0; i < XLENGTH(lines); i++) {
324
26
        if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) {
325
0
            memcpy(job->buf + job->len, "    ...\n", sizeof "    ...\n");
326
0
            break;
327
0
        }
328
26
    }
329
2
    Rf_unprotect(3);
330
2
}
rd.c:fuzz_do_deparse
Line
Count
Source
317
4
{
318
4
    fuzz_deparse_job_t *job = data;
319
4
    SEXP quoted, expr, lines;
320
4
    Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call));
321
4
    Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted));
322
4
    Rf_protect(lines = Rf_eval(expr, R_BaseEnv));
323
28
    for (R_xlen_t i = 0; i < XLENGTH(lines); i++) {
324
24
        if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) {
325
0
            memcpy(job->buf + job->len, "    ...\n", sizeof "    ...\n");
326
0
            break;
327
0
        }
328
24
    }
329
4
    Rf_unprotect(3);
330
4
}
sprintf.c:fuzz_do_deparse
Line
Count
Source
317
8
{
318
8
    fuzz_deparse_job_t *job = data;
319
8
    SEXP quoted, expr, lines;
320
8
    Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call));
321
8
    Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted));
322
8
    Rf_protect(lines = Rf_eval(expr, R_BaseEnv));
323
16
    for (R_xlen_t i = 0; i < XLENGTH(lines); i++) {
324
8
        if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) {
325
0
            memcpy(job->buf + job->len, "    ...\n", sizeof "    ...\n");
326
0
            break;
327
0
        }
328
8
    }
329
8
    Rf_unprotect(3);
330
8
}
Unexecuted instantiation: eval.c:fuzz_do_deparse
zip.c:fuzz_do_deparse
Line
Count
Source
317
8
{
318
8
    fuzz_deparse_job_t *job = data;
319
8
    SEXP quoted, expr, lines;
320
8
    Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call));
321
8
    Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted));
322
8
    Rf_protect(lines = Rf_eval(expr, R_BaseEnv));
323
68
    for (R_xlen_t i = 0; i < XLENGTH(lines); i++) {
324
60
        if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) {
325
0
            memcpy(job->buf + job->len, "    ...\n", sizeof "    ...\n");
326
0
            break;
327
0
        }
328
60
    }
329
8
    Rf_unprotect(3);
330
8
}
nmath.c:fuzz_do_deparse
Line
Count
Source
317
2
{
318
2
    fuzz_deparse_job_t *job = data;
319
2
    SEXP quoted, expr, lines;
320
2
    Rf_protect(quoted = Rf_lang2(R_QuoteSymbol, job->call));
321
2
    Rf_protect(expr = Rf_lang2(Rf_install("deparse"), quoted));
322
2
    Rf_protect(lines = Rf_eval(expr, R_BaseEnv));
323
88
    for (R_xlen_t i = 0; i < XLENGTH(lines); i++) {
324
86
        if (!fuzz_label_append_line(job, CHAR(STRING_ELT(lines, i)))) {
325
0
            memcpy(job->buf + job->len, "    ...\n", sizeof "    ...\n");
326
0
            break;
327
0
        }
328
86
    }
329
2
    Rf_unprotect(3);
330
2
}
331
332
static void fuzz_label_call(SEXP call, int slot, int n_slots)
333
652
{
334
652
    if (call == NULL || call == R_NilValue)
335
2
        return;
336
337
    /* A call shared by several slots (run under different settings, say)
338
     * keeps one label naming them all. */
339
10.0k
    for (int i = 0; i < fuzz_n_labels; i++) {
340
9.35k
        if (fuzz_labels[i].call != call)
341
9.35k
            continue;
342
4
        char *old = fuzz_labels[i].text;
343
4
        char *of = strstr(old, " of ");  /* "==fuzz== slot 7 of 9:" */
344
4
        size_t size = strlen(old) + 32;
345
4
        char *buf = malloc(size);
346
4
        if (of == NULL || buf == NULL) {
347
0
            free(buf);
348
0
            return;
349
0
        }
350
4
        snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of);
351
4
        fuzz_labels[i].text = buf;
352
4
        free(old);
353
4
        return;
354
4
    }
355
646
    if (fuzz_n_labels == FUZZ_MAX_LABELS)
356
0
        return;
357
358
646
    char *buf = malloc(FUZZ_LABEL_MAX);
359
646
    if (buf == NULL)
360
0
        return;
361
646
    int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots);
362
363
    /* A failed deparse leaves the header alone. */
364
646
    fuzz_deparse_job_t job = { call, buf, (size_t)n };
365
646
    R_ToplevelExec(fuzz_do_deparse, &job);
366
367
646
    fuzz_labels[fuzz_n_labels].call = call;
368
646
    fuzz_labels[fuzz_n_labels].text = buf;
369
646
    fuzz_n_labels++;
370
646
}
io.c:fuzz_label_call
Line
Count
Source
333
52
{
334
52
    if (call == NULL || call == R_NilValue)
335
0
        return;
336
337
    /* A call shared by several slots (run under different settings, say)
338
     * keeps one label naming them all. */
339
702
    for (int i = 0; i < fuzz_n_labels; i++) {
340
650
        if (fuzz_labels[i].call != call)
341
650
            continue;
342
0
        char *old = fuzz_labels[i].text;
343
0
        char *of = strstr(old, " of ");  /* "==fuzz== slot 7 of 9:" */
344
0
        size_t size = strlen(old) + 32;
345
0
        char *buf = malloc(size);
346
0
        if (of == NULL || buf == NULL) {
347
0
            free(buf);
348
0
            return;
349
0
        }
350
0
        snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of);
351
0
        fuzz_labels[i].text = buf;
352
0
        free(old);
353
0
        return;
354
0
    }
355
52
    if (fuzz_n_labels == FUZZ_MAX_LABELS)
356
0
        return;
357
358
52
    char *buf = malloc(FUZZ_LABEL_MAX);
359
52
    if (buf == NULL)
360
0
        return;
361
52
    int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots);
362
363
    /* A failed deparse leaves the header alone. */
364
52
    fuzz_deparse_job_t job = { call, buf, (size_t)n };
365
52
    R_ToplevelExec(fuzz_do_deparse, &job);
366
367
52
    fuzz_labels[fuzz_n_labels].call = call;
368
52
    fuzz_labels[fuzz_n_labels].text = buf;
369
52
    fuzz_n_labels++;
370
52
}
dcf.c:fuzz_label_call
Line
Count
Source
333
4
{
334
4
    if (call == NULL || call == R_NilValue)
335
0
        return;
336
337
    /* A call shared by several slots (run under different settings, say)
338
     * keeps one label naming them all. */
339
6
    for (int i = 0; i < fuzz_n_labels; i++) {
340
2
        if (fuzz_labels[i].call != call)
341
2
            continue;
342
0
        char *old = fuzz_labels[i].text;
343
0
        char *of = strstr(old, " of ");  /* "==fuzz== slot 7 of 9:" */
344
0
        size_t size = strlen(old) + 32;
345
0
        char *buf = malloc(size);
346
0
        if (of == NULL || buf == NULL) {
347
0
            free(buf);
348
0
            return;
349
0
        }
350
0
        snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of);
351
0
        fuzz_labels[i].text = buf;
352
0
        free(old);
353
0
        return;
354
0
    }
355
4
    if (fuzz_n_labels == FUZZ_MAX_LABELS)
356
0
        return;
357
358
4
    char *buf = malloc(FUZZ_LABEL_MAX);
359
4
    if (buf == NULL)
360
0
        return;
361
4
    int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots);
362
363
    /* A failed deparse leaves the header alone. */
364
4
    fuzz_deparse_job_t job = { call, buf, (size_t)n };
365
4
    R_ToplevelExec(fuzz_do_deparse, &job);
366
367
4
    fuzz_labels[fuzz_n_labels].call = call;
368
4
    fuzz_labels[fuzz_n_labels].text = buf;
369
4
    fuzz_n_labels++;
370
4
}
character.c:fuzz_label_call
Line
Count
Source
333
68
{
334
68
    if (call == NULL || call == R_NilValue)
335
0
        return;
336
337
    /* A call shared by several slots (run under different settings, say)
338
     * keeps one label naming them all. */
339
1.19k
    for (int i = 0; i < fuzz_n_labels; i++) {
340
1.12k
        if (fuzz_labels[i].call != call)
341
1.12k
            continue;
342
0
        char *old = fuzz_labels[i].text;
343
0
        char *of = strstr(old, " of ");  /* "==fuzz== slot 7 of 9:" */
344
0
        size_t size = strlen(old) + 32;
345
0
        char *buf = malloc(size);
346
0
        if (of == NULL || buf == NULL) {
347
0
            free(buf);
348
0
            return;
349
0
        }
350
0
        snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of);
351
0
        fuzz_labels[i].text = buf;
352
0
        free(old);
353
0
        return;
354
0
    }
355
68
    if (fuzz_n_labels == FUZZ_MAX_LABELS)
356
0
        return;
357
358
68
    char *buf = malloc(FUZZ_LABEL_MAX);
359
68
    if (buf == NULL)
360
0
        return;
361
68
    int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots);
362
363
    /* A failed deparse leaves the header alone. */
364
68
    fuzz_deparse_job_t job = { call, buf, (size_t)n };
365
68
    R_ToplevelExec(fuzz_do_deparse, &job);
366
367
68
    fuzz_labels[fuzz_n_labels].call = call;
368
68
    fuzz_labels[fuzz_n_labels].text = buf;
369
68
    fuzz_n_labels++;
370
68
}
encoding.c:fuzz_label_call
Line
Count
Source
333
56
{
334
56
    if (call == NULL || call == R_NilValue)
335
0
        return;
336
337
    /* A call shared by several slots (run under different settings, say)
338
     * keeps one label naming them all. */
339
812
    for (int i = 0; i < fuzz_n_labels; i++) {
340
756
        if (fuzz_labels[i].call != call)
341
756
            continue;
342
0
        char *old = fuzz_labels[i].text;
343
0
        char *of = strstr(old, " of ");  /* "==fuzz== slot 7 of 9:" */
344
0
        size_t size = strlen(old) + 32;
345
0
        char *buf = malloc(size);
346
0
        if (of == NULL || buf == NULL) {
347
0
            free(buf);
348
0
            return;
349
0
        }
350
0
        snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of);
351
0
        fuzz_labels[i].text = buf;
352
0
        free(old);
353
0
        return;
354
0
    }
355
56
    if (fuzz_n_labels == FUZZ_MAX_LABELS)
356
0
        return;
357
358
56
    char *buf = malloc(FUZZ_LABEL_MAX);
359
56
    if (buf == NULL)
360
0
        return;
361
56
    int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots);
362
363
    /* A failed deparse leaves the header alone. */
364
56
    fuzz_deparse_job_t job = { call, buf, (size_t)n };
365
56
    R_ToplevelExec(fuzz_do_deparse, &job);
366
367
56
    fuzz_labels[fuzz_n_labels].call = call;
368
56
    fuzz_labels[fuzz_n_labels].text = buf;
369
56
    fuzz_n_labels++;
370
56
}
sort.c:fuzz_label_call
Line
Count
Source
333
44
{
334
44
    if (call == NULL || call == R_NilValue)
335
0
        return;
336
337
    /* A call shared by several slots (run under different settings, say)
338
     * keeps one label naming them all. */
339
506
    for (int i = 0; i < fuzz_n_labels; i++) {
340
462
        if (fuzz_labels[i].call != call)
341
462
            continue;
342
0
        char *old = fuzz_labels[i].text;
343
0
        char *of = strstr(old, " of ");  /* "==fuzz== slot 7 of 9:" */
344
0
        size_t size = strlen(old) + 32;
345
0
        char *buf = malloc(size);
346
0
        if (of == NULL || buf == NULL) {
347
0
            free(buf);
348
0
            return;
349
0
        }
350
0
        snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of);
351
0
        fuzz_labels[i].text = buf;
352
0
        free(old);
353
0
        return;
354
0
    }
355
44
    if (fuzz_n_labels == FUZZ_MAX_LABELS)
356
0
        return;
357
358
44
    char *buf = malloc(FUZZ_LABEL_MAX);
359
44
    if (buf == NULL)
360
0
        return;
361
44
    int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots);
362
363
    /* A failed deparse leaves the header alone. */
364
44
    fuzz_deparse_job_t job = { call, buf, (size_t)n };
365
44
    R_ToplevelExec(fuzz_do_deparse, &job);
366
367
44
    fuzz_labels[fuzz_n_labels].call = call;
368
44
    fuzz_labels[fuzz_n_labels].text = buf;
369
44
    fuzz_n_labels++;
370
44
}
connections.c:fuzz_label_call
Line
Count
Source
333
132
{
334
132
    if (call == NULL || call == R_NilValue)
335
0
        return;
336
337
    /* A call shared by several slots (run under different settings, say)
338
     * keeps one label naming them all. */
339
4.42k
    for (int i = 0; i < fuzz_n_labels; i++) {
340
4.29k
        if (fuzz_labels[i].call != call)
341
4.29k
            continue;
342
0
        char *old = fuzz_labels[i].text;
343
0
        char *of = strstr(old, " of ");  /* "==fuzz== slot 7 of 9:" */
344
0
        size_t size = strlen(old) + 32;
345
0
        char *buf = malloc(size);
346
0
        if (of == NULL || buf == NULL) {
347
0
            free(buf);
348
0
            return;
349
0
        }
350
0
        snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of);
351
0
        fuzz_labels[i].text = buf;
352
0
        free(old);
353
0
        return;
354
0
    }
355
132
    if (fuzz_n_labels == FUZZ_MAX_LABELS)
356
0
        return;
357
358
132
    char *buf = malloc(FUZZ_LABEL_MAX);
359
132
    if (buf == NULL)
360
0
        return;
361
132
    int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots);
362
363
    /* A failed deparse leaves the header alone. */
364
132
    fuzz_deparse_job_t job = { call, buf, (size_t)n };
365
132
    R_ToplevelExec(fuzz_do_deparse, &job);
366
367
132
    fuzz_labels[fuzz_n_labels].call = call;
368
132
    fuzz_labels[fuzz_n_labels].text = buf;
369
132
    fuzz_n_labels++;
370
132
}
unserialize.c:fuzz_label_call
Line
Count
Source
333
8
{
334
8
    if (call == NULL || call == R_NilValue)
335
0
        return;
336
337
    /* A call shared by several slots (run under different settings, say)
338
     * keeps one label naming them all. */
339
20
    for (int i = 0; i < fuzz_n_labels; i++) {
340
12
        if (fuzz_labels[i].call != call)
341
12
            continue;
342
0
        char *old = fuzz_labels[i].text;
343
0
        char *of = strstr(old, " of ");  /* "==fuzz== slot 7 of 9:" */
344
0
        size_t size = strlen(old) + 32;
345
0
        char *buf = malloc(size);
346
0
        if (of == NULL || buf == NULL) {
347
0
            free(buf);
348
0
            return;
349
0
        }
350
0
        snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of);
351
0
        fuzz_labels[i].text = buf;
352
0
        free(old);
353
0
        return;
354
0
    }
355
8
    if (fuzz_n_labels == FUZZ_MAX_LABELS)
356
0
        return;
357
358
8
    char *buf = malloc(FUZZ_LABEL_MAX);
359
8
    if (buf == NULL)
360
0
        return;
361
8
    int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots);
362
363
    /* A failed deparse leaves the header alone. */
364
8
    fuzz_deparse_job_t job = { call, buf, (size_t)n };
365
8
    R_ToplevelExec(fuzz_do_deparse, &job);
366
367
8
    fuzz_labels[fuzz_n_labels].call = call;
368
8
    fuzz_labels[fuzz_n_labels].text = buf;
369
8
    fuzz_n_labels++;
370
8
}
formula.c:fuzz_label_call
Line
Count
Source
333
8
{
334
8
    if (call == NULL || call == R_NilValue)
335
0
        return;
336
337
    /* A call shared by several slots (run under different settings, say)
338
     * keeps one label naming them all. */
339
20
    for (int i = 0; i < fuzz_n_labels; i++) {
340
12
        if (fuzz_labels[i].call != call)
341
12
            continue;
342
0
        char *old = fuzz_labels[i].text;
343
0
        char *of = strstr(old, " of ");  /* "==fuzz== slot 7 of 9:" */
344
0
        size_t size = strlen(old) + 32;
345
0
        char *buf = malloc(size);
346
0
        if (of == NULL || buf == NULL) {
347
0
            free(buf);
348
0
            return;
349
0
        }
350
0
        snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of);
351
0
        fuzz_labels[i].text = buf;
352
0
        free(old);
353
0
        return;
354
0
    }
355
8
    if (fuzz_n_labels == FUZZ_MAX_LABELS)
356
0
        return;
357
358
8
    char *buf = malloc(FUZZ_LABEL_MAX);
359
8
    if (buf == NULL)
360
0
        return;
361
8
    int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots);
362
363
    /* A failed deparse leaves the header alone. */
364
8
    fuzz_deparse_job_t job = { call, buf, (size_t)n };
365
8
    R_ToplevelExec(fuzz_do_deparse, &job);
366
367
8
    fuzz_labels[fuzz_n_labels].call = call;
368
8
    fuzz_labels[fuzz_n_labels].text = buf;
369
8
    fuzz_n_labels++;
370
8
}
decompress.c:fuzz_label_call
Line
Count
Source
333
8
{
334
8
    if (call == NULL || call == R_NilValue)
335
0
        return;
336
337
    /* A call shared by several slots (run under different settings, say)
338
     * keeps one label naming them all. */
339
20
    for (int i = 0; i < fuzz_n_labels; i++) {
340
12
        if (fuzz_labels[i].call != call)
341
12
            continue;
342
0
        char *old = fuzz_labels[i].text;
343
0
        char *of = strstr(old, " of ");  /* "==fuzz== slot 7 of 9:" */
344
0
        size_t size = strlen(old) + 32;
345
0
        char *buf = malloc(size);
346
0
        if (of == NULL || buf == NULL) {
347
0
            free(buf);
348
0
            return;
349
0
        }
350
0
        snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of);
351
0
        fuzz_labels[i].text = buf;
352
0
        free(old);
353
0
        return;
354
0
    }
355
8
    if (fuzz_n_labels == FUZZ_MAX_LABELS)
356
0
        return;
357
358
8
    char *buf = malloc(FUZZ_LABEL_MAX);
359
8
    if (buf == NULL)
360
0
        return;
361
8
    int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots);
362
363
    /* A failed deparse leaves the header alone. */
364
8
    fuzz_deparse_job_t job = { call, buf, (size_t)n };
365
8
    R_ToplevelExec(fuzz_do_deparse, &job);
366
367
8
    fuzz_labels[fuzz_n_labels].call = call;
368
8
    fuzz_labels[fuzz_n_labels].text = buf;
369
8
    fuzz_n_labels++;
370
8
}
readtable.c:fuzz_label_call
Line
Count
Source
333
40
{
334
40
    if (call == NULL || call == R_NilValue)
335
0
        return;
336
337
    /* A call shared by several slots (run under different settings, say)
338
     * keeps one label naming them all. */
339
420
    for (int i = 0; i < fuzz_n_labels; i++) {
340
380
        if (fuzz_labels[i].call != call)
341
380
            continue;
342
0
        char *old = fuzz_labels[i].text;
343
0
        char *of = strstr(old, " of ");  /* "==fuzz== slot 7 of 9:" */
344
0
        size_t size = strlen(old) + 32;
345
0
        char *buf = malloc(size);
346
0
        if (of == NULL || buf == NULL) {
347
0
            free(buf);
348
0
            return;
349
0
        }
350
0
        snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of);
351
0
        fuzz_labels[i].text = buf;
352
0
        free(old);
353
0
        return;
354
0
    }
355
40
    if (fuzz_n_labels == FUZZ_MAX_LABELS)
356
0
        return;
357
358
40
    char *buf = malloc(FUZZ_LABEL_MAX);
359
40
    if (buf == NULL)
360
0
        return;
361
40
    int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots);
362
363
    /* A failed deparse leaves the header alone. */
364
40
    fuzz_deparse_job_t job = { call, buf, (size_t)n };
365
40
    R_ToplevelExec(fuzz_do_deparse, &job);
366
367
40
    fuzz_labels[fuzz_n_labels].call = call;
368
40
    fuzz_labels[fuzz_n_labels].text = buf;
369
40
    fuzz_n_labels++;
370
40
}
format.c:fuzz_label_call
Line
Count
Source
333
48
{
334
48
    if (call == NULL || call == R_NilValue)
335
0
        return;
336
337
    /* A call shared by several slots (run under different settings, say)
338
     * keeps one label naming them all. */
339
600
    for (int i = 0; i < fuzz_n_labels; i++) {
340
552
        if (fuzz_labels[i].call != call)
341
552
            continue;
342
0
        char *old = fuzz_labels[i].text;
343
0
        char *of = strstr(old, " of ");  /* "==fuzz== slot 7 of 9:" */
344
0
        size_t size = strlen(old) + 32;
345
0
        char *buf = malloc(size);
346
0
        if (of == NULL || buf == NULL) {
347
0
            free(buf);
348
0
            return;
349
0
        }
350
0
        snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of);
351
0
        fuzz_labels[i].text = buf;
352
0
        free(old);
353
0
        return;
354
0
    }
355
48
    if (fuzz_n_labels == FUZZ_MAX_LABELS)
356
0
        return;
357
358
48
    char *buf = malloc(FUZZ_LABEL_MAX);
359
48
    if (buf == NULL)
360
0
        return;
361
48
    int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots);
362
363
    /* A failed deparse leaves the header alone. */
364
48
    fuzz_deparse_job_t job = { call, buf, (size_t)n };
365
48
    R_ToplevelExec(fuzz_do_deparse, &job);
366
367
48
    fuzz_labels[fuzz_n_labels].call = call;
368
48
    fuzz_labels[fuzz_n_labels].text = buf;
369
48
    fuzz_n_labels++;
370
48
}
datetime.c:fuzz_label_call
Line
Count
Source
333
34
{
334
34
    if (call == NULL || call == R_NilValue)
335
0
        return;
336
337
    /* A call shared by several slots (run under different settings, say)
338
     * keeps one label naming them all. */
339
282
    for (int i = 0; i < fuzz_n_labels; i++) {
340
252
        if (fuzz_labels[i].call != call)
341
248
            continue;
342
4
        char *old = fuzz_labels[i].text;
343
4
        char *of = strstr(old, " of ");  /* "==fuzz== slot 7 of 9:" */
344
4
        size_t size = strlen(old) + 32;
345
4
        char *buf = malloc(size);
346
4
        if (of == NULL || buf == NULL) {
347
0
            free(buf);
348
0
            return;
349
0
        }
350
4
        snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of);
351
4
        fuzz_labels[i].text = buf;
352
4
        free(old);
353
4
        return;
354
4
    }
355
30
    if (fuzz_n_labels == FUZZ_MAX_LABELS)
356
0
        return;
357
358
30
    char *buf = malloc(FUZZ_LABEL_MAX);
359
30
    if (buf == NULL)
360
0
        return;
361
30
    int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots);
362
363
    /* A failed deparse leaves the header alone. */
364
30
    fuzz_deparse_job_t job = { call, buf, (size_t)n };
365
30
    R_ToplevelExec(fuzz_do_deparse, &job);
366
367
30
    fuzz_labels[fuzz_n_labels].call = call;
368
30
    fuzz_labels[fuzz_n_labels].text = buf;
369
30
    fuzz_n_labels++;
370
30
}
coerce.c:fuzz_label_call
Line
Count
Source
333
8
{
334
8
    if (call == NULL || call == R_NilValue)
335
0
        return;
336
337
    /* A call shared by several slots (run under different settings, say)
338
     * keeps one label naming them all. */
339
20
    for (int i = 0; i < fuzz_n_labels; i++) {
340
12
        if (fuzz_labels[i].call != call)
341
12
            continue;
342
0
        char *old = fuzz_labels[i].text;
343
0
        char *of = strstr(old, " of ");  /* "==fuzz== slot 7 of 9:" */
344
0
        size_t size = strlen(old) + 32;
345
0
        char *buf = malloc(size);
346
0
        if (of == NULL || buf == NULL) {
347
0
            free(buf);
348
0
            return;
349
0
        }
350
0
        snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of);
351
0
        fuzz_labels[i].text = buf;
352
0
        free(old);
353
0
        return;
354
0
    }
355
8
    if (fuzz_n_labels == FUZZ_MAX_LABELS)
356
0
        return;
357
358
8
    char *buf = malloc(FUZZ_LABEL_MAX);
359
8
    if (buf == NULL)
360
0
        return;
361
8
    int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots);
362
363
    /* A failed deparse leaves the header alone. */
364
8
    fuzz_deparse_job_t job = { call, buf, (size_t)n };
365
8
    R_ToplevelExec(fuzz_do_deparse, &job);
366
367
8
    fuzz_labels[fuzz_n_labels].call = call;
368
8
    fuzz_labels[fuzz_n_labels].text = buf;
369
8
    fuzz_n_labels++;
370
8
}
load.c:fuzz_label_call
Line
Count
Source
333
4
{
334
4
    if (call == NULL || call == R_NilValue)
335
0
        return;
336
337
    /* A call shared by several slots (run under different settings, say)
338
     * keeps one label naming them all. */
339
6
    for (int i = 0; i < fuzz_n_labels; i++) {
340
2
        if (fuzz_labels[i].call != call)
341
2
            continue;
342
0
        char *old = fuzz_labels[i].text;
343
0
        char *of = strstr(old, " of ");  /* "==fuzz== slot 7 of 9:" */
344
0
        size_t size = strlen(old) + 32;
345
0
        char *buf = malloc(size);
346
0
        if (of == NULL || buf == NULL) {
347
0
            free(buf);
348
0
            return;
349
0
        }
350
0
        snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of);
351
0
        fuzz_labels[i].text = buf;
352
0
        free(old);
353
0
        return;
354
0
    }
355
4
    if (fuzz_n_labels == FUZZ_MAX_LABELS)
356
0
        return;
357
358
4
    char *buf = malloc(FUZZ_LABEL_MAX);
359
4
    if (buf == NULL)
360
0
        return;
361
4
    int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots);
362
363
    /* A failed deparse leaves the header alone. */
364
4
    fuzz_deparse_job_t job = { call, buf, (size_t)n };
365
4
    R_ToplevelExec(fuzz_do_deparse, &job);
366
367
4
    fuzz_labels[fuzz_n_labels].call = call;
368
4
    fuzz_labels[fuzz_n_labels].text = buf;
369
4
    fuzz_n_labels++;
370
4
}
scan.c:fuzz_label_call
Line
Count
Source
333
36
{
334
36
    if (call == NULL || call == R_NilValue)
335
0
        return;
336
337
    /* A call shared by several slots (run under different settings, say)
338
     * keeps one label naming them all. */
339
342
    for (int i = 0; i < fuzz_n_labels; i++) {
340
306
        if (fuzz_labels[i].call != call)
341
306
            continue;
342
0
        char *old = fuzz_labels[i].text;
343
0
        char *of = strstr(old, " of ");  /* "==fuzz== slot 7 of 9:" */
344
0
        size_t size = strlen(old) + 32;
345
0
        char *buf = malloc(size);
346
0
        if (of == NULL || buf == NULL) {
347
0
            free(buf);
348
0
            return;
349
0
        }
350
0
        snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of);
351
0
        fuzz_labels[i].text = buf;
352
0
        free(old);
353
0
        return;
354
0
    }
355
36
    if (fuzz_n_labels == FUZZ_MAX_LABELS)
356
0
        return;
357
358
36
    char *buf = malloc(FUZZ_LABEL_MAX);
359
36
    if (buf == NULL)
360
0
        return;
361
36
    int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots);
362
363
    /* A failed deparse leaves the header alone. */
364
36
    fuzz_deparse_job_t job = { call, buf, (size_t)n };
365
36
    R_ToplevelExec(fuzz_do_deparse, &job);
366
367
36
    fuzz_labels[fuzz_n_labels].call = call;
368
36
    fuzz_labels[fuzz_n_labels].text = buf;
369
36
    fuzz_n_labels++;
370
36
}
colors.c:fuzz_label_call
Line
Count
Source
333
32
{
334
32
    if (call == NULL || call == R_NilValue)
335
0
        return;
336
337
    /* A call shared by several slots (run under different settings, say)
338
     * keeps one label naming them all. */
339
272
    for (int i = 0; i < fuzz_n_labels; i++) {
340
240
        if (fuzz_labels[i].call != call)
341
240
            continue;
342
0
        char *old = fuzz_labels[i].text;
343
0
        char *of = strstr(old, " of ");  /* "==fuzz== slot 7 of 9:" */
344
0
        size_t size = strlen(old) + 32;
345
0
        char *buf = malloc(size);
346
0
        if (of == NULL || buf == NULL) {
347
0
            free(buf);
348
0
            return;
349
0
        }
350
0
        snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of);
351
0
        fuzz_labels[i].text = buf;
352
0
        free(old);
353
0
        return;
354
0
    }
355
32
    if (fuzz_n_labels == FUZZ_MAX_LABELS)
356
0
        return;
357
358
32
    char *buf = malloc(FUZZ_LABEL_MAX);
359
32
    if (buf == NULL)
360
0
        return;
361
32
    int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots);
362
363
    /* A failed deparse leaves the header alone. */
364
32
    fuzz_deparse_job_t job = { call, buf, (size_t)n };
365
32
    R_ToplevelExec(fuzz_do_deparse, &job);
366
367
32
    fuzz_labels[fuzz_n_labels].call = call;
368
32
    fuzz_labels[fuzz_n_labels].text = buf;
369
32
    fuzz_n_labels++;
370
32
}
grep.c:fuzz_label_call
Line
Count
Source
333
32
{
334
32
    if (call == NULL || call == R_NilValue)
335
0
        return;
336
337
    /* A call shared by several slots (run under different settings, say)
338
     * keeps one label naming them all. */
339
272
    for (int i = 0; i < fuzz_n_labels; i++) {
340
240
        if (fuzz_labels[i].call != call)
341
240
            continue;
342
0
        char *old = fuzz_labels[i].text;
343
0
        char *of = strstr(old, " of ");  /* "==fuzz== slot 7 of 9:" */
344
0
        size_t size = strlen(old) + 32;
345
0
        char *buf = malloc(size);
346
0
        if (of == NULL || buf == NULL) {
347
0
            free(buf);
348
0
            return;
349
0
        }
350
0
        snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of);
351
0
        fuzz_labels[i].text = buf;
352
0
        free(old);
353
0
        return;
354
0
    }
355
32
    if (fuzz_n_labels == FUZZ_MAX_LABELS)
356
0
        return;
357
358
32
    char *buf = malloc(FUZZ_LABEL_MAX);
359
32
    if (buf == NULL)
360
0
        return;
361
32
    int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots);
362
363
    /* A failed deparse leaves the header alone. */
364
32
    fuzz_deparse_job_t job = { call, buf, (size_t)n };
365
32
    R_ToplevelExec(fuzz_do_deparse, &job);
366
367
32
    fuzz_labels[fuzz_n_labels].call = call;
368
32
    fuzz_labels[fuzz_n_labels].text = buf;
369
32
    fuzz_n_labels++;
370
32
}
parse.c:fuzz_label_call
Line
Count
Source
333
14
{
334
14
    if (call == NULL || call == R_NilValue)
335
2
        return;
336
337
    /* A call shared by several slots (run under different settings, say)
338
     * keeps one label naming them all. */
339
42
    for (int i = 0; i < fuzz_n_labels; i++) {
340
30
        if (fuzz_labels[i].call != call)
341
30
            continue;
342
0
        char *old = fuzz_labels[i].text;
343
0
        char *of = strstr(old, " of ");  /* "==fuzz== slot 7 of 9:" */
344
0
        size_t size = strlen(old) + 32;
345
0
        char *buf = malloc(size);
346
0
        if (of == NULL || buf == NULL) {
347
0
            free(buf);
348
0
            return;
349
0
        }
350
0
        snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of);
351
0
        fuzz_labels[i].text = buf;
352
0
        free(old);
353
0
        return;
354
0
    }
355
12
    if (fuzz_n_labels == FUZZ_MAX_LABELS)
356
0
        return;
357
358
12
    char *buf = malloc(FUZZ_LABEL_MAX);
359
12
    if (buf == NULL)
360
0
        return;
361
12
    int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots);
362
363
    /* A failed deparse leaves the header alone. */
364
12
    fuzz_deparse_job_t job = { call, buf, (size_t)n };
365
12
    R_ToplevelExec(fuzz_do_deparse, &job);
366
367
12
    fuzz_labels[fuzz_n_labels].call = call;
368
12
    fuzz_labels[fuzz_n_labels].text = buf;
369
12
    fuzz_n_labels++;
370
12
}
sockets.c:fuzz_label_call
Line
Count
Source
333
2
{
334
2
    if (call == NULL || call == R_NilValue)
335
0
        return;
336
337
    /* A call shared by several slots (run under different settings, say)
338
     * keeps one label naming them all. */
339
2
    for (int i = 0; i < fuzz_n_labels; i++) {
340
0
        if (fuzz_labels[i].call != call)
341
0
            continue;
342
0
        char *old = fuzz_labels[i].text;
343
0
        char *of = strstr(old, " of ");  /* "==fuzz== slot 7 of 9:" */
344
0
        size_t size = strlen(old) + 32;
345
0
        char *buf = malloc(size);
346
0
        if (of == NULL || buf == NULL) {
347
0
            free(buf);
348
0
            return;
349
0
        }
350
0
        snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of);
351
0
        fuzz_labels[i].text = buf;
352
0
        free(old);
353
0
        return;
354
0
    }
355
2
    if (fuzz_n_labels == FUZZ_MAX_LABELS)
356
0
        return;
357
358
2
    char *buf = malloc(FUZZ_LABEL_MAX);
359
2
    if (buf == NULL)
360
0
        return;
361
2
    int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots);
362
363
    /* A failed deparse leaves the header alone. */
364
2
    fuzz_deparse_job_t job = { call, buf, (size_t)n };
365
2
    R_ToplevelExec(fuzz_do_deparse, &job);
366
367
2
    fuzz_labels[fuzz_n_labels].call = call;
368
2
    fuzz_labels[fuzz_n_labels].text = buf;
369
2
    fuzz_n_labels++;
370
2
}
rd.c:fuzz_label_call
Line
Count
Source
333
4
{
334
4
    if (call == NULL || call == R_NilValue)
335
0
        return;
336
337
    /* A call shared by several slots (run under different settings, say)
338
     * keeps one label naming them all. */
339
6
    for (int i = 0; i < fuzz_n_labels; i++) {
340
2
        if (fuzz_labels[i].call != call)
341
2
            continue;
342
0
        char *old = fuzz_labels[i].text;
343
0
        char *of = strstr(old, " of ");  /* "==fuzz== slot 7 of 9:" */
344
0
        size_t size = strlen(old) + 32;
345
0
        char *buf = malloc(size);
346
0
        if (of == NULL || buf == NULL) {
347
0
            free(buf);
348
0
            return;
349
0
        }
350
0
        snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of);
351
0
        fuzz_labels[i].text = buf;
352
0
        free(old);
353
0
        return;
354
0
    }
355
4
    if (fuzz_n_labels == FUZZ_MAX_LABELS)
356
0
        return;
357
358
4
    char *buf = malloc(FUZZ_LABEL_MAX);
359
4
    if (buf == NULL)
360
0
        return;
361
4
    int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots);
362
363
    /* A failed deparse leaves the header alone. */
364
4
    fuzz_deparse_job_t job = { call, buf, (size_t)n };
365
4
    R_ToplevelExec(fuzz_do_deparse, &job);
366
367
4
    fuzz_labels[fuzz_n_labels].call = call;
368
4
    fuzz_labels[fuzz_n_labels].text = buf;
369
4
    fuzz_n_labels++;
370
4
}
sprintf.c:fuzz_label_call
Line
Count
Source
333
8
{
334
8
    if (call == NULL || call == R_NilValue)
335
0
        return;
336
337
    /* A call shared by several slots (run under different settings, say)
338
     * keeps one label naming them all. */
339
20
    for (int i = 0; i < fuzz_n_labels; i++) {
340
12
        if (fuzz_labels[i].call != call)
341
12
            continue;
342
0
        char *old = fuzz_labels[i].text;
343
0
        char *of = strstr(old, " of ");  /* "==fuzz== slot 7 of 9:" */
344
0
        size_t size = strlen(old) + 32;
345
0
        char *buf = malloc(size);
346
0
        if (of == NULL || buf == NULL) {
347
0
            free(buf);
348
0
            return;
349
0
        }
350
0
        snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of);
351
0
        fuzz_labels[i].text = buf;
352
0
        free(old);
353
0
        return;
354
0
    }
355
8
    if (fuzz_n_labels == FUZZ_MAX_LABELS)
356
0
        return;
357
358
8
    char *buf = malloc(FUZZ_LABEL_MAX);
359
8
    if (buf == NULL)
360
0
        return;
361
8
    int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots);
362
363
    /* A failed deparse leaves the header alone. */
364
8
    fuzz_deparse_job_t job = { call, buf, (size_t)n };
365
8
    R_ToplevelExec(fuzz_do_deparse, &job);
366
367
8
    fuzz_labels[fuzz_n_labels].call = call;
368
8
    fuzz_labels[fuzz_n_labels].text = buf;
369
8
    fuzz_n_labels++;
370
8
}
Unexecuted instantiation: eval.c:fuzz_label_call
zip.c:fuzz_label_call
Line
Count
Source
333
8
{
334
8
    if (call == NULL || call == R_NilValue)
335
0
        return;
336
337
    /* A call shared by several slots (run under different settings, say)
338
     * keeps one label naming them all. */
339
20
    for (int i = 0; i < fuzz_n_labels; i++) {
340
12
        if (fuzz_labels[i].call != call)
341
12
            continue;
342
0
        char *old = fuzz_labels[i].text;
343
0
        char *of = strstr(old, " of ");  /* "==fuzz== slot 7 of 9:" */
344
0
        size_t size = strlen(old) + 32;
345
0
        char *buf = malloc(size);
346
0
        if (of == NULL || buf == NULL) {
347
0
            free(buf);
348
0
            return;
349
0
        }
350
0
        snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of);
351
0
        fuzz_labels[i].text = buf;
352
0
        free(old);
353
0
        return;
354
0
    }
355
8
    if (fuzz_n_labels == FUZZ_MAX_LABELS)
356
0
        return;
357
358
8
    char *buf = malloc(FUZZ_LABEL_MAX);
359
8
    if (buf == NULL)
360
0
        return;
361
8
    int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots);
362
363
    /* A failed deparse leaves the header alone. */
364
8
    fuzz_deparse_job_t job = { call, buf, (size_t)n };
365
8
    R_ToplevelExec(fuzz_do_deparse, &job);
366
367
8
    fuzz_labels[fuzz_n_labels].call = call;
368
8
    fuzz_labels[fuzz_n_labels].text = buf;
369
8
    fuzz_n_labels++;
370
8
}
nmath.c:fuzz_label_call
Line
Count
Source
333
2
{
334
2
    if (call == NULL || call == R_NilValue)
335
0
        return;
336
337
    /* A call shared by several slots (run under different settings, say)
338
     * keeps one label naming them all. */
339
2
    for (int i = 0; i < fuzz_n_labels; i++) {
340
0
        if (fuzz_labels[i].call != call)
341
0
            continue;
342
0
        char *old = fuzz_labels[i].text;
343
0
        char *of = strstr(old, " of ");  /* "==fuzz== slot 7 of 9:" */
344
0
        size_t size = strlen(old) + 32;
345
0
        char *buf = malloc(size);
346
0
        if (of == NULL || buf == NULL) {
347
0
            free(buf);
348
0
            return;
349
0
        }
350
0
        snprintf(buf, size, "%.*s, %d%s", (int)(of - old), old, slot, of);
351
0
        fuzz_labels[i].text = buf;
352
0
        free(old);
353
0
        return;
354
0
    }
355
2
    if (fuzz_n_labels == FUZZ_MAX_LABELS)
356
0
        return;
357
358
2
    char *buf = malloc(FUZZ_LABEL_MAX);
359
2
    if (buf == NULL)
360
0
        return;
361
2
    int n = snprintf(buf, FUZZ_LABEL_MAX, "==fuzz== slot %d of %d:\n", slot, n_slots);
362
363
    /* A failed deparse leaves the header alone. */
364
2
    fuzz_deparse_job_t job = { call, buf, (size_t)n };
365
2
    R_ToplevelExec(fuzz_do_deparse, &job);
366
367
2
    fuzz_labels[fuzz_n_labels].call = call;
368
2
    fuzz_labels[fuzz_n_labels].text = buf;
369
2
    fuzz_n_labels++;
370
2
}
371
372
/* Label calls[0..n-1] as slots 0..n-1; NULL entries (slots run in C)
373
 * are skipped. */
374
static void fuzz_label_calls(const SEXP *calls, int n)
375
44
{
376
644
    for (int i = 0; i < n; i++)
377
600
        fuzz_label_call(calls[i], i, n);
378
44
}
Unexecuted instantiation: io.c:fuzz_label_calls
dcf.c:fuzz_label_calls
Line
Count
Source
375
2
{
376
6
    for (int i = 0; i < n; i++)
377
4
        fuzz_label_call(calls[i], i, n);
378
2
}
character.c:fuzz_label_calls
Line
Count
Source
375
2
{
376
70
    for (int i = 0; i < n; i++)
377
68
        fuzz_label_call(calls[i], i, n);
378
2
}
encoding.c:fuzz_label_calls
Line
Count
Source
375
2
{
376
58
    for (int i = 0; i < n; i++)
377
56
        fuzz_label_call(calls[i], i, n);
378
2
}
sort.c:fuzz_label_calls
Line
Count
Source
375
2
{
376
46
    for (int i = 0; i < n; i++)
377
44
        fuzz_label_call(calls[i], i, n);
378
2
}
connections.c:fuzz_label_calls
Line
Count
Source
375
2
{
376
134
    for (int i = 0; i < n; i++)
377
132
        fuzz_label_call(calls[i], i, n);
378
2
}
unserialize.c:fuzz_label_calls
Line
Count
Source
375
2
{
376
10
    for (int i = 0; i < n; i++)
377
8
        fuzz_label_call(calls[i], i, n);
378
2
}
formula.c:fuzz_label_calls
Line
Count
Source
375
2
{
376
10
    for (int i = 0; i < n; i++)
377
8
        fuzz_label_call(calls[i], i, n);
378
2
}
decompress.c:fuzz_label_calls
Line
Count
Source
375
2
{
376
10
    for (int i = 0; i < n; i++)
377
8
        fuzz_label_call(calls[i], i, n);
378
2
}
readtable.c:fuzz_label_calls
Line
Count
Source
375
2
{
376
42
    for (int i = 0; i < n; i++)
377
40
        fuzz_label_call(calls[i], i, n);
378
2
}
format.c:fuzz_label_calls
Line
Count
Source
375
2
{
376
50
    for (int i = 0; i < n; i++)
377
48
        fuzz_label_call(calls[i], i, n);
378
2
}
datetime.c:fuzz_label_calls
Line
Count
Source
375
2
{
376
36
    for (int i = 0; i < n; i++)
377
34
        fuzz_label_call(calls[i], i, n);
378
2
}
coerce.c:fuzz_label_calls
Line
Count
Source
375
2
{
376
10
    for (int i = 0; i < n; i++)
377
8
        fuzz_label_call(calls[i], i, n);
378
2
}
load.c:fuzz_label_calls
Line
Count
Source
375
2
{
376
6
    for (int i = 0; i < n; i++)
377
4
        fuzz_label_call(calls[i], i, n);
378
2
}
scan.c:fuzz_label_calls
Line
Count
Source
375
2
{
376
38
    for (int i = 0; i < n; i++)
377
36
        fuzz_label_call(calls[i], i, n);
378
2
}
colors.c:fuzz_label_calls
Line
Count
Source
375
2
{
376
34
    for (int i = 0; i < n; i++)
377
32
        fuzz_label_call(calls[i], i, n);
378
2
}
grep.c:fuzz_label_calls
Line
Count
Source
375
2
{
376
34
    for (int i = 0; i < n; i++)
377
32
        fuzz_label_call(calls[i], i, n);
378
2
}
parse.c:fuzz_label_calls
Line
Count
Source
375
2
{
376
16
    for (int i = 0; i < n; i++)
377
14
        fuzz_label_call(calls[i], i, n);
378
2
}
sockets.c:fuzz_label_calls
Line
Count
Source
375
2
{
376
4
    for (int i = 0; i < n; i++)
377
2
        fuzz_label_call(calls[i], i, n);
378
2
}
rd.c:fuzz_label_calls
Line
Count
Source
375
2
{
376
6
    for (int i = 0; i < n; i++)
377
4
        fuzz_label_call(calls[i], i, n);
378
2
}
sprintf.c:fuzz_label_calls
Line
Count
Source
375
2
{
376
10
    for (int i = 0; i < n; i++)
377
8
        fuzz_label_call(calls[i], i, n);
378
2
}
Unexecuted instantiation: eval.c:fuzz_label_calls
zip.c:fuzz_label_calls
Line
Count
Source
375
2
{
376
10
    for (int i = 0; i < n; i++)
377
8
        fuzz_label_call(calls[i], i, n);
378
2
}
nmath.c:fuzz_label_calls
Line
Count
Source
375
2
{
376
4
    for (int i = 0; i < n; i++)
377
2
        fuzz_label_call(calls[i], i, n);
378
2
}
379
380
/* Note the call about to be evaluated; an unregistered one clears it. */
381
static void fuzz_label_enter(SEXP call)
382
134k
{
383
134k
    int found = -1;
384
1.35M
    for (int i = 0; i < fuzz_n_labels; i++) {
385
1.34M
        if (fuzz_labels[i].call == call) {
386
127k
            found = i;
387
127k
            break;
388
127k
        }
389
1.34M
    }
390
134k
    atomic_store(&fuzz_label_current, found);
391
134k
}
io.c:fuzz_label_enter
Line
Count
Source
382
2.04k
{
383
2.04k
    int found = -1;
384
31.2k
    for (int i = 0; i < fuzz_n_labels; i++) {
385
31.2k
        if (fuzz_labels[i].call == call) {
386
2.04k
            found = i;
387
2.04k
            break;
388
2.04k
        }
389
31.2k
    }
390
    atomic_store(&fuzz_label_current, found);
391
2.04k
}
dcf.c:fuzz_label_enter
Line
Count
Source
382
4.72k
{
383
4.72k
    int found = -1;
384
8.62k
    for (int i = 0; i < fuzz_n_labels; i++) {
385
8.62k
        if (fuzz_labels[i].call == call) {
386
4.72k
            found = i;
387
4.72k
            break;
388
4.72k
        }
389
8.62k
    }
390
    atomic_store(&fuzz_label_current, found);
391
4.72k
}
character.c:fuzz_label_enter
Line
Count
Source
382
4.07k
{
383
4.07k
    int found = -1;
384
84.6k
    for (int i = 0; i < fuzz_n_labels; i++) {
385
84.6k
        if (fuzz_labels[i].call == call) {
386
4.07k
            found = i;
387
4.07k
            break;
388
4.07k
        }
389
84.6k
    }
390
    atomic_store(&fuzz_label_current, found);
391
4.07k
}
encoding.c:fuzz_label_enter
Line
Count
Source
382
1.76k
{
383
1.76k
    int found = -1;
384
30.9k
    for (int i = 0; i < fuzz_n_labels; i++) {
385
30.9k
        if (fuzz_labels[i].call == call) {
386
1.76k
            found = i;
387
1.76k
            break;
388
1.76k
        }
389
30.9k
    }
390
    atomic_store(&fuzz_label_current, found);
391
1.76k
}
sort.c:fuzz_label_enter
Line
Count
Source
382
6.79k
{
383
6.79k
    int found = -1;
384
75.6k
    for (int i = 0; i < fuzz_n_labels; i++) {
385
75.6k
        if (fuzz_labels[i].call == call) {
386
6.79k
            found = i;
387
6.79k
            break;
388
6.79k
        }
389
75.6k
    }
390
    atomic_store(&fuzz_label_current, found);
391
6.79k
}
connections.c:fuzz_label_enter
Line
Count
Source
382
11.9k
{
383
11.9k
    int found = -1;
384
636k
    for (int i = 0; i < fuzz_n_labels; i++) {
385
633k
        if (fuzz_labels[i].call == call) {
386
8.32k
            found = i;
387
8.32k
            break;
388
8.32k
        }
389
633k
    }
390
    atomic_store(&fuzz_label_current, found);
391
11.9k
}
unserialize.c:fuzz_label_enter
Line
Count
Source
382
5.70k
{
383
5.70k
    int found = -1;
384
13.6k
    for (int i = 0; i < fuzz_n_labels; i++) {
385
13.6k
        if (fuzz_labels[i].call == call) {
386
5.70k
            found = i;
387
5.70k
            break;
388
5.70k
        }
389
13.6k
    }
390
    atomic_store(&fuzz_label_current, found);
391
5.70k
}
formula.c:fuzz_label_enter
Line
Count
Source
382
10.2k
{
383
10.2k
    int found = -1;
384
28.0k
    for (int i = 0; i < fuzz_n_labels; i++) {
385
28.0k
        if (fuzz_labels[i].call == call) {
386
10.2k
            found = i;
387
10.2k
            break;
388
10.2k
        }
389
28.0k
    }
390
    atomic_store(&fuzz_label_current, found);
391
10.2k
}
decompress.c:fuzz_label_enter
Line
Count
Source
382
7.60k
{
383
7.60k
    int found = -1;
384
28.2k
    for (int i = 0; i < fuzz_n_labels; i++) {
385
28.2k
        if (fuzz_labels[i].call == call) {
386
7.60k
            found = i;
387
7.60k
            break;
388
7.60k
        }
389
28.2k
    }
390
    atomic_store(&fuzz_label_current, found);
391
7.60k
}
readtable.c:fuzz_label_enter
Line
Count
Source
382
5.13k
{
383
5.13k
    int found = -1;
384
60.9k
    for (int i = 0; i < fuzz_n_labels; i++) {
385
60.9k
        if (fuzz_labels[i].call == call) {
386
5.13k
            found = i;
387
5.13k
            break;
388
5.13k
        }
389
60.9k
    }
390
    atomic_store(&fuzz_label_current, found);
391
5.13k
}
format.c:fuzz_label_enter
Line
Count
Source
382
5.49k
{
383
5.49k
    int found = -1;
384
65.1k
    for (int i = 0; i < fuzz_n_labels; i++) {
385
65.1k
        if (fuzz_labels[i].call == call) {
386
5.49k
            found = i;
387
5.49k
            break;
388
5.49k
        }
389
65.1k
    }
390
    atomic_store(&fuzz_label_current, found);
391
5.49k
}
datetime.c:fuzz_label_enter
Line
Count
Source
382
9.17k
{
383
9.17k
    int found = -1;
384
115k
    for (int i = 0; i < fuzz_n_labels; i++) {
385
112k
        if (fuzz_labels[i].call == call) {
386
6.30k
            found = i;
387
6.30k
            break;
388
6.30k
        }
389
112k
    }
390
    atomic_store(&fuzz_label_current, found);
391
9.17k
}
coerce.c:fuzz_label_enter
Line
Count
Source
382
7.13k
{
383
7.13k
    int found = -1;
384
17.8k
    for (int i = 0; i < fuzz_n_labels; i++) {
385
17.8k
        if (fuzz_labels[i].call == call) {
386
7.13k
            found = i;
387
7.13k
            break;
388
7.13k
        }
389
17.8k
    }
390
    atomic_store(&fuzz_label_current, found);
391
7.13k
}
load.c:fuzz_label_enter
Line
Count
Source
382
11.1k
{
383
11.1k
    int found = -1;
384
15.2k
    for (int i = 0; i < fuzz_n_labels; i++) {
385
15.2k
        if (fuzz_labels[i].call == call) {
386
11.1k
            found = i;
387
11.1k
            break;
388
11.1k
        }
389
15.2k
    }
390
    atomic_store(&fuzz_label_current, found);
391
11.1k
}
scan.c:fuzz_label_enter
Line
Count
Source
382
2.90k
{
383
2.90k
    int found = -1;
384
27.1k
    for (int i = 0; i < fuzz_n_labels; i++) {
385
27.1k
        if (fuzz_labels[i].call == call) {
386
2.90k
            found = i;
387
2.90k
            break;
388
2.90k
        }
389
27.1k
    }
390
    atomic_store(&fuzz_label_current, found);
391
2.90k
}
colors.c:fuzz_label_enter
Line
Count
Source
382
3.92k
{
383
3.92k
    int found = -1;
384
34.6k
    for (int i = 0; i < fuzz_n_labels; i++) {
385
34.6k
        if (fuzz_labels[i].call == call) {
386
3.92k
            found = i;
387
3.92k
            break;
388
3.92k
        }
389
34.6k
    }
390
    atomic_store(&fuzz_label_current, found);
391
3.92k
}
grep.c:fuzz_label_enter
Line
Count
Source
382
2.18k
{
383
2.18k
    int found = -1;
384
19.7k
    for (int i = 0; i < fuzz_n_labels; i++) {
385
19.7k
        if (fuzz_labels[i].call == call) {
386
2.18k
            found = i;
387
2.18k
            break;
388
2.18k
        }
389
19.7k
    }
390
    atomic_store(&fuzz_label_current, found);
391
2.18k
}
parse.c:fuzz_label_enter
Line
Count
Source
382
8.61k
{
383
8.61k
    int found = -1;
384
25.9k
    for (int i = 0; i < fuzz_n_labels; i++) {
385
25.9k
        if (fuzz_labels[i].call == call) {
386
8.61k
            found = i;
387
8.61k
            break;
388
8.61k
        }
389
25.9k
    }
390
    atomic_store(&fuzz_label_current, found);
391
8.61k
}
sockets.c:fuzz_label_enter
Line
Count
Source
382
1.98k
{
383
1.98k
    int found = -1;
384
1.98k
    for (int i = 0; i < fuzz_n_labels; i++) {
385
1.98k
        if (fuzz_labels[i].call == call) {
386
1.98k
            found = i;
387
1.98k
            break;
388
1.98k
        }
389
1.98k
    }
390
    atomic_store(&fuzz_label_current, found);
391
1.98k
}
rd.c:fuzz_label_enter
Line
Count
Source
382
5.08k
{
383
5.08k
    int found = -1;
384
8.57k
    for (int i = 0; i < fuzz_n_labels; i++) {
385
8.57k
        if (fuzz_labels[i].call == call) {
386
5.08k
            found = i;
387
5.08k
            break;
388
5.08k
        }
389
8.57k
    }
390
    atomic_store(&fuzz_label_current, found);
391
5.08k
}
sprintf.c:fuzz_label_enter
Line
Count
Source
382
2.07k
{
383
2.07k
    int found = -1;
384
6.65k
    for (int i = 0; i < fuzz_n_labels; i++) {
385
6.65k
        if (fuzz_labels[i].call == call) {
386
2.07k
            found = i;
387
2.07k
            break;
388
2.07k
        }
389
6.65k
    }
390
    atomic_store(&fuzz_label_current, found);
391
2.07k
}
Unexecuted instantiation: eval.c:fuzz_label_enter
zip.c:fuzz_label_enter
Line
Count
Source
382
2.09k
{
383
2.09k
    int found = -1;
384
5.55k
    for (int i = 0; i < fuzz_n_labels; i++) {
385
5.55k
        if (fuzz_labels[i].call == call) {
386
2.09k
            found = i;
387
2.09k
            break;
388
2.09k
        }
389
5.55k
    }
390
    atomic_store(&fuzz_label_current, found);
391
2.09k
}
nmath.c:fuzz_label_enter
Line
Count
Source
382
12.2k
{
383
12.2k
    int found = -1;
384
12.2k
    for (int i = 0; i < fuzz_n_labels; i++) {
385
12.2k
        if (fuzz_labels[i].call == call) {
386
12.2k
            found = i;
387
12.2k
            break;
388
12.2k
        }
389
12.2k
    }
390
    atomic_store(&fuzz_label_current, found);
391
12.2k
}
392
393
/* Runs on the R thread, interrupting whatever the input is doing. */
394
static void fuzz_dump_handler(int sig, siginfo_t *info, void *context)
395
0
{
396
0
    (void)sig;
397
0
    (void)info;
398
0
    (void)context;
399
0
    unsigned input = atomic_load(&fuzz_alarm.requested);
400
0
    int label = atomic_load(&fuzz_label_current);
401
0
    if (label >= 0)
402
0
        fuzz_write_stderr(fuzz_labels[label].text);
403
0
    if (__sanitizer_print_stack_trace)
404
0
        __sanitizer_print_stack_trace();
405
0
    else
406
0
        fuzz_write_stderr("    (no sanitizer runtime to print it)\n");
407
0
    atomic_store(&fuzz_alarm.done, input);
408
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: formula.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: grep.c:fuzz_dump_handler
Unexecuted instantiation: parse.c:fuzz_dump_handler
Unexecuted instantiation: sockets.c:fuzz_dump_handler
Unexecuted instantiation: rd.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
Unexecuted instantiation: nmath.c:fuzz_dump_handler
409
410
/* Whole seconds since a moment. */
411
static long fuzz_seconds_since(const struct timespec *then)
412
49
{
413
49
    struct timespec now;
414
49
    clock_gettime(CLOCK_REALTIME, &now);
415
416
49
    long seconds = now.tv_sec - then->tv_sec;
417
49
    if (now.tv_nsec < then->tv_nsec)
418
9
        seconds--;
419
49
    return seconds;
420
49
}
Unexecuted instantiation: io.c:fuzz_seconds_since
dcf.c:fuzz_seconds_since
Line
Count
Source
412
3
{
413
3
    struct timespec now;
414
3
    clock_gettime(CLOCK_REALTIME, &now);
415
416
3
    long seconds = now.tv_sec - then->tv_sec;
417
3
    if (now.tv_nsec < then->tv_nsec)
418
1
        seconds--;
419
3
    return seconds;
420
3
}
Unexecuted instantiation: character.c:fuzz_seconds_since
Unexecuted instantiation: encoding.c:fuzz_seconds_since
Unexecuted instantiation: sort.c:fuzz_seconds_since
Unexecuted instantiation: connections.c:fuzz_seconds_since
unserialize.c:fuzz_seconds_since
Line
Count
Source
412
5
{
413
5
    struct timespec now;
414
5
    clock_gettime(CLOCK_REALTIME, &now);
415
416
5
    long seconds = now.tv_sec - then->tv_sec;
417
5
    if (now.tv_nsec < then->tv_nsec)
418
1
        seconds--;
419
5
    return seconds;
420
5
}
formula.c:fuzz_seconds_since
Line
Count
Source
412
3
{
413
3
    struct timespec now;
414
3
    clock_gettime(CLOCK_REALTIME, &now);
415
416
3
    long seconds = now.tv_sec - then->tv_sec;
417
3
    if (now.tv_nsec < then->tv_nsec)
418
0
        seconds--;
419
3
    return seconds;
420
3
}
decompress.c:fuzz_seconds_since
Line
Count
Source
412
1
{
413
1
    struct timespec now;
414
1
    clock_gettime(CLOCK_REALTIME, &now);
415
416
1
    long seconds = now.tv_sec - then->tv_sec;
417
1
    if (now.tv_nsec < then->tv_nsec)
418
0
        seconds--;
419
1
    return seconds;
420
1
}
readtable.c:fuzz_seconds_since
Line
Count
Source
412
4
{
413
4
    struct timespec now;
414
4
    clock_gettime(CLOCK_REALTIME, &now);
415
416
4
    long seconds = now.tv_sec - then->tv_sec;
417
4
    if (now.tv_nsec < then->tv_nsec)
418
0
        seconds--;
419
4
    return seconds;
420
4
}
format.c:fuzz_seconds_since
Line
Count
Source
412
2
{
413
2
    struct timespec now;
414
2
    clock_gettime(CLOCK_REALTIME, &now);
415
416
2
    long seconds = now.tv_sec - then->tv_sec;
417
2
    if (now.tv_nsec < then->tv_nsec)
418
0
        seconds--;
419
2
    return seconds;
420
2
}
Unexecuted instantiation: datetime.c:fuzz_seconds_since
Unexecuted instantiation: coerce.c:fuzz_seconds_since
load.c:fuzz_seconds_since
Line
Count
Source
412
2
{
413
2
    struct timespec now;
414
2
    clock_gettime(CLOCK_REALTIME, &now);
415
416
2
    long seconds = now.tv_sec - then->tv_sec;
417
2
    if (now.tv_nsec < then->tv_nsec)
418
0
        seconds--;
419
2
    return seconds;
420
2
}
Unexecuted instantiation: scan.c:fuzz_seconds_since
colors.c:fuzz_seconds_since
Line
Count
Source
412
3
{
413
3
    struct timespec now;
414
3
    clock_gettime(CLOCK_REALTIME, &now);
415
416
3
    long seconds = now.tv_sec - then->tv_sec;
417
3
    if (now.tv_nsec < then->tv_nsec)
418
1
        seconds--;
419
3
    return seconds;
420
3
}
grep.c:fuzz_seconds_since
Line
Count
Source
412
2
{
413
2
    struct timespec now;
414
2
    clock_gettime(CLOCK_REALTIME, &now);
415
416
2
    long seconds = now.tv_sec - then->tv_sec;
417
2
    if (now.tv_nsec < then->tv_nsec)
418
1
        seconds--;
419
2
    return seconds;
420
2
}
parse.c:fuzz_seconds_since
Line
Count
Source
412
3
{
413
3
    struct timespec now;
414
3
    clock_gettime(CLOCK_REALTIME, &now);
415
416
3
    long seconds = now.tv_sec - then->tv_sec;
417
3
    if (now.tv_nsec < then->tv_nsec)
418
1
        seconds--;
419
3
    return seconds;
420
3
}
Unexecuted instantiation: sockets.c:fuzz_seconds_since
rd.c:fuzz_seconds_since
Line
Count
Source
412
5
{
413
5
    struct timespec now;
414
5
    clock_gettime(CLOCK_REALTIME, &now);
415
416
5
    long seconds = now.tv_sec - then->tv_sec;
417
5
    if (now.tv_nsec < then->tv_nsec)
418
1
        seconds--;
419
5
    return seconds;
420
5
}
Unexecuted instantiation: sprintf.c:fuzz_seconds_since
eval.c:fuzz_seconds_since
Line
Count
Source
412
12
{
413
12
    struct timespec now;
414
12
    clock_gettime(CLOCK_REALTIME, &now);
415
416
12
    long seconds = now.tv_sec - then->tv_sec;
417
12
    if (now.tv_nsec < then->tv_nsec)
418
2
        seconds--;
419
12
    return seconds;
420
12
}
Unexecuted instantiation: zip.c:fuzz_seconds_since
nmath.c:fuzz_seconds_since
Line
Count
Source
412
4
{
413
4
    struct timespec now;
414
4
    clock_gettime(CLOCK_REALTIME, &now);
415
416
4
    long seconds = now.tv_sec - then->tv_sec;
417
4
    if (now.tv_nsec < then->tv_nsec)
418
1
        seconds--;
419
4
    return seconds;
420
4
}
421
422
/* Runs on the main thread, where libFuzzer's alarm lands. */
423
static void fuzz_alarm_handler(int sig, siginfo_t *info, void *context)
424
50
{
425
50
    if (atomic_load(&fuzz_alarm.finishing))
426
0
        return;
427
428
50
    if (atomic_load(&fuzz_alarm.running) &&
429
49
        fuzz_seconds_since(&fuzz_alarm.armed) >= fuzz_alarm.timeout - 1) {
430
0
        struct timespec tick = { 0, fuzz_alarm.poll_ns };
431
432
        /* Hold until the input is out of time by its own clock as well;
433
         * one that finishes first, even in the last sleep, was within
434
         * its time.  The clock is read before the input is looked at, so
435
         * an input seen running was running at a moment past the
436
         * timeout, whatever delay falls between the two. */
437
0
        for (;;) {
438
0
            long age = fuzz_seconds_since(&fuzz_alarm.started);
439
0
            if (!atomic_load(&fuzz_alarm.running)) {
440
0
                atomic_store(&fuzz_alarm.finishing, 1);
441
0
                return;
442
0
            }
443
0
            if (age >= fuzz_alarm.timeout)
444
0
                break;
445
0
            nanosleep(&tick, NULL);
446
0
        }
447
448
0
        unsigned input = atomic_load(&fuzz_alarm.input);
449
0
        if (atomic_load(&fuzz_alarm.requested) != input) {
450
0
            atomic_store(&fuzz_alarm.requested, input);
451
0
            fuzz_write_stderr("==fuzz== R thread, where the input is running:\n");
452
0
            if (pthread_kill(fuzz_r_thread.thread, FUZZ_DUMP_SIGNAL) != 0)
453
0
                atomic_store(&fuzz_alarm.done, input);
454
0
        }
455
456
        /* Symbolizing takes a moment; a thread that never answers (stuck
457
         * in the allocator, say) must not hold up the report, and an
458
         * input finishing now is reported all the same: it was out of
459
         * time already. */
460
0
        for (int i = 0; i < 5000; i++) {
461
0
            if (atomic_load(&fuzz_alarm.done) == input ||
462
0
                !atomic_load(&fuzz_alarm.running))
463
0
                break;
464
0
            nanosleep(&tick, NULL);
465
0
        }
466
0
    }
467
50
    fuzz_alarm.chain.sa_sigaction(sig, info, context);
468
50
}
Unexecuted instantiation: io.c:fuzz_alarm_handler
dcf.c:fuzz_alarm_handler
Line
Count
Source
424
3
{
425
3
    if (atomic_load(&fuzz_alarm.finishing))
426
0
        return;
427
428
3
    if (atomic_load(&fuzz_alarm.running) &&
429
3
        fuzz_seconds_since(&fuzz_alarm.armed) >= fuzz_alarm.timeout - 1) {
430
0
        struct timespec tick = { 0, fuzz_alarm.poll_ns };
431
432
        /* Hold until the input is out of time by its own clock as well;
433
         * one that finishes first, even in the last sleep, was within
434
         * its time.  The clock is read before the input is looked at, so
435
         * an input seen running was running at a moment past the
436
         * timeout, whatever delay falls between the two. */
437
0
        for (;;) {
438
0
            long age = fuzz_seconds_since(&fuzz_alarm.started);
439
0
            if (!atomic_load(&fuzz_alarm.running)) {
440
0
                atomic_store(&fuzz_alarm.finishing, 1);
441
0
                return;
442
0
            }
443
0
            if (age >= fuzz_alarm.timeout)
444
0
                break;
445
0
            nanosleep(&tick, NULL);
446
0
        }
447
448
0
        unsigned input = atomic_load(&fuzz_alarm.input);
449
0
        if (atomic_load(&fuzz_alarm.requested) != input) {
450
0
            atomic_store(&fuzz_alarm.requested, input);
451
0
            fuzz_write_stderr("==fuzz== R thread, where the input is running:\n");
452
0
            if (pthread_kill(fuzz_r_thread.thread, FUZZ_DUMP_SIGNAL) != 0)
453
0
                atomic_store(&fuzz_alarm.done, input);
454
0
        }
455
456
        /* Symbolizing takes a moment; a thread that never answers (stuck
457
         * in the allocator, say) must not hold up the report, and an
458
         * input finishing now is reported all the same: it was out of
459
         * time already. */
460
0
        for (int i = 0; i < 5000; i++) {
461
0
            if (atomic_load(&fuzz_alarm.done) == input ||
462
0
                !atomic_load(&fuzz_alarm.running))
463
0
                break;
464
0
            nanosleep(&tick, NULL);
465
0
        }
466
0
    }
467
3
    fuzz_alarm.chain.sa_sigaction(sig, info, context);
468
3
}
Unexecuted instantiation: character.c:fuzz_alarm_handler
Unexecuted instantiation: encoding.c:fuzz_alarm_handler
Unexecuted instantiation: sort.c:fuzz_alarm_handler
Unexecuted instantiation: connections.c:fuzz_alarm_handler
unserialize.c:fuzz_alarm_handler
Line
Count
Source
424
5
{
425
5
    if (atomic_load(&fuzz_alarm.finishing))
426
0
        return;
427
428
5
    if (atomic_load(&fuzz_alarm.running) &&
429
5
        fuzz_seconds_since(&fuzz_alarm.armed) >= fuzz_alarm.timeout - 1) {
430
0
        struct timespec tick = { 0, fuzz_alarm.poll_ns };
431
432
        /* Hold until the input is out of time by its own clock as well;
433
         * one that finishes first, even in the last sleep, was within
434
         * its time.  The clock is read before the input is looked at, so
435
         * an input seen running was running at a moment past the
436
         * timeout, whatever delay falls between the two. */
437
0
        for (;;) {
438
0
            long age = fuzz_seconds_since(&fuzz_alarm.started);
439
0
            if (!atomic_load(&fuzz_alarm.running)) {
440
0
                atomic_store(&fuzz_alarm.finishing, 1);
441
0
                return;
442
0
            }
443
0
            if (age >= fuzz_alarm.timeout)
444
0
                break;
445
0
            nanosleep(&tick, NULL);
446
0
        }
447
448
0
        unsigned input = atomic_load(&fuzz_alarm.input);
449
0
        if (atomic_load(&fuzz_alarm.requested) != input) {
450
0
            atomic_store(&fuzz_alarm.requested, input);
451
0
            fuzz_write_stderr("==fuzz== R thread, where the input is running:\n");
452
0
            if (pthread_kill(fuzz_r_thread.thread, FUZZ_DUMP_SIGNAL) != 0)
453
0
                atomic_store(&fuzz_alarm.done, input);
454
0
        }
455
456
        /* Symbolizing takes a moment; a thread that never answers (stuck
457
         * in the allocator, say) must not hold up the report, and an
458
         * input finishing now is reported all the same: it was out of
459
         * time already. */
460
0
        for (int i = 0; i < 5000; i++) {
461
0
            if (atomic_load(&fuzz_alarm.done) == input ||
462
0
                !atomic_load(&fuzz_alarm.running))
463
0
                break;
464
0
            nanosleep(&tick, NULL);
465
0
        }
466
0
    }
467
5
    fuzz_alarm.chain.sa_sigaction(sig, info, context);
468
5
}
formula.c:fuzz_alarm_handler
Line
Count
Source
424
3
{
425
3
    if (atomic_load(&fuzz_alarm.finishing))
426
0
        return;
427
428
3
    if (atomic_load(&fuzz_alarm.running) &&
429
3
        fuzz_seconds_since(&fuzz_alarm.armed) >= fuzz_alarm.timeout - 1) {
430
0
        struct timespec tick = { 0, fuzz_alarm.poll_ns };
431
432
        /* Hold until the input is out of time by its own clock as well;
433
         * one that finishes first, even in the last sleep, was within
434
         * its time.  The clock is read before the input is looked at, so
435
         * an input seen running was running at a moment past the
436
         * timeout, whatever delay falls between the two. */
437
0
        for (;;) {
438
0
            long age = fuzz_seconds_since(&fuzz_alarm.started);
439
0
            if (!atomic_load(&fuzz_alarm.running)) {
440
0
                atomic_store(&fuzz_alarm.finishing, 1);
441
0
                return;
442
0
            }
443
0
            if (age >= fuzz_alarm.timeout)
444
0
                break;
445
0
            nanosleep(&tick, NULL);
446
0
        }
447
448
0
        unsigned input = atomic_load(&fuzz_alarm.input);
449
0
        if (atomic_load(&fuzz_alarm.requested) != input) {
450
0
            atomic_store(&fuzz_alarm.requested, input);
451
0
            fuzz_write_stderr("==fuzz== R thread, where the input is running:\n");
452
0
            if (pthread_kill(fuzz_r_thread.thread, FUZZ_DUMP_SIGNAL) != 0)
453
0
                atomic_store(&fuzz_alarm.done, input);
454
0
        }
455
456
        /* Symbolizing takes a moment; a thread that never answers (stuck
457
         * in the allocator, say) must not hold up the report, and an
458
         * input finishing now is reported all the same: it was out of
459
         * time already. */
460
0
        for (int i = 0; i < 5000; i++) {
461
0
            if (atomic_load(&fuzz_alarm.done) == input ||
462
0
                !atomic_load(&fuzz_alarm.running))
463
0
                break;
464
0
            nanosleep(&tick, NULL);
465
0
        }
466
0
    }
467
3
    fuzz_alarm.chain.sa_sigaction(sig, info, context);
468
3
}
decompress.c:fuzz_alarm_handler
Line
Count
Source
424
1
{
425
1
    if (atomic_load(&fuzz_alarm.finishing))
426
0
        return;
427
428
1
    if (atomic_load(&fuzz_alarm.running) &&
429
1
        fuzz_seconds_since(&fuzz_alarm.armed) >= fuzz_alarm.timeout - 1) {
430
0
        struct timespec tick = { 0, fuzz_alarm.poll_ns };
431
432
        /* Hold until the input is out of time by its own clock as well;
433
         * one that finishes first, even in the last sleep, was within
434
         * its time.  The clock is read before the input is looked at, so
435
         * an input seen running was running at a moment past the
436
         * timeout, whatever delay falls between the two. */
437
0
        for (;;) {
438
0
            long age = fuzz_seconds_since(&fuzz_alarm.started);
439
0
            if (!atomic_load(&fuzz_alarm.running)) {
440
0
                atomic_store(&fuzz_alarm.finishing, 1);
441
0
                return;
442
0
            }
443
0
            if (age >= fuzz_alarm.timeout)
444
0
                break;
445
0
            nanosleep(&tick, NULL);
446
0
        }
447
448
0
        unsigned input = atomic_load(&fuzz_alarm.input);
449
0
        if (atomic_load(&fuzz_alarm.requested) != input) {
450
0
            atomic_store(&fuzz_alarm.requested, input);
451
0
            fuzz_write_stderr("==fuzz== R thread, where the input is running:\n");
452
0
            if (pthread_kill(fuzz_r_thread.thread, FUZZ_DUMP_SIGNAL) != 0)
453
0
                atomic_store(&fuzz_alarm.done, input);
454
0
        }
455
456
        /* Symbolizing takes a moment; a thread that never answers (stuck
457
         * in the allocator, say) must not hold up the report, and an
458
         * input finishing now is reported all the same: it was out of
459
         * time already. */
460
0
        for (int i = 0; i < 5000; i++) {
461
0
            if (atomic_load(&fuzz_alarm.done) == input ||
462
0
                !atomic_load(&fuzz_alarm.running))
463
0
                break;
464
0
            nanosleep(&tick, NULL);
465
0
        }
466
0
    }
467
1
    fuzz_alarm.chain.sa_sigaction(sig, info, context);
468
1
}
readtable.c:fuzz_alarm_handler
Line
Count
Source
424
4
{
425
4
    if (atomic_load(&fuzz_alarm.finishing))
426
0
        return;
427
428
4
    if (atomic_load(&fuzz_alarm.running) &&
429
4
        fuzz_seconds_since(&fuzz_alarm.armed) >= fuzz_alarm.timeout - 1) {
430
0
        struct timespec tick = { 0, fuzz_alarm.poll_ns };
431
432
        /* Hold until the input is out of time by its own clock as well;
433
         * one that finishes first, even in the last sleep, was within
434
         * its time.  The clock is read before the input is looked at, so
435
         * an input seen running was running at a moment past the
436
         * timeout, whatever delay falls between the two. */
437
0
        for (;;) {
438
0
            long age = fuzz_seconds_since(&fuzz_alarm.started);
439
0
            if (!atomic_load(&fuzz_alarm.running)) {
440
0
                atomic_store(&fuzz_alarm.finishing, 1);
441
0
                return;
442
0
            }
443
0
            if (age >= fuzz_alarm.timeout)
444
0
                break;
445
0
            nanosleep(&tick, NULL);
446
0
        }
447
448
0
        unsigned input = atomic_load(&fuzz_alarm.input);
449
0
        if (atomic_load(&fuzz_alarm.requested) != input) {
450
0
            atomic_store(&fuzz_alarm.requested, input);
451
0
            fuzz_write_stderr("==fuzz== R thread, where the input is running:\n");
452
0
            if (pthread_kill(fuzz_r_thread.thread, FUZZ_DUMP_SIGNAL) != 0)
453
0
                atomic_store(&fuzz_alarm.done, input);
454
0
        }
455
456
        /* Symbolizing takes a moment; a thread that never answers (stuck
457
         * in the allocator, say) must not hold up the report, and an
458
         * input finishing now is reported all the same: it was out of
459
         * time already. */
460
0
        for (int i = 0; i < 5000; i++) {
461
0
            if (atomic_load(&fuzz_alarm.done) == input ||
462
0
                !atomic_load(&fuzz_alarm.running))
463
0
                break;
464
0
            nanosleep(&tick, NULL);
465
0
        }
466
0
    }
467
4
    fuzz_alarm.chain.sa_sigaction(sig, info, context);
468
4
}
format.c:fuzz_alarm_handler
Line
Count
Source
424
2
{
425
2
    if (atomic_load(&fuzz_alarm.finishing))
426
0
        return;
427
428
2
    if (atomic_load(&fuzz_alarm.running) &&
429
2
        fuzz_seconds_since(&fuzz_alarm.armed) >= fuzz_alarm.timeout - 1) {
430
0
        struct timespec tick = { 0, fuzz_alarm.poll_ns };
431
432
        /* Hold until the input is out of time by its own clock as well;
433
         * one that finishes first, even in the last sleep, was within
434
         * its time.  The clock is read before the input is looked at, so
435
         * an input seen running was running at a moment past the
436
         * timeout, whatever delay falls between the two. */
437
0
        for (;;) {
438
0
            long age = fuzz_seconds_since(&fuzz_alarm.started);
439
0
            if (!atomic_load(&fuzz_alarm.running)) {
440
0
                atomic_store(&fuzz_alarm.finishing, 1);
441
0
                return;
442
0
            }
443
0
            if (age >= fuzz_alarm.timeout)
444
0
                break;
445
0
            nanosleep(&tick, NULL);
446
0
        }
447
448
0
        unsigned input = atomic_load(&fuzz_alarm.input);
449
0
        if (atomic_load(&fuzz_alarm.requested) != input) {
450
0
            atomic_store(&fuzz_alarm.requested, input);
451
0
            fuzz_write_stderr("==fuzz== R thread, where the input is running:\n");
452
0
            if (pthread_kill(fuzz_r_thread.thread, FUZZ_DUMP_SIGNAL) != 0)
453
0
                atomic_store(&fuzz_alarm.done, input);
454
0
        }
455
456
        /* Symbolizing takes a moment; a thread that never answers (stuck
457
         * in the allocator, say) must not hold up the report, and an
458
         * input finishing now is reported all the same: it was out of
459
         * time already. */
460
0
        for (int i = 0; i < 5000; i++) {
461
0
            if (atomic_load(&fuzz_alarm.done) == input ||
462
0
                !atomic_load(&fuzz_alarm.running))
463
0
                break;
464
0
            nanosleep(&tick, NULL);
465
0
        }
466
0
    }
467
2
    fuzz_alarm.chain.sa_sigaction(sig, info, context);
468
2
}
Unexecuted instantiation: datetime.c:fuzz_alarm_handler
Unexecuted instantiation: coerce.c:fuzz_alarm_handler
load.c:fuzz_alarm_handler
Line
Count
Source
424
2
{
425
2
    if (atomic_load(&fuzz_alarm.finishing))
426
0
        return;
427
428
2
    if (atomic_load(&fuzz_alarm.running) &&
429
2
        fuzz_seconds_since(&fuzz_alarm.armed) >= fuzz_alarm.timeout - 1) {
430
0
        struct timespec tick = { 0, fuzz_alarm.poll_ns };
431
432
        /* Hold until the input is out of time by its own clock as well;
433
         * one that finishes first, even in the last sleep, was within
434
         * its time.  The clock is read before the input is looked at, so
435
         * an input seen running was running at a moment past the
436
         * timeout, whatever delay falls between the two. */
437
0
        for (;;) {
438
0
            long age = fuzz_seconds_since(&fuzz_alarm.started);
439
0
            if (!atomic_load(&fuzz_alarm.running)) {
440
0
                atomic_store(&fuzz_alarm.finishing, 1);
441
0
                return;
442
0
            }
443
0
            if (age >= fuzz_alarm.timeout)
444
0
                break;
445
0
            nanosleep(&tick, NULL);
446
0
        }
447
448
0
        unsigned input = atomic_load(&fuzz_alarm.input);
449
0
        if (atomic_load(&fuzz_alarm.requested) != input) {
450
0
            atomic_store(&fuzz_alarm.requested, input);
451
0
            fuzz_write_stderr("==fuzz== R thread, where the input is running:\n");
452
0
            if (pthread_kill(fuzz_r_thread.thread, FUZZ_DUMP_SIGNAL) != 0)
453
0
                atomic_store(&fuzz_alarm.done, input);
454
0
        }
455
456
        /* Symbolizing takes a moment; a thread that never answers (stuck
457
         * in the allocator, say) must not hold up the report, and an
458
         * input finishing now is reported all the same: it was out of
459
         * time already. */
460
0
        for (int i = 0; i < 5000; i++) {
461
0
            if (atomic_load(&fuzz_alarm.done) == input ||
462
0
                !atomic_load(&fuzz_alarm.running))
463
0
                break;
464
0
            nanosleep(&tick, NULL);
465
0
        }
466
0
    }
467
2
    fuzz_alarm.chain.sa_sigaction(sig, info, context);
468
2
}
Unexecuted instantiation: scan.c:fuzz_alarm_handler
colors.c:fuzz_alarm_handler
Line
Count
Source
424
3
{
425
3
    if (atomic_load(&fuzz_alarm.finishing))
426
0
        return;
427
428
3
    if (atomic_load(&fuzz_alarm.running) &&
429
3
        fuzz_seconds_since(&fuzz_alarm.armed) >= fuzz_alarm.timeout - 1) {
430
0
        struct timespec tick = { 0, fuzz_alarm.poll_ns };
431
432
        /* Hold until the input is out of time by its own clock as well;
433
         * one that finishes first, even in the last sleep, was within
434
         * its time.  The clock is read before the input is looked at, so
435
         * an input seen running was running at a moment past the
436
         * timeout, whatever delay falls between the two. */
437
0
        for (;;) {
438
0
            long age = fuzz_seconds_since(&fuzz_alarm.started);
439
0
            if (!atomic_load(&fuzz_alarm.running)) {
440
0
                atomic_store(&fuzz_alarm.finishing, 1);
441
0
                return;
442
0
            }
443
0
            if (age >= fuzz_alarm.timeout)
444
0
                break;
445
0
            nanosleep(&tick, NULL);
446
0
        }
447
448
0
        unsigned input = atomic_load(&fuzz_alarm.input);
449
0
        if (atomic_load(&fuzz_alarm.requested) != input) {
450
0
            atomic_store(&fuzz_alarm.requested, input);
451
0
            fuzz_write_stderr("==fuzz== R thread, where the input is running:\n");
452
0
            if (pthread_kill(fuzz_r_thread.thread, FUZZ_DUMP_SIGNAL) != 0)
453
0
                atomic_store(&fuzz_alarm.done, input);
454
0
        }
455
456
        /* Symbolizing takes a moment; a thread that never answers (stuck
457
         * in the allocator, say) must not hold up the report, and an
458
         * input finishing now is reported all the same: it was out of
459
         * time already. */
460
0
        for (int i = 0; i < 5000; i++) {
461
0
            if (atomic_load(&fuzz_alarm.done) == input ||
462
0
                !atomic_load(&fuzz_alarm.running))
463
0
                break;
464
0
            nanosleep(&tick, NULL);
465
0
        }
466
0
    }
467
3
    fuzz_alarm.chain.sa_sigaction(sig, info, context);
468
3
}
grep.c:fuzz_alarm_handler
Line
Count
Source
424
2
{
425
2
    if (atomic_load(&fuzz_alarm.finishing))
426
0
        return;
427
428
2
    if (atomic_load(&fuzz_alarm.running) &&
429
2
        fuzz_seconds_since(&fuzz_alarm.armed) >= fuzz_alarm.timeout - 1) {
430
0
        struct timespec tick = { 0, fuzz_alarm.poll_ns };
431
432
        /* Hold until the input is out of time by its own clock as well;
433
         * one that finishes first, even in the last sleep, was within
434
         * its time.  The clock is read before the input is looked at, so
435
         * an input seen running was running at a moment past the
436
         * timeout, whatever delay falls between the two. */
437
0
        for (;;) {
438
0
            long age = fuzz_seconds_since(&fuzz_alarm.started);
439
0
            if (!atomic_load(&fuzz_alarm.running)) {
440
0
                atomic_store(&fuzz_alarm.finishing, 1);
441
0
                return;
442
0
            }
443
0
            if (age >= fuzz_alarm.timeout)
444
0
                break;
445
0
            nanosleep(&tick, NULL);
446
0
        }
447
448
0
        unsigned input = atomic_load(&fuzz_alarm.input);
449
0
        if (atomic_load(&fuzz_alarm.requested) != input) {
450
0
            atomic_store(&fuzz_alarm.requested, input);
451
0
            fuzz_write_stderr("==fuzz== R thread, where the input is running:\n");
452
0
            if (pthread_kill(fuzz_r_thread.thread, FUZZ_DUMP_SIGNAL) != 0)
453
0
                atomic_store(&fuzz_alarm.done, input);
454
0
        }
455
456
        /* Symbolizing takes a moment; a thread that never answers (stuck
457
         * in the allocator, say) must not hold up the report, and an
458
         * input finishing now is reported all the same: it was out of
459
         * time already. */
460
0
        for (int i = 0; i < 5000; i++) {
461
0
            if (atomic_load(&fuzz_alarm.done) == input ||
462
0
                !atomic_load(&fuzz_alarm.running))
463
0
                break;
464
0
            nanosleep(&tick, NULL);
465
0
        }
466
0
    }
467
2
    fuzz_alarm.chain.sa_sigaction(sig, info, context);
468
2
}
parse.c:fuzz_alarm_handler
Line
Count
Source
424
3
{
425
3
    if (atomic_load(&fuzz_alarm.finishing))
426
0
        return;
427
428
3
    if (atomic_load(&fuzz_alarm.running) &&
429
3
        fuzz_seconds_since(&fuzz_alarm.armed) >= fuzz_alarm.timeout - 1) {
430
0
        struct timespec tick = { 0, fuzz_alarm.poll_ns };
431
432
        /* Hold until the input is out of time by its own clock as well;
433
         * one that finishes first, even in the last sleep, was within
434
         * its time.  The clock is read before the input is looked at, so
435
         * an input seen running was running at a moment past the
436
         * timeout, whatever delay falls between the two. */
437
0
        for (;;) {
438
0
            long age = fuzz_seconds_since(&fuzz_alarm.started);
439
0
            if (!atomic_load(&fuzz_alarm.running)) {
440
0
                atomic_store(&fuzz_alarm.finishing, 1);
441
0
                return;
442
0
            }
443
0
            if (age >= fuzz_alarm.timeout)
444
0
                break;
445
0
            nanosleep(&tick, NULL);
446
0
        }
447
448
0
        unsigned input = atomic_load(&fuzz_alarm.input);
449
0
        if (atomic_load(&fuzz_alarm.requested) != input) {
450
0
            atomic_store(&fuzz_alarm.requested, input);
451
0
            fuzz_write_stderr("==fuzz== R thread, where the input is running:\n");
452
0
            if (pthread_kill(fuzz_r_thread.thread, FUZZ_DUMP_SIGNAL) != 0)
453
0
                atomic_store(&fuzz_alarm.done, input);
454
0
        }
455
456
        /* Symbolizing takes a moment; a thread that never answers (stuck
457
         * in the allocator, say) must not hold up the report, and an
458
         * input finishing now is reported all the same: it was out of
459
         * time already. */
460
0
        for (int i = 0; i < 5000; i++) {
461
0
            if (atomic_load(&fuzz_alarm.done) == input ||
462
0
                !atomic_load(&fuzz_alarm.running))
463
0
                break;
464
0
            nanosleep(&tick, NULL);
465
0
        }
466
0
    }
467
3
    fuzz_alarm.chain.sa_sigaction(sig, info, context);
468
3
}
Unexecuted instantiation: sockets.c:fuzz_alarm_handler
rd.c:fuzz_alarm_handler
Line
Count
Source
424
6
{
425
6
    if (atomic_load(&fuzz_alarm.finishing))
426
0
        return;
427
428
6
    if (atomic_load(&fuzz_alarm.running) &&
429
5
        fuzz_seconds_since(&fuzz_alarm.armed) >= fuzz_alarm.timeout - 1) {
430
0
        struct timespec tick = { 0, fuzz_alarm.poll_ns };
431
432
        /* Hold until the input is out of time by its own clock as well;
433
         * one that finishes first, even in the last sleep, was within
434
         * its time.  The clock is read before the input is looked at, so
435
         * an input seen running was running at a moment past the
436
         * timeout, whatever delay falls between the two. */
437
0
        for (;;) {
438
0
            long age = fuzz_seconds_since(&fuzz_alarm.started);
439
0
            if (!atomic_load(&fuzz_alarm.running)) {
440
0
                atomic_store(&fuzz_alarm.finishing, 1);
441
0
                return;
442
0
            }
443
0
            if (age >= fuzz_alarm.timeout)
444
0
                break;
445
0
            nanosleep(&tick, NULL);
446
0
        }
447
448
0
        unsigned input = atomic_load(&fuzz_alarm.input);
449
0
        if (atomic_load(&fuzz_alarm.requested) != input) {
450
0
            atomic_store(&fuzz_alarm.requested, input);
451
0
            fuzz_write_stderr("==fuzz== R thread, where the input is running:\n");
452
0
            if (pthread_kill(fuzz_r_thread.thread, FUZZ_DUMP_SIGNAL) != 0)
453
0
                atomic_store(&fuzz_alarm.done, input);
454
0
        }
455
456
        /* Symbolizing takes a moment; a thread that never answers (stuck
457
         * in the allocator, say) must not hold up the report, and an
458
         * input finishing now is reported all the same: it was out of
459
         * time already. */
460
0
        for (int i = 0; i < 5000; i++) {
461
0
            if (atomic_load(&fuzz_alarm.done) == input ||
462
0
                !atomic_load(&fuzz_alarm.running))
463
0
                break;
464
0
            nanosleep(&tick, NULL);
465
0
        }
466
0
    }
467
6
    fuzz_alarm.chain.sa_sigaction(sig, info, context);
468
6
}
Unexecuted instantiation: sprintf.c:fuzz_alarm_handler
eval.c:fuzz_alarm_handler
Line
Count
Source
424
12
{
425
12
    if (atomic_load(&fuzz_alarm.finishing))
426
0
        return;
427
428
12
    if (atomic_load(&fuzz_alarm.running) &&
429
12
        fuzz_seconds_since(&fuzz_alarm.armed) >= fuzz_alarm.timeout - 1) {
430
0
        struct timespec tick = { 0, fuzz_alarm.poll_ns };
431
432
        /* Hold until the input is out of time by its own clock as well;
433
         * one that finishes first, even in the last sleep, was within
434
         * its time.  The clock is read before the input is looked at, so
435
         * an input seen running was running at a moment past the
436
         * timeout, whatever delay falls between the two. */
437
0
        for (;;) {
438
0
            long age = fuzz_seconds_since(&fuzz_alarm.started);
439
0
            if (!atomic_load(&fuzz_alarm.running)) {
440
0
                atomic_store(&fuzz_alarm.finishing, 1);
441
0
                return;
442
0
            }
443
0
            if (age >= fuzz_alarm.timeout)
444
0
                break;
445
0
            nanosleep(&tick, NULL);
446
0
        }
447
448
0
        unsigned input = atomic_load(&fuzz_alarm.input);
449
0
        if (atomic_load(&fuzz_alarm.requested) != input) {
450
0
            atomic_store(&fuzz_alarm.requested, input);
451
0
            fuzz_write_stderr("==fuzz== R thread, where the input is running:\n");
452
0
            if (pthread_kill(fuzz_r_thread.thread, FUZZ_DUMP_SIGNAL) != 0)
453
0
                atomic_store(&fuzz_alarm.done, input);
454
0
        }
455
456
        /* Symbolizing takes a moment; a thread that never answers (stuck
457
         * in the allocator, say) must not hold up the report, and an
458
         * input finishing now is reported all the same: it was out of
459
         * time already. */
460
0
        for (int i = 0; i < 5000; i++) {
461
0
            if (atomic_load(&fuzz_alarm.done) == input ||
462
0
                !atomic_load(&fuzz_alarm.running))
463
0
                break;
464
0
            nanosleep(&tick, NULL);
465
0
        }
466
0
    }
467
12
    fuzz_alarm.chain.sa_sigaction(sig, info, context);
468
12
}
Unexecuted instantiation: zip.c:fuzz_alarm_handler
nmath.c:fuzz_alarm_handler
Line
Count
Source
424
4
{
425
4
    if (atomic_load(&fuzz_alarm.finishing))
426
0
        return;
427
428
4
    if (atomic_load(&fuzz_alarm.running) &&
429
4
        fuzz_seconds_since(&fuzz_alarm.armed) >= fuzz_alarm.timeout - 1) {
430
0
        struct timespec tick = { 0, fuzz_alarm.poll_ns };
431
432
        /* Hold until the input is out of time by its own clock as well;
433
         * one that finishes first, even in the last sleep, was within
434
         * its time.  The clock is read before the input is looked at, so
435
         * an input seen running was running at a moment past the
436
         * timeout, whatever delay falls between the two. */
437
0
        for (;;) {
438
0
            long age = fuzz_seconds_since(&fuzz_alarm.started);
439
0
            if (!atomic_load(&fuzz_alarm.running)) {
440
0
                atomic_store(&fuzz_alarm.finishing, 1);
441
0
                return;
442
0
            }
443
0
            if (age >= fuzz_alarm.timeout)
444
0
                break;
445
0
            nanosleep(&tick, NULL);
446
0
        }
447
448
0
        unsigned input = atomic_load(&fuzz_alarm.input);
449
0
        if (atomic_load(&fuzz_alarm.requested) != input) {
450
0
            atomic_store(&fuzz_alarm.requested, input);
451
0
            fuzz_write_stderr("==fuzz== R thread, where the input is running:\n");
452
0
            if (pthread_kill(fuzz_r_thread.thread, FUZZ_DUMP_SIGNAL) != 0)
453
0
                atomic_store(&fuzz_alarm.done, input);
454
0
        }
455
456
        /* Symbolizing takes a moment; a thread that never answers (stuck
457
         * in the allocator, say) must not hold up the report, and an
458
         * input finishing now is reported all the same: it was out of
459
         * time already. */
460
0
        for (int i = 0; i < 5000; i++) {
461
0
            if (atomic_load(&fuzz_alarm.done) == input ||
462
0
                !atomic_load(&fuzz_alarm.running))
463
0
                break;
464
0
            nanosleep(&tick, NULL);
465
0
        }
466
0
    }
467
4
    fuzz_alarm.chain.sa_sigaction(sig, info, context);
468
4
}
469
470
/* Wrap libFuzzer's SIGALRM handler, once it exists.  Called before each
471
 * input; the first call after libFuzzer's startup sees the handler. */
472
static void fuzz_alarm_wrap(void)
473
143k
{
474
143k
    if (fuzz_alarm.wrapped)
475
143k
        return;
476
24
    fuzz_alarm.wrapped = 1;
477
478
24
    struct sigaction current;
479
24
    if (sigaction(SIGALRM, NULL, &current) != 0 ||
480
24
        !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL)
481
0
        return;  /* no alarm: AFL++'s driver, -timeout=0, tests */
482
483
24
    struct sigaction dump;
484
24
    memset(&dump, 0, sizeof dump);
485
24
    dump.sa_sigaction = fuzz_dump_handler;
486
24
    dump.sa_flags = SA_SIGINFO;
487
24
    sigemptyset(&dump.sa_mask);
488
24
    if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0)
489
0
        return;
490
491
24
    fuzz_alarm.chain = current;
492
24
    struct sigaction wrapper = current;
493
24
    wrapper.sa_sigaction = fuzz_alarm_handler;
494
24
    if (sigaction(SIGALRM, &wrapper, NULL) != 0)
495
0
        sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL);
496
24
}
io.c:fuzz_alarm_wrap
Line
Count
Source
473
1.40k
{
474
1.40k
    if (fuzz_alarm.wrapped)
475
1.39k
        return;
476
1
    fuzz_alarm.wrapped = 1;
477
478
1
    struct sigaction current;
479
1
    if (sigaction(SIGALRM, NULL, &current) != 0 ||
480
1
        !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL)
481
0
        return;  /* no alarm: AFL++'s driver, -timeout=0, tests */
482
483
1
    struct sigaction dump;
484
1
    memset(&dump, 0, sizeof dump);
485
1
    dump.sa_sigaction = fuzz_dump_handler;
486
1
    dump.sa_flags = SA_SIGINFO;
487
1
    sigemptyset(&dump.sa_mask);
488
1
    if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0)
489
0
        return;
490
491
1
    fuzz_alarm.chain = current;
492
1
    struct sigaction wrapper = current;
493
1
    wrapper.sa_sigaction = fuzz_alarm_handler;
494
1
    if (sigaction(SIGALRM, &wrapper, NULL) != 0)
495
0
        sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL);
496
1
}
dcf.c:fuzz_alarm_wrap
Line
Count
Source
473
4.73k
{
474
4.73k
    if (fuzz_alarm.wrapped)
475
4.73k
        return;
476
1
    fuzz_alarm.wrapped = 1;
477
478
1
    struct sigaction current;
479
1
    if (sigaction(SIGALRM, NULL, &current) != 0 ||
480
1
        !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL)
481
0
        return;  /* no alarm: AFL++'s driver, -timeout=0, tests */
482
483
1
    struct sigaction dump;
484
1
    memset(&dump, 0, sizeof dump);
485
1
    dump.sa_sigaction = fuzz_dump_handler;
486
1
    dump.sa_flags = SA_SIGINFO;
487
1
    sigemptyset(&dump.sa_mask);
488
1
    if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0)
489
0
        return;
490
491
1
    fuzz_alarm.chain = current;
492
1
    struct sigaction wrapper = current;
493
1
    wrapper.sa_sigaction = fuzz_alarm_handler;
494
1
    if (sigaction(SIGALRM, &wrapper, NULL) != 0)
495
0
        sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL);
496
1
}
character.c:fuzz_alarm_wrap
Line
Count
Source
473
4.09k
{
474
4.09k
    if (fuzz_alarm.wrapped)
475
4.09k
        return;
476
1
    fuzz_alarm.wrapped = 1;
477
478
1
    struct sigaction current;
479
1
    if (sigaction(SIGALRM, NULL, &current) != 0 ||
480
1
        !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL)
481
0
        return;  /* no alarm: AFL++'s driver, -timeout=0, tests */
482
483
1
    struct sigaction dump;
484
1
    memset(&dump, 0, sizeof dump);
485
1
    dump.sa_sigaction = fuzz_dump_handler;
486
1
    dump.sa_flags = SA_SIGINFO;
487
1
    sigemptyset(&dump.sa_mask);
488
1
    if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0)
489
0
        return;
490
491
1
    fuzz_alarm.chain = current;
492
1
    struct sigaction wrapper = current;
493
1
    wrapper.sa_sigaction = fuzz_alarm_handler;
494
1
    if (sigaction(SIGALRM, &wrapper, NULL) != 0)
495
0
        sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL);
496
1
}
encoding.c:fuzz_alarm_wrap
Line
Count
Source
473
1.77k
{
474
1.77k
    if (fuzz_alarm.wrapped)
475
1.77k
        return;
476
1
    fuzz_alarm.wrapped = 1;
477
478
1
    struct sigaction current;
479
1
    if (sigaction(SIGALRM, NULL, &current) != 0 ||
480
1
        !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL)
481
0
        return;  /* no alarm: AFL++'s driver, -timeout=0, tests */
482
483
1
    struct sigaction dump;
484
1
    memset(&dump, 0, sizeof dump);
485
1
    dump.sa_sigaction = fuzz_dump_handler;
486
1
    dump.sa_flags = SA_SIGINFO;
487
1
    sigemptyset(&dump.sa_mask);
488
1
    if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0)
489
0
        return;
490
491
1
    fuzz_alarm.chain = current;
492
1
    struct sigaction wrapper = current;
493
1
    wrapper.sa_sigaction = fuzz_alarm_handler;
494
1
    if (sigaction(SIGALRM, &wrapper, NULL) != 0)
495
0
        sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL);
496
1
}
sort.c:fuzz_alarm_wrap
Line
Count
Source
473
6.80k
{
474
6.80k
    if (fuzz_alarm.wrapped)
475
6.79k
        return;
476
1
    fuzz_alarm.wrapped = 1;
477
478
1
    struct sigaction current;
479
1
    if (sigaction(SIGALRM, NULL, &current) != 0 ||
480
1
        !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL)
481
0
        return;  /* no alarm: AFL++'s driver, -timeout=0, tests */
482
483
1
    struct sigaction dump;
484
1
    memset(&dump, 0, sizeof dump);
485
1
    dump.sa_sigaction = fuzz_dump_handler;
486
1
    dump.sa_flags = SA_SIGINFO;
487
1
    sigemptyset(&dump.sa_mask);
488
1
    if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0)
489
0
        return;
490
491
1
    fuzz_alarm.chain = current;
492
1
    struct sigaction wrapper = current;
493
1
    wrapper.sa_sigaction = fuzz_alarm_handler;
494
1
    if (sigaction(SIGALRM, &wrapper, NULL) != 0)
495
0
        sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL);
496
1
}
connections.c:fuzz_alarm_wrap
Line
Count
Source
473
8.33k
{
474
8.33k
    if (fuzz_alarm.wrapped)
475
8.33k
        return;
476
1
    fuzz_alarm.wrapped = 1;
477
478
1
    struct sigaction current;
479
1
    if (sigaction(SIGALRM, NULL, &current) != 0 ||
480
1
        !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL)
481
0
        return;  /* no alarm: AFL++'s driver, -timeout=0, tests */
482
483
1
    struct sigaction dump;
484
1
    memset(&dump, 0, sizeof dump);
485
1
    dump.sa_sigaction = fuzz_dump_handler;
486
1
    dump.sa_flags = SA_SIGINFO;
487
1
    sigemptyset(&dump.sa_mask);
488
1
    if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0)
489
0
        return;
490
491
1
    fuzz_alarm.chain = current;
492
1
    struct sigaction wrapper = current;
493
1
    wrapper.sa_sigaction = fuzz_alarm_handler;
494
1
    if (sigaction(SIGALRM, &wrapper, NULL) != 0)
495
0
        sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL);
496
1
}
unserialize.c:fuzz_alarm_wrap
Line
Count
Source
473
5.70k
{
474
5.70k
    if (fuzz_alarm.wrapped)
475
5.70k
        return;
476
1
    fuzz_alarm.wrapped = 1;
477
478
1
    struct sigaction current;
479
1
    if (sigaction(SIGALRM, NULL, &current) != 0 ||
480
1
        !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL)
481
0
        return;  /* no alarm: AFL++'s driver, -timeout=0, tests */
482
483
1
    struct sigaction dump;
484
1
    memset(&dump, 0, sizeof dump);
485
1
    dump.sa_sigaction = fuzz_dump_handler;
486
1
    dump.sa_flags = SA_SIGINFO;
487
1
    sigemptyset(&dump.sa_mask);
488
1
    if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0)
489
0
        return;
490
491
1
    fuzz_alarm.chain = current;
492
1
    struct sigaction wrapper = current;
493
1
    wrapper.sa_sigaction = fuzz_alarm_handler;
494
1
    if (sigaction(SIGALRM, &wrapper, NULL) != 0)
495
0
        sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL);
496
1
}
formula.c:fuzz_alarm_wrap
Line
Count
Source
473
12.3k
{
474
12.3k
    if (fuzz_alarm.wrapped)
475
12.3k
        return;
476
1
    fuzz_alarm.wrapped = 1;
477
478
1
    struct sigaction current;
479
1
    if (sigaction(SIGALRM, NULL, &current) != 0 ||
480
1
        !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL)
481
0
        return;  /* no alarm: AFL++'s driver, -timeout=0, tests */
482
483
1
    struct sigaction dump;
484
1
    memset(&dump, 0, sizeof dump);
485
1
    dump.sa_sigaction = fuzz_dump_handler;
486
1
    dump.sa_flags = SA_SIGINFO;
487
1
    sigemptyset(&dump.sa_mask);
488
1
    if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0)
489
0
        return;
490
491
1
    fuzz_alarm.chain = current;
492
1
    struct sigaction wrapper = current;
493
1
    wrapper.sa_sigaction = fuzz_alarm_handler;
494
1
    if (sigaction(SIGALRM, &wrapper, NULL) != 0)
495
0
        sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL);
496
1
}
decompress.c:fuzz_alarm_wrap
Line
Count
Source
473
7.60k
{
474
7.60k
    if (fuzz_alarm.wrapped)
475
7.60k
        return;
476
1
    fuzz_alarm.wrapped = 1;
477
478
1
    struct sigaction current;
479
1
    if (sigaction(SIGALRM, NULL, &current) != 0 ||
480
1
        !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL)
481
0
        return;  /* no alarm: AFL++'s driver, -timeout=0, tests */
482
483
1
    struct sigaction dump;
484
1
    memset(&dump, 0, sizeof dump);
485
1
    dump.sa_sigaction = fuzz_dump_handler;
486
1
    dump.sa_flags = SA_SIGINFO;
487
1
    sigemptyset(&dump.sa_mask);
488
1
    if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0)
489
0
        return;
490
491
1
    fuzz_alarm.chain = current;
492
1
    struct sigaction wrapper = current;
493
1
    wrapper.sa_sigaction = fuzz_alarm_handler;
494
1
    if (sigaction(SIGALRM, &wrapper, NULL) != 0)
495
0
        sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL);
496
1
}
readtable.c:fuzz_alarm_wrap
Line
Count
Source
473
5.09k
{
474
5.09k
    if (fuzz_alarm.wrapped)
475
5.09k
        return;
476
1
    fuzz_alarm.wrapped = 1;
477
478
1
    struct sigaction current;
479
1
    if (sigaction(SIGALRM, NULL, &current) != 0 ||
480
1
        !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL)
481
0
        return;  /* no alarm: AFL++'s driver, -timeout=0, tests */
482
483
1
    struct sigaction dump;
484
1
    memset(&dump, 0, sizeof dump);
485
1
    dump.sa_sigaction = fuzz_dump_handler;
486
1
    dump.sa_flags = SA_SIGINFO;
487
1
    sigemptyset(&dump.sa_mask);
488
1
    if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0)
489
0
        return;
490
491
1
    fuzz_alarm.chain = current;
492
1
    struct sigaction wrapper = current;
493
1
    wrapper.sa_sigaction = fuzz_alarm_handler;
494
1
    if (sigaction(SIGALRM, &wrapper, NULL) != 0)
495
0
        sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL);
496
1
}
format.c:fuzz_alarm_wrap
Line
Count
Source
473
5.50k
{
474
5.50k
    if (fuzz_alarm.wrapped)
475
5.49k
        return;
476
1
    fuzz_alarm.wrapped = 1;
477
478
1
    struct sigaction current;
479
1
    if (sigaction(SIGALRM, NULL, &current) != 0 ||
480
1
        !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL)
481
0
        return;  /* no alarm: AFL++'s driver, -timeout=0, tests */
482
483
1
    struct sigaction dump;
484
1
    memset(&dump, 0, sizeof dump);
485
1
    dump.sa_sigaction = fuzz_dump_handler;
486
1
    dump.sa_flags = SA_SIGINFO;
487
1
    sigemptyset(&dump.sa_mask);
488
1
    if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0)
489
0
        return;
490
491
1
    fuzz_alarm.chain = current;
492
1
    struct sigaction wrapper = current;
493
1
    wrapper.sa_sigaction = fuzz_alarm_handler;
494
1
    if (sigaction(SIGALRM, &wrapper, NULL) != 0)
495
0
        sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL);
496
1
}
datetime.c:fuzz_alarm_wrap
Line
Count
Source
473
6.31k
{
474
6.31k
    if (fuzz_alarm.wrapped)
475
6.30k
        return;
476
1
    fuzz_alarm.wrapped = 1;
477
478
1
    struct sigaction current;
479
1
    if (sigaction(SIGALRM, NULL, &current) != 0 ||
480
1
        !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL)
481
0
        return;  /* no alarm: AFL++'s driver, -timeout=0, tests */
482
483
1
    struct sigaction dump;
484
1
    memset(&dump, 0, sizeof dump);
485
1
    dump.sa_sigaction = fuzz_dump_handler;
486
1
    dump.sa_flags = SA_SIGINFO;
487
1
    sigemptyset(&dump.sa_mask);
488
1
    if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0)
489
0
        return;
490
491
1
    fuzz_alarm.chain = current;
492
1
    struct sigaction wrapper = current;
493
1
    wrapper.sa_sigaction = fuzz_alarm_handler;
494
1
    if (sigaction(SIGALRM, &wrapper, NULL) != 0)
495
0
        sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL);
496
1
}
coerce.c:fuzz_alarm_wrap
Line
Count
Source
473
1.78k
{
474
1.78k
    if (fuzz_alarm.wrapped)
475
1.78k
        return;
476
1
    fuzz_alarm.wrapped = 1;
477
478
1
    struct sigaction current;
479
1
    if (sigaction(SIGALRM, NULL, &current) != 0 ||
480
1
        !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL)
481
0
        return;  /* no alarm: AFL++'s driver, -timeout=0, tests */
482
483
1
    struct sigaction dump;
484
1
    memset(&dump, 0, sizeof dump);
485
1
    dump.sa_sigaction = fuzz_dump_handler;
486
1
    dump.sa_flags = SA_SIGINFO;
487
1
    sigemptyset(&dump.sa_mask);
488
1
    if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0)
489
0
        return;
490
491
1
    fuzz_alarm.chain = current;
492
1
    struct sigaction wrapper = current;
493
1
    wrapper.sa_sigaction = fuzz_alarm_handler;
494
1
    if (sigaction(SIGALRM, &wrapper, NULL) != 0)
495
0
        sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL);
496
1
}
load.c:fuzz_alarm_wrap
Line
Count
Source
473
11.1k
{
474
11.1k
    if (fuzz_alarm.wrapped)
475
11.1k
        return;
476
1
    fuzz_alarm.wrapped = 1;
477
478
1
    struct sigaction current;
479
1
    if (sigaction(SIGALRM, NULL, &current) != 0 ||
480
1
        !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL)
481
0
        return;  /* no alarm: AFL++'s driver, -timeout=0, tests */
482
483
1
    struct sigaction dump;
484
1
    memset(&dump, 0, sizeof dump);
485
1
    dump.sa_sigaction = fuzz_dump_handler;
486
1
    dump.sa_flags = SA_SIGINFO;
487
1
    sigemptyset(&dump.sa_mask);
488
1
    if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0)
489
0
        return;
490
491
1
    fuzz_alarm.chain = current;
492
1
    struct sigaction wrapper = current;
493
1
    wrapper.sa_sigaction = fuzz_alarm_handler;
494
1
    if (sigaction(SIGALRM, &wrapper, NULL) != 0)
495
0
        sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL);
496
1
}
scan.c:fuzz_alarm_wrap
Line
Count
Source
473
2.87k
{
474
2.87k
    if (fuzz_alarm.wrapped)
475
2.87k
        return;
476
1
    fuzz_alarm.wrapped = 1;
477
478
1
    struct sigaction current;
479
1
    if (sigaction(SIGALRM, NULL, &current) != 0 ||
480
1
        !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL)
481
0
        return;  /* no alarm: AFL++'s driver, -timeout=0, tests */
482
483
1
    struct sigaction dump;
484
1
    memset(&dump, 0, sizeof dump);
485
1
    dump.sa_sigaction = fuzz_dump_handler;
486
1
    dump.sa_flags = SA_SIGINFO;
487
1
    sigemptyset(&dump.sa_mask);
488
1
    if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0)
489
0
        return;
490
491
1
    fuzz_alarm.chain = current;
492
1
    struct sigaction wrapper = current;
493
1
    wrapper.sa_sigaction = fuzz_alarm_handler;
494
1
    if (sigaction(SIGALRM, &wrapper, NULL) != 0)
495
0
        sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL);
496
1
}
colors.c:fuzz_alarm_wrap
Line
Count
Source
473
3.90k
{
474
3.90k
    if (fuzz_alarm.wrapped)
475
3.90k
        return;
476
1
    fuzz_alarm.wrapped = 1;
477
478
1
    struct sigaction current;
479
1
    if (sigaction(SIGALRM, NULL, &current) != 0 ||
480
1
        !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL)
481
0
        return;  /* no alarm: AFL++'s driver, -timeout=0, tests */
482
483
1
    struct sigaction dump;
484
1
    memset(&dump, 0, sizeof dump);
485
1
    dump.sa_sigaction = fuzz_dump_handler;
486
1
    dump.sa_flags = SA_SIGINFO;
487
1
    sigemptyset(&dump.sa_mask);
488
1
    if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0)
489
0
        return;
490
491
1
    fuzz_alarm.chain = current;
492
1
    struct sigaction wrapper = current;
493
1
    wrapper.sa_sigaction = fuzz_alarm_handler;
494
1
    if (sigaction(SIGALRM, &wrapper, NULL) != 0)
495
0
        sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL);
496
1
}
grep.c:fuzz_alarm_wrap
Line
Count
Source
473
2.17k
{
474
2.17k
    if (fuzz_alarm.wrapped)
475
2.17k
        return;
476
1
    fuzz_alarm.wrapped = 1;
477
478
1
    struct sigaction current;
479
1
    if (sigaction(SIGALRM, NULL, &current) != 0 ||
480
1
        !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL)
481
0
        return;  /* no alarm: AFL++'s driver, -timeout=0, tests */
482
483
1
    struct sigaction dump;
484
1
    memset(&dump, 0, sizeof dump);
485
1
    dump.sa_sigaction = fuzz_dump_handler;
486
1
    dump.sa_flags = SA_SIGINFO;
487
1
    sigemptyset(&dump.sa_mask);
488
1
    if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0)
489
0
        return;
490
491
1
    fuzz_alarm.chain = current;
492
1
    struct sigaction wrapper = current;
493
1
    wrapper.sa_sigaction = fuzz_alarm_handler;
494
1
    if (sigaction(SIGALRM, &wrapper, NULL) != 0)
495
0
        sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL);
496
1
}
parse.c:fuzz_alarm_wrap
Line
Count
Source
473
9.28k
{
474
9.28k
    if (fuzz_alarm.wrapped)
475
9.28k
        return;
476
1
    fuzz_alarm.wrapped = 1;
477
478
1
    struct sigaction current;
479
1
    if (sigaction(SIGALRM, NULL, &current) != 0 ||
480
1
        !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL)
481
0
        return;  /* no alarm: AFL++'s driver, -timeout=0, tests */
482
483
1
    struct sigaction dump;
484
1
    memset(&dump, 0, sizeof dump);
485
1
    dump.sa_sigaction = fuzz_dump_handler;
486
1
    dump.sa_flags = SA_SIGINFO;
487
1
    sigemptyset(&dump.sa_mask);
488
1
    if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0)
489
0
        return;
490
491
1
    fuzz_alarm.chain = current;
492
1
    struct sigaction wrapper = current;
493
1
    wrapper.sa_sigaction = fuzz_alarm_handler;
494
1
    if (sigaction(SIGALRM, &wrapper, NULL) != 0)
495
0
        sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL);
496
1
}
sockets.c:fuzz_alarm_wrap
Line
Count
Source
473
1.98k
{
474
1.98k
    if (fuzz_alarm.wrapped)
475
1.98k
        return;
476
1
    fuzz_alarm.wrapped = 1;
477
478
1
    struct sigaction current;
479
1
    if (sigaction(SIGALRM, NULL, &current) != 0 ||
480
1
        !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL)
481
0
        return;  /* no alarm: AFL++'s driver, -timeout=0, tests */
482
483
1
    struct sigaction dump;
484
1
    memset(&dump, 0, sizeof dump);
485
1
    dump.sa_sigaction = fuzz_dump_handler;
486
1
    dump.sa_flags = SA_SIGINFO;
487
1
    sigemptyset(&dump.sa_mask);
488
1
    if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0)
489
0
        return;
490
491
1
    fuzz_alarm.chain = current;
492
1
    struct sigaction wrapper = current;
493
1
    wrapper.sa_sigaction = fuzz_alarm_handler;
494
1
    if (sigaction(SIGALRM, &wrapper, NULL) != 0)
495
0
        sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL);
496
1
}
rd.c:fuzz_alarm_wrap
Line
Count
Source
473
5.09k
{
474
5.09k
    if (fuzz_alarm.wrapped)
475
5.08k
        return;
476
1
    fuzz_alarm.wrapped = 1;
477
478
1
    struct sigaction current;
479
1
    if (sigaction(SIGALRM, NULL, &current) != 0 ||
480
1
        !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL)
481
0
        return;  /* no alarm: AFL++'s driver, -timeout=0, tests */
482
483
1
    struct sigaction dump;
484
1
    memset(&dump, 0, sizeof dump);
485
1
    dump.sa_sigaction = fuzz_dump_handler;
486
1
    dump.sa_flags = SA_SIGINFO;
487
1
    sigemptyset(&dump.sa_mask);
488
1
    if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0)
489
0
        return;
490
491
1
    fuzz_alarm.chain = current;
492
1
    struct sigaction wrapper = current;
493
1
    wrapper.sa_sigaction = fuzz_alarm_handler;
494
1
    if (sigaction(SIGALRM, &wrapper, NULL) != 0)
495
0
        sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL);
496
1
}
sprintf.c:fuzz_alarm_wrap
Line
Count
Source
473
2.08k
{
474
2.08k
    if (fuzz_alarm.wrapped)
475
2.08k
        return;
476
1
    fuzz_alarm.wrapped = 1;
477
478
1
    struct sigaction current;
479
1
    if (sigaction(SIGALRM, NULL, &current) != 0 ||
480
1
        !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL)
481
0
        return;  /* no alarm: AFL++'s driver, -timeout=0, tests */
482
483
1
    struct sigaction dump;
484
1
    memset(&dump, 0, sizeof dump);
485
1
    dump.sa_sigaction = fuzz_dump_handler;
486
1
    dump.sa_flags = SA_SIGINFO;
487
1
    sigemptyset(&dump.sa_mask);
488
1
    if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0)
489
0
        return;
490
491
1
    fuzz_alarm.chain = current;
492
1
    struct sigaction wrapper = current;
493
1
    wrapper.sa_sigaction = fuzz_alarm_handler;
494
1
    if (sigaction(SIGALRM, &wrapper, NULL) != 0)
495
0
        sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL);
496
1
}
eval.c:fuzz_alarm_wrap
Line
Count
Source
473
18.7k
{
474
18.7k
    if (fuzz_alarm.wrapped)
475
18.7k
        return;
476
1
    fuzz_alarm.wrapped = 1;
477
478
1
    struct sigaction current;
479
1
    if (sigaction(SIGALRM, NULL, &current) != 0 ||
480
1
        !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL)
481
0
        return;  /* no alarm: AFL++'s driver, -timeout=0, tests */
482
483
1
    struct sigaction dump;
484
1
    memset(&dump, 0, sizeof dump);
485
1
    dump.sa_sigaction = fuzz_dump_handler;
486
1
    dump.sa_flags = SA_SIGINFO;
487
1
    sigemptyset(&dump.sa_mask);
488
1
    if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0)
489
0
        return;
490
491
1
    fuzz_alarm.chain = current;
492
1
    struct sigaction wrapper = current;
493
1
    wrapper.sa_sigaction = fuzz_alarm_handler;
494
1
    if (sigaction(SIGALRM, &wrapper, NULL) != 0)
495
0
        sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL);
496
1
}
zip.c:fuzz_alarm_wrap
Line
Count
Source
473
2.09k
{
474
2.09k
    if (fuzz_alarm.wrapped)
475
2.09k
        return;
476
1
    fuzz_alarm.wrapped = 1;
477
478
1
    struct sigaction current;
479
1
    if (sigaction(SIGALRM, NULL, &current) != 0 ||
480
1
        !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL)
481
0
        return;  /* no alarm: AFL++'s driver, -timeout=0, tests */
482
483
1
    struct sigaction dump;
484
1
    memset(&dump, 0, sizeof dump);
485
1
    dump.sa_sigaction = fuzz_dump_handler;
486
1
    dump.sa_flags = SA_SIGINFO;
487
1
    sigemptyset(&dump.sa_mask);
488
1
    if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0)
489
0
        return;
490
491
1
    fuzz_alarm.chain = current;
492
1
    struct sigaction wrapper = current;
493
1
    wrapper.sa_sigaction = fuzz_alarm_handler;
494
1
    if (sigaction(SIGALRM, &wrapper, NULL) != 0)
495
0
        sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL);
496
1
}
nmath.c:fuzz_alarm_wrap
Line
Count
Source
473
12.2k
{
474
12.2k
    if (fuzz_alarm.wrapped)
475
12.2k
        return;
476
1
    fuzz_alarm.wrapped = 1;
477
478
1
    struct sigaction current;
479
1
    if (sigaction(SIGALRM, NULL, &current) != 0 ||
480
1
        !(current.sa_flags & SA_SIGINFO) || current.sa_sigaction == NULL)
481
0
        return;  /* no alarm: AFL++'s driver, -timeout=0, tests */
482
483
1
    struct sigaction dump;
484
1
    memset(&dump, 0, sizeof dump);
485
1
    dump.sa_sigaction = fuzz_dump_handler;
486
1
    dump.sa_flags = SA_SIGINFO;
487
1
    sigemptyset(&dump.sa_mask);
488
1
    if (sigaction(FUZZ_DUMP_SIGNAL, &dump, NULL) != 0)
489
0
        return;
490
491
1
    fuzz_alarm.chain = current;
492
1
    struct sigaction wrapper = current;
493
1
    wrapper.sa_sigaction = fuzz_alarm_handler;
494
1
    if (sigaction(SIGALRM, &wrapper, NULL) != 0)
495
0
        sigaction(FUZZ_DUMP_SIGNAL, &(struct sigaction){ .sa_handler = SIG_DFL }, NULL);
496
1
}
497
498
static void *fuzz_r_thread_main(void *unused)
499
48
{
500
48
    (void)unused;
501
    /* The frame address rather than a local's: under ASAN an address-taken
502
     * local may sit on the fake stack, nowhere near this thread's stack.
503
     * R_CStackStart matters only once R is initialized; fuzz_init_r()
504
     * sets it again after Rf_initialize_R has overwritten it. */
505
48
    fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0);
506
48
    R_CStackStart = fuzz_r_thread.stack_top;
507
508
    /* libFuzzer's -timeout alarm is acted on only by the thread running
509
     * its loop (the main thread); delivered here it would be ignored and
510
     * the input would run on.  Block it so the kernel cannot pick this
511
     * thread; fuzz_alarm_handler below gets this thread's stack into the
512
     * timeout report instead. */
513
48
    sigset_t alarm;
514
48
    sigemptyset(&alarm);
515
48
    sigaddset(&alarm, SIGALRM);
516
48
    pthread_sigmask(SIG_BLOCK, &alarm, NULL);
517
518
48
    pthread_mutex_lock(&fuzz_r_thread.mutex);
519
143k
    for (;;) {
520
286k
        while (fuzz_r_thread.job == NULL)
521
143k
            pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
522
143k
        fuzz_job_t *job = fuzz_r_thread.job;
523
143k
        pthread_mutex_unlock(&fuzz_r_thread.mutex);
524
525
143k
        clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started);
526
143k
        atomic_store(&fuzz_alarm.running, 1);
527
143k
        job->fn(job->arg);
528
143k
        atomic_store(&fuzz_alarm.running, 0);
529
530
143k
        pthread_mutex_lock(&fuzz_r_thread.mutex);
531
143k
        fuzz_r_thread.job = NULL;
532
143k
        pthread_cond_broadcast(&fuzz_r_thread.cond);
533
143k
    }
534
48
    return NULL;
535
48
}
io.c:fuzz_r_thread_main
Line
Count
Source
499
2
{
500
2
    (void)unused;
501
    /* The frame address rather than a local's: under ASAN an address-taken
502
     * local may sit on the fake stack, nowhere near this thread's stack.
503
     * R_CStackStart matters only once R is initialized; fuzz_init_r()
504
     * sets it again after Rf_initialize_R has overwritten it. */
505
2
    fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0);
506
2
    R_CStackStart = fuzz_r_thread.stack_top;
507
508
    /* libFuzzer's -timeout alarm is acted on only by the thread running
509
     * its loop (the main thread); delivered here it would be ignored and
510
     * the input would run on.  Block it so the kernel cannot pick this
511
     * thread; fuzz_alarm_handler below gets this thread's stack into the
512
     * timeout report instead. */
513
2
    sigset_t alarm;
514
2
    sigemptyset(&alarm);
515
2
    sigaddset(&alarm, SIGALRM);
516
2
    pthread_sigmask(SIG_BLOCK, &alarm, NULL);
517
518
2
    pthread_mutex_lock(&fuzz_r_thread.mutex);
519
1.40k
    for (;;) {
520
2.80k
        while (fuzz_r_thread.job == NULL)
521
1.40k
            pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
522
1.40k
        fuzz_job_t *job = fuzz_r_thread.job;
523
1.40k
        pthread_mutex_unlock(&fuzz_r_thread.mutex);
524
525
1.40k
        clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started);
526
1.40k
        atomic_store(&fuzz_alarm.running, 1);
527
1.40k
        job->fn(job->arg);
528
1.40k
        atomic_store(&fuzz_alarm.running, 0);
529
530
1.40k
        pthread_mutex_lock(&fuzz_r_thread.mutex);
531
1.40k
        fuzz_r_thread.job = NULL;
532
1.40k
        pthread_cond_broadcast(&fuzz_r_thread.cond);
533
1.40k
    }
534
    return NULL;
535
2
}
dcf.c:fuzz_r_thread_main
Line
Count
Source
499
2
{
500
2
    (void)unused;
501
    /* The frame address rather than a local's: under ASAN an address-taken
502
     * local may sit on the fake stack, nowhere near this thread's stack.
503
     * R_CStackStart matters only once R is initialized; fuzz_init_r()
504
     * sets it again after Rf_initialize_R has overwritten it. */
505
2
    fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0);
506
2
    R_CStackStart = fuzz_r_thread.stack_top;
507
508
    /* libFuzzer's -timeout alarm is acted on only by the thread running
509
     * its loop (the main thread); delivered here it would be ignored and
510
     * the input would run on.  Block it so the kernel cannot pick this
511
     * thread; fuzz_alarm_handler below gets this thread's stack into the
512
     * timeout report instead. */
513
2
    sigset_t alarm;
514
2
    sigemptyset(&alarm);
515
2
    sigaddset(&alarm, SIGALRM);
516
2
    pthread_sigmask(SIG_BLOCK, &alarm, NULL);
517
518
2
    pthread_mutex_lock(&fuzz_r_thread.mutex);
519
4.73k
    for (;;) {
520
9.47k
        while (fuzz_r_thread.job == NULL)
521
4.73k
            pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
522
4.73k
        fuzz_job_t *job = fuzz_r_thread.job;
523
4.73k
        pthread_mutex_unlock(&fuzz_r_thread.mutex);
524
525
4.73k
        clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started);
526
4.73k
        atomic_store(&fuzz_alarm.running, 1);
527
4.73k
        job->fn(job->arg);
528
4.73k
        atomic_store(&fuzz_alarm.running, 0);
529
530
4.73k
        pthread_mutex_lock(&fuzz_r_thread.mutex);
531
4.73k
        fuzz_r_thread.job = NULL;
532
4.73k
        pthread_cond_broadcast(&fuzz_r_thread.cond);
533
4.73k
    }
534
    return NULL;
535
2
}
character.c:fuzz_r_thread_main
Line
Count
Source
499
2
{
500
2
    (void)unused;
501
    /* The frame address rather than a local's: under ASAN an address-taken
502
     * local may sit on the fake stack, nowhere near this thread's stack.
503
     * R_CStackStart matters only once R is initialized; fuzz_init_r()
504
     * sets it again after Rf_initialize_R has overwritten it. */
505
2
    fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0);
506
2
    R_CStackStart = fuzz_r_thread.stack_top;
507
508
    /* libFuzzer's -timeout alarm is acted on only by the thread running
509
     * its loop (the main thread); delivered here it would be ignored and
510
     * the input would run on.  Block it so the kernel cannot pick this
511
     * thread; fuzz_alarm_handler below gets this thread's stack into the
512
     * timeout report instead. */
513
2
    sigset_t alarm;
514
2
    sigemptyset(&alarm);
515
2
    sigaddset(&alarm, SIGALRM);
516
2
    pthread_sigmask(SIG_BLOCK, &alarm, NULL);
517
518
2
    pthread_mutex_lock(&fuzz_r_thread.mutex);
519
4.10k
    for (;;) {
520
8.20k
        while (fuzz_r_thread.job == NULL)
521
4.09k
            pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
522
4.10k
        fuzz_job_t *job = fuzz_r_thread.job;
523
4.10k
        pthread_mutex_unlock(&fuzz_r_thread.mutex);
524
525
4.10k
        clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started);
526
4.10k
        atomic_store(&fuzz_alarm.running, 1);
527
4.10k
        job->fn(job->arg);
528
4.10k
        atomic_store(&fuzz_alarm.running, 0);
529
530
4.10k
        pthread_mutex_lock(&fuzz_r_thread.mutex);
531
4.10k
        fuzz_r_thread.job = NULL;
532
4.10k
        pthread_cond_broadcast(&fuzz_r_thread.cond);
533
4.10k
    }
534
    return NULL;
535
2
}
encoding.c:fuzz_r_thread_main
Line
Count
Source
499
2
{
500
2
    (void)unused;
501
    /* The frame address rather than a local's: under ASAN an address-taken
502
     * local may sit on the fake stack, nowhere near this thread's stack.
503
     * R_CStackStart matters only once R is initialized; fuzz_init_r()
504
     * sets it again after Rf_initialize_R has overwritten it. */
505
2
    fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0);
506
2
    R_CStackStart = fuzz_r_thread.stack_top;
507
508
    /* libFuzzer's -timeout alarm is acted on only by the thread running
509
     * its loop (the main thread); delivered here it would be ignored and
510
     * the input would run on.  Block it so the kernel cannot pick this
511
     * thread; fuzz_alarm_handler below gets this thread's stack into the
512
     * timeout report instead. */
513
2
    sigset_t alarm;
514
2
    sigemptyset(&alarm);
515
2
    sigaddset(&alarm, SIGALRM);
516
2
    pthread_sigmask(SIG_BLOCK, &alarm, NULL);
517
518
2
    pthread_mutex_lock(&fuzz_r_thread.mutex);
519
1.78k
    for (;;) {
520
3.55k
        while (fuzz_r_thread.job == NULL)
521
1.77k
            pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
522
1.78k
        fuzz_job_t *job = fuzz_r_thread.job;
523
1.78k
        pthread_mutex_unlock(&fuzz_r_thread.mutex);
524
525
1.78k
        clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started);
526
1.78k
        atomic_store(&fuzz_alarm.running, 1);
527
1.78k
        job->fn(job->arg);
528
1.78k
        atomic_store(&fuzz_alarm.running, 0);
529
530
1.78k
        pthread_mutex_lock(&fuzz_r_thread.mutex);
531
1.78k
        fuzz_r_thread.job = NULL;
532
1.78k
        pthread_cond_broadcast(&fuzz_r_thread.cond);
533
1.78k
    }
534
    return NULL;
535
2
}
sort.c:fuzz_r_thread_main
Line
Count
Source
499
2
{
500
2
    (void)unused;
501
    /* The frame address rather than a local's: under ASAN an address-taken
502
     * local may sit on the fake stack, nowhere near this thread's stack.
503
     * R_CStackStart matters only once R is initialized; fuzz_init_r()
504
     * sets it again after Rf_initialize_R has overwritten it. */
505
2
    fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0);
506
2
    R_CStackStart = fuzz_r_thread.stack_top;
507
508
    /* libFuzzer's -timeout alarm is acted on only by the thread running
509
     * its loop (the main thread); delivered here it would be ignored and
510
     * the input would run on.  Block it so the kernel cannot pick this
511
     * thread; fuzz_alarm_handler below gets this thread's stack into the
512
     * timeout report instead. */
513
2
    sigset_t alarm;
514
2
    sigemptyset(&alarm);
515
2
    sigaddset(&alarm, SIGALRM);
516
2
    pthread_sigmask(SIG_BLOCK, &alarm, NULL);
517
518
2
    pthread_mutex_lock(&fuzz_r_thread.mutex);
519
6.80k
    for (;;) {
520
13.6k
        while (fuzz_r_thread.job == NULL)
521
6.80k
            pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
522
6.80k
        fuzz_job_t *job = fuzz_r_thread.job;
523
6.80k
        pthread_mutex_unlock(&fuzz_r_thread.mutex);
524
525
6.80k
        clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started);
526
6.80k
        atomic_store(&fuzz_alarm.running, 1);
527
6.80k
        job->fn(job->arg);
528
6.80k
        atomic_store(&fuzz_alarm.running, 0);
529
530
6.80k
        pthread_mutex_lock(&fuzz_r_thread.mutex);
531
6.80k
        fuzz_r_thread.job = NULL;
532
6.80k
        pthread_cond_broadcast(&fuzz_r_thread.cond);
533
6.80k
    }
534
    return NULL;
535
2
}
connections.c:fuzz_r_thread_main
Line
Count
Source
499
2
{
500
2
    (void)unused;
501
    /* The frame address rather than a local's: under ASAN an address-taken
502
     * local may sit on the fake stack, nowhere near this thread's stack.
503
     * R_CStackStart matters only once R is initialized; fuzz_init_r()
504
     * sets it again after Rf_initialize_R has overwritten it. */
505
2
    fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0);
506
2
    R_CStackStart = fuzz_r_thread.stack_top;
507
508
    /* libFuzzer's -timeout alarm is acted on only by the thread running
509
     * its loop (the main thread); delivered here it would be ignored and
510
     * the input would run on.  Block it so the kernel cannot pick this
511
     * thread; fuzz_alarm_handler below gets this thread's stack into the
512
     * timeout report instead. */
513
2
    sigset_t alarm;
514
2
    sigemptyset(&alarm);
515
2
    sigaddset(&alarm, SIGALRM);
516
2
    pthread_sigmask(SIG_BLOCK, &alarm, NULL);
517
518
2
    pthread_mutex_lock(&fuzz_r_thread.mutex);
519
8.33k
    for (;;) {
520
16.6k
        while (fuzz_r_thread.job == NULL)
521
8.33k
            pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
522
8.33k
        fuzz_job_t *job = fuzz_r_thread.job;
523
8.33k
        pthread_mutex_unlock(&fuzz_r_thread.mutex);
524
525
8.33k
        clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started);
526
8.33k
        atomic_store(&fuzz_alarm.running, 1);
527
8.33k
        job->fn(job->arg);
528
8.33k
        atomic_store(&fuzz_alarm.running, 0);
529
530
8.33k
        pthread_mutex_lock(&fuzz_r_thread.mutex);
531
8.33k
        fuzz_r_thread.job = NULL;
532
8.33k
        pthread_cond_broadcast(&fuzz_r_thread.cond);
533
8.33k
    }
534
    return NULL;
535
2
}
unserialize.c:fuzz_r_thread_main
Line
Count
Source
499
2
{
500
2
    (void)unused;
501
    /* The frame address rather than a local's: under ASAN an address-taken
502
     * local may sit on the fake stack, nowhere near this thread's stack.
503
     * R_CStackStart matters only once R is initialized; fuzz_init_r()
504
     * sets it again after Rf_initialize_R has overwritten it. */
505
2
    fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0);
506
2
    R_CStackStart = fuzz_r_thread.stack_top;
507
508
    /* libFuzzer's -timeout alarm is acted on only by the thread running
509
     * its loop (the main thread); delivered here it would be ignored and
510
     * the input would run on.  Block it so the kernel cannot pick this
511
     * thread; fuzz_alarm_handler below gets this thread's stack into the
512
     * timeout report instead. */
513
2
    sigset_t alarm;
514
2
    sigemptyset(&alarm);
515
2
    sigaddset(&alarm, SIGALRM);
516
2
    pthread_sigmask(SIG_BLOCK, &alarm, NULL);
517
518
2
    pthread_mutex_lock(&fuzz_r_thread.mutex);
519
5.70k
    for (;;) {
520
11.4k
        while (fuzz_r_thread.job == NULL)
521
5.70k
            pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
522
5.70k
        fuzz_job_t *job = fuzz_r_thread.job;
523
5.70k
        pthread_mutex_unlock(&fuzz_r_thread.mutex);
524
525
5.70k
        clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started);
526
5.70k
        atomic_store(&fuzz_alarm.running, 1);
527
5.70k
        job->fn(job->arg);
528
5.70k
        atomic_store(&fuzz_alarm.running, 0);
529
530
5.70k
        pthread_mutex_lock(&fuzz_r_thread.mutex);
531
5.70k
        fuzz_r_thread.job = NULL;
532
5.70k
        pthread_cond_broadcast(&fuzz_r_thread.cond);
533
5.70k
    }
534
    return NULL;
535
2
}
formula.c:fuzz_r_thread_main
Line
Count
Source
499
2
{
500
2
    (void)unused;
501
    /* The frame address rather than a local's: under ASAN an address-taken
502
     * local may sit on the fake stack, nowhere near this thread's stack.
503
     * R_CStackStart matters only once R is initialized; fuzz_init_r()
504
     * sets it again after Rf_initialize_R has overwritten it. */
505
2
    fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0);
506
2
    R_CStackStart = fuzz_r_thread.stack_top;
507
508
    /* libFuzzer's -timeout alarm is acted on only by the thread running
509
     * its loop (the main thread); delivered here it would be ignored and
510
     * the input would run on.  Block it so the kernel cannot pick this
511
     * thread; fuzz_alarm_handler below gets this thread's stack into the
512
     * timeout report instead. */
513
2
    sigset_t alarm;
514
2
    sigemptyset(&alarm);
515
2
    sigaddset(&alarm, SIGALRM);
516
2
    pthread_sigmask(SIG_BLOCK, &alarm, NULL);
517
518
2
    pthread_mutex_lock(&fuzz_r_thread.mutex);
519
12.3k
    for (;;) {
520
24.7k
        while (fuzz_r_thread.job == NULL)
521
12.3k
            pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
522
12.3k
        fuzz_job_t *job = fuzz_r_thread.job;
523
12.3k
        pthread_mutex_unlock(&fuzz_r_thread.mutex);
524
525
12.3k
        clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started);
526
12.3k
        atomic_store(&fuzz_alarm.running, 1);
527
12.3k
        job->fn(job->arg);
528
12.3k
        atomic_store(&fuzz_alarm.running, 0);
529
530
12.3k
        pthread_mutex_lock(&fuzz_r_thread.mutex);
531
12.3k
        fuzz_r_thread.job = NULL;
532
12.3k
        pthread_cond_broadcast(&fuzz_r_thread.cond);
533
12.3k
    }
534
    return NULL;
535
2
}
decompress.c:fuzz_r_thread_main
Line
Count
Source
499
2
{
500
2
    (void)unused;
501
    /* The frame address rather than a local's: under ASAN an address-taken
502
     * local may sit on the fake stack, nowhere near this thread's stack.
503
     * R_CStackStart matters only once R is initialized; fuzz_init_r()
504
     * sets it again after Rf_initialize_R has overwritten it. */
505
2
    fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0);
506
2
    R_CStackStart = fuzz_r_thread.stack_top;
507
508
    /* libFuzzer's -timeout alarm is acted on only by the thread running
509
     * its loop (the main thread); delivered here it would be ignored and
510
     * the input would run on.  Block it so the kernel cannot pick this
511
     * thread; fuzz_alarm_handler below gets this thread's stack into the
512
     * timeout report instead. */
513
2
    sigset_t alarm;
514
2
    sigemptyset(&alarm);
515
2
    sigaddset(&alarm, SIGALRM);
516
2
    pthread_sigmask(SIG_BLOCK, &alarm, NULL);
517
518
2
    pthread_mutex_lock(&fuzz_r_thread.mutex);
519
7.60k
    for (;;) {
520
15.2k
        while (fuzz_r_thread.job == NULL)
521
7.60k
            pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
522
7.60k
        fuzz_job_t *job = fuzz_r_thread.job;
523
7.60k
        pthread_mutex_unlock(&fuzz_r_thread.mutex);
524
525
7.60k
        clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started);
526
7.60k
        atomic_store(&fuzz_alarm.running, 1);
527
7.60k
        job->fn(job->arg);
528
7.60k
        atomic_store(&fuzz_alarm.running, 0);
529
530
7.60k
        pthread_mutex_lock(&fuzz_r_thread.mutex);
531
7.60k
        fuzz_r_thread.job = NULL;
532
7.60k
        pthread_cond_broadcast(&fuzz_r_thread.cond);
533
7.60k
    }
534
    return NULL;
535
2
}
readtable.c:fuzz_r_thread_main
Line
Count
Source
499
2
{
500
2
    (void)unused;
501
    /* The frame address rather than a local's: under ASAN an address-taken
502
     * local may sit on the fake stack, nowhere near this thread's stack.
503
     * R_CStackStart matters only once R is initialized; fuzz_init_r()
504
     * sets it again after Rf_initialize_R has overwritten it. */
505
2
    fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0);
506
2
    R_CStackStart = fuzz_r_thread.stack_top;
507
508
    /* libFuzzer's -timeout alarm is acted on only by the thread running
509
     * its loop (the main thread); delivered here it would be ignored and
510
     * the input would run on.  Block it so the kernel cannot pick this
511
     * thread; fuzz_alarm_handler below gets this thread's stack into the
512
     * timeout report instead. */
513
2
    sigset_t alarm;
514
2
    sigemptyset(&alarm);
515
2
    sigaddset(&alarm, SIGALRM);
516
2
    pthread_sigmask(SIG_BLOCK, &alarm, NULL);
517
518
2
    pthread_mutex_lock(&fuzz_r_thread.mutex);
519
5.10k
    for (;;) {
520
10.2k
        while (fuzz_r_thread.job == NULL)
521
5.10k
            pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
522
5.10k
        fuzz_job_t *job = fuzz_r_thread.job;
523
5.10k
        pthread_mutex_unlock(&fuzz_r_thread.mutex);
524
525
5.10k
        clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started);
526
5.10k
        atomic_store(&fuzz_alarm.running, 1);
527
5.10k
        job->fn(job->arg);
528
5.10k
        atomic_store(&fuzz_alarm.running, 0);
529
530
5.10k
        pthread_mutex_lock(&fuzz_r_thread.mutex);
531
5.10k
        fuzz_r_thread.job = NULL;
532
5.10k
        pthread_cond_broadcast(&fuzz_r_thread.cond);
533
5.10k
    }
534
    return NULL;
535
2
}
format.c:fuzz_r_thread_main
Line
Count
Source
499
2
{
500
2
    (void)unused;
501
    /* The frame address rather than a local's: under ASAN an address-taken
502
     * local may sit on the fake stack, nowhere near this thread's stack.
503
     * R_CStackStart matters only once R is initialized; fuzz_init_r()
504
     * sets it again after Rf_initialize_R has overwritten it. */
505
2
    fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0);
506
2
    R_CStackStart = fuzz_r_thread.stack_top;
507
508
    /* libFuzzer's -timeout alarm is acted on only by the thread running
509
     * its loop (the main thread); delivered here it would be ignored and
510
     * the input would run on.  Block it so the kernel cannot pick this
511
     * thread; fuzz_alarm_handler below gets this thread's stack into the
512
     * timeout report instead. */
513
2
    sigset_t alarm;
514
2
    sigemptyset(&alarm);
515
2
    sigaddset(&alarm, SIGALRM);
516
2
    pthread_sigmask(SIG_BLOCK, &alarm, NULL);
517
518
2
    pthread_mutex_lock(&fuzz_r_thread.mutex);
519
5.50k
    for (;;) {
520
11.0k
        while (fuzz_r_thread.job == NULL)
521
5.50k
            pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
522
5.50k
        fuzz_job_t *job = fuzz_r_thread.job;
523
5.50k
        pthread_mutex_unlock(&fuzz_r_thread.mutex);
524
525
5.50k
        clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started);
526
5.50k
        atomic_store(&fuzz_alarm.running, 1);
527
5.50k
        job->fn(job->arg);
528
5.50k
        atomic_store(&fuzz_alarm.running, 0);
529
530
5.50k
        pthread_mutex_lock(&fuzz_r_thread.mutex);
531
5.50k
        fuzz_r_thread.job = NULL;
532
5.50k
        pthread_cond_broadcast(&fuzz_r_thread.cond);
533
5.50k
    }
534
    return NULL;
535
2
}
datetime.c:fuzz_r_thread_main
Line
Count
Source
499
2
{
500
2
    (void)unused;
501
    /* The frame address rather than a local's: under ASAN an address-taken
502
     * local may sit on the fake stack, nowhere near this thread's stack.
503
     * R_CStackStart matters only once R is initialized; fuzz_init_r()
504
     * sets it again after Rf_initialize_R has overwritten it. */
505
2
    fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0);
506
2
    R_CStackStart = fuzz_r_thread.stack_top;
507
508
    /* libFuzzer's -timeout alarm is acted on only by the thread running
509
     * its loop (the main thread); delivered here it would be ignored and
510
     * the input would run on.  Block it so the kernel cannot pick this
511
     * thread; fuzz_alarm_handler below gets this thread's stack into the
512
     * timeout report instead. */
513
2
    sigset_t alarm;
514
2
    sigemptyset(&alarm);
515
2
    sigaddset(&alarm, SIGALRM);
516
2
    pthread_sigmask(SIG_BLOCK, &alarm, NULL);
517
518
2
    pthread_mutex_lock(&fuzz_r_thread.mutex);
519
6.31k
    for (;;) {
520
12.6k
        while (fuzz_r_thread.job == NULL)
521
6.31k
            pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
522
6.31k
        fuzz_job_t *job = fuzz_r_thread.job;
523
6.31k
        pthread_mutex_unlock(&fuzz_r_thread.mutex);
524
525
6.31k
        clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started);
526
6.31k
        atomic_store(&fuzz_alarm.running, 1);
527
6.31k
        job->fn(job->arg);
528
6.31k
        atomic_store(&fuzz_alarm.running, 0);
529
530
6.31k
        pthread_mutex_lock(&fuzz_r_thread.mutex);
531
6.31k
        fuzz_r_thread.job = NULL;
532
6.31k
        pthread_cond_broadcast(&fuzz_r_thread.cond);
533
6.31k
    }
534
    return NULL;
535
2
}
coerce.c:fuzz_r_thread_main
Line
Count
Source
499
2
{
500
2
    (void)unused;
501
    /* The frame address rather than a local's: under ASAN an address-taken
502
     * local may sit on the fake stack, nowhere near this thread's stack.
503
     * R_CStackStart matters only once R is initialized; fuzz_init_r()
504
     * sets it again after Rf_initialize_R has overwritten it. */
505
2
    fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0);
506
2
    R_CStackStart = fuzz_r_thread.stack_top;
507
508
    /* libFuzzer's -timeout alarm is acted on only by the thread running
509
     * its loop (the main thread); delivered here it would be ignored and
510
     * the input would run on.  Block it so the kernel cannot pick this
511
     * thread; fuzz_alarm_handler below gets this thread's stack into the
512
     * timeout report instead. */
513
2
    sigset_t alarm;
514
2
    sigemptyset(&alarm);
515
2
    sigaddset(&alarm, SIGALRM);
516
2
    pthread_sigmask(SIG_BLOCK, &alarm, NULL);
517
518
2
    pthread_mutex_lock(&fuzz_r_thread.mutex);
519
1.78k
    for (;;) {
520
3.57k
        while (fuzz_r_thread.job == NULL)
521
1.78k
            pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
522
1.78k
        fuzz_job_t *job = fuzz_r_thread.job;
523
1.78k
        pthread_mutex_unlock(&fuzz_r_thread.mutex);
524
525
1.78k
        clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started);
526
1.78k
        atomic_store(&fuzz_alarm.running, 1);
527
1.78k
        job->fn(job->arg);
528
1.78k
        atomic_store(&fuzz_alarm.running, 0);
529
530
1.78k
        pthread_mutex_lock(&fuzz_r_thread.mutex);
531
1.78k
        fuzz_r_thread.job = NULL;
532
1.78k
        pthread_cond_broadcast(&fuzz_r_thread.cond);
533
1.78k
    }
534
    return NULL;
535
2
}
load.c:fuzz_r_thread_main
Line
Count
Source
499
2
{
500
2
    (void)unused;
501
    /* The frame address rather than a local's: under ASAN an address-taken
502
     * local may sit on the fake stack, nowhere near this thread's stack.
503
     * R_CStackStart matters only once R is initialized; fuzz_init_r()
504
     * sets it again after Rf_initialize_R has overwritten it. */
505
2
    fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0);
506
2
    R_CStackStart = fuzz_r_thread.stack_top;
507
508
    /* libFuzzer's -timeout alarm is acted on only by the thread running
509
     * its loop (the main thread); delivered here it would be ignored and
510
     * the input would run on.  Block it so the kernel cannot pick this
511
     * thread; fuzz_alarm_handler below gets this thread's stack into the
512
     * timeout report instead. */
513
2
    sigset_t alarm;
514
2
    sigemptyset(&alarm);
515
2
    sigaddset(&alarm, SIGALRM);
516
2
    pthread_sigmask(SIG_BLOCK, &alarm, NULL);
517
518
2
    pthread_mutex_lock(&fuzz_r_thread.mutex);
519
11.1k
    for (;;) {
520
22.2k
        while (fuzz_r_thread.job == NULL)
521
11.1k
            pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
522
11.1k
        fuzz_job_t *job = fuzz_r_thread.job;
523
11.1k
        pthread_mutex_unlock(&fuzz_r_thread.mutex);
524
525
11.1k
        clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started);
526
11.1k
        atomic_store(&fuzz_alarm.running, 1);
527
11.1k
        job->fn(job->arg);
528
11.1k
        atomic_store(&fuzz_alarm.running, 0);
529
530
11.1k
        pthread_mutex_lock(&fuzz_r_thread.mutex);
531
11.1k
        fuzz_r_thread.job = NULL;
532
11.1k
        pthread_cond_broadcast(&fuzz_r_thread.cond);
533
11.1k
    }
534
    return NULL;
535
2
}
scan.c:fuzz_r_thread_main
Line
Count
Source
499
2
{
500
2
    (void)unused;
501
    /* The frame address rather than a local's: under ASAN an address-taken
502
     * local may sit on the fake stack, nowhere near this thread's stack.
503
     * R_CStackStart matters only once R is initialized; fuzz_init_r()
504
     * sets it again after Rf_initialize_R has overwritten it. */
505
2
    fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0);
506
2
    R_CStackStart = fuzz_r_thread.stack_top;
507
508
    /* libFuzzer's -timeout alarm is acted on only by the thread running
509
     * its loop (the main thread); delivered here it would be ignored and
510
     * the input would run on.  Block it so the kernel cannot pick this
511
     * thread; fuzz_alarm_handler below gets this thread's stack into the
512
     * timeout report instead. */
513
2
    sigset_t alarm;
514
2
    sigemptyset(&alarm);
515
2
    sigaddset(&alarm, SIGALRM);
516
2
    pthread_sigmask(SIG_BLOCK, &alarm, NULL);
517
518
2
    pthread_mutex_lock(&fuzz_r_thread.mutex);
519
2.87k
    for (;;) {
520
5.75k
        while (fuzz_r_thread.job == NULL)
521
2.87k
            pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
522
2.87k
        fuzz_job_t *job = fuzz_r_thread.job;
523
2.87k
        pthread_mutex_unlock(&fuzz_r_thread.mutex);
524
525
2.87k
        clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started);
526
2.87k
        atomic_store(&fuzz_alarm.running, 1);
527
2.87k
        job->fn(job->arg);
528
2.87k
        atomic_store(&fuzz_alarm.running, 0);
529
530
2.87k
        pthread_mutex_lock(&fuzz_r_thread.mutex);
531
2.87k
        fuzz_r_thread.job = NULL;
532
2.87k
        pthread_cond_broadcast(&fuzz_r_thread.cond);
533
2.87k
    }
534
    return NULL;
535
2
}
colors.c:fuzz_r_thread_main
Line
Count
Source
499
2
{
500
2
    (void)unused;
501
    /* The frame address rather than a local's: under ASAN an address-taken
502
     * local may sit on the fake stack, nowhere near this thread's stack.
503
     * R_CStackStart matters only once R is initialized; fuzz_init_r()
504
     * sets it again after Rf_initialize_R has overwritten it. */
505
2
    fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0);
506
2
    R_CStackStart = fuzz_r_thread.stack_top;
507
508
    /* libFuzzer's -timeout alarm is acted on only by the thread running
509
     * its loop (the main thread); delivered here it would be ignored and
510
     * the input would run on.  Block it so the kernel cannot pick this
511
     * thread; fuzz_alarm_handler below gets this thread's stack into the
512
     * timeout report instead. */
513
2
    sigset_t alarm;
514
2
    sigemptyset(&alarm);
515
2
    sigaddset(&alarm, SIGALRM);
516
2
    pthread_sigmask(SIG_BLOCK, &alarm, NULL);
517
518
2
    pthread_mutex_lock(&fuzz_r_thread.mutex);
519
3.90k
    for (;;) {
520
7.80k
        while (fuzz_r_thread.job == NULL)
521
3.90k
            pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
522
3.90k
        fuzz_job_t *job = fuzz_r_thread.job;
523
3.90k
        pthread_mutex_unlock(&fuzz_r_thread.mutex);
524
525
3.90k
        clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started);
526
3.90k
        atomic_store(&fuzz_alarm.running, 1);
527
3.90k
        job->fn(job->arg);
528
3.90k
        atomic_store(&fuzz_alarm.running, 0);
529
530
3.90k
        pthread_mutex_lock(&fuzz_r_thread.mutex);
531
3.90k
        fuzz_r_thread.job = NULL;
532
3.90k
        pthread_cond_broadcast(&fuzz_r_thread.cond);
533
3.90k
    }
534
    return NULL;
535
2
}
grep.c:fuzz_r_thread_main
Line
Count
Source
499
2
{
500
2
    (void)unused;
501
    /* The frame address rather than a local's: under ASAN an address-taken
502
     * local may sit on the fake stack, nowhere near this thread's stack.
503
     * R_CStackStart matters only once R is initialized; fuzz_init_r()
504
     * sets it again after Rf_initialize_R has overwritten it. */
505
2
    fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0);
506
2
    R_CStackStart = fuzz_r_thread.stack_top;
507
508
    /* libFuzzer's -timeout alarm is acted on only by the thread running
509
     * its loop (the main thread); delivered here it would be ignored and
510
     * the input would run on.  Block it so the kernel cannot pick this
511
     * thread; fuzz_alarm_handler below gets this thread's stack into the
512
     * timeout report instead. */
513
2
    sigset_t alarm;
514
2
    sigemptyset(&alarm);
515
2
    sigaddset(&alarm, SIGALRM);
516
2
    pthread_sigmask(SIG_BLOCK, &alarm, NULL);
517
518
2
    pthread_mutex_lock(&fuzz_r_thread.mutex);
519
2.17k
    for (;;) {
520
4.35k
        while (fuzz_r_thread.job == NULL)
521
2.17k
            pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
522
2.17k
        fuzz_job_t *job = fuzz_r_thread.job;
523
2.17k
        pthread_mutex_unlock(&fuzz_r_thread.mutex);
524
525
2.17k
        clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started);
526
2.17k
        atomic_store(&fuzz_alarm.running, 1);
527
2.17k
        job->fn(job->arg);
528
2.17k
        atomic_store(&fuzz_alarm.running, 0);
529
530
2.17k
        pthread_mutex_lock(&fuzz_r_thread.mutex);
531
2.17k
        fuzz_r_thread.job = NULL;
532
2.17k
        pthread_cond_broadcast(&fuzz_r_thread.cond);
533
2.17k
    }
534
    return NULL;
535
2
}
parse.c:fuzz_r_thread_main
Line
Count
Source
499
2
{
500
2
    (void)unused;
501
    /* The frame address rather than a local's: under ASAN an address-taken
502
     * local may sit on the fake stack, nowhere near this thread's stack.
503
     * R_CStackStart matters only once R is initialized; fuzz_init_r()
504
     * sets it again after Rf_initialize_R has overwritten it. */
505
2
    fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0);
506
2
    R_CStackStart = fuzz_r_thread.stack_top;
507
508
    /* libFuzzer's -timeout alarm is acted on only by the thread running
509
     * its loop (the main thread); delivered here it would be ignored and
510
     * the input would run on.  Block it so the kernel cannot pick this
511
     * thread; fuzz_alarm_handler below gets this thread's stack into the
512
     * timeout report instead. */
513
2
    sigset_t alarm;
514
2
    sigemptyset(&alarm);
515
2
    sigaddset(&alarm, SIGALRM);
516
2
    pthread_sigmask(SIG_BLOCK, &alarm, NULL);
517
518
2
    pthread_mutex_lock(&fuzz_r_thread.mutex);
519
9.28k
    for (;;) {
520
18.5k
        while (fuzz_r_thread.job == NULL)
521
9.28k
            pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
522
9.28k
        fuzz_job_t *job = fuzz_r_thread.job;
523
9.28k
        pthread_mutex_unlock(&fuzz_r_thread.mutex);
524
525
9.28k
        clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started);
526
9.28k
        atomic_store(&fuzz_alarm.running, 1);
527
9.28k
        job->fn(job->arg);
528
9.28k
        atomic_store(&fuzz_alarm.running, 0);
529
530
9.28k
        pthread_mutex_lock(&fuzz_r_thread.mutex);
531
9.28k
        fuzz_r_thread.job = NULL;
532
9.28k
        pthread_cond_broadcast(&fuzz_r_thread.cond);
533
9.28k
    }
534
    return NULL;
535
2
}
sockets.c:fuzz_r_thread_main
Line
Count
Source
499
2
{
500
2
    (void)unused;
501
    /* The frame address rather than a local's: under ASAN an address-taken
502
     * local may sit on the fake stack, nowhere near this thread's stack.
503
     * R_CStackStart matters only once R is initialized; fuzz_init_r()
504
     * sets it again after Rf_initialize_R has overwritten it. */
505
2
    fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0);
506
2
    R_CStackStart = fuzz_r_thread.stack_top;
507
508
    /* libFuzzer's -timeout alarm is acted on only by the thread running
509
     * its loop (the main thread); delivered here it would be ignored and
510
     * the input would run on.  Block it so the kernel cannot pick this
511
     * thread; fuzz_alarm_handler below gets this thread's stack into the
512
     * timeout report instead. */
513
2
    sigset_t alarm;
514
2
    sigemptyset(&alarm);
515
2
    sigaddset(&alarm, SIGALRM);
516
2
    pthread_sigmask(SIG_BLOCK, &alarm, NULL);
517
518
2
    pthread_mutex_lock(&fuzz_r_thread.mutex);
519
1.98k
    for (;;) {
520
3.97k
        while (fuzz_r_thread.job == NULL)
521
1.98k
            pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
522
1.98k
        fuzz_job_t *job = fuzz_r_thread.job;
523
1.98k
        pthread_mutex_unlock(&fuzz_r_thread.mutex);
524
525
1.98k
        clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started);
526
1.98k
        atomic_store(&fuzz_alarm.running, 1);
527
1.98k
        job->fn(job->arg);
528
1.98k
        atomic_store(&fuzz_alarm.running, 0);
529
530
1.98k
        pthread_mutex_lock(&fuzz_r_thread.mutex);
531
1.98k
        fuzz_r_thread.job = NULL;
532
1.98k
        pthread_cond_broadcast(&fuzz_r_thread.cond);
533
1.98k
    }
534
    return NULL;
535
2
}
rd.c:fuzz_r_thread_main
Line
Count
Source
499
2
{
500
2
    (void)unused;
501
    /* The frame address rather than a local's: under ASAN an address-taken
502
     * local may sit on the fake stack, nowhere near this thread's stack.
503
     * R_CStackStart matters only once R is initialized; fuzz_init_r()
504
     * sets it again after Rf_initialize_R has overwritten it. */
505
2
    fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0);
506
2
    R_CStackStart = fuzz_r_thread.stack_top;
507
508
    /* libFuzzer's -timeout alarm is acted on only by the thread running
509
     * its loop (the main thread); delivered here it would be ignored and
510
     * the input would run on.  Block it so the kernel cannot pick this
511
     * thread; fuzz_alarm_handler below gets this thread's stack into the
512
     * timeout report instead. */
513
2
    sigset_t alarm;
514
2
    sigemptyset(&alarm);
515
2
    sigaddset(&alarm, SIGALRM);
516
2
    pthread_sigmask(SIG_BLOCK, &alarm, NULL);
517
518
2
    pthread_mutex_lock(&fuzz_r_thread.mutex);
519
5.09k
    for (;;) {
520
10.1k
        while (fuzz_r_thread.job == NULL)
521
5.09k
            pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
522
5.09k
        fuzz_job_t *job = fuzz_r_thread.job;
523
5.09k
        pthread_mutex_unlock(&fuzz_r_thread.mutex);
524
525
5.09k
        clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started);
526
5.09k
        atomic_store(&fuzz_alarm.running, 1);
527
5.09k
        job->fn(job->arg);
528
5.09k
        atomic_store(&fuzz_alarm.running, 0);
529
530
5.09k
        pthread_mutex_lock(&fuzz_r_thread.mutex);
531
5.09k
        fuzz_r_thread.job = NULL;
532
5.09k
        pthread_cond_broadcast(&fuzz_r_thread.cond);
533
5.09k
    }
534
    return NULL;
535
2
}
sprintf.c:fuzz_r_thread_main
Line
Count
Source
499
2
{
500
2
    (void)unused;
501
    /* The frame address rather than a local's: under ASAN an address-taken
502
     * local may sit on the fake stack, nowhere near this thread's stack.
503
     * R_CStackStart matters only once R is initialized; fuzz_init_r()
504
     * sets it again after Rf_initialize_R has overwritten it. */
505
2
    fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0);
506
2
    R_CStackStart = fuzz_r_thread.stack_top;
507
508
    /* libFuzzer's -timeout alarm is acted on only by the thread running
509
     * its loop (the main thread); delivered here it would be ignored and
510
     * the input would run on.  Block it so the kernel cannot pick this
511
     * thread; fuzz_alarm_handler below gets this thread's stack into the
512
     * timeout report instead. */
513
2
    sigset_t alarm;
514
2
    sigemptyset(&alarm);
515
2
    sigaddset(&alarm, SIGALRM);
516
2
    pthread_sigmask(SIG_BLOCK, &alarm, NULL);
517
518
2
    pthread_mutex_lock(&fuzz_r_thread.mutex);
519
2.08k
    for (;;) {
520
4.17k
        while (fuzz_r_thread.job == NULL)
521
2.08k
            pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
522
2.08k
        fuzz_job_t *job = fuzz_r_thread.job;
523
2.08k
        pthread_mutex_unlock(&fuzz_r_thread.mutex);
524
525
2.08k
        clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started);
526
2.08k
        atomic_store(&fuzz_alarm.running, 1);
527
2.08k
        job->fn(job->arg);
528
2.08k
        atomic_store(&fuzz_alarm.running, 0);
529
530
2.08k
        pthread_mutex_lock(&fuzz_r_thread.mutex);
531
2.08k
        fuzz_r_thread.job = NULL;
532
2.08k
        pthread_cond_broadcast(&fuzz_r_thread.cond);
533
2.08k
    }
534
    return NULL;
535
2
}
eval.c:fuzz_r_thread_main
Line
Count
Source
499
2
{
500
2
    (void)unused;
501
    /* The frame address rather than a local's: under ASAN an address-taken
502
     * local may sit on the fake stack, nowhere near this thread's stack.
503
     * R_CStackStart matters only once R is initialized; fuzz_init_r()
504
     * sets it again after Rf_initialize_R has overwritten it. */
505
2
    fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0);
506
2
    R_CStackStart = fuzz_r_thread.stack_top;
507
508
    /* libFuzzer's -timeout alarm is acted on only by the thread running
509
     * its loop (the main thread); delivered here it would be ignored and
510
     * the input would run on.  Block it so the kernel cannot pick this
511
     * thread; fuzz_alarm_handler below gets this thread's stack into the
512
     * timeout report instead. */
513
2
    sigset_t alarm;
514
2
    sigemptyset(&alarm);
515
2
    sigaddset(&alarm, SIGALRM);
516
2
    pthread_sigmask(SIG_BLOCK, &alarm, NULL);
517
518
2
    pthread_mutex_lock(&fuzz_r_thread.mutex);
519
18.7k
    for (;;) {
520
37.5k
        while (fuzz_r_thread.job == NULL)
521
18.7k
            pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
522
18.7k
        fuzz_job_t *job = fuzz_r_thread.job;
523
18.7k
        pthread_mutex_unlock(&fuzz_r_thread.mutex);
524
525
18.7k
        clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started);
526
18.7k
        atomic_store(&fuzz_alarm.running, 1);
527
18.7k
        job->fn(job->arg);
528
18.7k
        atomic_store(&fuzz_alarm.running, 0);
529
530
18.7k
        pthread_mutex_lock(&fuzz_r_thread.mutex);
531
18.7k
        fuzz_r_thread.job = NULL;
532
18.7k
        pthread_cond_broadcast(&fuzz_r_thread.cond);
533
18.7k
    }
534
    return NULL;
535
2
}
zip.c:fuzz_r_thread_main
Line
Count
Source
499
2
{
500
2
    (void)unused;
501
    /* The frame address rather than a local's: under ASAN an address-taken
502
     * local may sit on the fake stack, nowhere near this thread's stack.
503
     * R_CStackStart matters only once R is initialized; fuzz_init_r()
504
     * sets it again after Rf_initialize_R has overwritten it. */
505
2
    fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0);
506
2
    R_CStackStart = fuzz_r_thread.stack_top;
507
508
    /* libFuzzer's -timeout alarm is acted on only by the thread running
509
     * its loop (the main thread); delivered here it would be ignored and
510
     * the input would run on.  Block it so the kernel cannot pick this
511
     * thread; fuzz_alarm_handler below gets this thread's stack into the
512
     * timeout report instead. */
513
2
    sigset_t alarm;
514
2
    sigemptyset(&alarm);
515
2
    sigaddset(&alarm, SIGALRM);
516
2
    pthread_sigmask(SIG_BLOCK, &alarm, NULL);
517
518
2
    pthread_mutex_lock(&fuzz_r_thread.mutex);
519
2.09k
    for (;;) {
520
4.19k
        while (fuzz_r_thread.job == NULL)
521
2.09k
            pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
522
2.09k
        fuzz_job_t *job = fuzz_r_thread.job;
523
2.09k
        pthread_mutex_unlock(&fuzz_r_thread.mutex);
524
525
2.09k
        clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started);
526
2.09k
        atomic_store(&fuzz_alarm.running, 1);
527
2.09k
        job->fn(job->arg);
528
2.09k
        atomic_store(&fuzz_alarm.running, 0);
529
530
2.09k
        pthread_mutex_lock(&fuzz_r_thread.mutex);
531
2.09k
        fuzz_r_thread.job = NULL;
532
2.09k
        pthread_cond_broadcast(&fuzz_r_thread.cond);
533
2.09k
    }
534
    return NULL;
535
2
}
nmath.c:fuzz_r_thread_main
Line
Count
Source
499
2
{
500
2
    (void)unused;
501
    /* The frame address rather than a local's: under ASAN an address-taken
502
     * local may sit on the fake stack, nowhere near this thread's stack.
503
     * R_CStackStart matters only once R is initialized; fuzz_init_r()
504
     * sets it again after Rf_initialize_R has overwritten it. */
505
2
    fuzz_r_thread.stack_top = (uintptr_t)__builtin_frame_address(0);
506
2
    R_CStackStart = fuzz_r_thread.stack_top;
507
508
    /* libFuzzer's -timeout alarm is acted on only by the thread running
509
     * its loop (the main thread); delivered here it would be ignored and
510
     * the input would run on.  Block it so the kernel cannot pick this
511
     * thread; fuzz_alarm_handler below gets this thread's stack into the
512
     * timeout report instead. */
513
2
    sigset_t alarm;
514
2
    sigemptyset(&alarm);
515
2
    sigaddset(&alarm, SIGALRM);
516
2
    pthread_sigmask(SIG_BLOCK, &alarm, NULL);
517
518
2
    pthread_mutex_lock(&fuzz_r_thread.mutex);
519
12.2k
    for (;;) {
520
24.4k
        while (fuzz_r_thread.job == NULL)
521
12.2k
            pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
522
12.2k
        fuzz_job_t *job = fuzz_r_thread.job;
523
12.2k
        pthread_mutex_unlock(&fuzz_r_thread.mutex);
524
525
12.2k
        clock_gettime(CLOCK_REALTIME, &fuzz_alarm.started);
526
12.2k
        atomic_store(&fuzz_alarm.running, 1);
527
12.2k
        job->fn(job->arg);
528
12.2k
        atomic_store(&fuzz_alarm.running, 0);
529
530
12.2k
        pthread_mutex_lock(&fuzz_r_thread.mutex);
531
12.2k
        fuzz_r_thread.job = NULL;
532
12.2k
        pthread_cond_broadcast(&fuzz_r_thread.cond);
533
12.2k
    }
534
    return NULL;
535
2
}
536
537
static int fuzz_on_r_thread(void)
538
143k
{
539
143k
    return fuzz_r_thread.started &&
540
143k
           pthread_equal(pthread_self(), fuzz_r_thread.thread);
541
143k
}
io.c:fuzz_on_r_thread
Line
Count
Source
538
1.40k
{
539
1.40k
    return fuzz_r_thread.started &&
540
1.40k
           pthread_equal(pthread_self(), fuzz_r_thread.thread);
541
1.40k
}
dcf.c:fuzz_on_r_thread
Line
Count
Source
538
4.73k
{
539
4.73k
    return fuzz_r_thread.started &&
540
4.73k
           pthread_equal(pthread_self(), fuzz_r_thread.thread);
541
4.73k
}
character.c:fuzz_on_r_thread
Line
Count
Source
538
4.10k
{
539
4.10k
    return fuzz_r_thread.started &&
540
4.10k
           pthread_equal(pthread_self(), fuzz_r_thread.thread);
541
4.10k
}
encoding.c:fuzz_on_r_thread
Line
Count
Source
538
1.78k
{
539
1.78k
    return fuzz_r_thread.started &&
540
1.78k
           pthread_equal(pthread_self(), fuzz_r_thread.thread);
541
1.78k
}
sort.c:fuzz_on_r_thread
Line
Count
Source
538
6.80k
{
539
6.80k
    return fuzz_r_thread.started &&
540
6.80k
           pthread_equal(pthread_self(), fuzz_r_thread.thread);
541
6.80k
}
connections.c:fuzz_on_r_thread
Line
Count
Source
538
8.33k
{
539
8.33k
    return fuzz_r_thread.started &&
540
8.33k
           pthread_equal(pthread_self(), fuzz_r_thread.thread);
541
8.33k
}
unserialize.c:fuzz_on_r_thread
Line
Count
Source
538
5.70k
{
539
5.70k
    return fuzz_r_thread.started &&
540
5.70k
           pthread_equal(pthread_self(), fuzz_r_thread.thread);
541
5.70k
}
formula.c:fuzz_on_r_thread
Line
Count
Source
538
12.3k
{
539
12.3k
    return fuzz_r_thread.started &&
540
12.3k
           pthread_equal(pthread_self(), fuzz_r_thread.thread);
541
12.3k
}
decompress.c:fuzz_on_r_thread
Line
Count
Source
538
7.60k
{
539
7.60k
    return fuzz_r_thread.started &&
540
7.60k
           pthread_equal(pthread_self(), fuzz_r_thread.thread);
541
7.60k
}
readtable.c:fuzz_on_r_thread
Line
Count
Source
538
5.10k
{
539
5.10k
    return fuzz_r_thread.started &&
540
5.10k
           pthread_equal(pthread_self(), fuzz_r_thread.thread);
541
5.10k
}
format.c:fuzz_on_r_thread
Line
Count
Source
538
5.50k
{
539
5.50k
    return fuzz_r_thread.started &&
540
5.50k
           pthread_equal(pthread_self(), fuzz_r_thread.thread);
541
5.50k
}
datetime.c:fuzz_on_r_thread
Line
Count
Source
538
6.31k
{
539
6.31k
    return fuzz_r_thread.started &&
540
6.31k
           pthread_equal(pthread_self(), fuzz_r_thread.thread);
541
6.31k
}
coerce.c:fuzz_on_r_thread
Line
Count
Source
538
1.78k
{
539
1.78k
    return fuzz_r_thread.started &&
540
1.78k
           pthread_equal(pthread_self(), fuzz_r_thread.thread);
541
1.78k
}
load.c:fuzz_on_r_thread
Line
Count
Source
538
11.1k
{
539
11.1k
    return fuzz_r_thread.started &&
540
11.1k
           pthread_equal(pthread_self(), fuzz_r_thread.thread);
541
11.1k
}
scan.c:fuzz_on_r_thread
Line
Count
Source
538
2.87k
{
539
2.87k
    return fuzz_r_thread.started &&
540
2.87k
           pthread_equal(pthread_self(), fuzz_r_thread.thread);
541
2.87k
}
colors.c:fuzz_on_r_thread
Line
Count
Source
538
3.90k
{
539
3.90k
    return fuzz_r_thread.started &&
540
3.90k
           pthread_equal(pthread_self(), fuzz_r_thread.thread);
541
3.90k
}
grep.c:fuzz_on_r_thread
Line
Count
Source
538
2.17k
{
539
2.17k
    return fuzz_r_thread.started &&
540
2.17k
           pthread_equal(pthread_self(), fuzz_r_thread.thread);
541
2.17k
}
parse.c:fuzz_on_r_thread
Line
Count
Source
538
9.28k
{
539
9.28k
    return fuzz_r_thread.started &&
540
9.28k
           pthread_equal(pthread_self(), fuzz_r_thread.thread);
541
9.28k
}
sockets.c:fuzz_on_r_thread
Line
Count
Source
538
1.98k
{
539
1.98k
    return fuzz_r_thread.started &&
540
1.98k
           pthread_equal(pthread_self(), fuzz_r_thread.thread);
541
1.98k
}
rd.c:fuzz_on_r_thread
Line
Count
Source
538
5.09k
{
539
5.09k
    return fuzz_r_thread.started &&
540
5.09k
           pthread_equal(pthread_self(), fuzz_r_thread.thread);
541
5.09k
}
sprintf.c:fuzz_on_r_thread
Line
Count
Source
538
2.08k
{
539
2.08k
    return fuzz_r_thread.started &&
540
2.08k
           pthread_equal(pthread_self(), fuzz_r_thread.thread);
541
2.08k
}
eval.c:fuzz_on_r_thread
Line
Count
Source
538
18.7k
{
539
18.7k
    return fuzz_r_thread.started &&
540
18.7k
           pthread_equal(pthread_self(), fuzz_r_thread.thread);
541
18.7k
}
zip.c:fuzz_on_r_thread
Line
Count
Source
538
2.09k
{
539
2.09k
    return fuzz_r_thread.started &&
540
2.09k
           pthread_equal(pthread_self(), fuzz_r_thread.thread);
541
2.09k
}
nmath.c:fuzz_on_r_thread
Line
Count
Source
538
12.2k
{
539
12.2k
    return fuzz_r_thread.started &&
540
12.2k
           pthread_equal(pthread_self(), fuzz_r_thread.thread);
541
12.2k
}
542
543
/* Child side of fork: only the forking thread survives, so the R thread
544
 * is gone, and if it was the one waiting in pthread_cond_wait the
545
 * condition variable still counts it.  Nothing holds the mutex during a
546
 * fork from either side of the handoff, so resetting both is safe;
547
 * pthread_cond_destroy would wait for the phantom waiter instead. */
548
static void fuzz_r_thread_forget(void)
549
0
{
550
0
    fuzz_r_thread.started = 0;
551
0
    fuzz_r_thread.job = NULL;
552
0
    fuzz_r_thread.mutex = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;
553
0
    fuzz_r_thread.cond = (pthread_cond_t)PTHREAD_COND_INITIALIZER;
554
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: formula.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: grep.c:fuzz_r_thread_forget
Unexecuted instantiation: parse.c:fuzz_r_thread_forget
Unexecuted instantiation: sockets.c:fuzz_r_thread_forget
Unexecuted instantiation: rd.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
Unexecuted instantiation: nmath.c:fuzz_r_thread_forget
555
556
/* Run fn(arg) on the R thread and wait for it to return, starting the
557
 * thread on first use.  From the R thread itself this is a plain call. */
558
static void fuzz_run_on_r_thread(void (*fn)(void *), void *arg)
559
143k
{
560
143k
    if (!fuzz_r_thread.started) {
561
48
        static int atfork_registered = 0;
562
48
        if (!atfork_registered) {
563
48
            if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) {
564
0
                fprintf(stderr, "fuzz: cannot register the fork handler\n");
565
0
                abort();
566
0
            }
567
48
            atfork_registered = 1;
568
48
        }
569
570
48
        pthread_attr_t attr;
571
48
        if (pthread_attr_init(&attr) != 0 ||
572
48
            pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 ||
573
48
            pthread_create(&fuzz_r_thread.thread, &attr,
574
48
                           fuzz_r_thread_main, NULL) != 0) {
575
0
            fprintf(stderr, "fuzz: cannot start the R thread\n");
576
0
            abort();
577
0
        }
578
48
        pthread_attr_destroy(&attr);
579
48
        fuzz_r_thread.started = 1;
580
48
    }
581
582
143k
    if (fuzz_on_r_thread()) {
583
0
        fn(arg);
584
0
        return;
585
0
    }
586
587
143k
    fuzz_job_t job = { fn, arg };
588
143k
    if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0)
589
143k
        atomic_fetch_add(&fuzz_alarm.input, 1);  /* wrapped past 0, which is none */
590
591
143k
    pthread_mutex_lock(&fuzz_r_thread.mutex);
592
143k
    fuzz_r_thread.job = &job;
593
143k
    pthread_cond_broadcast(&fuzz_r_thread.cond);
594
286k
    while (fuzz_r_thread.job != NULL)
595
143k
        pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
596
143k
    pthread_mutex_unlock(&fuzz_r_thread.mutex);
597
598
    /* Idle again: ticks count, and libFuzzer's clock for the next input
599
     * starts after this. */
600
143k
    atomic_store(&fuzz_alarm.finishing, 0);
601
143k
    clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed);
602
143k
}
io.c:fuzz_run_on_r_thread
Line
Count
Source
559
1.40k
{
560
1.40k
    if (!fuzz_r_thread.started) {
561
2
        static int atfork_registered = 0;
562
2
        if (!atfork_registered) {
563
2
            if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) {
564
0
                fprintf(stderr, "fuzz: cannot register the fork handler\n");
565
0
                abort();
566
0
            }
567
2
            atfork_registered = 1;
568
2
        }
569
570
2
        pthread_attr_t attr;
571
2
        if (pthread_attr_init(&attr) != 0 ||
572
2
            pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 ||
573
2
            pthread_create(&fuzz_r_thread.thread, &attr,
574
2
                           fuzz_r_thread_main, NULL) != 0) {
575
0
            fprintf(stderr, "fuzz: cannot start the R thread\n");
576
0
            abort();
577
0
        }
578
2
        pthread_attr_destroy(&attr);
579
2
        fuzz_r_thread.started = 1;
580
2
    }
581
582
1.40k
    if (fuzz_on_r_thread()) {
583
0
        fn(arg);
584
0
        return;
585
0
    }
586
587
1.40k
    fuzz_job_t job = { fn, arg };
588
1.40k
    if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0)
589
1.40k
        atomic_fetch_add(&fuzz_alarm.input, 1);  /* wrapped past 0, which is none */
590
591
1.40k
    pthread_mutex_lock(&fuzz_r_thread.mutex);
592
1.40k
    fuzz_r_thread.job = &job;
593
1.40k
    pthread_cond_broadcast(&fuzz_r_thread.cond);
594
2.80k
    while (fuzz_r_thread.job != NULL)
595
1.40k
        pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
596
1.40k
    pthread_mutex_unlock(&fuzz_r_thread.mutex);
597
598
    /* Idle again: ticks count, and libFuzzer's clock for the next input
599
     * starts after this. */
600
1.40k
    atomic_store(&fuzz_alarm.finishing, 0);
601
    clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed);
602
1.40k
}
dcf.c:fuzz_run_on_r_thread
Line
Count
Source
559
4.73k
{
560
4.73k
    if (!fuzz_r_thread.started) {
561
2
        static int atfork_registered = 0;
562
2
        if (!atfork_registered) {
563
2
            if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) {
564
0
                fprintf(stderr, "fuzz: cannot register the fork handler\n");
565
0
                abort();
566
0
            }
567
2
            atfork_registered = 1;
568
2
        }
569
570
2
        pthread_attr_t attr;
571
2
        if (pthread_attr_init(&attr) != 0 ||
572
2
            pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 ||
573
2
            pthread_create(&fuzz_r_thread.thread, &attr,
574
2
                           fuzz_r_thread_main, NULL) != 0) {
575
0
            fprintf(stderr, "fuzz: cannot start the R thread\n");
576
0
            abort();
577
0
        }
578
2
        pthread_attr_destroy(&attr);
579
2
        fuzz_r_thread.started = 1;
580
2
    }
581
582
4.73k
    if (fuzz_on_r_thread()) {
583
0
        fn(arg);
584
0
        return;
585
0
    }
586
587
4.73k
    fuzz_job_t job = { fn, arg };
588
4.73k
    if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0)
589
4.73k
        atomic_fetch_add(&fuzz_alarm.input, 1);  /* wrapped past 0, which is none */
590
591
4.73k
    pthread_mutex_lock(&fuzz_r_thread.mutex);
592
4.73k
    fuzz_r_thread.job = &job;
593
4.73k
    pthread_cond_broadcast(&fuzz_r_thread.cond);
594
9.47k
    while (fuzz_r_thread.job != NULL)
595
4.73k
        pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
596
4.73k
    pthread_mutex_unlock(&fuzz_r_thread.mutex);
597
598
    /* Idle again: ticks count, and libFuzzer's clock for the next input
599
     * starts after this. */
600
4.73k
    atomic_store(&fuzz_alarm.finishing, 0);
601
    clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed);
602
4.73k
}
character.c:fuzz_run_on_r_thread
Line
Count
Source
559
4.09k
{
560
4.09k
    if (!fuzz_r_thread.started) {
561
2
        static int atfork_registered = 0;
562
2
        if (!atfork_registered) {
563
2
            if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) {
564
0
                fprintf(stderr, "fuzz: cannot register the fork handler\n");
565
0
                abort();
566
0
            }
567
2
            atfork_registered = 1;
568
2
        }
569
570
2
        pthread_attr_t attr;
571
2
        if (pthread_attr_init(&attr) != 0 ||
572
2
            pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 ||
573
2
            pthread_create(&fuzz_r_thread.thread, &attr,
574
2
                           fuzz_r_thread_main, NULL) != 0) {
575
0
            fprintf(stderr, "fuzz: cannot start the R thread\n");
576
0
            abort();
577
0
        }
578
2
        pthread_attr_destroy(&attr);
579
2
        fuzz_r_thread.started = 1;
580
2
    }
581
582
4.09k
    if (fuzz_on_r_thread()) {
583
0
        fn(arg);
584
0
        return;
585
0
    }
586
587
4.09k
    fuzz_job_t job = { fn, arg };
588
4.09k
    if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0)
589
4.09k
        atomic_fetch_add(&fuzz_alarm.input, 1);  /* wrapped past 0, which is none */
590
591
4.09k
    pthread_mutex_lock(&fuzz_r_thread.mutex);
592
4.09k
    fuzz_r_thread.job = &job;
593
4.09k
    pthread_cond_broadcast(&fuzz_r_thread.cond);
594
8.19k
    while (fuzz_r_thread.job != NULL)
595
4.09k
        pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
596
4.09k
    pthread_mutex_unlock(&fuzz_r_thread.mutex);
597
598
    /* Idle again: ticks count, and libFuzzer's clock for the next input
599
     * starts after this. */
600
4.09k
    atomic_store(&fuzz_alarm.finishing, 0);
601
    clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed);
602
4.09k
}
encoding.c:fuzz_run_on_r_thread
Line
Count
Source
559
1.77k
{
560
1.77k
    if (!fuzz_r_thread.started) {
561
2
        static int atfork_registered = 0;
562
2
        if (!atfork_registered) {
563
2
            if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) {
564
0
                fprintf(stderr, "fuzz: cannot register the fork handler\n");
565
0
                abort();
566
0
            }
567
2
            atfork_registered = 1;
568
2
        }
569
570
2
        pthread_attr_t attr;
571
2
        if (pthread_attr_init(&attr) != 0 ||
572
2
            pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 ||
573
2
            pthread_create(&fuzz_r_thread.thread, &attr,
574
2
                           fuzz_r_thread_main, NULL) != 0) {
575
0
            fprintf(stderr, "fuzz: cannot start the R thread\n");
576
0
            abort();
577
0
        }
578
2
        pthread_attr_destroy(&attr);
579
2
        fuzz_r_thread.started = 1;
580
2
    }
581
582
1.77k
    if (fuzz_on_r_thread()) {
583
0
        fn(arg);
584
0
        return;
585
0
    }
586
587
1.77k
    fuzz_job_t job = { fn, arg };
588
1.77k
    if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0)
589
1.77k
        atomic_fetch_add(&fuzz_alarm.input, 1);  /* wrapped past 0, which is none */
590
591
1.77k
    pthread_mutex_lock(&fuzz_r_thread.mutex);
592
1.77k
    fuzz_r_thread.job = &job;
593
1.77k
    pthread_cond_broadcast(&fuzz_r_thread.cond);
594
3.55k
    while (fuzz_r_thread.job != NULL)
595
1.77k
        pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
596
1.77k
    pthread_mutex_unlock(&fuzz_r_thread.mutex);
597
598
    /* Idle again: ticks count, and libFuzzer's clock for the next input
599
     * starts after this. */
600
1.77k
    atomic_store(&fuzz_alarm.finishing, 0);
601
    clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed);
602
1.77k
}
sort.c:fuzz_run_on_r_thread
Line
Count
Source
559
6.80k
{
560
6.80k
    if (!fuzz_r_thread.started) {
561
2
        static int atfork_registered = 0;
562
2
        if (!atfork_registered) {
563
2
            if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) {
564
0
                fprintf(stderr, "fuzz: cannot register the fork handler\n");
565
0
                abort();
566
0
            }
567
2
            atfork_registered = 1;
568
2
        }
569
570
2
        pthread_attr_t attr;
571
2
        if (pthread_attr_init(&attr) != 0 ||
572
2
            pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 ||
573
2
            pthread_create(&fuzz_r_thread.thread, &attr,
574
2
                           fuzz_r_thread_main, NULL) != 0) {
575
0
            fprintf(stderr, "fuzz: cannot start the R thread\n");
576
0
            abort();
577
0
        }
578
2
        pthread_attr_destroy(&attr);
579
2
        fuzz_r_thread.started = 1;
580
2
    }
581
582
6.80k
    if (fuzz_on_r_thread()) {
583
0
        fn(arg);
584
0
        return;
585
0
    }
586
587
6.80k
    fuzz_job_t job = { fn, arg };
588
6.80k
    if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0)
589
6.80k
        atomic_fetch_add(&fuzz_alarm.input, 1);  /* wrapped past 0, which is none */
590
591
6.80k
    pthread_mutex_lock(&fuzz_r_thread.mutex);
592
6.80k
    fuzz_r_thread.job = &job;
593
6.80k
    pthread_cond_broadcast(&fuzz_r_thread.cond);
594
13.6k
    while (fuzz_r_thread.job != NULL)
595
6.80k
        pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
596
6.80k
    pthread_mutex_unlock(&fuzz_r_thread.mutex);
597
598
    /* Idle again: ticks count, and libFuzzer's clock for the next input
599
     * starts after this. */
600
6.80k
    atomic_store(&fuzz_alarm.finishing, 0);
601
    clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed);
602
6.80k
}
connections.c:fuzz_run_on_r_thread
Line
Count
Source
559
8.33k
{
560
8.33k
    if (!fuzz_r_thread.started) {
561
2
        static int atfork_registered = 0;
562
2
        if (!atfork_registered) {
563
2
            if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) {
564
0
                fprintf(stderr, "fuzz: cannot register the fork handler\n");
565
0
                abort();
566
0
            }
567
2
            atfork_registered = 1;
568
2
        }
569
570
2
        pthread_attr_t attr;
571
2
        if (pthread_attr_init(&attr) != 0 ||
572
2
            pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 ||
573
2
            pthread_create(&fuzz_r_thread.thread, &attr,
574
2
                           fuzz_r_thread_main, NULL) != 0) {
575
0
            fprintf(stderr, "fuzz: cannot start the R thread\n");
576
0
            abort();
577
0
        }
578
2
        pthread_attr_destroy(&attr);
579
2
        fuzz_r_thread.started = 1;
580
2
    }
581
582
8.33k
    if (fuzz_on_r_thread()) {
583
0
        fn(arg);
584
0
        return;
585
0
    }
586
587
8.33k
    fuzz_job_t job = { fn, arg };
588
8.33k
    if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0)
589
8.33k
        atomic_fetch_add(&fuzz_alarm.input, 1);  /* wrapped past 0, which is none */
590
591
8.33k
    pthread_mutex_lock(&fuzz_r_thread.mutex);
592
8.33k
    fuzz_r_thread.job = &job;
593
8.33k
    pthread_cond_broadcast(&fuzz_r_thread.cond);
594
16.6k
    while (fuzz_r_thread.job != NULL)
595
8.33k
        pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
596
8.33k
    pthread_mutex_unlock(&fuzz_r_thread.mutex);
597
598
    /* Idle again: ticks count, and libFuzzer's clock for the next input
599
     * starts after this. */
600
8.33k
    atomic_store(&fuzz_alarm.finishing, 0);
601
    clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed);
602
8.33k
}
unserialize.c:fuzz_run_on_r_thread
Line
Count
Source
559
5.70k
{
560
5.70k
    if (!fuzz_r_thread.started) {
561
2
        static int atfork_registered = 0;
562
2
        if (!atfork_registered) {
563
2
            if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) {
564
0
                fprintf(stderr, "fuzz: cannot register the fork handler\n");
565
0
                abort();
566
0
            }
567
2
            atfork_registered = 1;
568
2
        }
569
570
2
        pthread_attr_t attr;
571
2
        if (pthread_attr_init(&attr) != 0 ||
572
2
            pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 ||
573
2
            pthread_create(&fuzz_r_thread.thread, &attr,
574
2
                           fuzz_r_thread_main, NULL) != 0) {
575
0
            fprintf(stderr, "fuzz: cannot start the R thread\n");
576
0
            abort();
577
0
        }
578
2
        pthread_attr_destroy(&attr);
579
2
        fuzz_r_thread.started = 1;
580
2
    }
581
582
5.70k
    if (fuzz_on_r_thread()) {
583
0
        fn(arg);
584
0
        return;
585
0
    }
586
587
5.70k
    fuzz_job_t job = { fn, arg };
588
5.70k
    if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0)
589
5.70k
        atomic_fetch_add(&fuzz_alarm.input, 1);  /* wrapped past 0, which is none */
590
591
5.70k
    pthread_mutex_lock(&fuzz_r_thread.mutex);
592
5.70k
    fuzz_r_thread.job = &job;
593
5.70k
    pthread_cond_broadcast(&fuzz_r_thread.cond);
594
11.4k
    while (fuzz_r_thread.job != NULL)
595
5.70k
        pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
596
5.70k
    pthread_mutex_unlock(&fuzz_r_thread.mutex);
597
598
    /* Idle again: ticks count, and libFuzzer's clock for the next input
599
     * starts after this. */
600
5.70k
    atomic_store(&fuzz_alarm.finishing, 0);
601
    clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed);
602
5.70k
}
formula.c:fuzz_run_on_r_thread
Line
Count
Source
559
12.3k
{
560
12.3k
    if (!fuzz_r_thread.started) {
561
2
        static int atfork_registered = 0;
562
2
        if (!atfork_registered) {
563
2
            if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) {
564
0
                fprintf(stderr, "fuzz: cannot register the fork handler\n");
565
0
                abort();
566
0
            }
567
2
            atfork_registered = 1;
568
2
        }
569
570
2
        pthread_attr_t attr;
571
2
        if (pthread_attr_init(&attr) != 0 ||
572
2
            pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 ||
573
2
            pthread_create(&fuzz_r_thread.thread, &attr,
574
2
                           fuzz_r_thread_main, NULL) != 0) {
575
0
            fprintf(stderr, "fuzz: cannot start the R thread\n");
576
0
            abort();
577
0
        }
578
2
        pthread_attr_destroy(&attr);
579
2
        fuzz_r_thread.started = 1;
580
2
    }
581
582
12.3k
    if (fuzz_on_r_thread()) {
583
0
        fn(arg);
584
0
        return;
585
0
    }
586
587
12.3k
    fuzz_job_t job = { fn, arg };
588
12.3k
    if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0)
589
12.3k
        atomic_fetch_add(&fuzz_alarm.input, 1);  /* wrapped past 0, which is none */
590
591
12.3k
    pthread_mutex_lock(&fuzz_r_thread.mutex);
592
12.3k
    fuzz_r_thread.job = &job;
593
12.3k
    pthread_cond_broadcast(&fuzz_r_thread.cond);
594
24.7k
    while (fuzz_r_thread.job != NULL)
595
12.3k
        pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
596
12.3k
    pthread_mutex_unlock(&fuzz_r_thread.mutex);
597
598
    /* Idle again: ticks count, and libFuzzer's clock for the next input
599
     * starts after this. */
600
12.3k
    atomic_store(&fuzz_alarm.finishing, 0);
601
    clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed);
602
12.3k
}
decompress.c:fuzz_run_on_r_thread
Line
Count
Source
559
7.60k
{
560
7.60k
    if (!fuzz_r_thread.started) {
561
2
        static int atfork_registered = 0;
562
2
        if (!atfork_registered) {
563
2
            if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) {
564
0
                fprintf(stderr, "fuzz: cannot register the fork handler\n");
565
0
                abort();
566
0
            }
567
2
            atfork_registered = 1;
568
2
        }
569
570
2
        pthread_attr_t attr;
571
2
        if (pthread_attr_init(&attr) != 0 ||
572
2
            pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 ||
573
2
            pthread_create(&fuzz_r_thread.thread, &attr,
574
2
                           fuzz_r_thread_main, NULL) != 0) {
575
0
            fprintf(stderr, "fuzz: cannot start the R thread\n");
576
0
            abort();
577
0
        }
578
2
        pthread_attr_destroy(&attr);
579
2
        fuzz_r_thread.started = 1;
580
2
    }
581
582
7.60k
    if (fuzz_on_r_thread()) {
583
0
        fn(arg);
584
0
        return;
585
0
    }
586
587
7.60k
    fuzz_job_t job = { fn, arg };
588
7.60k
    if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0)
589
7.60k
        atomic_fetch_add(&fuzz_alarm.input, 1);  /* wrapped past 0, which is none */
590
591
7.60k
    pthread_mutex_lock(&fuzz_r_thread.mutex);
592
7.60k
    fuzz_r_thread.job = &job;
593
7.60k
    pthread_cond_broadcast(&fuzz_r_thread.cond);
594
15.2k
    while (fuzz_r_thread.job != NULL)
595
7.60k
        pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
596
7.60k
    pthread_mutex_unlock(&fuzz_r_thread.mutex);
597
598
    /* Idle again: ticks count, and libFuzzer's clock for the next input
599
     * starts after this. */
600
7.60k
    atomic_store(&fuzz_alarm.finishing, 0);
601
    clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed);
602
7.60k
}
readtable.c:fuzz_run_on_r_thread
Line
Count
Source
559
5.10k
{
560
5.10k
    if (!fuzz_r_thread.started) {
561
2
        static int atfork_registered = 0;
562
2
        if (!atfork_registered) {
563
2
            if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) {
564
0
                fprintf(stderr, "fuzz: cannot register the fork handler\n");
565
0
                abort();
566
0
            }
567
2
            atfork_registered = 1;
568
2
        }
569
570
2
        pthread_attr_t attr;
571
2
        if (pthread_attr_init(&attr) != 0 ||
572
2
            pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 ||
573
2
            pthread_create(&fuzz_r_thread.thread, &attr,
574
2
                           fuzz_r_thread_main, NULL) != 0) {
575
0
            fprintf(stderr, "fuzz: cannot start the R thread\n");
576
0
            abort();
577
0
        }
578
2
        pthread_attr_destroy(&attr);
579
2
        fuzz_r_thread.started = 1;
580
2
    }
581
582
5.10k
    if (fuzz_on_r_thread()) {
583
0
        fn(arg);
584
0
        return;
585
0
    }
586
587
5.10k
    fuzz_job_t job = { fn, arg };
588
5.10k
    if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0)
589
5.10k
        atomic_fetch_add(&fuzz_alarm.input, 1);  /* wrapped past 0, which is none */
590
591
5.10k
    pthread_mutex_lock(&fuzz_r_thread.mutex);
592
5.10k
    fuzz_r_thread.job = &job;
593
5.10k
    pthread_cond_broadcast(&fuzz_r_thread.cond);
594
10.2k
    while (fuzz_r_thread.job != NULL)
595
5.10k
        pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
596
5.10k
    pthread_mutex_unlock(&fuzz_r_thread.mutex);
597
598
    /* Idle again: ticks count, and libFuzzer's clock for the next input
599
     * starts after this. */
600
5.10k
    atomic_store(&fuzz_alarm.finishing, 0);
601
    clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed);
602
5.10k
}
format.c:fuzz_run_on_r_thread
Line
Count
Source
559
5.50k
{
560
5.50k
    if (!fuzz_r_thread.started) {
561
2
        static int atfork_registered = 0;
562
2
        if (!atfork_registered) {
563
2
            if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) {
564
0
                fprintf(stderr, "fuzz: cannot register the fork handler\n");
565
0
                abort();
566
0
            }
567
2
            atfork_registered = 1;
568
2
        }
569
570
2
        pthread_attr_t attr;
571
2
        if (pthread_attr_init(&attr) != 0 ||
572
2
            pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 ||
573
2
            pthread_create(&fuzz_r_thread.thread, &attr,
574
2
                           fuzz_r_thread_main, NULL) != 0) {
575
0
            fprintf(stderr, "fuzz: cannot start the R thread\n");
576
0
            abort();
577
0
        }
578
2
        pthread_attr_destroy(&attr);
579
2
        fuzz_r_thread.started = 1;
580
2
    }
581
582
5.50k
    if (fuzz_on_r_thread()) {
583
0
        fn(arg);
584
0
        return;
585
0
    }
586
587
5.50k
    fuzz_job_t job = { fn, arg };
588
5.50k
    if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0)
589
5.50k
        atomic_fetch_add(&fuzz_alarm.input, 1);  /* wrapped past 0, which is none */
590
591
5.50k
    pthread_mutex_lock(&fuzz_r_thread.mutex);
592
5.50k
    fuzz_r_thread.job = &job;
593
5.50k
    pthread_cond_broadcast(&fuzz_r_thread.cond);
594
11.0k
    while (fuzz_r_thread.job != NULL)
595
5.50k
        pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
596
5.50k
    pthread_mutex_unlock(&fuzz_r_thread.mutex);
597
598
    /* Idle again: ticks count, and libFuzzer's clock for the next input
599
     * starts after this. */
600
5.50k
    atomic_store(&fuzz_alarm.finishing, 0);
601
    clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed);
602
5.50k
}
datetime.c:fuzz_run_on_r_thread
Line
Count
Source
559
6.31k
{
560
6.31k
    if (!fuzz_r_thread.started) {
561
2
        static int atfork_registered = 0;
562
2
        if (!atfork_registered) {
563
2
            if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) {
564
0
                fprintf(stderr, "fuzz: cannot register the fork handler\n");
565
0
                abort();
566
0
            }
567
2
            atfork_registered = 1;
568
2
        }
569
570
2
        pthread_attr_t attr;
571
2
        if (pthread_attr_init(&attr) != 0 ||
572
2
            pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 ||
573
2
            pthread_create(&fuzz_r_thread.thread, &attr,
574
2
                           fuzz_r_thread_main, NULL) != 0) {
575
0
            fprintf(stderr, "fuzz: cannot start the R thread\n");
576
0
            abort();
577
0
        }
578
2
        pthread_attr_destroy(&attr);
579
2
        fuzz_r_thread.started = 1;
580
2
    }
581
582
6.31k
    if (fuzz_on_r_thread()) {
583
0
        fn(arg);
584
0
        return;
585
0
    }
586
587
6.31k
    fuzz_job_t job = { fn, arg };
588
6.31k
    if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0)
589
6.31k
        atomic_fetch_add(&fuzz_alarm.input, 1);  /* wrapped past 0, which is none */
590
591
6.31k
    pthread_mutex_lock(&fuzz_r_thread.mutex);
592
6.31k
    fuzz_r_thread.job = &job;
593
6.31k
    pthread_cond_broadcast(&fuzz_r_thread.cond);
594
12.6k
    while (fuzz_r_thread.job != NULL)
595
6.31k
        pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
596
6.31k
    pthread_mutex_unlock(&fuzz_r_thread.mutex);
597
598
    /* Idle again: ticks count, and libFuzzer's clock for the next input
599
     * starts after this. */
600
6.31k
    atomic_store(&fuzz_alarm.finishing, 0);
601
    clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed);
602
6.31k
}
coerce.c:fuzz_run_on_r_thread
Line
Count
Source
559
1.78k
{
560
1.78k
    if (!fuzz_r_thread.started) {
561
2
        static int atfork_registered = 0;
562
2
        if (!atfork_registered) {
563
2
            if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) {
564
0
                fprintf(stderr, "fuzz: cannot register the fork handler\n");
565
0
                abort();
566
0
            }
567
2
            atfork_registered = 1;
568
2
        }
569
570
2
        pthread_attr_t attr;
571
2
        if (pthread_attr_init(&attr) != 0 ||
572
2
            pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 ||
573
2
            pthread_create(&fuzz_r_thread.thread, &attr,
574
2
                           fuzz_r_thread_main, NULL) != 0) {
575
0
            fprintf(stderr, "fuzz: cannot start the R thread\n");
576
0
            abort();
577
0
        }
578
2
        pthread_attr_destroy(&attr);
579
2
        fuzz_r_thread.started = 1;
580
2
    }
581
582
1.78k
    if (fuzz_on_r_thread()) {
583
0
        fn(arg);
584
0
        return;
585
0
    }
586
587
1.78k
    fuzz_job_t job = { fn, arg };
588
1.78k
    if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0)
589
1.78k
        atomic_fetch_add(&fuzz_alarm.input, 1);  /* wrapped past 0, which is none */
590
591
1.78k
    pthread_mutex_lock(&fuzz_r_thread.mutex);
592
1.78k
    fuzz_r_thread.job = &job;
593
1.78k
    pthread_cond_broadcast(&fuzz_r_thread.cond);
594
3.57k
    while (fuzz_r_thread.job != NULL)
595
1.78k
        pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
596
1.78k
    pthread_mutex_unlock(&fuzz_r_thread.mutex);
597
598
    /* Idle again: ticks count, and libFuzzer's clock for the next input
599
     * starts after this. */
600
1.78k
    atomic_store(&fuzz_alarm.finishing, 0);
601
    clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed);
602
1.78k
}
load.c:fuzz_run_on_r_thread
Line
Count
Source
559
11.1k
{
560
11.1k
    if (!fuzz_r_thread.started) {
561
2
        static int atfork_registered = 0;
562
2
        if (!atfork_registered) {
563
2
            if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) {
564
0
                fprintf(stderr, "fuzz: cannot register the fork handler\n");
565
0
                abort();
566
0
            }
567
2
            atfork_registered = 1;
568
2
        }
569
570
2
        pthread_attr_t attr;
571
2
        if (pthread_attr_init(&attr) != 0 ||
572
2
            pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 ||
573
2
            pthread_create(&fuzz_r_thread.thread, &attr,
574
2
                           fuzz_r_thread_main, NULL) != 0) {
575
0
            fprintf(stderr, "fuzz: cannot start the R thread\n");
576
0
            abort();
577
0
        }
578
2
        pthread_attr_destroy(&attr);
579
2
        fuzz_r_thread.started = 1;
580
2
    }
581
582
11.1k
    if (fuzz_on_r_thread()) {
583
0
        fn(arg);
584
0
        return;
585
0
    }
586
587
11.1k
    fuzz_job_t job = { fn, arg };
588
11.1k
    if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0)
589
11.1k
        atomic_fetch_add(&fuzz_alarm.input, 1);  /* wrapped past 0, which is none */
590
591
11.1k
    pthread_mutex_lock(&fuzz_r_thread.mutex);
592
11.1k
    fuzz_r_thread.job = &job;
593
11.1k
    pthread_cond_broadcast(&fuzz_r_thread.cond);
594
22.2k
    while (fuzz_r_thread.job != NULL)
595
11.1k
        pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
596
11.1k
    pthread_mutex_unlock(&fuzz_r_thread.mutex);
597
598
    /* Idle again: ticks count, and libFuzzer's clock for the next input
599
     * starts after this. */
600
11.1k
    atomic_store(&fuzz_alarm.finishing, 0);
601
    clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed);
602
11.1k
}
scan.c:fuzz_run_on_r_thread
Line
Count
Source
559
2.87k
{
560
2.87k
    if (!fuzz_r_thread.started) {
561
2
        static int atfork_registered = 0;
562
2
        if (!atfork_registered) {
563
2
            if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) {
564
0
                fprintf(stderr, "fuzz: cannot register the fork handler\n");
565
0
                abort();
566
0
            }
567
2
            atfork_registered = 1;
568
2
        }
569
570
2
        pthread_attr_t attr;
571
2
        if (pthread_attr_init(&attr) != 0 ||
572
2
            pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 ||
573
2
            pthread_create(&fuzz_r_thread.thread, &attr,
574
2
                           fuzz_r_thread_main, NULL) != 0) {
575
0
            fprintf(stderr, "fuzz: cannot start the R thread\n");
576
0
            abort();
577
0
        }
578
2
        pthread_attr_destroy(&attr);
579
2
        fuzz_r_thread.started = 1;
580
2
    }
581
582
2.87k
    if (fuzz_on_r_thread()) {
583
0
        fn(arg);
584
0
        return;
585
0
    }
586
587
2.87k
    fuzz_job_t job = { fn, arg };
588
2.87k
    if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0)
589
2.87k
        atomic_fetch_add(&fuzz_alarm.input, 1);  /* wrapped past 0, which is none */
590
591
2.87k
    pthread_mutex_lock(&fuzz_r_thread.mutex);
592
2.87k
    fuzz_r_thread.job = &job;
593
2.87k
    pthread_cond_broadcast(&fuzz_r_thread.cond);
594
5.75k
    while (fuzz_r_thread.job != NULL)
595
2.87k
        pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
596
2.87k
    pthread_mutex_unlock(&fuzz_r_thread.mutex);
597
598
    /* Idle again: ticks count, and libFuzzer's clock for the next input
599
     * starts after this. */
600
2.87k
    atomic_store(&fuzz_alarm.finishing, 0);
601
    clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed);
602
2.87k
}
colors.c:fuzz_run_on_r_thread
Line
Count
Source
559
3.90k
{
560
3.90k
    if (!fuzz_r_thread.started) {
561
2
        static int atfork_registered = 0;
562
2
        if (!atfork_registered) {
563
2
            if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) {
564
0
                fprintf(stderr, "fuzz: cannot register the fork handler\n");
565
0
                abort();
566
0
            }
567
2
            atfork_registered = 1;
568
2
        }
569
570
2
        pthread_attr_t attr;
571
2
        if (pthread_attr_init(&attr) != 0 ||
572
2
            pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 ||
573
2
            pthread_create(&fuzz_r_thread.thread, &attr,
574
2
                           fuzz_r_thread_main, NULL) != 0) {
575
0
            fprintf(stderr, "fuzz: cannot start the R thread\n");
576
0
            abort();
577
0
        }
578
2
        pthread_attr_destroy(&attr);
579
2
        fuzz_r_thread.started = 1;
580
2
    }
581
582
3.90k
    if (fuzz_on_r_thread()) {
583
0
        fn(arg);
584
0
        return;
585
0
    }
586
587
3.90k
    fuzz_job_t job = { fn, arg };
588
3.90k
    if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0)
589
3.90k
        atomic_fetch_add(&fuzz_alarm.input, 1);  /* wrapped past 0, which is none */
590
591
3.90k
    pthread_mutex_lock(&fuzz_r_thread.mutex);
592
3.90k
    fuzz_r_thread.job = &job;
593
3.90k
    pthread_cond_broadcast(&fuzz_r_thread.cond);
594
7.80k
    while (fuzz_r_thread.job != NULL)
595
3.90k
        pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
596
3.90k
    pthread_mutex_unlock(&fuzz_r_thread.mutex);
597
598
    /* Idle again: ticks count, and libFuzzer's clock for the next input
599
     * starts after this. */
600
3.90k
    atomic_store(&fuzz_alarm.finishing, 0);
601
    clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed);
602
3.90k
}
grep.c:fuzz_run_on_r_thread
Line
Count
Source
559
2.17k
{
560
2.17k
    if (!fuzz_r_thread.started) {
561
2
        static int atfork_registered = 0;
562
2
        if (!atfork_registered) {
563
2
            if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) {
564
0
                fprintf(stderr, "fuzz: cannot register the fork handler\n");
565
0
                abort();
566
0
            }
567
2
            atfork_registered = 1;
568
2
        }
569
570
2
        pthread_attr_t attr;
571
2
        if (pthread_attr_init(&attr) != 0 ||
572
2
            pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 ||
573
2
            pthread_create(&fuzz_r_thread.thread, &attr,
574
2
                           fuzz_r_thread_main, NULL) != 0) {
575
0
            fprintf(stderr, "fuzz: cannot start the R thread\n");
576
0
            abort();
577
0
        }
578
2
        pthread_attr_destroy(&attr);
579
2
        fuzz_r_thread.started = 1;
580
2
    }
581
582
2.17k
    if (fuzz_on_r_thread()) {
583
0
        fn(arg);
584
0
        return;
585
0
    }
586
587
2.17k
    fuzz_job_t job = { fn, arg };
588
2.17k
    if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0)
589
2.17k
        atomic_fetch_add(&fuzz_alarm.input, 1);  /* wrapped past 0, which is none */
590
591
2.17k
    pthread_mutex_lock(&fuzz_r_thread.mutex);
592
2.17k
    fuzz_r_thread.job = &job;
593
2.17k
    pthread_cond_broadcast(&fuzz_r_thread.cond);
594
4.35k
    while (fuzz_r_thread.job != NULL)
595
2.17k
        pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
596
2.17k
    pthread_mutex_unlock(&fuzz_r_thread.mutex);
597
598
    /* Idle again: ticks count, and libFuzzer's clock for the next input
599
     * starts after this. */
600
2.17k
    atomic_store(&fuzz_alarm.finishing, 0);
601
    clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed);
602
2.17k
}
parse.c:fuzz_run_on_r_thread
Line
Count
Source
559
9.28k
{
560
9.28k
    if (!fuzz_r_thread.started) {
561
2
        static int atfork_registered = 0;
562
2
        if (!atfork_registered) {
563
2
            if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) {
564
0
                fprintf(stderr, "fuzz: cannot register the fork handler\n");
565
0
                abort();
566
0
            }
567
2
            atfork_registered = 1;
568
2
        }
569
570
2
        pthread_attr_t attr;
571
2
        if (pthread_attr_init(&attr) != 0 ||
572
2
            pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 ||
573
2
            pthread_create(&fuzz_r_thread.thread, &attr,
574
2
                           fuzz_r_thread_main, NULL) != 0) {
575
0
            fprintf(stderr, "fuzz: cannot start the R thread\n");
576
0
            abort();
577
0
        }
578
2
        pthread_attr_destroy(&attr);
579
2
        fuzz_r_thread.started = 1;
580
2
    }
581
582
9.28k
    if (fuzz_on_r_thread()) {
583
0
        fn(arg);
584
0
        return;
585
0
    }
586
587
9.28k
    fuzz_job_t job = { fn, arg };
588
9.28k
    if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0)
589
9.28k
        atomic_fetch_add(&fuzz_alarm.input, 1);  /* wrapped past 0, which is none */
590
591
9.28k
    pthread_mutex_lock(&fuzz_r_thread.mutex);
592
9.28k
    fuzz_r_thread.job = &job;
593
9.28k
    pthread_cond_broadcast(&fuzz_r_thread.cond);
594
18.5k
    while (fuzz_r_thread.job != NULL)
595
9.28k
        pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
596
9.28k
    pthread_mutex_unlock(&fuzz_r_thread.mutex);
597
598
    /* Idle again: ticks count, and libFuzzer's clock for the next input
599
     * starts after this. */
600
9.28k
    atomic_store(&fuzz_alarm.finishing, 0);
601
    clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed);
602
9.28k
}
sockets.c:fuzz_run_on_r_thread
Line
Count
Source
559
1.98k
{
560
1.98k
    if (!fuzz_r_thread.started) {
561
2
        static int atfork_registered = 0;
562
2
        if (!atfork_registered) {
563
2
            if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) {
564
0
                fprintf(stderr, "fuzz: cannot register the fork handler\n");
565
0
                abort();
566
0
            }
567
2
            atfork_registered = 1;
568
2
        }
569
570
2
        pthread_attr_t attr;
571
2
        if (pthread_attr_init(&attr) != 0 ||
572
2
            pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 ||
573
2
            pthread_create(&fuzz_r_thread.thread, &attr,
574
2
                           fuzz_r_thread_main, NULL) != 0) {
575
0
            fprintf(stderr, "fuzz: cannot start the R thread\n");
576
0
            abort();
577
0
        }
578
2
        pthread_attr_destroy(&attr);
579
2
        fuzz_r_thread.started = 1;
580
2
    }
581
582
1.98k
    if (fuzz_on_r_thread()) {
583
0
        fn(arg);
584
0
        return;
585
0
    }
586
587
1.98k
    fuzz_job_t job = { fn, arg };
588
1.98k
    if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0)
589
1.98k
        atomic_fetch_add(&fuzz_alarm.input, 1);  /* wrapped past 0, which is none */
590
591
1.98k
    pthread_mutex_lock(&fuzz_r_thread.mutex);
592
1.98k
    fuzz_r_thread.job = &job;
593
1.98k
    pthread_cond_broadcast(&fuzz_r_thread.cond);
594
3.97k
    while (fuzz_r_thread.job != NULL)
595
1.98k
        pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
596
1.98k
    pthread_mutex_unlock(&fuzz_r_thread.mutex);
597
598
    /* Idle again: ticks count, and libFuzzer's clock for the next input
599
     * starts after this. */
600
1.98k
    atomic_store(&fuzz_alarm.finishing, 0);
601
    clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed);
602
1.98k
}
rd.c:fuzz_run_on_r_thread
Line
Count
Source
559
5.09k
{
560
5.09k
    if (!fuzz_r_thread.started) {
561
2
        static int atfork_registered = 0;
562
2
        if (!atfork_registered) {
563
2
            if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) {
564
0
                fprintf(stderr, "fuzz: cannot register the fork handler\n");
565
0
                abort();
566
0
            }
567
2
            atfork_registered = 1;
568
2
        }
569
570
2
        pthread_attr_t attr;
571
2
        if (pthread_attr_init(&attr) != 0 ||
572
2
            pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 ||
573
2
            pthread_create(&fuzz_r_thread.thread, &attr,
574
2
                           fuzz_r_thread_main, NULL) != 0) {
575
0
            fprintf(stderr, "fuzz: cannot start the R thread\n");
576
0
            abort();
577
0
        }
578
2
        pthread_attr_destroy(&attr);
579
2
        fuzz_r_thread.started = 1;
580
2
    }
581
582
5.09k
    if (fuzz_on_r_thread()) {
583
0
        fn(arg);
584
0
        return;
585
0
    }
586
587
5.09k
    fuzz_job_t job = { fn, arg };
588
5.09k
    if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0)
589
5.09k
        atomic_fetch_add(&fuzz_alarm.input, 1);  /* wrapped past 0, which is none */
590
591
5.09k
    pthread_mutex_lock(&fuzz_r_thread.mutex);
592
5.09k
    fuzz_r_thread.job = &job;
593
5.09k
    pthread_cond_broadcast(&fuzz_r_thread.cond);
594
10.1k
    while (fuzz_r_thread.job != NULL)
595
5.09k
        pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
596
5.09k
    pthread_mutex_unlock(&fuzz_r_thread.mutex);
597
598
    /* Idle again: ticks count, and libFuzzer's clock for the next input
599
     * starts after this. */
600
5.09k
    atomic_store(&fuzz_alarm.finishing, 0);
601
    clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed);
602
5.09k
}
sprintf.c:fuzz_run_on_r_thread
Line
Count
Source
559
2.08k
{
560
2.08k
    if (!fuzz_r_thread.started) {
561
2
        static int atfork_registered = 0;
562
2
        if (!atfork_registered) {
563
2
            if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) {
564
0
                fprintf(stderr, "fuzz: cannot register the fork handler\n");
565
0
                abort();
566
0
            }
567
2
            atfork_registered = 1;
568
2
        }
569
570
2
        pthread_attr_t attr;
571
2
        if (pthread_attr_init(&attr) != 0 ||
572
2
            pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 ||
573
2
            pthread_create(&fuzz_r_thread.thread, &attr,
574
2
                           fuzz_r_thread_main, NULL) != 0) {
575
0
            fprintf(stderr, "fuzz: cannot start the R thread\n");
576
0
            abort();
577
0
        }
578
2
        pthread_attr_destroy(&attr);
579
2
        fuzz_r_thread.started = 1;
580
2
    }
581
582
2.08k
    if (fuzz_on_r_thread()) {
583
0
        fn(arg);
584
0
        return;
585
0
    }
586
587
2.08k
    fuzz_job_t job = { fn, arg };
588
2.08k
    if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0)
589
2.08k
        atomic_fetch_add(&fuzz_alarm.input, 1);  /* wrapped past 0, which is none */
590
591
2.08k
    pthread_mutex_lock(&fuzz_r_thread.mutex);
592
2.08k
    fuzz_r_thread.job = &job;
593
2.08k
    pthread_cond_broadcast(&fuzz_r_thread.cond);
594
4.16k
    while (fuzz_r_thread.job != NULL)
595
2.08k
        pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
596
2.08k
    pthread_mutex_unlock(&fuzz_r_thread.mutex);
597
598
    /* Idle again: ticks count, and libFuzzer's clock for the next input
599
     * starts after this. */
600
2.08k
    atomic_store(&fuzz_alarm.finishing, 0);
601
    clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed);
602
2.08k
}
eval.c:fuzz_run_on_r_thread
Line
Count
Source
559
18.7k
{
560
18.7k
    if (!fuzz_r_thread.started) {
561
2
        static int atfork_registered = 0;
562
2
        if (!atfork_registered) {
563
2
            if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) {
564
0
                fprintf(stderr, "fuzz: cannot register the fork handler\n");
565
0
                abort();
566
0
            }
567
2
            atfork_registered = 1;
568
2
        }
569
570
2
        pthread_attr_t attr;
571
2
        if (pthread_attr_init(&attr) != 0 ||
572
2
            pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 ||
573
2
            pthread_create(&fuzz_r_thread.thread, &attr,
574
2
                           fuzz_r_thread_main, NULL) != 0) {
575
0
            fprintf(stderr, "fuzz: cannot start the R thread\n");
576
0
            abort();
577
0
        }
578
2
        pthread_attr_destroy(&attr);
579
2
        fuzz_r_thread.started = 1;
580
2
    }
581
582
18.7k
    if (fuzz_on_r_thread()) {
583
0
        fn(arg);
584
0
        return;
585
0
    }
586
587
18.7k
    fuzz_job_t job = { fn, arg };
588
18.7k
    if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0)
589
18.7k
        atomic_fetch_add(&fuzz_alarm.input, 1);  /* wrapped past 0, which is none */
590
591
18.7k
    pthread_mutex_lock(&fuzz_r_thread.mutex);
592
18.7k
    fuzz_r_thread.job = &job;
593
18.7k
    pthread_cond_broadcast(&fuzz_r_thread.cond);
594
37.5k
    while (fuzz_r_thread.job != NULL)
595
18.7k
        pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
596
18.7k
    pthread_mutex_unlock(&fuzz_r_thread.mutex);
597
598
    /* Idle again: ticks count, and libFuzzer's clock for the next input
599
     * starts after this. */
600
18.7k
    atomic_store(&fuzz_alarm.finishing, 0);
601
    clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed);
602
18.7k
}
zip.c:fuzz_run_on_r_thread
Line
Count
Source
559
2.09k
{
560
2.09k
    if (!fuzz_r_thread.started) {
561
2
        static int atfork_registered = 0;
562
2
        if (!atfork_registered) {
563
2
            if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) {
564
0
                fprintf(stderr, "fuzz: cannot register the fork handler\n");
565
0
                abort();
566
0
            }
567
2
            atfork_registered = 1;
568
2
        }
569
570
2
        pthread_attr_t attr;
571
2
        if (pthread_attr_init(&attr) != 0 ||
572
2
            pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 ||
573
2
            pthread_create(&fuzz_r_thread.thread, &attr,
574
2
                           fuzz_r_thread_main, NULL) != 0) {
575
0
            fprintf(stderr, "fuzz: cannot start the R thread\n");
576
0
            abort();
577
0
        }
578
2
        pthread_attr_destroy(&attr);
579
2
        fuzz_r_thread.started = 1;
580
2
    }
581
582
2.09k
    if (fuzz_on_r_thread()) {
583
0
        fn(arg);
584
0
        return;
585
0
    }
586
587
2.09k
    fuzz_job_t job = { fn, arg };
588
2.09k
    if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0)
589
2.09k
        atomic_fetch_add(&fuzz_alarm.input, 1);  /* wrapped past 0, which is none */
590
591
2.09k
    pthread_mutex_lock(&fuzz_r_thread.mutex);
592
2.09k
    fuzz_r_thread.job = &job;
593
2.09k
    pthread_cond_broadcast(&fuzz_r_thread.cond);
594
4.19k
    while (fuzz_r_thread.job != NULL)
595
2.09k
        pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
596
2.09k
    pthread_mutex_unlock(&fuzz_r_thread.mutex);
597
598
    /* Idle again: ticks count, and libFuzzer's clock for the next input
599
     * starts after this. */
600
2.09k
    atomic_store(&fuzz_alarm.finishing, 0);
601
    clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed);
602
2.09k
}
nmath.c:fuzz_run_on_r_thread
Line
Count
Source
559
12.2k
{
560
12.2k
    if (!fuzz_r_thread.started) {
561
2
        static int atfork_registered = 0;
562
2
        if (!atfork_registered) {
563
2
            if (pthread_atfork(NULL, NULL, fuzz_r_thread_forget) != 0) {
564
0
                fprintf(stderr, "fuzz: cannot register the fork handler\n");
565
0
                abort();
566
0
            }
567
2
            atfork_registered = 1;
568
2
        }
569
570
2
        pthread_attr_t attr;
571
2
        if (pthread_attr_init(&attr) != 0 ||
572
2
            pthread_attr_setstacksize(&attr, FUZZ_R_STACK_SIZE) != 0 ||
573
2
            pthread_create(&fuzz_r_thread.thread, &attr,
574
2
                           fuzz_r_thread_main, NULL) != 0) {
575
0
            fprintf(stderr, "fuzz: cannot start the R thread\n");
576
0
            abort();
577
0
        }
578
2
        pthread_attr_destroy(&attr);
579
2
        fuzz_r_thread.started = 1;
580
2
    }
581
582
12.2k
    if (fuzz_on_r_thread()) {
583
0
        fn(arg);
584
0
        return;
585
0
    }
586
587
12.2k
    fuzz_job_t job = { fn, arg };
588
12.2k
    if (atomic_fetch_add(&fuzz_alarm.input, 1) + 1 == 0)
589
12.2k
        atomic_fetch_add(&fuzz_alarm.input, 1);  /* wrapped past 0, which is none */
590
591
12.2k
    pthread_mutex_lock(&fuzz_r_thread.mutex);
592
12.2k
    fuzz_r_thread.job = &job;
593
12.2k
    pthread_cond_broadcast(&fuzz_r_thread.cond);
594
24.4k
    while (fuzz_r_thread.job != NULL)
595
12.2k
        pthread_cond_wait(&fuzz_r_thread.cond, &fuzz_r_thread.mutex);
596
12.2k
    pthread_mutex_unlock(&fuzz_r_thread.mutex);
597
598
    /* Idle again: ticks count, and libFuzzer's clock for the next input
599
     * starts after this. */
600
12.2k
    atomic_store(&fuzz_alarm.finishing, 0);
601
    clock_gettime(CLOCK_REALTIME, &fuzz_alarm.armed);
602
12.2k
}
603
604
/*
605
 * Initialize R for fuzzing.  Call once from fuzz_target_init.
606
 *
607
 * Performs:
608
 *   1. Set R_HOME from binary location
609
 *   2. Cap the vector heap (must precede R's startup, which reads it)
610
 *   3. Initialize embedded R, without R's signal handlers
611
 *   4. Point R's C stack check at the R thread's stack
612
 *   5. Suppress warnings
613
 */
614
static void fuzz_init_r(void)
615
48
{
616
48
    if (!fuzz_on_r_thread()) {
617
0
        fprintf(stderr, "fuzz_init_r: must run on the R thread "
618
0
                        "(define fuzz_target_init, not LLVMFuzzerInitialize)\n");
619
0
        abort();
620
0
    }
621
622
48
    fuzz_set_r_home();
623
48
    fuzz_set_vsize_limit();
624
625
    /* GC consistency failures ("untraced old-to-new reference", a node
626
     * with a bad type) are memory corruption, not input errors.  R's
627
     * default is to report and carry on; this makes gc_error() fatal
628
     * (through R_Suicide, which instrumentation/0004 turns into abort)
629
     * so they surface as crashes at the collection that found them. */
630
48
    if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL)
631
24
        setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1);
632
633
    /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery
634
     * prompt instead of crashing, which would hang the fuzzer.  Telling
635
     * R not to install them (rather than resetting to SIG_DFL after
636
     * init) keeps the sanitizers' own handlers in place, so wild-pointer
637
     * faults still get full ASAN reports and clean deduplication. */
638
48
    R_SignalHandlers = 0;
639
640
    /* The two halves of Rf_initEmbeddedR, with the C stack check fixed
641
     * up in between.  On Linux Rf_initialize_R takes R_CStackStart from
642
     * __libc_stack_end, the main thread's stack, so from this thread
643
     * every R_CheckStack() while setup_Rmainloop loads base would see
644
     * terabytes of usage and R would abort ("unable to initialize the
645
     * JIT").  macOS never sets it when embedded, which hides this
646
     * locally.  Switch the check off for startup, then measure against
647
     * this thread: R_CheckStack() fires as an ordinary R error at
648
     * FUZZ_R_CSTACK_LIMIT (see there for why it is not the whole stack).
649
     * setup_Rmainloop itself would turn any limit above 100 MB into
650
     * "unlimited", hence setting it after. */
651
48
    char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"};
652
48
    int r_argc = sizeof(r_argv) / sizeof(r_argv[0]);
653
48
    Rf_initialize_R(r_argc, r_argv);
654
48
    R_CStackStart = fuzz_r_thread.stack_top;
655
48
    R_CStackLimit = (uintptr_t)-1;
656
48
    R_Interactive = TRUE;   /* as Rf_initEmbeddedR */
657
48
    setup_Rmainloop();
658
48
    R_CStackLimit = FUZZ_R_CSTACK_LIMIT;
659
660
48
    fuzz_suppress_warnings();
661
48
}
io.c:fuzz_init_r
Line
Count
Source
615
2
{
616
2
    if (!fuzz_on_r_thread()) {
617
0
        fprintf(stderr, "fuzz_init_r: must run on the R thread "
618
0
                        "(define fuzz_target_init, not LLVMFuzzerInitialize)\n");
619
0
        abort();
620
0
    }
621
622
2
    fuzz_set_r_home();
623
2
    fuzz_set_vsize_limit();
624
625
    /* GC consistency failures ("untraced old-to-new reference", a node
626
     * with a bad type) are memory corruption, not input errors.  R's
627
     * default is to report and carry on; this makes gc_error() fatal
628
     * (through R_Suicide, which instrumentation/0004 turns into abort)
629
     * so they surface as crashes at the collection that found them. */
630
2
    if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL)
631
1
        setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1);
632
633
    /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery
634
     * prompt instead of crashing, which would hang the fuzzer.  Telling
635
     * R not to install them (rather than resetting to SIG_DFL after
636
     * init) keeps the sanitizers' own handlers in place, so wild-pointer
637
     * faults still get full ASAN reports and clean deduplication. */
638
2
    R_SignalHandlers = 0;
639
640
    /* The two halves of Rf_initEmbeddedR, with the C stack check fixed
641
     * up in between.  On Linux Rf_initialize_R takes R_CStackStart from
642
     * __libc_stack_end, the main thread's stack, so from this thread
643
     * every R_CheckStack() while setup_Rmainloop loads base would see
644
     * terabytes of usage and R would abort ("unable to initialize the
645
     * JIT").  macOS never sets it when embedded, which hides this
646
     * locally.  Switch the check off for startup, then measure against
647
     * this thread: R_CheckStack() fires as an ordinary R error at
648
     * FUZZ_R_CSTACK_LIMIT (see there for why it is not the whole stack).
649
     * setup_Rmainloop itself would turn any limit above 100 MB into
650
     * "unlimited", hence setting it after. */
651
2
    char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"};
652
2
    int r_argc = sizeof(r_argv) / sizeof(r_argv[0]);
653
2
    Rf_initialize_R(r_argc, r_argv);
654
2
    R_CStackStart = fuzz_r_thread.stack_top;
655
2
    R_CStackLimit = (uintptr_t)-1;
656
2
    R_Interactive = TRUE;   /* as Rf_initEmbeddedR */
657
2
    setup_Rmainloop();
658
2
    R_CStackLimit = FUZZ_R_CSTACK_LIMIT;
659
660
2
    fuzz_suppress_warnings();
661
2
}
dcf.c:fuzz_init_r
Line
Count
Source
615
2
{
616
2
    if (!fuzz_on_r_thread()) {
617
0
        fprintf(stderr, "fuzz_init_r: must run on the R thread "
618
0
                        "(define fuzz_target_init, not LLVMFuzzerInitialize)\n");
619
0
        abort();
620
0
    }
621
622
2
    fuzz_set_r_home();
623
2
    fuzz_set_vsize_limit();
624
625
    /* GC consistency failures ("untraced old-to-new reference", a node
626
     * with a bad type) are memory corruption, not input errors.  R's
627
     * default is to report and carry on; this makes gc_error() fatal
628
     * (through R_Suicide, which instrumentation/0004 turns into abort)
629
     * so they surface as crashes at the collection that found them. */
630
2
    if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL)
631
1
        setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1);
632
633
    /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery
634
     * prompt instead of crashing, which would hang the fuzzer.  Telling
635
     * R not to install them (rather than resetting to SIG_DFL after
636
     * init) keeps the sanitizers' own handlers in place, so wild-pointer
637
     * faults still get full ASAN reports and clean deduplication. */
638
2
    R_SignalHandlers = 0;
639
640
    /* The two halves of Rf_initEmbeddedR, with the C stack check fixed
641
     * up in between.  On Linux Rf_initialize_R takes R_CStackStart from
642
     * __libc_stack_end, the main thread's stack, so from this thread
643
     * every R_CheckStack() while setup_Rmainloop loads base would see
644
     * terabytes of usage and R would abort ("unable to initialize the
645
     * JIT").  macOS never sets it when embedded, which hides this
646
     * locally.  Switch the check off for startup, then measure against
647
     * this thread: R_CheckStack() fires as an ordinary R error at
648
     * FUZZ_R_CSTACK_LIMIT (see there for why it is not the whole stack).
649
     * setup_Rmainloop itself would turn any limit above 100 MB into
650
     * "unlimited", hence setting it after. */
651
2
    char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"};
652
2
    int r_argc = sizeof(r_argv) / sizeof(r_argv[0]);
653
2
    Rf_initialize_R(r_argc, r_argv);
654
2
    R_CStackStart = fuzz_r_thread.stack_top;
655
2
    R_CStackLimit = (uintptr_t)-1;
656
2
    R_Interactive = TRUE;   /* as Rf_initEmbeddedR */
657
2
    setup_Rmainloop();
658
2
    R_CStackLimit = FUZZ_R_CSTACK_LIMIT;
659
660
2
    fuzz_suppress_warnings();
661
2
}
character.c:fuzz_init_r
Line
Count
Source
615
2
{
616
2
    if (!fuzz_on_r_thread()) {
617
0
        fprintf(stderr, "fuzz_init_r: must run on the R thread "
618
0
                        "(define fuzz_target_init, not LLVMFuzzerInitialize)\n");
619
0
        abort();
620
0
    }
621
622
2
    fuzz_set_r_home();
623
2
    fuzz_set_vsize_limit();
624
625
    /* GC consistency failures ("untraced old-to-new reference", a node
626
     * with a bad type) are memory corruption, not input errors.  R's
627
     * default is to report and carry on; this makes gc_error() fatal
628
     * (through R_Suicide, which instrumentation/0004 turns into abort)
629
     * so they surface as crashes at the collection that found them. */
630
2
    if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL)
631
1
        setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1);
632
633
    /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery
634
     * prompt instead of crashing, which would hang the fuzzer.  Telling
635
     * R not to install them (rather than resetting to SIG_DFL after
636
     * init) keeps the sanitizers' own handlers in place, so wild-pointer
637
     * faults still get full ASAN reports and clean deduplication. */
638
2
    R_SignalHandlers = 0;
639
640
    /* The two halves of Rf_initEmbeddedR, with the C stack check fixed
641
     * up in between.  On Linux Rf_initialize_R takes R_CStackStart from
642
     * __libc_stack_end, the main thread's stack, so from this thread
643
     * every R_CheckStack() while setup_Rmainloop loads base would see
644
     * terabytes of usage and R would abort ("unable to initialize the
645
     * JIT").  macOS never sets it when embedded, which hides this
646
     * locally.  Switch the check off for startup, then measure against
647
     * this thread: R_CheckStack() fires as an ordinary R error at
648
     * FUZZ_R_CSTACK_LIMIT (see there for why it is not the whole stack).
649
     * setup_Rmainloop itself would turn any limit above 100 MB into
650
     * "unlimited", hence setting it after. */
651
2
    char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"};
652
2
    int r_argc = sizeof(r_argv) / sizeof(r_argv[0]);
653
2
    Rf_initialize_R(r_argc, r_argv);
654
2
    R_CStackStart = fuzz_r_thread.stack_top;
655
2
    R_CStackLimit = (uintptr_t)-1;
656
2
    R_Interactive = TRUE;   /* as Rf_initEmbeddedR */
657
2
    setup_Rmainloop();
658
2
    R_CStackLimit = FUZZ_R_CSTACK_LIMIT;
659
660
2
    fuzz_suppress_warnings();
661
2
}
encoding.c:fuzz_init_r
Line
Count
Source
615
2
{
616
2
    if (!fuzz_on_r_thread()) {
617
0
        fprintf(stderr, "fuzz_init_r: must run on the R thread "
618
0
                        "(define fuzz_target_init, not LLVMFuzzerInitialize)\n");
619
0
        abort();
620
0
    }
621
622
2
    fuzz_set_r_home();
623
2
    fuzz_set_vsize_limit();
624
625
    /* GC consistency failures ("untraced old-to-new reference", a node
626
     * with a bad type) are memory corruption, not input errors.  R's
627
     * default is to report and carry on; this makes gc_error() fatal
628
     * (through R_Suicide, which instrumentation/0004 turns into abort)
629
     * so they surface as crashes at the collection that found them. */
630
2
    if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL)
631
1
        setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1);
632
633
    /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery
634
     * prompt instead of crashing, which would hang the fuzzer.  Telling
635
     * R not to install them (rather than resetting to SIG_DFL after
636
     * init) keeps the sanitizers' own handlers in place, so wild-pointer
637
     * faults still get full ASAN reports and clean deduplication. */
638
2
    R_SignalHandlers = 0;
639
640
    /* The two halves of Rf_initEmbeddedR, with the C stack check fixed
641
     * up in between.  On Linux Rf_initialize_R takes R_CStackStart from
642
     * __libc_stack_end, the main thread's stack, so from this thread
643
     * every R_CheckStack() while setup_Rmainloop loads base would see
644
     * terabytes of usage and R would abort ("unable to initialize the
645
     * JIT").  macOS never sets it when embedded, which hides this
646
     * locally.  Switch the check off for startup, then measure against
647
     * this thread: R_CheckStack() fires as an ordinary R error at
648
     * FUZZ_R_CSTACK_LIMIT (see there for why it is not the whole stack).
649
     * setup_Rmainloop itself would turn any limit above 100 MB into
650
     * "unlimited", hence setting it after. */
651
2
    char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"};
652
2
    int r_argc = sizeof(r_argv) / sizeof(r_argv[0]);
653
2
    Rf_initialize_R(r_argc, r_argv);
654
2
    R_CStackStart = fuzz_r_thread.stack_top;
655
2
    R_CStackLimit = (uintptr_t)-1;
656
2
    R_Interactive = TRUE;   /* as Rf_initEmbeddedR */
657
2
    setup_Rmainloop();
658
2
    R_CStackLimit = FUZZ_R_CSTACK_LIMIT;
659
660
2
    fuzz_suppress_warnings();
661
2
}
sort.c:fuzz_init_r
Line
Count
Source
615
2
{
616
2
    if (!fuzz_on_r_thread()) {
617
0
        fprintf(stderr, "fuzz_init_r: must run on the R thread "
618
0
                        "(define fuzz_target_init, not LLVMFuzzerInitialize)\n");
619
0
        abort();
620
0
    }
621
622
2
    fuzz_set_r_home();
623
2
    fuzz_set_vsize_limit();
624
625
    /* GC consistency failures ("untraced old-to-new reference", a node
626
     * with a bad type) are memory corruption, not input errors.  R's
627
     * default is to report and carry on; this makes gc_error() fatal
628
     * (through R_Suicide, which instrumentation/0004 turns into abort)
629
     * so they surface as crashes at the collection that found them. */
630
2
    if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL)
631
1
        setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1);
632
633
    /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery
634
     * prompt instead of crashing, which would hang the fuzzer.  Telling
635
     * R not to install them (rather than resetting to SIG_DFL after
636
     * init) keeps the sanitizers' own handlers in place, so wild-pointer
637
     * faults still get full ASAN reports and clean deduplication. */
638
2
    R_SignalHandlers = 0;
639
640
    /* The two halves of Rf_initEmbeddedR, with the C stack check fixed
641
     * up in between.  On Linux Rf_initialize_R takes R_CStackStart from
642
     * __libc_stack_end, the main thread's stack, so from this thread
643
     * every R_CheckStack() while setup_Rmainloop loads base would see
644
     * terabytes of usage and R would abort ("unable to initialize the
645
     * JIT").  macOS never sets it when embedded, which hides this
646
     * locally.  Switch the check off for startup, then measure against
647
     * this thread: R_CheckStack() fires as an ordinary R error at
648
     * FUZZ_R_CSTACK_LIMIT (see there for why it is not the whole stack).
649
     * setup_Rmainloop itself would turn any limit above 100 MB into
650
     * "unlimited", hence setting it after. */
651
2
    char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"};
652
2
    int r_argc = sizeof(r_argv) / sizeof(r_argv[0]);
653
2
    Rf_initialize_R(r_argc, r_argv);
654
2
    R_CStackStart = fuzz_r_thread.stack_top;
655
2
    R_CStackLimit = (uintptr_t)-1;
656
2
    R_Interactive = TRUE;   /* as Rf_initEmbeddedR */
657
2
    setup_Rmainloop();
658
2
    R_CStackLimit = FUZZ_R_CSTACK_LIMIT;
659
660
2
    fuzz_suppress_warnings();
661
2
}
connections.c:fuzz_init_r
Line
Count
Source
615
2
{
616
2
    if (!fuzz_on_r_thread()) {
617
0
        fprintf(stderr, "fuzz_init_r: must run on the R thread "
618
0
                        "(define fuzz_target_init, not LLVMFuzzerInitialize)\n");
619
0
        abort();
620
0
    }
621
622
2
    fuzz_set_r_home();
623
2
    fuzz_set_vsize_limit();
624
625
    /* GC consistency failures ("untraced old-to-new reference", a node
626
     * with a bad type) are memory corruption, not input errors.  R's
627
     * default is to report and carry on; this makes gc_error() fatal
628
     * (through R_Suicide, which instrumentation/0004 turns into abort)
629
     * so they surface as crashes at the collection that found them. */
630
2
    if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL)
631
1
        setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1);
632
633
    /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery
634
     * prompt instead of crashing, which would hang the fuzzer.  Telling
635
     * R not to install them (rather than resetting to SIG_DFL after
636
     * init) keeps the sanitizers' own handlers in place, so wild-pointer
637
     * faults still get full ASAN reports and clean deduplication. */
638
2
    R_SignalHandlers = 0;
639
640
    /* The two halves of Rf_initEmbeddedR, with the C stack check fixed
641
     * up in between.  On Linux Rf_initialize_R takes R_CStackStart from
642
     * __libc_stack_end, the main thread's stack, so from this thread
643
     * every R_CheckStack() while setup_Rmainloop loads base would see
644
     * terabytes of usage and R would abort ("unable to initialize the
645
     * JIT").  macOS never sets it when embedded, which hides this
646
     * locally.  Switch the check off for startup, then measure against
647
     * this thread: R_CheckStack() fires as an ordinary R error at
648
     * FUZZ_R_CSTACK_LIMIT (see there for why it is not the whole stack).
649
     * setup_Rmainloop itself would turn any limit above 100 MB into
650
     * "unlimited", hence setting it after. */
651
2
    char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"};
652
2
    int r_argc = sizeof(r_argv) / sizeof(r_argv[0]);
653
2
    Rf_initialize_R(r_argc, r_argv);
654
2
    R_CStackStart = fuzz_r_thread.stack_top;
655
2
    R_CStackLimit = (uintptr_t)-1;
656
2
    R_Interactive = TRUE;   /* as Rf_initEmbeddedR */
657
2
    setup_Rmainloop();
658
2
    R_CStackLimit = FUZZ_R_CSTACK_LIMIT;
659
660
2
    fuzz_suppress_warnings();
661
2
}
unserialize.c:fuzz_init_r
Line
Count
Source
615
2
{
616
2
    if (!fuzz_on_r_thread()) {
617
0
        fprintf(stderr, "fuzz_init_r: must run on the R thread "
618
0
                        "(define fuzz_target_init, not LLVMFuzzerInitialize)\n");
619
0
        abort();
620
0
    }
621
622
2
    fuzz_set_r_home();
623
2
    fuzz_set_vsize_limit();
624
625
    /* GC consistency failures ("untraced old-to-new reference", a node
626
     * with a bad type) are memory corruption, not input errors.  R's
627
     * default is to report and carry on; this makes gc_error() fatal
628
     * (through R_Suicide, which instrumentation/0004 turns into abort)
629
     * so they surface as crashes at the collection that found them. */
630
2
    if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL)
631
1
        setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1);
632
633
    /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery
634
     * prompt instead of crashing, which would hang the fuzzer.  Telling
635
     * R not to install them (rather than resetting to SIG_DFL after
636
     * init) keeps the sanitizers' own handlers in place, so wild-pointer
637
     * faults still get full ASAN reports and clean deduplication. */
638
2
    R_SignalHandlers = 0;
639
640
    /* The two halves of Rf_initEmbeddedR, with the C stack check fixed
641
     * up in between.  On Linux Rf_initialize_R takes R_CStackStart from
642
     * __libc_stack_end, the main thread's stack, so from this thread
643
     * every R_CheckStack() while setup_Rmainloop loads base would see
644
     * terabytes of usage and R would abort ("unable to initialize the
645
     * JIT").  macOS never sets it when embedded, which hides this
646
     * locally.  Switch the check off for startup, then measure against
647
     * this thread: R_CheckStack() fires as an ordinary R error at
648
     * FUZZ_R_CSTACK_LIMIT (see there for why it is not the whole stack).
649
     * setup_Rmainloop itself would turn any limit above 100 MB into
650
     * "unlimited", hence setting it after. */
651
2
    char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"};
652
2
    int r_argc = sizeof(r_argv) / sizeof(r_argv[0]);
653
2
    Rf_initialize_R(r_argc, r_argv);
654
2
    R_CStackStart = fuzz_r_thread.stack_top;
655
2
    R_CStackLimit = (uintptr_t)-1;
656
2
    R_Interactive = TRUE;   /* as Rf_initEmbeddedR */
657
2
    setup_Rmainloop();
658
2
    R_CStackLimit = FUZZ_R_CSTACK_LIMIT;
659
660
2
    fuzz_suppress_warnings();
661
2
}
formula.c:fuzz_init_r
Line
Count
Source
615
2
{
616
2
    if (!fuzz_on_r_thread()) {
617
0
        fprintf(stderr, "fuzz_init_r: must run on the R thread "
618
0
                        "(define fuzz_target_init, not LLVMFuzzerInitialize)\n");
619
0
        abort();
620
0
    }
621
622
2
    fuzz_set_r_home();
623
2
    fuzz_set_vsize_limit();
624
625
    /* GC consistency failures ("untraced old-to-new reference", a node
626
     * with a bad type) are memory corruption, not input errors.  R's
627
     * default is to report and carry on; this makes gc_error() fatal
628
     * (through R_Suicide, which instrumentation/0004 turns into abort)
629
     * so they surface as crashes at the collection that found them. */
630
2
    if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL)
631
1
        setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1);
632
633
    /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery
634
     * prompt instead of crashing, which would hang the fuzzer.  Telling
635
     * R not to install them (rather than resetting to SIG_DFL after
636
     * init) keeps the sanitizers' own handlers in place, so wild-pointer
637
     * faults still get full ASAN reports and clean deduplication. */
638
2
    R_SignalHandlers = 0;
639
640
    /* The two halves of Rf_initEmbeddedR, with the C stack check fixed
641
     * up in between.  On Linux Rf_initialize_R takes R_CStackStart from
642
     * __libc_stack_end, the main thread's stack, so from this thread
643
     * every R_CheckStack() while setup_Rmainloop loads base would see
644
     * terabytes of usage and R would abort ("unable to initialize the
645
     * JIT").  macOS never sets it when embedded, which hides this
646
     * locally.  Switch the check off for startup, then measure against
647
     * this thread: R_CheckStack() fires as an ordinary R error at
648
     * FUZZ_R_CSTACK_LIMIT (see there for why it is not the whole stack).
649
     * setup_Rmainloop itself would turn any limit above 100 MB into
650
     * "unlimited", hence setting it after. */
651
2
    char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"};
652
2
    int r_argc = sizeof(r_argv) / sizeof(r_argv[0]);
653
2
    Rf_initialize_R(r_argc, r_argv);
654
2
    R_CStackStart = fuzz_r_thread.stack_top;
655
2
    R_CStackLimit = (uintptr_t)-1;
656
2
    R_Interactive = TRUE;   /* as Rf_initEmbeddedR */
657
2
    setup_Rmainloop();
658
2
    R_CStackLimit = FUZZ_R_CSTACK_LIMIT;
659
660
2
    fuzz_suppress_warnings();
661
2
}
decompress.c:fuzz_init_r
Line
Count
Source
615
2
{
616
2
    if (!fuzz_on_r_thread()) {
617
0
        fprintf(stderr, "fuzz_init_r: must run on the R thread "
618
0
                        "(define fuzz_target_init, not LLVMFuzzerInitialize)\n");
619
0
        abort();
620
0
    }
621
622
2
    fuzz_set_r_home();
623
2
    fuzz_set_vsize_limit();
624
625
    /* GC consistency failures ("untraced old-to-new reference", a node
626
     * with a bad type) are memory corruption, not input errors.  R's
627
     * default is to report and carry on; this makes gc_error() fatal
628
     * (through R_Suicide, which instrumentation/0004 turns into abort)
629
     * so they surface as crashes at the collection that found them. */
630
2
    if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL)
631
1
        setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1);
632
633
    /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery
634
     * prompt instead of crashing, which would hang the fuzzer.  Telling
635
     * R not to install them (rather than resetting to SIG_DFL after
636
     * init) keeps the sanitizers' own handlers in place, so wild-pointer
637
     * faults still get full ASAN reports and clean deduplication. */
638
2
    R_SignalHandlers = 0;
639
640
    /* The two halves of Rf_initEmbeddedR, with the C stack check fixed
641
     * up in between.  On Linux Rf_initialize_R takes R_CStackStart from
642
     * __libc_stack_end, the main thread's stack, so from this thread
643
     * every R_CheckStack() while setup_Rmainloop loads base would see
644
     * terabytes of usage and R would abort ("unable to initialize the
645
     * JIT").  macOS never sets it when embedded, which hides this
646
     * locally.  Switch the check off for startup, then measure against
647
     * this thread: R_CheckStack() fires as an ordinary R error at
648
     * FUZZ_R_CSTACK_LIMIT (see there for why it is not the whole stack).
649
     * setup_Rmainloop itself would turn any limit above 100 MB into
650
     * "unlimited", hence setting it after. */
651
2
    char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"};
652
2
    int r_argc = sizeof(r_argv) / sizeof(r_argv[0]);
653
2
    Rf_initialize_R(r_argc, r_argv);
654
2
    R_CStackStart = fuzz_r_thread.stack_top;
655
2
    R_CStackLimit = (uintptr_t)-1;
656
2
    R_Interactive = TRUE;   /* as Rf_initEmbeddedR */
657
2
    setup_Rmainloop();
658
2
    R_CStackLimit = FUZZ_R_CSTACK_LIMIT;
659
660
2
    fuzz_suppress_warnings();
661
2
}
readtable.c:fuzz_init_r
Line
Count
Source
615
2
{
616
2
    if (!fuzz_on_r_thread()) {
617
0
        fprintf(stderr, "fuzz_init_r: must run on the R thread "
618
0
                        "(define fuzz_target_init, not LLVMFuzzerInitialize)\n");
619
0
        abort();
620
0
    }
621
622
2
    fuzz_set_r_home();
623
2
    fuzz_set_vsize_limit();
624
625
    /* GC consistency failures ("untraced old-to-new reference", a node
626
     * with a bad type) are memory corruption, not input errors.  R's
627
     * default is to report and carry on; this makes gc_error() fatal
628
     * (through R_Suicide, which instrumentation/0004 turns into abort)
629
     * so they surface as crashes at the collection that found them. */
630
2
    if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL)
631
1
        setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1);
632
633
    /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery
634
     * prompt instead of crashing, which would hang the fuzzer.  Telling
635
     * R not to install them (rather than resetting to SIG_DFL after
636
     * init) keeps the sanitizers' own handlers in place, so wild-pointer
637
     * faults still get full ASAN reports and clean deduplication. */
638
2
    R_SignalHandlers = 0;
639
640
    /* The two halves of Rf_initEmbeddedR, with the C stack check fixed
641
     * up in between.  On Linux Rf_initialize_R takes R_CStackStart from
642
     * __libc_stack_end, the main thread's stack, so from this thread
643
     * every R_CheckStack() while setup_Rmainloop loads base would see
644
     * terabytes of usage and R would abort ("unable to initialize the
645
     * JIT").  macOS never sets it when embedded, which hides this
646
     * locally.  Switch the check off for startup, then measure against
647
     * this thread: R_CheckStack() fires as an ordinary R error at
648
     * FUZZ_R_CSTACK_LIMIT (see there for why it is not the whole stack).
649
     * setup_Rmainloop itself would turn any limit above 100 MB into
650
     * "unlimited", hence setting it after. */
651
2
    char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"};
652
2
    int r_argc = sizeof(r_argv) / sizeof(r_argv[0]);
653
2
    Rf_initialize_R(r_argc, r_argv);
654
2
    R_CStackStart = fuzz_r_thread.stack_top;
655
2
    R_CStackLimit = (uintptr_t)-1;
656
2
    R_Interactive = TRUE;   /* as Rf_initEmbeddedR */
657
2
    setup_Rmainloop();
658
2
    R_CStackLimit = FUZZ_R_CSTACK_LIMIT;
659
660
2
    fuzz_suppress_warnings();
661
2
}
format.c:fuzz_init_r
Line
Count
Source
615
2
{
616
2
    if (!fuzz_on_r_thread()) {
617
0
        fprintf(stderr, "fuzz_init_r: must run on the R thread "
618
0
                        "(define fuzz_target_init, not LLVMFuzzerInitialize)\n");
619
0
        abort();
620
0
    }
621
622
2
    fuzz_set_r_home();
623
2
    fuzz_set_vsize_limit();
624
625
    /* GC consistency failures ("untraced old-to-new reference", a node
626
     * with a bad type) are memory corruption, not input errors.  R's
627
     * default is to report and carry on; this makes gc_error() fatal
628
     * (through R_Suicide, which instrumentation/0004 turns into abort)
629
     * so they surface as crashes at the collection that found them. */
630
2
    if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL)
631
1
        setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1);
632
633
    /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery
634
     * prompt instead of crashing, which would hang the fuzzer.  Telling
635
     * R not to install them (rather than resetting to SIG_DFL after
636
     * init) keeps the sanitizers' own handlers in place, so wild-pointer
637
     * faults still get full ASAN reports and clean deduplication. */
638
2
    R_SignalHandlers = 0;
639
640
    /* The two halves of Rf_initEmbeddedR, with the C stack check fixed
641
     * up in between.  On Linux Rf_initialize_R takes R_CStackStart from
642
     * __libc_stack_end, the main thread's stack, so from this thread
643
     * every R_CheckStack() while setup_Rmainloop loads base would see
644
     * terabytes of usage and R would abort ("unable to initialize the
645
     * JIT").  macOS never sets it when embedded, which hides this
646
     * locally.  Switch the check off for startup, then measure against
647
     * this thread: R_CheckStack() fires as an ordinary R error at
648
     * FUZZ_R_CSTACK_LIMIT (see there for why it is not the whole stack).
649
     * setup_Rmainloop itself would turn any limit above 100 MB into
650
     * "unlimited", hence setting it after. */
651
2
    char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"};
652
2
    int r_argc = sizeof(r_argv) / sizeof(r_argv[0]);
653
2
    Rf_initialize_R(r_argc, r_argv);
654
2
    R_CStackStart = fuzz_r_thread.stack_top;
655
2
    R_CStackLimit = (uintptr_t)-1;
656
2
    R_Interactive = TRUE;   /* as Rf_initEmbeddedR */
657
2
    setup_Rmainloop();
658
2
    R_CStackLimit = FUZZ_R_CSTACK_LIMIT;
659
660
2
    fuzz_suppress_warnings();
661
2
}
datetime.c:fuzz_init_r
Line
Count
Source
615
2
{
616
2
    if (!fuzz_on_r_thread()) {
617
0
        fprintf(stderr, "fuzz_init_r: must run on the R thread "
618
0
                        "(define fuzz_target_init, not LLVMFuzzerInitialize)\n");
619
0
        abort();
620
0
    }
621
622
2
    fuzz_set_r_home();
623
2
    fuzz_set_vsize_limit();
624
625
    /* GC consistency failures ("untraced old-to-new reference", a node
626
     * with a bad type) are memory corruption, not input errors.  R's
627
     * default is to report and carry on; this makes gc_error() fatal
628
     * (through R_Suicide, which instrumentation/0004 turns into abort)
629
     * so they surface as crashes at the collection that found them. */
630
2
    if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL)
631
1
        setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1);
632
633
    /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery
634
     * prompt instead of crashing, which would hang the fuzzer.  Telling
635
     * R not to install them (rather than resetting to SIG_DFL after
636
     * init) keeps the sanitizers' own handlers in place, so wild-pointer
637
     * faults still get full ASAN reports and clean deduplication. */
638
2
    R_SignalHandlers = 0;
639
640
    /* The two halves of Rf_initEmbeddedR, with the C stack check fixed
641
     * up in between.  On Linux Rf_initialize_R takes R_CStackStart from
642
     * __libc_stack_end, the main thread's stack, so from this thread
643
     * every R_CheckStack() while setup_Rmainloop loads base would see
644
     * terabytes of usage and R would abort ("unable to initialize the
645
     * JIT").  macOS never sets it when embedded, which hides this
646
     * locally.  Switch the check off for startup, then measure against
647
     * this thread: R_CheckStack() fires as an ordinary R error at
648
     * FUZZ_R_CSTACK_LIMIT (see there for why it is not the whole stack).
649
     * setup_Rmainloop itself would turn any limit above 100 MB into
650
     * "unlimited", hence setting it after. */
651
2
    char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"};
652
2
    int r_argc = sizeof(r_argv) / sizeof(r_argv[0]);
653
2
    Rf_initialize_R(r_argc, r_argv);
654
2
    R_CStackStart = fuzz_r_thread.stack_top;
655
2
    R_CStackLimit = (uintptr_t)-1;
656
2
    R_Interactive = TRUE;   /* as Rf_initEmbeddedR */
657
2
    setup_Rmainloop();
658
2
    R_CStackLimit = FUZZ_R_CSTACK_LIMIT;
659
660
2
    fuzz_suppress_warnings();
661
2
}
coerce.c:fuzz_init_r
Line
Count
Source
615
2
{
616
2
    if (!fuzz_on_r_thread()) {
617
0
        fprintf(stderr, "fuzz_init_r: must run on the R thread "
618
0
                        "(define fuzz_target_init, not LLVMFuzzerInitialize)\n");
619
0
        abort();
620
0
    }
621
622
2
    fuzz_set_r_home();
623
2
    fuzz_set_vsize_limit();
624
625
    /* GC consistency failures ("untraced old-to-new reference", a node
626
     * with a bad type) are memory corruption, not input errors.  R's
627
     * default is to report and carry on; this makes gc_error() fatal
628
     * (through R_Suicide, which instrumentation/0004 turns into abort)
629
     * so they surface as crashes at the collection that found them. */
630
2
    if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL)
631
1
        setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1);
632
633
    /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery
634
     * prompt instead of crashing, which would hang the fuzzer.  Telling
635
     * R not to install them (rather than resetting to SIG_DFL after
636
     * init) keeps the sanitizers' own handlers in place, so wild-pointer
637
     * faults still get full ASAN reports and clean deduplication. */
638
2
    R_SignalHandlers = 0;
639
640
    /* The two halves of Rf_initEmbeddedR, with the C stack check fixed
641
     * up in between.  On Linux Rf_initialize_R takes R_CStackStart from
642
     * __libc_stack_end, the main thread's stack, so from this thread
643
     * every R_CheckStack() while setup_Rmainloop loads base would see
644
     * terabytes of usage and R would abort ("unable to initialize the
645
     * JIT").  macOS never sets it when embedded, which hides this
646
     * locally.  Switch the check off for startup, then measure against
647
     * this thread: R_CheckStack() fires as an ordinary R error at
648
     * FUZZ_R_CSTACK_LIMIT (see there for why it is not the whole stack).
649
     * setup_Rmainloop itself would turn any limit above 100 MB into
650
     * "unlimited", hence setting it after. */
651
2
    char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"};
652
2
    int r_argc = sizeof(r_argv) / sizeof(r_argv[0]);
653
2
    Rf_initialize_R(r_argc, r_argv);
654
2
    R_CStackStart = fuzz_r_thread.stack_top;
655
2
    R_CStackLimit = (uintptr_t)-1;
656
2
    R_Interactive = TRUE;   /* as Rf_initEmbeddedR */
657
2
    setup_Rmainloop();
658
2
    R_CStackLimit = FUZZ_R_CSTACK_LIMIT;
659
660
2
    fuzz_suppress_warnings();
661
2
}
load.c:fuzz_init_r
Line
Count
Source
615
2
{
616
2
    if (!fuzz_on_r_thread()) {
617
0
        fprintf(stderr, "fuzz_init_r: must run on the R thread "
618
0
                        "(define fuzz_target_init, not LLVMFuzzerInitialize)\n");
619
0
        abort();
620
0
    }
621
622
2
    fuzz_set_r_home();
623
2
    fuzz_set_vsize_limit();
624
625
    /* GC consistency failures ("untraced old-to-new reference", a node
626
     * with a bad type) are memory corruption, not input errors.  R's
627
     * default is to report and carry on; this makes gc_error() fatal
628
     * (through R_Suicide, which instrumentation/0004 turns into abort)
629
     * so they surface as crashes at the collection that found them. */
630
2
    if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL)
631
1
        setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1);
632
633
    /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery
634
     * prompt instead of crashing, which would hang the fuzzer.  Telling
635
     * R not to install them (rather than resetting to SIG_DFL after
636
     * init) keeps the sanitizers' own handlers in place, so wild-pointer
637
     * faults still get full ASAN reports and clean deduplication. */
638
2
    R_SignalHandlers = 0;
639
640
    /* The two halves of Rf_initEmbeddedR, with the C stack check fixed
641
     * up in between.  On Linux Rf_initialize_R takes R_CStackStart from
642
     * __libc_stack_end, the main thread's stack, so from this thread
643
     * every R_CheckStack() while setup_Rmainloop loads base would see
644
     * terabytes of usage and R would abort ("unable to initialize the
645
     * JIT").  macOS never sets it when embedded, which hides this
646
     * locally.  Switch the check off for startup, then measure against
647
     * this thread: R_CheckStack() fires as an ordinary R error at
648
     * FUZZ_R_CSTACK_LIMIT (see there for why it is not the whole stack).
649
     * setup_Rmainloop itself would turn any limit above 100 MB into
650
     * "unlimited", hence setting it after. */
651
2
    char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"};
652
2
    int r_argc = sizeof(r_argv) / sizeof(r_argv[0]);
653
2
    Rf_initialize_R(r_argc, r_argv);
654
2
    R_CStackStart = fuzz_r_thread.stack_top;
655
2
    R_CStackLimit = (uintptr_t)-1;
656
2
    R_Interactive = TRUE;   /* as Rf_initEmbeddedR */
657
2
    setup_Rmainloop();
658
2
    R_CStackLimit = FUZZ_R_CSTACK_LIMIT;
659
660
2
    fuzz_suppress_warnings();
661
2
}
scan.c:fuzz_init_r
Line
Count
Source
615
2
{
616
2
    if (!fuzz_on_r_thread()) {
617
0
        fprintf(stderr, "fuzz_init_r: must run on the R thread "
618
0
                        "(define fuzz_target_init, not LLVMFuzzerInitialize)\n");
619
0
        abort();
620
0
    }
621
622
2
    fuzz_set_r_home();
623
2
    fuzz_set_vsize_limit();
624
625
    /* GC consistency failures ("untraced old-to-new reference", a node
626
     * with a bad type) are memory corruption, not input errors.  R's
627
     * default is to report and carry on; this makes gc_error() fatal
628
     * (through R_Suicide, which instrumentation/0004 turns into abort)
629
     * so they surface as crashes at the collection that found them. */
630
2
    if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL)
631
1
        setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1);
632
633
    /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery
634
     * prompt instead of crashing, which would hang the fuzzer.  Telling
635
     * R not to install them (rather than resetting to SIG_DFL after
636
     * init) keeps the sanitizers' own handlers in place, so wild-pointer
637
     * faults still get full ASAN reports and clean deduplication. */
638
2
    R_SignalHandlers = 0;
639
640
    /* The two halves of Rf_initEmbeddedR, with the C stack check fixed
641
     * up in between.  On Linux Rf_initialize_R takes R_CStackStart from
642
     * __libc_stack_end, the main thread's stack, so from this thread
643
     * every R_CheckStack() while setup_Rmainloop loads base would see
644
     * terabytes of usage and R would abort ("unable to initialize the
645
     * JIT").  macOS never sets it when embedded, which hides this
646
     * locally.  Switch the check off for startup, then measure against
647
     * this thread: R_CheckStack() fires as an ordinary R error at
648
     * FUZZ_R_CSTACK_LIMIT (see there for why it is not the whole stack).
649
     * setup_Rmainloop itself would turn any limit above 100 MB into
650
     * "unlimited", hence setting it after. */
651
2
    char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"};
652
2
    int r_argc = sizeof(r_argv) / sizeof(r_argv[0]);
653
2
    Rf_initialize_R(r_argc, r_argv);
654
2
    R_CStackStart = fuzz_r_thread.stack_top;
655
2
    R_CStackLimit = (uintptr_t)-1;
656
2
    R_Interactive = TRUE;   /* as Rf_initEmbeddedR */
657
2
    setup_Rmainloop();
658
2
    R_CStackLimit = FUZZ_R_CSTACK_LIMIT;
659
660
2
    fuzz_suppress_warnings();
661
2
}
colors.c:fuzz_init_r
Line
Count
Source
615
2
{
616
2
    if (!fuzz_on_r_thread()) {
617
0
        fprintf(stderr, "fuzz_init_r: must run on the R thread "
618
0
                        "(define fuzz_target_init, not LLVMFuzzerInitialize)\n");
619
0
        abort();
620
0
    }
621
622
2
    fuzz_set_r_home();
623
2
    fuzz_set_vsize_limit();
624
625
    /* GC consistency failures ("untraced old-to-new reference", a node
626
     * with a bad type) are memory corruption, not input errors.  R's
627
     * default is to report and carry on; this makes gc_error() fatal
628
     * (through R_Suicide, which instrumentation/0004 turns into abort)
629
     * so they surface as crashes at the collection that found them. */
630
2
    if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL)
631
1
        setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1);
632
633
    /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery
634
     * prompt instead of crashing, which would hang the fuzzer.  Telling
635
     * R not to install them (rather than resetting to SIG_DFL after
636
     * init) keeps the sanitizers' own handlers in place, so wild-pointer
637
     * faults still get full ASAN reports and clean deduplication. */
638
2
    R_SignalHandlers = 0;
639
640
    /* The two halves of Rf_initEmbeddedR, with the C stack check fixed
641
     * up in between.  On Linux Rf_initialize_R takes R_CStackStart from
642
     * __libc_stack_end, the main thread's stack, so from this thread
643
     * every R_CheckStack() while setup_Rmainloop loads base would see
644
     * terabytes of usage and R would abort ("unable to initialize the
645
     * JIT").  macOS never sets it when embedded, which hides this
646
     * locally.  Switch the check off for startup, then measure against
647
     * this thread: R_CheckStack() fires as an ordinary R error at
648
     * FUZZ_R_CSTACK_LIMIT (see there for why it is not the whole stack).
649
     * setup_Rmainloop itself would turn any limit above 100 MB into
650
     * "unlimited", hence setting it after. */
651
2
    char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"};
652
2
    int r_argc = sizeof(r_argv) / sizeof(r_argv[0]);
653
2
    Rf_initialize_R(r_argc, r_argv);
654
2
    R_CStackStart = fuzz_r_thread.stack_top;
655
2
    R_CStackLimit = (uintptr_t)-1;
656
2
    R_Interactive = TRUE;   /* as Rf_initEmbeddedR */
657
2
    setup_Rmainloop();
658
2
    R_CStackLimit = FUZZ_R_CSTACK_LIMIT;
659
660
2
    fuzz_suppress_warnings();
661
2
}
grep.c:fuzz_init_r
Line
Count
Source
615
2
{
616
2
    if (!fuzz_on_r_thread()) {
617
0
        fprintf(stderr, "fuzz_init_r: must run on the R thread "
618
0
                        "(define fuzz_target_init, not LLVMFuzzerInitialize)\n");
619
0
        abort();
620
0
    }
621
622
2
    fuzz_set_r_home();
623
2
    fuzz_set_vsize_limit();
624
625
    /* GC consistency failures ("untraced old-to-new reference", a node
626
     * with a bad type) are memory corruption, not input errors.  R's
627
     * default is to report and carry on; this makes gc_error() fatal
628
     * (through R_Suicide, which instrumentation/0004 turns into abort)
629
     * so they surface as crashes at the collection that found them. */
630
2
    if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL)
631
1
        setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1);
632
633
    /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery
634
     * prompt instead of crashing, which would hang the fuzzer.  Telling
635
     * R not to install them (rather than resetting to SIG_DFL after
636
     * init) keeps the sanitizers' own handlers in place, so wild-pointer
637
     * faults still get full ASAN reports and clean deduplication. */
638
2
    R_SignalHandlers = 0;
639
640
    /* The two halves of Rf_initEmbeddedR, with the C stack check fixed
641
     * up in between.  On Linux Rf_initialize_R takes R_CStackStart from
642
     * __libc_stack_end, the main thread's stack, so from this thread
643
     * every R_CheckStack() while setup_Rmainloop loads base would see
644
     * terabytes of usage and R would abort ("unable to initialize the
645
     * JIT").  macOS never sets it when embedded, which hides this
646
     * locally.  Switch the check off for startup, then measure against
647
     * this thread: R_CheckStack() fires as an ordinary R error at
648
     * FUZZ_R_CSTACK_LIMIT (see there for why it is not the whole stack).
649
     * setup_Rmainloop itself would turn any limit above 100 MB into
650
     * "unlimited", hence setting it after. */
651
2
    char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"};
652
2
    int r_argc = sizeof(r_argv) / sizeof(r_argv[0]);
653
2
    Rf_initialize_R(r_argc, r_argv);
654
2
    R_CStackStart = fuzz_r_thread.stack_top;
655
2
    R_CStackLimit = (uintptr_t)-1;
656
2
    R_Interactive = TRUE;   /* as Rf_initEmbeddedR */
657
2
    setup_Rmainloop();
658
2
    R_CStackLimit = FUZZ_R_CSTACK_LIMIT;
659
660
2
    fuzz_suppress_warnings();
661
2
}
parse.c:fuzz_init_r
Line
Count
Source
615
2
{
616
2
    if (!fuzz_on_r_thread()) {
617
0
        fprintf(stderr, "fuzz_init_r: must run on the R thread "
618
0
                        "(define fuzz_target_init, not LLVMFuzzerInitialize)\n");
619
0
        abort();
620
0
    }
621
622
2
    fuzz_set_r_home();
623
2
    fuzz_set_vsize_limit();
624
625
    /* GC consistency failures ("untraced old-to-new reference", a node
626
     * with a bad type) are memory corruption, not input errors.  R's
627
     * default is to report and carry on; this makes gc_error() fatal
628
     * (through R_Suicide, which instrumentation/0004 turns into abort)
629
     * so they surface as crashes at the collection that found them. */
630
2
    if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL)
631
1
        setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1);
632
633
    /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery
634
     * prompt instead of crashing, which would hang the fuzzer.  Telling
635
     * R not to install them (rather than resetting to SIG_DFL after
636
     * init) keeps the sanitizers' own handlers in place, so wild-pointer
637
     * faults still get full ASAN reports and clean deduplication. */
638
2
    R_SignalHandlers = 0;
639
640
    /* The two halves of Rf_initEmbeddedR, with the C stack check fixed
641
     * up in between.  On Linux Rf_initialize_R takes R_CStackStart from
642
     * __libc_stack_end, the main thread's stack, so from this thread
643
     * every R_CheckStack() while setup_Rmainloop loads base would see
644
     * terabytes of usage and R would abort ("unable to initialize the
645
     * JIT").  macOS never sets it when embedded, which hides this
646
     * locally.  Switch the check off for startup, then measure against
647
     * this thread: R_CheckStack() fires as an ordinary R error at
648
     * FUZZ_R_CSTACK_LIMIT (see there for why it is not the whole stack).
649
     * setup_Rmainloop itself would turn any limit above 100 MB into
650
     * "unlimited", hence setting it after. */
651
2
    char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"};
652
2
    int r_argc = sizeof(r_argv) / sizeof(r_argv[0]);
653
2
    Rf_initialize_R(r_argc, r_argv);
654
2
    R_CStackStart = fuzz_r_thread.stack_top;
655
2
    R_CStackLimit = (uintptr_t)-1;
656
2
    R_Interactive = TRUE;   /* as Rf_initEmbeddedR */
657
2
    setup_Rmainloop();
658
2
    R_CStackLimit = FUZZ_R_CSTACK_LIMIT;
659
660
2
    fuzz_suppress_warnings();
661
2
}
sockets.c:fuzz_init_r
Line
Count
Source
615
2
{
616
2
    if (!fuzz_on_r_thread()) {
617
0
        fprintf(stderr, "fuzz_init_r: must run on the R thread "
618
0
                        "(define fuzz_target_init, not LLVMFuzzerInitialize)\n");
619
0
        abort();
620
0
    }
621
622
2
    fuzz_set_r_home();
623
2
    fuzz_set_vsize_limit();
624
625
    /* GC consistency failures ("untraced old-to-new reference", a node
626
     * with a bad type) are memory corruption, not input errors.  R's
627
     * default is to report and carry on; this makes gc_error() fatal
628
     * (through R_Suicide, which instrumentation/0004 turns into abort)
629
     * so they surface as crashes at the collection that found them. */
630
2
    if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL)
631
1
        setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1);
632
633
    /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery
634
     * prompt instead of crashing, which would hang the fuzzer.  Telling
635
     * R not to install them (rather than resetting to SIG_DFL after
636
     * init) keeps the sanitizers' own handlers in place, so wild-pointer
637
     * faults still get full ASAN reports and clean deduplication. */
638
2
    R_SignalHandlers = 0;
639
640
    /* The two halves of Rf_initEmbeddedR, with the C stack check fixed
641
     * up in between.  On Linux Rf_initialize_R takes R_CStackStart from
642
     * __libc_stack_end, the main thread's stack, so from this thread
643
     * every R_CheckStack() while setup_Rmainloop loads base would see
644
     * terabytes of usage and R would abort ("unable to initialize the
645
     * JIT").  macOS never sets it when embedded, which hides this
646
     * locally.  Switch the check off for startup, then measure against
647
     * this thread: R_CheckStack() fires as an ordinary R error at
648
     * FUZZ_R_CSTACK_LIMIT (see there for why it is not the whole stack).
649
     * setup_Rmainloop itself would turn any limit above 100 MB into
650
     * "unlimited", hence setting it after. */
651
2
    char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"};
652
2
    int r_argc = sizeof(r_argv) / sizeof(r_argv[0]);
653
2
    Rf_initialize_R(r_argc, r_argv);
654
2
    R_CStackStart = fuzz_r_thread.stack_top;
655
2
    R_CStackLimit = (uintptr_t)-1;
656
2
    R_Interactive = TRUE;   /* as Rf_initEmbeddedR */
657
2
    setup_Rmainloop();
658
2
    R_CStackLimit = FUZZ_R_CSTACK_LIMIT;
659
660
2
    fuzz_suppress_warnings();
661
2
}
rd.c:fuzz_init_r
Line
Count
Source
615
2
{
616
2
    if (!fuzz_on_r_thread()) {
617
0
        fprintf(stderr, "fuzz_init_r: must run on the R thread "
618
0
                        "(define fuzz_target_init, not LLVMFuzzerInitialize)\n");
619
0
        abort();
620
0
    }
621
622
2
    fuzz_set_r_home();
623
2
    fuzz_set_vsize_limit();
624
625
    /* GC consistency failures ("untraced old-to-new reference", a node
626
     * with a bad type) are memory corruption, not input errors.  R's
627
     * default is to report and carry on; this makes gc_error() fatal
628
     * (through R_Suicide, which instrumentation/0004 turns into abort)
629
     * so they surface as crashes at the collection that found them. */
630
2
    if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL)
631
1
        setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1);
632
633
    /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery
634
     * prompt instead of crashing, which would hang the fuzzer.  Telling
635
     * R not to install them (rather than resetting to SIG_DFL after
636
     * init) keeps the sanitizers' own handlers in place, so wild-pointer
637
     * faults still get full ASAN reports and clean deduplication. */
638
2
    R_SignalHandlers = 0;
639
640
    /* The two halves of Rf_initEmbeddedR, with the C stack check fixed
641
     * up in between.  On Linux Rf_initialize_R takes R_CStackStart from
642
     * __libc_stack_end, the main thread's stack, so from this thread
643
     * every R_CheckStack() while setup_Rmainloop loads base would see
644
     * terabytes of usage and R would abort ("unable to initialize the
645
     * JIT").  macOS never sets it when embedded, which hides this
646
     * locally.  Switch the check off for startup, then measure against
647
     * this thread: R_CheckStack() fires as an ordinary R error at
648
     * FUZZ_R_CSTACK_LIMIT (see there for why it is not the whole stack).
649
     * setup_Rmainloop itself would turn any limit above 100 MB into
650
     * "unlimited", hence setting it after. */
651
2
    char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"};
652
2
    int r_argc = sizeof(r_argv) / sizeof(r_argv[0]);
653
2
    Rf_initialize_R(r_argc, r_argv);
654
2
    R_CStackStart = fuzz_r_thread.stack_top;
655
2
    R_CStackLimit = (uintptr_t)-1;
656
2
    R_Interactive = TRUE;   /* as Rf_initEmbeddedR */
657
2
    setup_Rmainloop();
658
2
    R_CStackLimit = FUZZ_R_CSTACK_LIMIT;
659
660
2
    fuzz_suppress_warnings();
661
2
}
sprintf.c:fuzz_init_r
Line
Count
Source
615
2
{
616
2
    if (!fuzz_on_r_thread()) {
617
0
        fprintf(stderr, "fuzz_init_r: must run on the R thread "
618
0
                        "(define fuzz_target_init, not LLVMFuzzerInitialize)\n");
619
0
        abort();
620
0
    }
621
622
2
    fuzz_set_r_home();
623
2
    fuzz_set_vsize_limit();
624
625
    /* GC consistency failures ("untraced old-to-new reference", a node
626
     * with a bad type) are memory corruption, not input errors.  R's
627
     * default is to report and carry on; this makes gc_error() fatal
628
     * (through R_Suicide, which instrumentation/0004 turns into abort)
629
     * so they surface as crashes at the collection that found them. */
630
2
    if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL)
631
1
        setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1);
632
633
    /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery
634
     * prompt instead of crashing, which would hang the fuzzer.  Telling
635
     * R not to install them (rather than resetting to SIG_DFL after
636
     * init) keeps the sanitizers' own handlers in place, so wild-pointer
637
     * faults still get full ASAN reports and clean deduplication. */
638
2
    R_SignalHandlers = 0;
639
640
    /* The two halves of Rf_initEmbeddedR, with the C stack check fixed
641
     * up in between.  On Linux Rf_initialize_R takes R_CStackStart from
642
     * __libc_stack_end, the main thread's stack, so from this thread
643
     * every R_CheckStack() while setup_Rmainloop loads base would see
644
     * terabytes of usage and R would abort ("unable to initialize the
645
     * JIT").  macOS never sets it when embedded, which hides this
646
     * locally.  Switch the check off for startup, then measure against
647
     * this thread: R_CheckStack() fires as an ordinary R error at
648
     * FUZZ_R_CSTACK_LIMIT (see there for why it is not the whole stack).
649
     * setup_Rmainloop itself would turn any limit above 100 MB into
650
     * "unlimited", hence setting it after. */
651
2
    char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"};
652
2
    int r_argc = sizeof(r_argv) / sizeof(r_argv[0]);
653
2
    Rf_initialize_R(r_argc, r_argv);
654
2
    R_CStackStart = fuzz_r_thread.stack_top;
655
2
    R_CStackLimit = (uintptr_t)-1;
656
2
    R_Interactive = TRUE;   /* as Rf_initEmbeddedR */
657
2
    setup_Rmainloop();
658
2
    R_CStackLimit = FUZZ_R_CSTACK_LIMIT;
659
660
2
    fuzz_suppress_warnings();
661
2
}
eval.c:fuzz_init_r
Line
Count
Source
615
2
{
616
2
    if (!fuzz_on_r_thread()) {
617
0
        fprintf(stderr, "fuzz_init_r: must run on the R thread "
618
0
                        "(define fuzz_target_init, not LLVMFuzzerInitialize)\n");
619
0
        abort();
620
0
    }
621
622
2
    fuzz_set_r_home();
623
2
    fuzz_set_vsize_limit();
624
625
    /* GC consistency failures ("untraced old-to-new reference", a node
626
     * with a bad type) are memory corruption, not input errors.  R's
627
     * default is to report and carry on; this makes gc_error() fatal
628
     * (through R_Suicide, which instrumentation/0004 turns into abort)
629
     * so they surface as crashes at the collection that found them. */
630
2
    if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL)
631
1
        setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1);
632
633
    /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery
634
     * prompt instead of crashing, which would hang the fuzzer.  Telling
635
     * R not to install them (rather than resetting to SIG_DFL after
636
     * init) keeps the sanitizers' own handlers in place, so wild-pointer
637
     * faults still get full ASAN reports and clean deduplication. */
638
2
    R_SignalHandlers = 0;
639
640
    /* The two halves of Rf_initEmbeddedR, with the C stack check fixed
641
     * up in between.  On Linux Rf_initialize_R takes R_CStackStart from
642
     * __libc_stack_end, the main thread's stack, so from this thread
643
     * every R_CheckStack() while setup_Rmainloop loads base would see
644
     * terabytes of usage and R would abort ("unable to initialize the
645
     * JIT").  macOS never sets it when embedded, which hides this
646
     * locally.  Switch the check off for startup, then measure against
647
     * this thread: R_CheckStack() fires as an ordinary R error at
648
     * FUZZ_R_CSTACK_LIMIT (see there for why it is not the whole stack).
649
     * setup_Rmainloop itself would turn any limit above 100 MB into
650
     * "unlimited", hence setting it after. */
651
2
    char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"};
652
2
    int r_argc = sizeof(r_argv) / sizeof(r_argv[0]);
653
2
    Rf_initialize_R(r_argc, r_argv);
654
2
    R_CStackStart = fuzz_r_thread.stack_top;
655
2
    R_CStackLimit = (uintptr_t)-1;
656
2
    R_Interactive = TRUE;   /* as Rf_initEmbeddedR */
657
2
    setup_Rmainloop();
658
2
    R_CStackLimit = FUZZ_R_CSTACK_LIMIT;
659
660
2
    fuzz_suppress_warnings();
661
2
}
zip.c:fuzz_init_r
Line
Count
Source
615
2
{
616
2
    if (!fuzz_on_r_thread()) {
617
0
        fprintf(stderr, "fuzz_init_r: must run on the R thread "
618
0
                        "(define fuzz_target_init, not LLVMFuzzerInitialize)\n");
619
0
        abort();
620
0
    }
621
622
2
    fuzz_set_r_home();
623
2
    fuzz_set_vsize_limit();
624
625
    /* GC consistency failures ("untraced old-to-new reference", a node
626
     * with a bad type) are memory corruption, not input errors.  R's
627
     * default is to report and carry on; this makes gc_error() fatal
628
     * (through R_Suicide, which instrumentation/0004 turns into abort)
629
     * so they surface as crashes at the collection that found them. */
630
2
    if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL)
631
1
        setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1);
632
633
    /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery
634
     * prompt instead of crashing, which would hang the fuzzer.  Telling
635
     * R not to install them (rather than resetting to SIG_DFL after
636
     * init) keeps the sanitizers' own handlers in place, so wild-pointer
637
     * faults still get full ASAN reports and clean deduplication. */
638
2
    R_SignalHandlers = 0;
639
640
    /* The two halves of Rf_initEmbeddedR, with the C stack check fixed
641
     * up in between.  On Linux Rf_initialize_R takes R_CStackStart from
642
     * __libc_stack_end, the main thread's stack, so from this thread
643
     * every R_CheckStack() while setup_Rmainloop loads base would see
644
     * terabytes of usage and R would abort ("unable to initialize the
645
     * JIT").  macOS never sets it when embedded, which hides this
646
     * locally.  Switch the check off for startup, then measure against
647
     * this thread: R_CheckStack() fires as an ordinary R error at
648
     * FUZZ_R_CSTACK_LIMIT (see there for why it is not the whole stack).
649
     * setup_Rmainloop itself would turn any limit above 100 MB into
650
     * "unlimited", hence setting it after. */
651
2
    char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"};
652
2
    int r_argc = sizeof(r_argv) / sizeof(r_argv[0]);
653
2
    Rf_initialize_R(r_argc, r_argv);
654
2
    R_CStackStart = fuzz_r_thread.stack_top;
655
2
    R_CStackLimit = (uintptr_t)-1;
656
2
    R_Interactive = TRUE;   /* as Rf_initEmbeddedR */
657
2
    setup_Rmainloop();
658
2
    R_CStackLimit = FUZZ_R_CSTACK_LIMIT;
659
660
2
    fuzz_suppress_warnings();
661
2
}
nmath.c:fuzz_init_r
Line
Count
Source
615
2
{
616
2
    if (!fuzz_on_r_thread()) {
617
0
        fprintf(stderr, "fuzz_init_r: must run on the R thread "
618
0
                        "(define fuzz_target_init, not LLVMFuzzerInitialize)\n");
619
0
        abort();
620
0
    }
621
622
2
    fuzz_set_r_home();
623
2
    fuzz_set_vsize_limit();
624
625
    /* GC consistency failures ("untraced old-to-new reference", a node
626
     * with a bad type) are memory corruption, not input errors.  R's
627
     * default is to report and carry on; this makes gc_error() fatal
628
     * (through R_Suicide, which instrumentation/0004 turns into abort)
629
     * so they surface as crashes at the collection that found them. */
630
2
    if (getenv("_R_GC_FAIL_ON_ERROR_") == NULL)
631
1
        setenv("_R_GC_FAIL_ON_ERROR_", "yes", 1);
632
633
    /* R's SIGSEGV/SIGILL/etc. handlers enter an interactive recovery
634
     * prompt instead of crashing, which would hang the fuzzer.  Telling
635
     * R not to install them (rather than resetting to SIG_DFL after
636
     * init) keeps the sanitizers' own handlers in place, so wild-pointer
637
     * faults still get full ASAN reports and clean deduplication. */
638
2
    R_SignalHandlers = 0;
639
640
    /* The two halves of Rf_initEmbeddedR, with the C stack check fixed
641
     * up in between.  On Linux Rf_initialize_R takes R_CStackStart from
642
     * __libc_stack_end, the main thread's stack, so from this thread
643
     * every R_CheckStack() while setup_Rmainloop loads base would see
644
     * terabytes of usage and R would abort ("unable to initialize the
645
     * JIT").  macOS never sets it when embedded, which hides this
646
     * locally.  Switch the check off for startup, then measure against
647
     * this thread: R_CheckStack() fires as an ordinary R error at
648
     * FUZZ_R_CSTACK_LIMIT (see there for why it is not the whole stack).
649
     * setup_Rmainloop itself would turn any limit above 100 MB into
650
     * "unlimited", hence setting it after. */
651
2
    char *r_argv[] = {"R", "--vanilla", "--no-echo", "--no-restore"};
652
2
    int r_argc = sizeof(r_argv) / sizeof(r_argv[0]);
653
2
    Rf_initialize_R(r_argc, r_argv);
654
2
    R_CStackStart = fuzz_r_thread.stack_top;
655
2
    R_CStackLimit = (uintptr_t)-1;
656
2
    R_Interactive = TRUE;   /* as Rf_initEmbeddedR */
657
2
    setup_Rmainloop();
658
2
    R_CStackLimit = FUZZ_R_CSTACK_LIMIT;
659
660
2
    fuzz_suppress_warnings();
661
2
}
662
663
/*
664
 * Helper for protected evaluation via R_ToplevelExec.
665
 *
666
 * R API calls that touch R objects can longjmp on error.  Without a
667
 * top-level context, R's error handler crashes.  Wrapping calls in
668
 * R_ToplevelExec catches the longjmp cleanly.
669
 */
670
typedef struct {
671
    SEXP call;
672
    SEXP env;
673
} fuzz_eval_data_t;
674
675
static void fuzz_do_eval(void *data)
676
21.0k
{
677
21.0k
    fuzz_eval_data_t *ed = (fuzz_eval_data_t *)data;
678
21.0k
    fuzz_label_enter(ed->call);
679
21.0k
    Rf_eval(ed->call, ed->env);
680
21.0k
}
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
Unexecuted instantiation: formula.c:fuzz_do_eval
decompress.c:fuzz_do_eval
Line
Count
Source
676
7.60k
{
677
7.60k
    fuzz_eval_data_t *ed = (fuzz_eval_data_t *)data;
678
7.60k
    fuzz_label_enter(ed->call);
679
7.60k
    Rf_eval(ed->call, ed->env);
680
7.60k
}
Unexecuted instantiation: readtable.c:fuzz_do_eval
Unexecuted instantiation: format.c:fuzz_do_eval
datetime.c:fuzz_do_eval
Line
Count
Source
676
6.30k
{
677
6.30k
    fuzz_eval_data_t *ed = (fuzz_eval_data_t *)data;
678
6.30k
    fuzz_label_enter(ed->call);
679
6.30k
    Rf_eval(ed->call, ed->env);
680
6.30k
}
coerce.c:fuzz_do_eval
Line
Count
Source
676
7.13k
{
677
7.13k
    fuzz_eval_data_t *ed = (fuzz_eval_data_t *)data;
678
7.13k
    fuzz_label_enter(ed->call);
679
7.13k
    Rf_eval(ed->call, ed->env);
680
7.13k
}
Unexecuted instantiation: load.c:fuzz_do_eval
Unexecuted instantiation: scan.c:fuzz_do_eval
Unexecuted instantiation: colors.c:fuzz_do_eval
Unexecuted instantiation: grep.c:fuzz_do_eval
Unexecuted instantiation: parse.c:fuzz_do_eval
Unexecuted instantiation: sockets.c:fuzz_do_eval
Unexecuted instantiation: rd.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
Unexecuted instantiation: nmath.c:fuzz_do_eval
681
682
/* Evaluate malformed-input-heavy targets without printing each expected
683
 * R error. R_tryEvalSilent installs its own top-level error context.
684
 * FUZZ_PRINT_ERRORS prints them instead, for scripts/check-wrappers.sh. */
685
static void fuzz_eval_silent(SEXP call, SEXP env)
686
108k
{
687
108k
    int error = 0;
688
108k
    fuzz_label_enter(call);
689
#ifdef FUZZ_PRINT_ERRORS
690
    R_tryEval(call, env, &error);
691
#else
692
108k
    R_tryEvalSilent(call, env, &error);
693
108k
#endif
694
108k
}
io.c:fuzz_eval_silent
Line
Count
Source
686
1.07k
{
687
1.07k
    int error = 0;
688
1.07k
    fuzz_label_enter(call);
689
#ifdef FUZZ_PRINT_ERRORS
690
    R_tryEval(call, env, &error);
691
#else
692
1.07k
    R_tryEvalSilent(call, env, &error);
693
1.07k
#endif
694
1.07k
}
dcf.c:fuzz_eval_silent
Line
Count
Source
686
4.72k
{
687
4.72k
    int error = 0;
688
4.72k
    fuzz_label_enter(call);
689
#ifdef FUZZ_PRINT_ERRORS
690
    R_tryEval(call, env, &error);
691
#else
692
4.72k
    R_tryEvalSilent(call, env, &error);
693
4.72k
#endif
694
4.72k
}
character.c:fuzz_eval_silent
Line
Count
Source
686
4.07k
{
687
4.07k
    int error = 0;
688
4.07k
    fuzz_label_enter(call);
689
#ifdef FUZZ_PRINT_ERRORS
690
    R_tryEval(call, env, &error);
691
#else
692
4.07k
    R_tryEvalSilent(call, env, &error);
693
4.07k
#endif
694
4.07k
}
encoding.c:fuzz_eval_silent
Line
Count
Source
686
1.76k
{
687
1.76k
    int error = 0;
688
1.76k
    fuzz_label_enter(call);
689
#ifdef FUZZ_PRINT_ERRORS
690
    R_tryEval(call, env, &error);
691
#else
692
1.76k
    R_tryEvalSilent(call, env, &error);
693
1.76k
#endif
694
1.76k
}
sort.c:fuzz_eval_silent
Line
Count
Source
686
6.79k
{
687
6.79k
    int error = 0;
688
6.79k
    fuzz_label_enter(call);
689
#ifdef FUZZ_PRINT_ERRORS
690
    R_tryEval(call, env, &error);
691
#else
692
6.79k
    R_tryEvalSilent(call, env, &error);
693
6.79k
#endif
694
6.79k
}
connections.c:fuzz_eval_silent
Line
Count
Source
686
8.32k
{
687
8.32k
    int error = 0;
688
8.32k
    fuzz_label_enter(call);
689
#ifdef FUZZ_PRINT_ERRORS
690
    R_tryEval(call, env, &error);
691
#else
692
8.32k
    R_tryEvalSilent(call, env, &error);
693
8.32k
#endif
694
8.32k
}
unserialize.c:fuzz_eval_silent
Line
Count
Source
686
5.70k
{
687
5.70k
    int error = 0;
688
5.70k
    fuzz_label_enter(call);
689
#ifdef FUZZ_PRINT_ERRORS
690
    R_tryEval(call, env, &error);
691
#else
692
5.70k
    R_tryEvalSilent(call, env, &error);
693
5.70k
#endif
694
5.70k
}
formula.c:fuzz_eval_silent
Line
Count
Source
686
10.2k
{
687
10.2k
    int error = 0;
688
10.2k
    fuzz_label_enter(call);
689
#ifdef FUZZ_PRINT_ERRORS
690
    R_tryEval(call, env, &error);
691
#else
692
10.2k
    R_tryEvalSilent(call, env, &error);
693
10.2k
#endif
694
10.2k
}
Unexecuted instantiation: decompress.c:fuzz_eval_silent
readtable.c:fuzz_eval_silent
Line
Count
Source
686
5.13k
{
687
5.13k
    int error = 0;
688
5.13k
    fuzz_label_enter(call);
689
#ifdef FUZZ_PRINT_ERRORS
690
    R_tryEval(call, env, &error);
691
#else
692
5.13k
    R_tryEvalSilent(call, env, &error);
693
5.13k
#endif
694
5.13k
}
format.c:fuzz_eval_silent
Line
Count
Source
686
5.49k
{
687
5.49k
    int error = 0;
688
5.49k
    fuzz_label_enter(call);
689
#ifdef FUZZ_PRINT_ERRORS
690
    R_tryEval(call, env, &error);
691
#else
692
5.49k
    R_tryEvalSilent(call, env, &error);
693
5.49k
#endif
694
5.49k
}
datetime.c:fuzz_eval_silent
Line
Count
Source
686
2.87k
{
687
2.87k
    int error = 0;
688
2.87k
    fuzz_label_enter(call);
689
#ifdef FUZZ_PRINT_ERRORS
690
    R_tryEval(call, env, &error);
691
#else
692
2.87k
    R_tryEvalSilent(call, env, &error);
693
2.87k
#endif
694
2.87k
}
Unexecuted instantiation: coerce.c:fuzz_eval_silent
load.c:fuzz_eval_silent
Line
Count
Source
686
11.1k
{
687
11.1k
    int error = 0;
688
11.1k
    fuzz_label_enter(call);
689
#ifdef FUZZ_PRINT_ERRORS
690
    R_tryEval(call, env, &error);
691
#else
692
11.1k
    R_tryEvalSilent(call, env, &error);
693
11.1k
#endif
694
11.1k
}
scan.c:fuzz_eval_silent
Line
Count
Source
686
2.90k
{
687
2.90k
    int error = 0;
688
2.90k
    fuzz_label_enter(call);
689
#ifdef FUZZ_PRINT_ERRORS
690
    R_tryEval(call, env, &error);
691
#else
692
2.90k
    R_tryEvalSilent(call, env, &error);
693
2.90k
#endif
694
2.90k
}
colors.c:fuzz_eval_silent
Line
Count
Source
686
3.92k
{
687
3.92k
    int error = 0;
688
3.92k
    fuzz_label_enter(call);
689
#ifdef FUZZ_PRINT_ERRORS
690
    R_tryEval(call, env, &error);
691
#else
692
3.92k
    R_tryEvalSilent(call, env, &error);
693
3.92k
#endif
694
3.92k
}
grep.c:fuzz_eval_silent
Line
Count
Source
686
2.18k
{
687
2.18k
    int error = 0;
688
2.18k
    fuzz_label_enter(call);
689
#ifdef FUZZ_PRINT_ERRORS
690
    R_tryEval(call, env, &error);
691
#else
692
2.18k
    R_tryEvalSilent(call, env, &error);
693
2.18k
#endif
694
2.18k
}
parse.c:fuzz_eval_silent
Line
Count
Source
686
8.61k
{
687
8.61k
    int error = 0;
688
8.61k
    fuzz_label_enter(call);
689
#ifdef FUZZ_PRINT_ERRORS
690
    R_tryEval(call, env, &error);
691
#else
692
8.61k
    R_tryEvalSilent(call, env, &error);
693
8.61k
#endif
694
8.61k
}
sockets.c:fuzz_eval_silent
Line
Count
Source
686
1.98k
{
687
1.98k
    int error = 0;
688
1.98k
    fuzz_label_enter(call);
689
#ifdef FUZZ_PRINT_ERRORS
690
    R_tryEval(call, env, &error);
691
#else
692
1.98k
    R_tryEvalSilent(call, env, &error);
693
1.98k
#endif
694
1.98k
}
rd.c:fuzz_eval_silent
Line
Count
Source
686
5.08k
{
687
5.08k
    int error = 0;
688
5.08k
    fuzz_label_enter(call);
689
#ifdef FUZZ_PRINT_ERRORS
690
    R_tryEval(call, env, &error);
691
#else
692
5.08k
    R_tryEvalSilent(call, env, &error);
693
5.08k
#endif
694
5.08k
}
sprintf.c:fuzz_eval_silent
Line
Count
Source
686
2.07k
{
687
2.07k
    int error = 0;
688
2.07k
    fuzz_label_enter(call);
689
#ifdef FUZZ_PRINT_ERRORS
690
    R_tryEval(call, env, &error);
691
#else
692
2.07k
    R_tryEvalSilent(call, env, &error);
693
2.07k
#endif
694
2.07k
}
Unexecuted instantiation: eval.c:fuzz_eval_silent
zip.c:fuzz_eval_silent
Line
Count
Source
686
2.09k
{
687
2.09k
    int error = 0;
688
2.09k
    fuzz_label_enter(call);
689
#ifdef FUZZ_PRINT_ERRORS
690
    R_tryEval(call, env, &error);
691
#else
692
2.09k
    R_tryEvalSilent(call, env, &error);
693
2.09k
#endif
694
2.09k
}
nmath.c:fuzz_eval_silent
Line
Count
Source
686
12.2k
{
687
12.2k
    int error = 0;
688
12.2k
    fuzz_label_enter(call);
689
#ifdef FUZZ_PRINT_ERRORS
690
    R_tryEval(call, env, &error);
691
#else
692
12.2k
    R_tryEvalSilent(call, env, &error);
693
12.2k
#endif
694
12.2k
}
695
696
/*
697
 * Stage per-iteration inputs under a toplevel context.
698
 *
699
 * Rf_mkChar and Rf_allocVector can themselves signal the vector-limit
700
 * error.  Outside a toplevel context that error longjmps into a stack
701
 * frame that returned during Rf_initEmbeddedR -- undefined behaviour --
702
 * so input staging must be wrapped just like evaluation.  Both helpers
703
 * return FALSE when the allocation failed; skip the iteration then.
704
 */
705
typedef struct {
706
    SEXP vec;
707
    const char *str;
708
} fuzz_string_data_t;
709
710
static void fuzz_do_set_string(void *data)
711
59.1k
{
712
59.1k
    fuzz_string_data_t *sd = (fuzz_string_data_t *)data;
713
59.1k
    SET_STRING_ELT(sd->vec, 0, Rf_mkChar(sd->str));
714
59.1k
}
Unexecuted instantiation: io.c:fuzz_do_set_string
dcf.c:fuzz_do_set_string
Line
Count
Source
711
4.72k
{
712
4.72k
    fuzz_string_data_t *sd = (fuzz_string_data_t *)data;
713
4.72k
    SET_STRING_ELT(sd->vec, 0, Rf_mkChar(sd->str));
714
4.72k
}
character.c:fuzz_do_set_string
Line
Count
Source
711
3.28k
{
712
3.28k
    fuzz_string_data_t *sd = (fuzz_string_data_t *)data;
713
3.28k
    SET_STRING_ELT(sd->vec, 0, Rf_mkChar(sd->str));
714
3.28k
}
encoding.c:fuzz_do_set_string
Line
Count
Source
711
827
{
712
827
    fuzz_string_data_t *sd = (fuzz_string_data_t *)data;
713
827
    SET_STRING_ELT(sd->vec, 0, Rf_mkChar(sd->str));
714
827
}
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: formula.c:fuzz_do_set_string
Unexecuted instantiation: decompress.c:fuzz_do_set_string
readtable.c:fuzz_do_set_string
Line
Count
Source
711
5.09k
{
712
5.09k
    fuzz_string_data_t *sd = (fuzz_string_data_t *)data;
713
5.09k
    SET_STRING_ELT(sd->vec, 0, Rf_mkChar(sd->str));
714
5.09k
}
format.c:fuzz_do_set_string
Line
Count
Source
711
5.49k
{
712
5.49k
    fuzz_string_data_t *sd = (fuzz_string_data_t *)data;
713
5.49k
    SET_STRING_ELT(sd->vec, 0, Rf_mkChar(sd->str));
714
5.49k
}
datetime.c:fuzz_do_set_string
Line
Count
Source
711
12.6k
{
712
12.6k
    fuzz_string_data_t *sd = (fuzz_string_data_t *)data;
713
12.6k
    SET_STRING_ELT(sd->vec, 0, Rf_mkChar(sd->str));
714
12.6k
}
coerce.c:fuzz_do_set_string
Line
Count
Source
711
1.78k
{
712
1.78k
    fuzz_string_data_t *sd = (fuzz_string_data_t *)data;
713
1.78k
    SET_STRING_ELT(sd->vec, 0, Rf_mkChar(sd->str));
714
1.78k
}
Unexecuted instantiation: load.c:fuzz_do_set_string
scan.c:fuzz_do_set_string
Line
Count
Source
711
2.86k
{
712
2.86k
    fuzz_string_data_t *sd = (fuzz_string_data_t *)data;
713
2.86k
    SET_STRING_ELT(sd->vec, 0, Rf_mkChar(sd->str));
714
2.86k
}
colors.c:fuzz_do_set_string
Line
Count
Source
711
3.89k
{
712
3.89k
    fuzz_string_data_t *sd = (fuzz_string_data_t *)data;
713
3.89k
    SET_STRING_ELT(sd->vec, 0, Rf_mkChar(sd->str));
714
3.89k
}
grep.c:fuzz_do_set_string
Line
Count
Source
711
2.15k
{
712
2.15k
    fuzz_string_data_t *sd = (fuzz_string_data_t *)data;
713
2.15k
    SET_STRING_ELT(sd->vec, 0, Rf_mkChar(sd->str));
714
2.15k
}
parse.c:fuzz_do_set_string
Line
Count
Source
711
9.27k
{
712
9.27k
    fuzz_string_data_t *sd = (fuzz_string_data_t *)data;
713
9.27k
    SET_STRING_ELT(sd->vec, 0, Rf_mkChar(sd->str));
714
9.27k
}
Unexecuted instantiation: sockets.c:fuzz_do_set_string
rd.c:fuzz_do_set_string
Line
Count
Source
711
5.08k
{
712
5.08k
    fuzz_string_data_t *sd = (fuzz_string_data_t *)data;
713
5.08k
    SET_STRING_ELT(sd->vec, 0, Rf_mkChar(sd->str));
714
5.08k
}
sprintf.c:fuzz_do_set_string
Line
Count
Source
711
2.07k
{
712
2.07k
    fuzz_string_data_t *sd = (fuzz_string_data_t *)data;
713
2.07k
    SET_STRING_ELT(sd->vec, 0, Rf_mkChar(sd->str));
714
2.07k
}
Unexecuted instantiation: eval.c:fuzz_do_set_string
Unexecuted instantiation: zip.c:fuzz_do_set_string
Unexecuted instantiation: nmath.c:fuzz_do_set_string
715
716
static Rboolean fuzz_set_string(SEXP vec, const char *str)
717
59.1k
{
718
59.1k
    fuzz_string_data_t sd = { vec, str };
719
59.1k
    return R_ToplevelExec(fuzz_do_set_string, &sd);
720
59.1k
}
Unexecuted instantiation: io.c:fuzz_set_string
dcf.c:fuzz_set_string
Line
Count
Source
717
4.72k
{
718
4.72k
    fuzz_string_data_t sd = { vec, str };
719
4.72k
    return R_ToplevelExec(fuzz_do_set_string, &sd);
720
4.72k
}
character.c:fuzz_set_string
Line
Count
Source
717
3.28k
{
718
3.28k
    fuzz_string_data_t sd = { vec, str };
719
3.28k
    return R_ToplevelExec(fuzz_do_set_string, &sd);
720
3.28k
}
encoding.c:fuzz_set_string
Line
Count
Source
717
827
{
718
827
    fuzz_string_data_t sd = { vec, str };
719
827
    return R_ToplevelExec(fuzz_do_set_string, &sd);
720
827
}
Unexecuted instantiation: sort.c:fuzz_set_string
Unexecuted instantiation: connections.c:fuzz_set_string
Unexecuted instantiation: unserialize.c:fuzz_set_string
Unexecuted instantiation: formula.c:fuzz_set_string
Unexecuted instantiation: decompress.c:fuzz_set_string
readtable.c:fuzz_set_string
Line
Count
Source
717
5.09k
{
718
5.09k
    fuzz_string_data_t sd = { vec, str };
719
5.09k
    return R_ToplevelExec(fuzz_do_set_string, &sd);
720
5.09k
}
format.c:fuzz_set_string
Line
Count
Source
717
5.49k
{
718
5.49k
    fuzz_string_data_t sd = { vec, str };
719
5.49k
    return R_ToplevelExec(fuzz_do_set_string, &sd);
720
5.49k
}
datetime.c:fuzz_set_string
Line
Count
Source
717
12.6k
{
718
12.6k
    fuzz_string_data_t sd = { vec, str };
719
12.6k
    return R_ToplevelExec(fuzz_do_set_string, &sd);
720
12.6k
}
coerce.c:fuzz_set_string
Line
Count
Source
717
1.78k
{
718
1.78k
    fuzz_string_data_t sd = { vec, str };
719
1.78k
    return R_ToplevelExec(fuzz_do_set_string, &sd);
720
1.78k
}
Unexecuted instantiation: load.c:fuzz_set_string
scan.c:fuzz_set_string
Line
Count
Source
717
2.86k
{
718
2.86k
    fuzz_string_data_t sd = { vec, str };
719
2.86k
    return R_ToplevelExec(fuzz_do_set_string, &sd);
720
2.86k
}
colors.c:fuzz_set_string
Line
Count
Source
717
3.89k
{
718
3.89k
    fuzz_string_data_t sd = { vec, str };
719
3.89k
    return R_ToplevelExec(fuzz_do_set_string, &sd);
720
3.89k
}
grep.c:fuzz_set_string
Line
Count
Source
717
2.15k
{
718
2.15k
    fuzz_string_data_t sd = { vec, str };
719
2.15k
    return R_ToplevelExec(fuzz_do_set_string, &sd);
720
2.15k
}
parse.c:fuzz_set_string
Line
Count
Source
717
9.27k
{
718
9.27k
    fuzz_string_data_t sd = { vec, str };
719
9.27k
    return R_ToplevelExec(fuzz_do_set_string, &sd);
720
9.27k
}
Unexecuted instantiation: sockets.c:fuzz_set_string
rd.c:fuzz_set_string
Line
Count
Source
717
5.08k
{
718
5.08k
    fuzz_string_data_t sd = { vec, str };
719
5.08k
    return R_ToplevelExec(fuzz_do_set_string, &sd);
720
5.08k
}
sprintf.c:fuzz_set_string
Line
Count
Source
717
2.07k
{
718
2.07k
    fuzz_string_data_t sd = { vec, str };
719
2.07k
    return R_ToplevelExec(fuzz_do_set_string, &sd);
720
2.07k
}
Unexecuted instantiation: eval.c:fuzz_set_string
Unexecuted instantiation: zip.c:fuzz_set_string
Unexecuted instantiation: nmath.c:fuzz_set_string
721
722
/*
723
 * Parse and evaluate one R function literal, once, at initialization.
724
 *
725
 * Harnesses whose calls need named arguments, on.exit(close(con)) or a
726
 * few R-level steps around the entry point express each slot as an R
727
 * closure and call it with Rf_lang*; that keeps the C side free of
728
 * argument plumbing.  The source is harness-authored (never fuzz
729
 * input), so a parse or evaluation failure is a harness bug: abort.
730
 *
731
 * The closure is created in the global environment so its body sees
732
 * the attached packages.  Created in base it would not: base's enclosure
733
 * is the empty environment, so every call to a grDevices, utils or
734
 * stats function fails with "could not find function", silently under
735
 * fuzz_eval_silent.  scripts/check-wrappers.sh checks for that.
736
 */
737
static SEXP fuzz_make_wrapper(const char *source)
738
326
{
739
326
    ParseStatus status;
740
326
    SEXP text, parsed, wrapper;
741
326
    Rf_protect(text = Rf_mkString(source));
742
326
    Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue));
743
326
    if (status != PARSE_OK || XLENGTH(parsed) != 1)
744
0
        abort();
745
746
326
    wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_GlobalEnv);
747
326
    Rf_unprotect(2);
748
326
    return wrapper;
749
326
}
io.c:fuzz_make_wrapper
Line
Count
Source
738
20
{
739
20
    ParseStatus status;
740
20
    SEXP text, parsed, wrapper;
741
20
    Rf_protect(text = Rf_mkString(source));
742
20
    Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue));
743
20
    if (status != PARSE_OK || XLENGTH(parsed) != 1)
744
0
        abort();
745
746
20
    wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_GlobalEnv);
747
20
    Rf_unprotect(2);
748
20
    return wrapper;
749
20
}
Unexecuted instantiation: dcf.c:fuzz_make_wrapper
Unexecuted instantiation: character.c:fuzz_make_wrapper
Unexecuted instantiation: encoding.c:fuzz_make_wrapper
sort.c:fuzz_make_wrapper
Line
Count
Source
738
44
{
739
44
    ParseStatus status;
740
44
    SEXP text, parsed, wrapper;
741
44
    Rf_protect(text = Rf_mkString(source));
742
44
    Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue));
743
44
    if (status != PARSE_OK || XLENGTH(parsed) != 1)
744
0
        abort();
745
746
44
    wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_GlobalEnv);
747
44
    Rf_unprotect(2);
748
44
    return wrapper;
749
44
}
connections.c:fuzz_make_wrapper
Line
Count
Source
738
22
{
739
22
    ParseStatus status;
740
22
    SEXP text, parsed, wrapper;
741
22
    Rf_protect(text = Rf_mkString(source));
742
22
    Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue));
743
22
    if (status != PARSE_OK || XLENGTH(parsed) != 1)
744
0
        abort();
745
746
22
    wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_GlobalEnv);
747
22
    Rf_unprotect(2);
748
22
    return wrapper;
749
22
}
unserialize.c:fuzz_make_wrapper
Line
Count
Source
738
8
{
739
8
    ParseStatus status;
740
8
    SEXP text, parsed, wrapper;
741
8
    Rf_protect(text = Rf_mkString(source));
742
8
    Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue));
743
8
    if (status != PARSE_OK || XLENGTH(parsed) != 1)
744
0
        abort();
745
746
8
    wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_GlobalEnv);
747
8
    Rf_unprotect(2);
748
8
    return wrapper;
749
8
}
formula.c:fuzz_make_wrapper
Line
Count
Source
738
12
{
739
12
    ParseStatus status;
740
12
    SEXP text, parsed, wrapper;
741
12
    Rf_protect(text = Rf_mkString(source));
742
12
    Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue));
743
12
    if (status != PARSE_OK || XLENGTH(parsed) != 1)
744
0
        abort();
745
746
12
    wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_GlobalEnv);
747
12
    Rf_unprotect(2);
748
12
    return wrapper;
749
12
}
Unexecuted instantiation: decompress.c:fuzz_make_wrapper
readtable.c:fuzz_make_wrapper
Line
Count
Source
738
40
{
739
40
    ParseStatus status;
740
40
    SEXP text, parsed, wrapper;
741
40
    Rf_protect(text = Rf_mkString(source));
742
40
    Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue));
743
40
    if (status != PARSE_OK || XLENGTH(parsed) != 1)
744
0
        abort();
745
746
40
    wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_GlobalEnv);
747
40
    Rf_unprotect(2);
748
40
    return wrapper;
749
40
}
format.c:fuzz_make_wrapper
Line
Count
Source
738
48
{
739
48
    ParseStatus status;
740
48
    SEXP text, parsed, wrapper;
741
48
    Rf_protect(text = Rf_mkString(source));
742
48
    Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue));
743
48
    if (status != PARSE_OK || XLENGTH(parsed) != 1)
744
0
        abort();
745
746
48
    wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_GlobalEnv);
747
48
    Rf_unprotect(2);
748
48
    return wrapper;
749
48
}
datetime.c:fuzz_make_wrapper
Line
Count
Source
738
2
{
739
2
    ParseStatus status;
740
2
    SEXP text, parsed, wrapper;
741
2
    Rf_protect(text = Rf_mkString(source));
742
2
    Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue));
743
2
    if (status != PARSE_OK || XLENGTH(parsed) != 1)
744
0
        abort();
745
746
2
    wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_GlobalEnv);
747
2
    Rf_unprotect(2);
748
2
    return wrapper;
749
2
}
Unexecuted instantiation: coerce.c:fuzz_make_wrapper
load.c:fuzz_make_wrapper
Line
Count
Source
738
4
{
739
4
    ParseStatus status;
740
4
    SEXP text, parsed, wrapper;
741
4
    Rf_protect(text = Rf_mkString(source));
742
4
    Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue));
743
4
    if (status != PARSE_OK || XLENGTH(parsed) != 1)
744
0
        abort();
745
746
4
    wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_GlobalEnv);
747
4
    Rf_unprotect(2);
748
4
    return wrapper;
749
4
}
scan.c:fuzz_make_wrapper
Line
Count
Source
738
36
{
739
36
    ParseStatus status;
740
36
    SEXP text, parsed, wrapper;
741
36
    Rf_protect(text = Rf_mkString(source));
742
36
    Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue));
743
36
    if (status != PARSE_OK || XLENGTH(parsed) != 1)
744
0
        abort();
745
746
36
    wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_GlobalEnv);
747
36
    Rf_unprotect(2);
748
36
    return wrapper;
749
36
}
colors.c:fuzz_make_wrapper
Line
Count
Source
738
32
{
739
32
    ParseStatus status;
740
32
    SEXP text, parsed, wrapper;
741
32
    Rf_protect(text = Rf_mkString(source));
742
32
    Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue));
743
32
    if (status != PARSE_OK || XLENGTH(parsed) != 1)
744
0
        abort();
745
746
32
    wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_GlobalEnv);
747
32
    Rf_unprotect(2);
748
32
    return wrapper;
749
32
}
grep.c:fuzz_make_wrapper
Line
Count
Source
738
32
{
739
32
    ParseStatus status;
740
32
    SEXP text, parsed, wrapper;
741
32
    Rf_protect(text = Rf_mkString(source));
742
32
    Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue));
743
32
    if (status != PARSE_OK || XLENGTH(parsed) != 1)
744
0
        abort();
745
746
32
    wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_GlobalEnv);
747
32
    Rf_unprotect(2);
748
32
    return wrapper;
749
32
}
parse.c:fuzz_make_wrapper
Line
Count
Source
738
12
{
739
12
    ParseStatus status;
740
12
    SEXP text, parsed, wrapper;
741
12
    Rf_protect(text = Rf_mkString(source));
742
12
    Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue));
743
12
    if (status != PARSE_OK || XLENGTH(parsed) != 1)
744
0
        abort();
745
746
12
    wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_GlobalEnv);
747
12
    Rf_unprotect(2);
748
12
    return wrapper;
749
12
}
sockets.c:fuzz_make_wrapper
Line
Count
Source
738
4
{
739
4
    ParseStatus status;
740
4
    SEXP text, parsed, wrapper;
741
4
    Rf_protect(text = Rf_mkString(source));
742
4
    Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue));
743
4
    if (status != PARSE_OK || XLENGTH(parsed) != 1)
744
0
        abort();
745
746
4
    wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_GlobalEnv);
747
4
    Rf_unprotect(2);
748
4
    return wrapper;
749
4
}
Unexecuted instantiation: rd.c:fuzz_make_wrapper
Unexecuted instantiation: sprintf.c:fuzz_make_wrapper
Unexecuted instantiation: eval.c:fuzz_make_wrapper
zip.c:fuzz_make_wrapper
Line
Count
Source
738
8
{
739
8
    ParseStatus status;
740
8
    SEXP text, parsed, wrapper;
741
8
    Rf_protect(text = Rf_mkString(source));
742
8
    Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue));
743
8
    if (status != PARSE_OK || XLENGTH(parsed) != 1)
744
0
        abort();
745
746
8
    wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_GlobalEnv);
747
8
    Rf_unprotect(2);
748
8
    return wrapper;
749
8
}
nmath.c:fuzz_make_wrapper
Line
Count
Source
738
2
{
739
2
    ParseStatus status;
740
2
    SEXP text, parsed, wrapper;
741
2
    Rf_protect(text = Rf_mkString(source));
742
2
    Rf_protect(parsed = R_ParseVector(text, -1, &status, R_NilValue));
743
2
    if (status != PARSE_OK || XLENGTH(parsed) != 1)
744
0
        abort();
745
746
2
    wrapper = Rf_eval(VECTOR_ELT(parsed, 0), R_GlobalEnv);
747
2
    Rf_unprotect(2);
748
2
    return wrapper;
749
2
}
750
751
/*
752
 * fuzz_set_string with an explicit encoding mark.
753
 *
754
 * R does not validate the mark (Encoding<- lets users set it on any
755
 * bytes), so handing the same payload over as UTF-8 or latin1 reaches
756
 * the multibyte branches and their handling of invalid sequences
757
 * without touching the process locale.
758
 */
759
typedef struct {
760
    SEXP vec;
761
    const char *str;
762
    cetype_t ce;
763
} fuzz_ce_string_data_t;
764
765
static void fuzz_do_set_string_ce(void *data)
766
2.56k
{
767
2.56k
    fuzz_ce_string_data_t *sd = (fuzz_ce_string_data_t *)data;
768
2.56k
    SET_STRING_ELT(sd->vec, 0, Rf_mkCharCE(sd->str, sd->ce));
769
2.56k
}
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
766
2.36k
{
767
2.36k
    fuzz_ce_string_data_t *sd = (fuzz_ce_string_data_t *)data;
768
2.36k
    SET_STRING_ELT(sd->vec, 0, Rf_mkCharCE(sd->str, sd->ce));
769
2.36k
}
encoding.c:fuzz_do_set_string_ce
Line
Count
Source
766
194
{
767
194
    fuzz_ce_string_data_t *sd = (fuzz_ce_string_data_t *)data;
768
194
    SET_STRING_ELT(sd->vec, 0, Rf_mkCharCE(sd->str, sd->ce));
769
194
}
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: formula.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: grep.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: rd.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
Unexecuted instantiation: nmath.c:fuzz_do_set_string_ce
770
771
static Rboolean fuzz_set_string_ce(SEXP vec, const char *str, cetype_t ce)
772
2.56k
{
773
2.56k
    fuzz_ce_string_data_t sd = { vec, str, ce };
774
2.56k
    return R_ToplevelExec(fuzz_do_set_string_ce, &sd);
775
2.56k
}
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
772
2.36k
{
773
2.36k
    fuzz_ce_string_data_t sd = { vec, str, ce };
774
2.36k
    return R_ToplevelExec(fuzz_do_set_string_ce, &sd);
775
2.36k
}
encoding.c:fuzz_set_string_ce
Line
Count
Source
772
194
{
773
194
    fuzz_ce_string_data_t sd = { vec, str, ce };
774
194
    return R_ToplevelExec(fuzz_do_set_string_ce, &sd);
775
194
}
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: formula.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: grep.c:fuzz_set_string_ce
Unexecuted instantiation: parse.c:fuzz_set_string_ce
Unexecuted instantiation: sockets.c:fuzz_set_string_ce
Unexecuted instantiation: rd.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
Unexecuted instantiation: nmath.c:fuzz_set_string_ce
776
777
typedef struct {
778
    SEXP call;
779
    const uint8_t *data;
780
    size_t size;
781
} fuzz_raw_data_t;
782
783
static void fuzz_do_set_raw(void *data)
784
36.9k
{
785
36.9k
    fuzz_raw_data_t *rd = (fuzz_raw_data_t *)data;
786
787
    /* The raw vector is reachable from the (protected) call as soon as
788
     * SETCADR runs, and nothing allocates before the memcpy completes,
789
     * so no extra protection is needed. */
790
36.9k
    SEXP raw = Rf_allocVector(RAWSXP, (R_xlen_t)rd->size);
791
36.9k
    SETCADR(rd->call, raw);
792
36.9k
    memcpy(RAW(raw), rd->data, rd->size);
793
36.9k
}
io.c:fuzz_do_set_raw
Line
Count
Source
784
1.07k
{
785
1.07k
    fuzz_raw_data_t *rd = (fuzz_raw_data_t *)data;
786
787
    /* The raw vector is reachable from the (protected) call as soon as
788
     * SETCADR runs, and nothing allocates before the memcpy completes,
789
     * so no extra protection is needed. */
790
1.07k
    SEXP raw = Rf_allocVector(RAWSXP, (R_xlen_t)rd->size);
791
1.07k
    SETCADR(rd->call, raw);
792
1.07k
    memcpy(RAW(raw), rd->data, rd->size);
793
1.07k
}
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
784
8.32k
{
785
8.32k
    fuzz_raw_data_t *rd = (fuzz_raw_data_t *)data;
786
787
    /* The raw vector is reachable from the (protected) call as soon as
788
     * SETCADR runs, and nothing allocates before the memcpy completes,
789
     * so no extra protection is needed. */
790
8.32k
    SEXP raw = Rf_allocVector(RAWSXP, (R_xlen_t)rd->size);
791
8.32k
    SETCADR(rd->call, raw);
792
8.32k
    memcpy(RAW(raw), rd->data, rd->size);
793
8.32k
}
unserialize.c:fuzz_do_set_raw
Line
Count
Source
784
5.69k
{
785
5.69k
    fuzz_raw_data_t *rd = (fuzz_raw_data_t *)data;
786
787
    /* The raw vector is reachable from the (protected) call as soon as
788
     * SETCADR runs, and nothing allocates before the memcpy completes,
789
     * so no extra protection is needed. */
790
5.69k
    SEXP raw = Rf_allocVector(RAWSXP, (R_xlen_t)rd->size);
791
5.69k
    SETCADR(rd->call, raw);
792
5.69k
    memcpy(RAW(raw), rd->data, rd->size);
793
5.69k
}
Unexecuted instantiation: formula.c:fuzz_do_set_raw
decompress.c:fuzz_do_set_raw
Line
Count
Source
784
7.60k
{
785
7.60k
    fuzz_raw_data_t *rd = (fuzz_raw_data_t *)data;
786
787
    /* The raw vector is reachable from the (protected) call as soon as
788
     * SETCADR runs, and nothing allocates before the memcpy completes,
789
     * so no extra protection is needed. */
790
7.60k
    SEXP raw = Rf_allocVector(RAWSXP, (R_xlen_t)rd->size);
791
7.60k
    SETCADR(rd->call, raw);
792
7.60k
    memcpy(RAW(raw), rd->data, rd->size);
793
7.60k
}
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: grep.c:fuzz_do_set_raw
Unexecuted instantiation: parse.c:fuzz_do_set_raw
sockets.c:fuzz_do_set_raw
Line
Count
Source
784
1.98k
{
785
1.98k
    fuzz_raw_data_t *rd = (fuzz_raw_data_t *)data;
786
787
    /* The raw vector is reachable from the (protected) call as soon as
788
     * SETCADR runs, and nothing allocates before the memcpy completes,
789
     * so no extra protection is needed. */
790
1.98k
    SEXP raw = Rf_allocVector(RAWSXP, (R_xlen_t)rd->size);
791
1.98k
    SETCADR(rd->call, raw);
792
1.98k
    memcpy(RAW(raw), rd->data, rd->size);
793
1.98k
}
Unexecuted instantiation: rd.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
nmath.c:fuzz_do_set_raw
Line
Count
Source
784
12.2k
{
785
12.2k
    fuzz_raw_data_t *rd = (fuzz_raw_data_t *)data;
786
787
    /* The raw vector is reachable from the (protected) call as soon as
788
     * SETCADR runs, and nothing allocates before the memcpy completes,
789
     * so no extra protection is needed. */
790
12.2k
    SEXP raw = Rf_allocVector(RAWSXP, (R_xlen_t)rd->size);
791
12.2k
    SETCADR(rd->call, raw);
792
12.2k
    memcpy(RAW(raw), rd->data, rd->size);
793
12.2k
}
794
795
static Rboolean fuzz_set_raw_arg(SEXP call, const uint8_t *data, size_t size)
796
36.9k
{
797
36.9k
    fuzz_raw_data_t rd = { call, data, size };
798
36.9k
    return R_ToplevelExec(fuzz_do_set_raw, &rd);
799
36.9k
}
io.c:fuzz_set_raw_arg
Line
Count
Source
796
1.07k
{
797
1.07k
    fuzz_raw_data_t rd = { call, data, size };
798
1.07k
    return R_ToplevelExec(fuzz_do_set_raw, &rd);
799
1.07k
}
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
796
8.32k
{
797
8.32k
    fuzz_raw_data_t rd = { call, data, size };
798
8.32k
    return R_ToplevelExec(fuzz_do_set_raw, &rd);
799
8.32k
}
unserialize.c:fuzz_set_raw_arg
Line
Count
Source
796
5.69k
{
797
5.69k
    fuzz_raw_data_t rd = { call, data, size };
798
5.69k
    return R_ToplevelExec(fuzz_do_set_raw, &rd);
799
5.69k
}
Unexecuted instantiation: formula.c:fuzz_set_raw_arg
decompress.c:fuzz_set_raw_arg
Line
Count
Source
796
7.60k
{
797
7.60k
    fuzz_raw_data_t rd = { call, data, size };
798
7.60k
    return R_ToplevelExec(fuzz_do_set_raw, &rd);
799
7.60k
}
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: grep.c:fuzz_set_raw_arg
Unexecuted instantiation: parse.c:fuzz_set_raw_arg
sockets.c:fuzz_set_raw_arg
Line
Count
Source
796
1.98k
{
797
1.98k
    fuzz_raw_data_t rd = { call, data, size };
798
1.98k
    return R_ToplevelExec(fuzz_do_set_raw, &rd);
799
1.98k
}
Unexecuted instantiation: rd.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
nmath.c:fuzz_set_raw_arg
Line
Count
Source
796
12.2k
{
797
12.2k
    fuzz_raw_data_t rd = { call, data, size };
798
12.2k
    return R_ToplevelExec(fuzz_do_set_raw, &rd);
799
12.2k
}
800
801
/*
802
 * Stage the input in a scratch file.
803
 *
804
 * Some R entry points only take a path (load() of a pre-1.4 save file,
805
 * unzip(), file(encoding=)), so those targets rewrite one per-process
806
 * file each iteration instead of handing R a raw vector.  The file lives
807
 * in the system temp directory, which OSS-Fuzz runners allow writes to,
808
 * and is created once in fuzz_target_init so fuzzing never pays a
809
 * mkstemp per input.  Returns a malloc'd path, or NULL on failure.
810
 */
811
static char *fuzz_scratch_file(const char *name)
812
6
{
813
6
    const char *tmpdir = getenv("TMPDIR");
814
6
    if (tmpdir == NULL || *tmpdir == '\0')
815
6
        tmpdir = "/tmp";
816
817
6
    char *path = malloc(PATH_MAX);
818
6
    if (path == NULL)
819
0
        return NULL;
820
6
    snprintf(path, PATH_MAX, "%s/fuzz-%s-XXXXXX", tmpdir, name);
821
822
6
    int fd = mkstemp(path);
823
6
    if (fd < 0) {
824
0
        free(path);
825
0
        return NULL;
826
0
    }
827
6
    close(fd);
828
6
    return path;
829
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
812
2
{
813
2
    const char *tmpdir = getenv("TMPDIR");
814
2
    if (tmpdir == NULL || *tmpdir == '\0')
815
2
        tmpdir = "/tmp";
816
817
2
    char *path = malloc(PATH_MAX);
818
2
    if (path == NULL)
819
0
        return NULL;
820
2
    snprintf(path, PATH_MAX, "%s/fuzz-%s-XXXXXX", tmpdir, name);
821
822
2
    int fd = mkstemp(path);
823
2
    if (fd < 0) {
824
0
        free(path);
825
0
        return NULL;
826
0
    }
827
2
    close(fd);
828
2
    return path;
829
2
}
Unexecuted instantiation: unserialize.c:fuzz_scratch_file
Unexecuted instantiation: formula.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
load.c:fuzz_scratch_file
Line
Count
Source
812
2
{
813
2
    const char *tmpdir = getenv("TMPDIR");
814
2
    if (tmpdir == NULL || *tmpdir == '\0')
815
2
        tmpdir = "/tmp";
816
817
2
    char *path = malloc(PATH_MAX);
818
2
    if (path == NULL)
819
0
        return NULL;
820
2
    snprintf(path, PATH_MAX, "%s/fuzz-%s-XXXXXX", tmpdir, name);
821
822
2
    int fd = mkstemp(path);
823
2
    if (fd < 0) {
824
0
        free(path);
825
0
        return NULL;
826
0
    }
827
2
    close(fd);
828
2
    return path;
829
2
}
Unexecuted instantiation: scan.c:fuzz_scratch_file
Unexecuted instantiation: colors.c:fuzz_scratch_file
Unexecuted instantiation: grep.c:fuzz_scratch_file
Unexecuted instantiation: parse.c:fuzz_scratch_file
Unexecuted instantiation: sockets.c:fuzz_scratch_file
Unexecuted instantiation: rd.c:fuzz_scratch_file
Unexecuted instantiation: sprintf.c:fuzz_scratch_file
Unexecuted instantiation: eval.c:fuzz_scratch_file
zip.c:fuzz_scratch_file
Line
Count
Source
812
2
{
813
2
    const char *tmpdir = getenv("TMPDIR");
814
2
    if (tmpdir == NULL || *tmpdir == '\0')
815
2
        tmpdir = "/tmp";
816
817
2
    char *path = malloc(PATH_MAX);
818
2
    if (path == NULL)
819
0
        return NULL;
820
2
    snprintf(path, PATH_MAX, "%s/fuzz-%s-XXXXXX", tmpdir, name);
821
822
2
    int fd = mkstemp(path);
823
2
    if (fd < 0) {
824
0
        free(path);
825
0
        return NULL;
826
0
    }
827
2
    close(fd);
828
2
    return path;
829
2
}
Unexecuted instantiation: nmath.c:fuzz_scratch_file
830
831
/* Replace the scratch file's contents.  Returns FALSE on any I/O error so
832
 * the iteration can be skipped rather than fuzzing a stale file. */
833
static Rboolean fuzz_write_scratch(const char *path, const uint8_t *data,
834
                                   size_t size)
835
21.5k
{
836
21.5k
    FILE *fp = fopen(path, "wb");
837
21.5k
    if (fp == NULL)
838
0
        return FALSE;
839
840
21.5k
    size_t written = size > 0 ? fwrite(data, 1, size, fp) : 0;
841
21.5k
    int rc = fclose(fp);
842
21.5k
    return written == size && rc == 0;
843
21.5k
}
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
835
8.33k
{
836
8.33k
    FILE *fp = fopen(path, "wb");
837
8.33k
    if (fp == NULL)
838
0
        return FALSE;
839
840
8.33k
    size_t written = size > 0 ? fwrite(data, 1, size, fp) : 0;
841
8.33k
    int rc = fclose(fp);
842
8.33k
    return written == size && rc == 0;
843
8.33k
}
Unexecuted instantiation: unserialize.c:fuzz_write_scratch
Unexecuted instantiation: formula.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
835
11.1k
{
836
11.1k
    FILE *fp = fopen(path, "wb");
837
11.1k
    if (fp == NULL)
838
0
        return FALSE;
839
840
11.1k
    size_t written = size > 0 ? fwrite(data, 1, size, fp) : 0;
841
11.1k
    int rc = fclose(fp);
842
11.1k
    return written == size && rc == 0;
843
11.1k
}
Unexecuted instantiation: scan.c:fuzz_write_scratch
Unexecuted instantiation: colors.c:fuzz_write_scratch
Unexecuted instantiation: grep.c:fuzz_write_scratch
Unexecuted instantiation: parse.c:fuzz_write_scratch
Unexecuted instantiation: sockets.c:fuzz_write_scratch
Unexecuted instantiation: rd.c:fuzz_write_scratch
Unexecuted instantiation: sprintf.c:fuzz_write_scratch
Unexecuted instantiation: eval.c:fuzz_write_scratch
zip.c:fuzz_write_scratch
Line
Count
Source
835
2.09k
{
836
2.09k
    FILE *fp = fopen(path, "wb");
837
2.09k
    if (fp == NULL)
838
0
        return FALSE;
839
840
2.09k
    size_t written = size > 0 ? fwrite(data, 1, size, fp) : 0;
841
2.09k
    int rc = fclose(fp);
842
2.09k
    return written == size && rc == 0;
843
2.09k
}
Unexecuted instantiation: nmath.c:fuzz_write_scratch
844
845
/*
846
 * Guard against TRE's bounded-repeat blowup.
847
 *
848
 * TRE compiles bounded repeats by duplicating the pattern AST, so nested
849
 * counted repeats multiply: a 36-byte pattern like
850
 * (?:a{2,101,})(?:a{2,101,}){100}{100} expands to ~10^8 nodes and >8GB of
851
 * allocations at compile time.  Those allocations are malloc, not R's
852
 * vector heap, so R_MAX_VSIZE cannot bound them; reject the pattern
853
 * before it reaches R instead.
854
 *
855
 * The product of all repeat bounds is a deliberate over-estimate --
856
 * sequential (non-nested) repeats add rather than multiply -- trading a
857
 * little coverage of repeat-heavy patterns for a hard bound on compile
858
 * cost.
859
 */
860
3.02k
#define FUZZ_MAX_REPEAT_PRODUCT 1000000.0
861
862
static int fuzz_repeat_product_excessive(const char *pattern)
863
2.49k
{
864
2.49k
    double product = 1.0;
865
866
3.68M
    for (const char *p = pattern; *p != '\0'; p++) {
867
3.68M
        if (*p != '{')
868
3.67M
            continue;
869
870
        /* The largest number inside the braces bounds this repeat. */
871
9.64k
        unsigned long bound = 0, cur = 0;
872
9.64k
        int counted = 0;
873
9.64k
        const char *q = p + 1;
874
22.7k
        for (; *q != '\0' && *q != '}'; q++) {
875
19.1k
            if (*q >= '0' && *q <= '9') {
876
9.33k
                cur = cur * 10 + (unsigned long)(*q - '0');
877
9.33k
                if (cur > 10000000)
878
591
                    cur = 10000000;  /* saturate; already over any budget */
879
9.33k
                counted = 1;
880
9.82k
            } else if (*q == ',') {
881
3.73k
                if (cur > bound)
882
1.19k
                    bound = cur;
883
3.73k
                cur = 0;
884
6.09k
            } else {
885
6.09k
                counted = 0;  /* not a counted repeat, e.g. "{a}" */
886
6.09k
                break;
887
6.09k
            }
888
19.1k
        }
889
9.64k
        if (!counted || *q != '}')
890
6.62k
            continue;
891
892
3.02k
        if (cur > bound)
893
1.41k
            bound = cur;
894
3.02k
        if (bound > 1)
895
290
            product *= (double)bound;
896
3.02k
        if (product > FUZZ_MAX_REPEAT_PRODUCT)
897
15
            return 1;
898
899
3.00k
        p = q;
900
3.00k
    }
901
902
2.48k
    return 0;
903
2.49k
}
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
863
331
{
864
331
    double product = 1.0;
865
866
209k
    for (const char *p = pattern; *p != '\0'; p++) {
867
209k
        if (*p != '{')
868
207k
            continue;
869
870
        /* The largest number inside the braces bounds this repeat. */
871
1.62k
        unsigned long bound = 0, cur = 0;
872
1.62k
        int counted = 0;
873
1.62k
        const char *q = p + 1;
874
5.23k
        for (; *q != '\0' && *q != '}'; q++) {
875
4.41k
            if (*q >= '0' && *q <= '9') {
876
3.03k
                cur = cur * 10 + (unsigned long)(*q - '0');
877
3.03k
                if (cur > 10000000)
878
291
                    cur = 10000000;  /* saturate; already over any budget */
879
3.03k
                counted = 1;
880
3.03k
            } else if (*q == ',') {
881
576
                if (cur > bound)
882
249
                    bound = cur;
883
576
                cur = 0;
884
806
            } else {
885
806
                counted = 0;  /* not a counted repeat, e.g. "{a}" */
886
806
                break;
887
806
            }
888
4.41k
        }
889
1.62k
        if (!counted || *q != '}')
890
987
            continue;
891
892
636
        if (cur > bound)
893
337
            bound = cur;
894
636
        if (bound > 1)
895
106
            product *= (double)bound;
896
636
        if (product > FUZZ_MAX_REPEAT_PRODUCT)
897
6
            return 1;
898
899
630
        p = q;
900
630
    }
901
902
325
    return 0;
903
331
}
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: formula.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
grep.c:fuzz_repeat_product_excessive
Line
Count
Source
863
2.16k
{
864
2.16k
    double product = 1.0;
865
866
3.47M
    for (const char *p = pattern; *p != '\0'; p++) {
867
3.47M
        if (*p != '{')
868
3.46M
            continue;
869
870
        /* The largest number inside the braces bounds this repeat. */
871
8.01k
        unsigned long bound = 0, cur = 0;
872
8.01k
        int counted = 0;
873
8.01k
        const char *q = p + 1;
874
17.4k
        for (; *q != '\0' && *q != '}'; q++) {
875
14.7k
            if (*q >= '0' && *q <= '9') {
876
6.30k
                cur = cur * 10 + (unsigned long)(*q - '0');
877
6.30k
                if (cur > 10000000)
878
300
                    cur = 10000000;  /* saturate; already over any budget */
879
6.30k
                counted = 1;
880
8.44k
            } else if (*q == ',') {
881
3.15k
                if (cur > bound)
882
942
                    bound = cur;
883
3.15k
                cur = 0;
884
5.28k
            } else {
885
5.28k
                counted = 0;  /* not a counted repeat, e.g. "{a}" */
886
5.28k
                break;
887
5.28k
            }
888
14.7k
        }
889
8.01k
        if (!counted || *q != '}')
890
5.63k
            continue;
891
892
2.38k
        if (cur > bound)
893
1.08k
            bound = cur;
894
2.38k
        if (bound > 1)
895
184
            product *= (double)bound;
896
2.38k
        if (product > FUZZ_MAX_REPEAT_PRODUCT)
897
9
            return 1;
898
899
2.37k
        p = q;
900
2.37k
    }
901
902
2.15k
    return 0;
903
2.16k
}
Unexecuted instantiation: parse.c:fuzz_repeat_product_excessive
Unexecuted instantiation: sockets.c:fuzz_repeat_product_excessive
Unexecuted instantiation: rd.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
Unexecuted instantiation: nmath.c:fuzz_repeat_product_excessive
904
905
/*
906
 * libFuzzer entry points.
907
 *
908
 * A harness defines fuzz_target_init and fuzz_target_run with the
909
 * LLVMFuzzerInitialize / LLVMFuzzerTestOneInput signatures; these run
910
 * them on the R thread, one condition-variable handoff each way per input.
911
 */
912
int fuzz_target_init(int *argc, char ***argv);
913
int fuzz_target_run(const uint8_t *data, size_t size);
914
915
typedef struct {
916
    int *argc;
917
    char ***argv;
918
    int result;
919
} fuzz_init_job_t;
920
921
static void fuzz_do_target_init(void *data)
922
48
{
923
48
    fuzz_init_job_t *job = data;
924
48
    job->result = fuzz_target_init(job->argc, job->argv);
925
48
}
io.c:fuzz_do_target_init
Line
Count
Source
922
2
{
923
2
    fuzz_init_job_t *job = data;
924
2
    job->result = fuzz_target_init(job->argc, job->argv);
925
2
}
dcf.c:fuzz_do_target_init
Line
Count
Source
922
2
{
923
2
    fuzz_init_job_t *job = data;
924
2
    job->result = fuzz_target_init(job->argc, job->argv);
925
2
}
character.c:fuzz_do_target_init
Line
Count
Source
922
2
{
923
2
    fuzz_init_job_t *job = data;
924
2
    job->result = fuzz_target_init(job->argc, job->argv);
925
2
}
encoding.c:fuzz_do_target_init
Line
Count
Source
922
2
{
923
2
    fuzz_init_job_t *job = data;
924
2
    job->result = fuzz_target_init(job->argc, job->argv);
925
2
}
sort.c:fuzz_do_target_init
Line
Count
Source
922
2
{
923
2
    fuzz_init_job_t *job = data;
924
2
    job->result = fuzz_target_init(job->argc, job->argv);
925
2
}
connections.c:fuzz_do_target_init
Line
Count
Source
922
2
{
923
2
    fuzz_init_job_t *job = data;
924
2
    job->result = fuzz_target_init(job->argc, job->argv);
925
2
}
unserialize.c:fuzz_do_target_init
Line
Count
Source
922
2
{
923
2
    fuzz_init_job_t *job = data;
924
2
    job->result = fuzz_target_init(job->argc, job->argv);
925
2
}
formula.c:fuzz_do_target_init
Line
Count
Source
922
2
{
923
2
    fuzz_init_job_t *job = data;
924
2
    job->result = fuzz_target_init(job->argc, job->argv);
925
2
}
decompress.c:fuzz_do_target_init
Line
Count
Source
922
2
{
923
2
    fuzz_init_job_t *job = data;
924
2
    job->result = fuzz_target_init(job->argc, job->argv);
925
2
}
readtable.c:fuzz_do_target_init
Line
Count
Source
922
2
{
923
2
    fuzz_init_job_t *job = data;
924
2
    job->result = fuzz_target_init(job->argc, job->argv);
925
2
}
format.c:fuzz_do_target_init
Line
Count
Source
922
2
{
923
2
    fuzz_init_job_t *job = data;
924
2
    job->result = fuzz_target_init(job->argc, job->argv);
925
2
}
datetime.c:fuzz_do_target_init
Line
Count
Source
922
2
{
923
2
    fuzz_init_job_t *job = data;
924
2
    job->result = fuzz_target_init(job->argc, job->argv);
925
2
}
coerce.c:fuzz_do_target_init
Line
Count
Source
922
2
{
923
2
    fuzz_init_job_t *job = data;
924
2
    job->result = fuzz_target_init(job->argc, job->argv);
925
2
}
load.c:fuzz_do_target_init
Line
Count
Source
922
2
{
923
2
    fuzz_init_job_t *job = data;
924
2
    job->result = fuzz_target_init(job->argc, job->argv);
925
2
}
scan.c:fuzz_do_target_init
Line
Count
Source
922
2
{
923
2
    fuzz_init_job_t *job = data;
924
2
    job->result = fuzz_target_init(job->argc, job->argv);
925
2
}
colors.c:fuzz_do_target_init
Line
Count
Source
922
2
{
923
2
    fuzz_init_job_t *job = data;
924
2
    job->result = fuzz_target_init(job->argc, job->argv);
925
2
}
grep.c:fuzz_do_target_init
Line
Count
Source
922
2
{
923
2
    fuzz_init_job_t *job = data;
924
2
    job->result = fuzz_target_init(job->argc, job->argv);
925
2
}
parse.c:fuzz_do_target_init
Line
Count
Source
922
2
{
923
2
    fuzz_init_job_t *job = data;
924
2
    job->result = fuzz_target_init(job->argc, job->argv);
925
2
}
sockets.c:fuzz_do_target_init
Line
Count
Source
922
2
{
923
2
    fuzz_init_job_t *job = data;
924
2
    job->result = fuzz_target_init(job->argc, job->argv);
925
2
}
rd.c:fuzz_do_target_init
Line
Count
Source
922
2
{
923
2
    fuzz_init_job_t *job = data;
924
2
    job->result = fuzz_target_init(job->argc, job->argv);
925
2
}
sprintf.c:fuzz_do_target_init
Line
Count
Source
922
2
{
923
2
    fuzz_init_job_t *job = data;
924
2
    job->result = fuzz_target_init(job->argc, job->argv);
925
2
}
eval.c:fuzz_do_target_init
Line
Count
Source
922
2
{
923
2
    fuzz_init_job_t *job = data;
924
2
    job->result = fuzz_target_init(job->argc, job->argv);
925
2
}
zip.c:fuzz_do_target_init
Line
Count
Source
922
2
{
923
2
    fuzz_init_job_t *job = data;
924
2
    job->result = fuzz_target_init(job->argc, job->argv);
925
2
}
nmath.c:fuzz_do_target_init
Line
Count
Source
922
2
{
923
2
    fuzz_init_job_t *job = data;
924
2
    job->result = fuzz_target_init(job->argc, job->argv);
925
2
}
926
927
typedef struct {
928
    const uint8_t *data;
929
    size_t size;
930
    int result;
931
} fuzz_run_job_t;
932
933
static void fuzz_do_target_run(void *data)
934
143k
{
935
143k
    fuzz_run_job_t *job = data;
936
143k
    atomic_store(&fuzz_label_current, -1);
937
143k
    job->result = fuzz_target_run(job->data, job->size);
938
143k
    atomic_store(&fuzz_label_current, -1);
939
143k
}
io.c:fuzz_do_target_run
Line
Count
Source
934
1.40k
{
935
1.40k
    fuzz_run_job_t *job = data;
936
1.40k
    atomic_store(&fuzz_label_current, -1);
937
1.40k
    job->result = fuzz_target_run(job->data, job->size);
938
    atomic_store(&fuzz_label_current, -1);
939
1.40k
}
dcf.c:fuzz_do_target_run
Line
Count
Source
934
4.73k
{
935
4.73k
    fuzz_run_job_t *job = data;
936
4.73k
    atomic_store(&fuzz_label_current, -1);
937
4.73k
    job->result = fuzz_target_run(job->data, job->size);
938
    atomic_store(&fuzz_label_current, -1);
939
4.73k
}
character.c:fuzz_do_target_run
Line
Count
Source
934
4.09k
{
935
4.09k
    fuzz_run_job_t *job = data;
936
4.09k
    atomic_store(&fuzz_label_current, -1);
937
4.09k
    job->result = fuzz_target_run(job->data, job->size);
938
    atomic_store(&fuzz_label_current, -1);
939
4.09k
}
encoding.c:fuzz_do_target_run
Line
Count
Source
934
1.77k
{
935
1.77k
    fuzz_run_job_t *job = data;
936
1.77k
    atomic_store(&fuzz_label_current, -1);
937
1.77k
    job->result = fuzz_target_run(job->data, job->size);
938
    atomic_store(&fuzz_label_current, -1);
939
1.77k
}
sort.c:fuzz_do_target_run
Line
Count
Source
934
6.80k
{
935
6.80k
    fuzz_run_job_t *job = data;
936
6.80k
    atomic_store(&fuzz_label_current, -1);
937
6.80k
    job->result = fuzz_target_run(job->data, job->size);
938
    atomic_store(&fuzz_label_current, -1);
939
6.80k
}
connections.c:fuzz_do_target_run
Line
Count
Source
934
8.33k
{
935
8.33k
    fuzz_run_job_t *job = data;
936
8.33k
    atomic_store(&fuzz_label_current, -1);
937
8.33k
    job->result = fuzz_target_run(job->data, job->size);
938
    atomic_store(&fuzz_label_current, -1);
939
8.33k
}
unserialize.c:fuzz_do_target_run
Line
Count
Source
934
5.70k
{
935
5.70k
    fuzz_run_job_t *job = data;
936
5.70k
    atomic_store(&fuzz_label_current, -1);
937
5.70k
    job->result = fuzz_target_run(job->data, job->size);
938
    atomic_store(&fuzz_label_current, -1);
939
5.70k
}
formula.c:fuzz_do_target_run
Line
Count
Source
934
12.3k
{
935
12.3k
    fuzz_run_job_t *job = data;
936
12.3k
    atomic_store(&fuzz_label_current, -1);
937
12.3k
    job->result = fuzz_target_run(job->data, job->size);
938
    atomic_store(&fuzz_label_current, -1);
939
12.3k
}
decompress.c:fuzz_do_target_run
Line
Count
Source
934
7.60k
{
935
7.60k
    fuzz_run_job_t *job = data;
936
7.60k
    atomic_store(&fuzz_label_current, -1);
937
7.60k
    job->result = fuzz_target_run(job->data, job->size);
938
    atomic_store(&fuzz_label_current, -1);
939
7.60k
}
readtable.c:fuzz_do_target_run
Line
Count
Source
934
5.09k
{
935
5.09k
    fuzz_run_job_t *job = data;
936
5.09k
    atomic_store(&fuzz_label_current, -1);
937
5.09k
    job->result = fuzz_target_run(job->data, job->size);
938
    atomic_store(&fuzz_label_current, -1);
939
5.09k
}
format.c:fuzz_do_target_run
Line
Count
Source
934
5.50k
{
935
5.50k
    fuzz_run_job_t *job = data;
936
5.50k
    atomic_store(&fuzz_label_current, -1);
937
5.50k
    job->result = fuzz_target_run(job->data, job->size);
938
    atomic_store(&fuzz_label_current, -1);
939
5.50k
}
datetime.c:fuzz_do_target_run
Line
Count
Source
934
6.31k
{
935
6.31k
    fuzz_run_job_t *job = data;
936
6.31k
    atomic_store(&fuzz_label_current, -1);
937
6.31k
    job->result = fuzz_target_run(job->data, job->size);
938
    atomic_store(&fuzz_label_current, -1);
939
6.31k
}
coerce.c:fuzz_do_target_run
Line
Count
Source
934
1.78k
{
935
1.78k
    fuzz_run_job_t *job = data;
936
1.78k
    atomic_store(&fuzz_label_current, -1);
937
1.78k
    job->result = fuzz_target_run(job->data, job->size);
938
    atomic_store(&fuzz_label_current, -1);
939
1.78k
}
load.c:fuzz_do_target_run
Line
Count
Source
934
11.1k
{
935
11.1k
    fuzz_run_job_t *job = data;
936
11.1k
    atomic_store(&fuzz_label_current, -1);
937
11.1k
    job->result = fuzz_target_run(job->data, job->size);
938
    atomic_store(&fuzz_label_current, -1);
939
11.1k
}
scan.c:fuzz_do_target_run
Line
Count
Source
934
2.87k
{
935
2.87k
    fuzz_run_job_t *job = data;
936
2.87k
    atomic_store(&fuzz_label_current, -1);
937
2.87k
    job->result = fuzz_target_run(job->data, job->size);
938
    atomic_store(&fuzz_label_current, -1);
939
2.87k
}
colors.c:fuzz_do_target_run
Line
Count
Source
934
3.90k
{
935
3.90k
    fuzz_run_job_t *job = data;
936
3.90k
    atomic_store(&fuzz_label_current, -1);
937
3.90k
    job->result = fuzz_target_run(job->data, job->size);
938
    atomic_store(&fuzz_label_current, -1);
939
3.90k
}
grep.c:fuzz_do_target_run
Line
Count
Source
934
2.17k
{
935
2.17k
    fuzz_run_job_t *job = data;
936
2.17k
    atomic_store(&fuzz_label_current, -1);
937
2.17k
    job->result = fuzz_target_run(job->data, job->size);
938
    atomic_store(&fuzz_label_current, -1);
939
2.17k
}
parse.c:fuzz_do_target_run
Line
Count
Source
934
9.28k
{
935
9.28k
    fuzz_run_job_t *job = data;
936
9.28k
    atomic_store(&fuzz_label_current, -1);
937
9.28k
    job->result = fuzz_target_run(job->data, job->size);
938
    atomic_store(&fuzz_label_current, -1);
939
9.28k
}
sockets.c:fuzz_do_target_run
Line
Count
Source
934
1.98k
{
935
1.98k
    fuzz_run_job_t *job = data;
936
1.98k
    atomic_store(&fuzz_label_current, -1);
937
1.98k
    job->result = fuzz_target_run(job->data, job->size);
938
    atomic_store(&fuzz_label_current, -1);
939
1.98k
}
rd.c:fuzz_do_target_run
Line
Count
Source
934
5.09k
{
935
5.09k
    fuzz_run_job_t *job = data;
936
5.09k
    atomic_store(&fuzz_label_current, -1);
937
5.09k
    job->result = fuzz_target_run(job->data, job->size);
938
    atomic_store(&fuzz_label_current, -1);
939
5.09k
}
sprintf.c:fuzz_do_target_run
Line
Count
Source
934
2.08k
{
935
2.08k
    fuzz_run_job_t *job = data;
936
2.08k
    atomic_store(&fuzz_label_current, -1);
937
2.08k
    job->result = fuzz_target_run(job->data, job->size);
938
    atomic_store(&fuzz_label_current, -1);
939
2.08k
}
eval.c:fuzz_do_target_run
Line
Count
Source
934
18.7k
{
935
18.7k
    fuzz_run_job_t *job = data;
936
18.7k
    atomic_store(&fuzz_label_current, -1);
937
18.7k
    job->result = fuzz_target_run(job->data, job->size);
938
    atomic_store(&fuzz_label_current, -1);
939
18.7k
}
zip.c:fuzz_do_target_run
Line
Count
Source
934
2.09k
{
935
2.09k
    fuzz_run_job_t *job = data;
936
2.09k
    atomic_store(&fuzz_label_current, -1);
937
2.09k
    job->result = fuzz_target_run(job->data, job->size);
938
    atomic_store(&fuzz_label_current, -1);
939
2.09k
}
nmath.c:fuzz_do_target_run
Line
Count
Source
934
12.2k
{
935
12.2k
    fuzz_run_job_t *job = data;
936
12.2k
    atomic_store(&fuzz_label_current, -1);
937
12.2k
    job->result = fuzz_target_run(job->data, job->size);
938
    atomic_store(&fuzz_label_current, -1);
939
12.2k
}
940
941
#ifdef FUZZ_ENGINE_LIBFUZZER
942
/*
943
 * Split the libFuzzer sessions on entropic exec-time scaling (README.md,
944
 * "Engine options").  Not `random(0, 1)` in the .options files: ClusterFuzz
945
 * expands it, but OSS-Fuzz's build check pastes option values into
946
 * `bash -c` unquoted, the parentheses are a syntax error, and every target
947
 * counts as broken.  libFuzzer parses its flags only after
948
 * LLVMFuzzerInitialize returns, so the flag is appended to argv here.  One
949
 * already on the command line wins; that also keeps a fork-mode parent's
950
 * choice in its children, which inherit its flags.
951
 */
952
408
#define FUZZ_EXEC_TIME_FLAG "-entropic_scale_per_exec_time="
953
954
/* Static so LeakSanitizer counts the array as reachable. */
955
static char **fuzz_split_argv;
956
957
static void fuzz_split_exec_time_scaling(int *argc, char ***argv)
958
48
{
959
216
    for (int i = 1; i < *argc; i++) {
960
192
        if (strncmp((*argv)[i], FUZZ_EXEC_TIME_FLAG,
961
192
                    strlen(FUZZ_EXEC_TIME_FLAG)) == 0)
962
24
            return;
963
192
    }
964
965
    /* Not rand(): unseeded, it gives every session the same answer. */
966
24
    unsigned char coin;
967
24
    FILE *urandom = fopen("/dev/urandom", "rb");
968
24
    if (urandom == NULL || fread(&coin, 1, 1, urandom) != 1)
969
0
        coin = (unsigned char)getpid();
970
24
    if (urandom != NULL)
971
24
        fclose(urandom);
972
973
24
    fuzz_split_argv = malloc((*argc + 2) * sizeof(char *));
974
24
    if (fuzz_split_argv == NULL)
975
0
        return;
976
24
    memcpy(fuzz_split_argv, *argv, *argc * sizeof(char *));
977
24
    fuzz_split_argv[*argc] = (coin & 1) ? FUZZ_EXEC_TIME_FLAG "1"
978
24
                                        : FUZZ_EXEC_TIME_FLAG "0";
979
24
    fuzz_split_argv[*argc + 1] = NULL;
980
981
24
    fprintf(stderr, "fuzz: this session runs with %s\n",
982
24
            fuzz_split_argv[*argc]);
983
24
    *argv = fuzz_split_argv;
984
24
    (*argc)++;
985
24
}
io.c:fuzz_split_exec_time_scaling
Line
Count
Source
958
2
{
959
9
    for (int i = 1; i < *argc; i++) {
960
8
        if (strncmp((*argv)[i], FUZZ_EXEC_TIME_FLAG,
961
8
                    strlen(FUZZ_EXEC_TIME_FLAG)) == 0)
962
1
            return;
963
8
    }
964
965
    /* Not rand(): unseeded, it gives every session the same answer. */
966
1
    unsigned char coin;
967
1
    FILE *urandom = fopen("/dev/urandom", "rb");
968
1
    if (urandom == NULL || fread(&coin, 1, 1, urandom) != 1)
969
0
        coin = (unsigned char)getpid();
970
1
    if (urandom != NULL)
971
1
        fclose(urandom);
972
973
1
    fuzz_split_argv = malloc((*argc + 2) * sizeof(char *));
974
1
    if (fuzz_split_argv == NULL)
975
0
        return;
976
1
    memcpy(fuzz_split_argv, *argv, *argc * sizeof(char *));
977
1
    fuzz_split_argv[*argc] = (coin & 1) ? FUZZ_EXEC_TIME_FLAG "1"
978
1
                                        : FUZZ_EXEC_TIME_FLAG "0";
979
1
    fuzz_split_argv[*argc + 1] = NULL;
980
981
    fprintf(stderr, "fuzz: this session runs with %s\n",
982
1
            fuzz_split_argv[*argc]);
983
1
    *argv = fuzz_split_argv;
984
1
    (*argc)++;
985
1
}
dcf.c:fuzz_split_exec_time_scaling
Line
Count
Source
958
2
{
959
9
    for (int i = 1; i < *argc; i++) {
960
8
        if (strncmp((*argv)[i], FUZZ_EXEC_TIME_FLAG,
961
8
                    strlen(FUZZ_EXEC_TIME_FLAG)) == 0)
962
1
            return;
963
8
    }
964
965
    /* Not rand(): unseeded, it gives every session the same answer. */
966
1
    unsigned char coin;
967
1
    FILE *urandom = fopen("/dev/urandom", "rb");
968
1
    if (urandom == NULL || fread(&coin, 1, 1, urandom) != 1)
969
0
        coin = (unsigned char)getpid();
970
1
    if (urandom != NULL)
971
1
        fclose(urandom);
972
973
1
    fuzz_split_argv = malloc((*argc + 2) * sizeof(char *));
974
1
    if (fuzz_split_argv == NULL)
975
0
        return;
976
1
    memcpy(fuzz_split_argv, *argv, *argc * sizeof(char *));
977
1
    fuzz_split_argv[*argc] = (coin & 1) ? FUZZ_EXEC_TIME_FLAG "1"
978
1
                                        : FUZZ_EXEC_TIME_FLAG "0";
979
1
    fuzz_split_argv[*argc + 1] = NULL;
980
981
    fprintf(stderr, "fuzz: this session runs with %s\n",
982
1
            fuzz_split_argv[*argc]);
983
1
    *argv = fuzz_split_argv;
984
1
    (*argc)++;
985
1
}
character.c:fuzz_split_exec_time_scaling
Line
Count
Source
958
2
{
959
9
    for (int i = 1; i < *argc; i++) {
960
8
        if (strncmp((*argv)[i], FUZZ_EXEC_TIME_FLAG,
961
8
                    strlen(FUZZ_EXEC_TIME_FLAG)) == 0)
962
1
            return;
963
8
    }
964
965
    /* Not rand(): unseeded, it gives every session the same answer. */
966
1
    unsigned char coin;
967
1
    FILE *urandom = fopen("/dev/urandom", "rb");
968
1
    if (urandom == NULL || fread(&coin, 1, 1, urandom) != 1)
969
0
        coin = (unsigned char)getpid();
970
1
    if (urandom != NULL)
971
1
        fclose(urandom);
972
973
1
    fuzz_split_argv = malloc((*argc + 2) * sizeof(char *));
974
1
    if (fuzz_split_argv == NULL)
975
0
        return;
976
1
    memcpy(fuzz_split_argv, *argv, *argc * sizeof(char *));
977
1
    fuzz_split_argv[*argc] = (coin & 1) ? FUZZ_EXEC_TIME_FLAG "1"
978
1
                                        : FUZZ_EXEC_TIME_FLAG "0";
979
1
    fuzz_split_argv[*argc + 1] = NULL;
980
981
    fprintf(stderr, "fuzz: this session runs with %s\n",
982
1
            fuzz_split_argv[*argc]);
983
1
    *argv = fuzz_split_argv;
984
1
    (*argc)++;
985
1
}
encoding.c:fuzz_split_exec_time_scaling
Line
Count
Source
958
2
{
959
9
    for (int i = 1; i < *argc; i++) {
960
8
        if (strncmp((*argv)[i], FUZZ_EXEC_TIME_FLAG,
961
8
                    strlen(FUZZ_EXEC_TIME_FLAG)) == 0)
962
1
            return;
963
8
    }
964
965
    /* Not rand(): unseeded, it gives every session the same answer. */
966
1
    unsigned char coin;
967
1
    FILE *urandom = fopen("/dev/urandom", "rb");
968
1
    if (urandom == NULL || fread(&coin, 1, 1, urandom) != 1)
969
0
        coin = (unsigned char)getpid();
970
1
    if (urandom != NULL)
971
1
        fclose(urandom);
972
973
1
    fuzz_split_argv = malloc((*argc + 2) * sizeof(char *));
974
1
    if (fuzz_split_argv == NULL)
975
0
        return;
976
1
    memcpy(fuzz_split_argv, *argv, *argc * sizeof(char *));
977
1
    fuzz_split_argv[*argc] = (coin & 1) ? FUZZ_EXEC_TIME_FLAG "1"
978
1
                                        : FUZZ_EXEC_TIME_FLAG "0";
979
1
    fuzz_split_argv[*argc + 1] = NULL;
980
981
    fprintf(stderr, "fuzz: this session runs with %s\n",
982
1
            fuzz_split_argv[*argc]);
983
1
    *argv = fuzz_split_argv;
984
1
    (*argc)++;
985
1
}
sort.c:fuzz_split_exec_time_scaling
Line
Count
Source
958
2
{
959
9
    for (int i = 1; i < *argc; i++) {
960
8
        if (strncmp((*argv)[i], FUZZ_EXEC_TIME_FLAG,
961
8
                    strlen(FUZZ_EXEC_TIME_FLAG)) == 0)
962
1
            return;
963
8
    }
964
965
    /* Not rand(): unseeded, it gives every session the same answer. */
966
1
    unsigned char coin;
967
1
    FILE *urandom = fopen("/dev/urandom", "rb");
968
1
    if (urandom == NULL || fread(&coin, 1, 1, urandom) != 1)
969
0
        coin = (unsigned char)getpid();
970
1
    if (urandom != NULL)
971
1
        fclose(urandom);
972
973
1
    fuzz_split_argv = malloc((*argc + 2) * sizeof(char *));
974
1
    if (fuzz_split_argv == NULL)
975
0
        return;
976
1
    memcpy(fuzz_split_argv, *argv, *argc * sizeof(char *));
977
1
    fuzz_split_argv[*argc] = (coin & 1) ? FUZZ_EXEC_TIME_FLAG "1"
978
1
                                        : FUZZ_EXEC_TIME_FLAG "0";
979
1
    fuzz_split_argv[*argc + 1] = NULL;
980
981
    fprintf(stderr, "fuzz: this session runs with %s\n",
982
1
            fuzz_split_argv[*argc]);
983
1
    *argv = fuzz_split_argv;
984
1
    (*argc)++;
985
1
}
connections.c:fuzz_split_exec_time_scaling
Line
Count
Source
958
2
{
959
9
    for (int i = 1; i < *argc; i++) {
960
8
        if (strncmp((*argv)[i], FUZZ_EXEC_TIME_FLAG,
961
8
                    strlen(FUZZ_EXEC_TIME_FLAG)) == 0)
962
1
            return;
963
8
    }
964
965
    /* Not rand(): unseeded, it gives every session the same answer. */
966
1
    unsigned char coin;
967
1
    FILE *urandom = fopen("/dev/urandom", "rb");
968
1
    if (urandom == NULL || fread(&coin, 1, 1, urandom) != 1)
969
0
        coin = (unsigned char)getpid();
970
1
    if (urandom != NULL)
971
1
        fclose(urandom);
972
973
1
    fuzz_split_argv = malloc((*argc + 2) * sizeof(char *));
974
1
    if (fuzz_split_argv == NULL)
975
0
        return;
976
1
    memcpy(fuzz_split_argv, *argv, *argc * sizeof(char *));
977
1
    fuzz_split_argv[*argc] = (coin & 1) ? FUZZ_EXEC_TIME_FLAG "1"
978
1
                                        : FUZZ_EXEC_TIME_FLAG "0";
979
1
    fuzz_split_argv[*argc + 1] = NULL;
980
981
    fprintf(stderr, "fuzz: this session runs with %s\n",
982
1
            fuzz_split_argv[*argc]);
983
1
    *argv = fuzz_split_argv;
984
1
    (*argc)++;
985
1
}
unserialize.c:fuzz_split_exec_time_scaling
Line
Count
Source
958
2
{
959
9
    for (int i = 1; i < *argc; i++) {
960
8
        if (strncmp((*argv)[i], FUZZ_EXEC_TIME_FLAG,
961
8
                    strlen(FUZZ_EXEC_TIME_FLAG)) == 0)
962
1
            return;
963
8
    }
964
965
    /* Not rand(): unseeded, it gives every session the same answer. */
966
1
    unsigned char coin;
967
1
    FILE *urandom = fopen("/dev/urandom", "rb");
968
1
    if (urandom == NULL || fread(&coin, 1, 1, urandom) != 1)
969
0
        coin = (unsigned char)getpid();
970
1
    if (urandom != NULL)
971
1
        fclose(urandom);
972
973
1
    fuzz_split_argv = malloc((*argc + 2) * sizeof(char *));
974
1
    if (fuzz_split_argv == NULL)
975
0
        return;
976
1
    memcpy(fuzz_split_argv, *argv, *argc * sizeof(char *));
977
1
    fuzz_split_argv[*argc] = (coin & 1) ? FUZZ_EXEC_TIME_FLAG "1"
978
1
                                        : FUZZ_EXEC_TIME_FLAG "0";
979
1
    fuzz_split_argv[*argc + 1] = NULL;
980
981
    fprintf(stderr, "fuzz: this session runs with %s\n",
982
1
            fuzz_split_argv[*argc]);
983
1
    *argv = fuzz_split_argv;
984
1
    (*argc)++;
985
1
}
formula.c:fuzz_split_exec_time_scaling
Line
Count
Source
958
2
{
959
9
    for (int i = 1; i < *argc; i++) {
960
8
        if (strncmp((*argv)[i], FUZZ_EXEC_TIME_FLAG,
961
8
                    strlen(FUZZ_EXEC_TIME_FLAG)) == 0)
962
1
            return;
963
8
    }
964
965
    /* Not rand(): unseeded, it gives every session the same answer. */
966
1
    unsigned char coin;
967
1
    FILE *urandom = fopen("/dev/urandom", "rb");
968
1
    if (urandom == NULL || fread(&coin, 1, 1, urandom) != 1)
969
0
        coin = (unsigned char)getpid();
970
1
    if (urandom != NULL)
971
1
        fclose(urandom);
972
973
1
    fuzz_split_argv = malloc((*argc + 2) * sizeof(char *));
974
1
    if (fuzz_split_argv == NULL)
975
0
        return;
976
1
    memcpy(fuzz_split_argv, *argv, *argc * sizeof(char *));
977
1
    fuzz_split_argv[*argc] = (coin & 1) ? FUZZ_EXEC_TIME_FLAG "1"
978
1
                                        : FUZZ_EXEC_TIME_FLAG "0";
979
1
    fuzz_split_argv[*argc + 1] = NULL;
980
981
    fprintf(stderr, "fuzz: this session runs with %s\n",
982
1
            fuzz_split_argv[*argc]);
983
1
    *argv = fuzz_split_argv;
984
1
    (*argc)++;
985
1
}
decompress.c:fuzz_split_exec_time_scaling
Line
Count
Source
958
2
{
959
9
    for (int i = 1; i < *argc; i++) {
960
8
        if (strncmp((*argv)[i], FUZZ_EXEC_TIME_FLAG,
961
8
                    strlen(FUZZ_EXEC_TIME_FLAG)) == 0)
962
1
            return;
963
8
    }
964
965
    /* Not rand(): unseeded, it gives every session the same answer. */
966
1
    unsigned char coin;
967
1
    FILE *urandom = fopen("/dev/urandom", "rb");
968
1
    if (urandom == NULL || fread(&coin, 1, 1, urandom) != 1)
969
0
        coin = (unsigned char)getpid();
970
1
    if (urandom != NULL)
971
1
        fclose(urandom);
972
973
1
    fuzz_split_argv = malloc((*argc + 2) * sizeof(char *));
974
1
    if (fuzz_split_argv == NULL)
975
0
        return;
976
1
    memcpy(fuzz_split_argv, *argv, *argc * sizeof(char *));
977
1
    fuzz_split_argv[*argc] = (coin & 1) ? FUZZ_EXEC_TIME_FLAG "1"
978
1
                                        : FUZZ_EXEC_TIME_FLAG "0";
979
1
    fuzz_split_argv[*argc + 1] = NULL;
980
981
    fprintf(stderr, "fuzz: this session runs with %s\n",
982
1
            fuzz_split_argv[*argc]);
983
1
    *argv = fuzz_split_argv;
984
1
    (*argc)++;
985
1
}
readtable.c:fuzz_split_exec_time_scaling
Line
Count
Source
958
2
{
959
9
    for (int i = 1; i < *argc; i++) {
960
8
        if (strncmp((*argv)[i], FUZZ_EXEC_TIME_FLAG,
961
8
                    strlen(FUZZ_EXEC_TIME_FLAG)) == 0)
962
1
            return;
963
8
    }
964
965
    /* Not rand(): unseeded, it gives every session the same answer. */
966
1
    unsigned char coin;
967
1
    FILE *urandom = fopen("/dev/urandom", "rb");
968
1
    if (urandom == NULL || fread(&coin, 1, 1, urandom) != 1)
969
0
        coin = (unsigned char)getpid();
970
1
    if (urandom != NULL)
971
1
        fclose(urandom);
972
973
1
    fuzz_split_argv = malloc((*argc + 2) * sizeof(char *));
974
1
    if (fuzz_split_argv == NULL)
975
0
        return;
976
1
    memcpy(fuzz_split_argv, *argv, *argc * sizeof(char *));
977
1
    fuzz_split_argv[*argc] = (coin & 1) ? FUZZ_EXEC_TIME_FLAG "1"
978
1
                                        : FUZZ_EXEC_TIME_FLAG "0";
979
1
    fuzz_split_argv[*argc + 1] = NULL;
980
981
    fprintf(stderr, "fuzz: this session runs with %s\n",
982
1
            fuzz_split_argv[*argc]);
983
1
    *argv = fuzz_split_argv;
984
1
    (*argc)++;
985
1
}
format.c:fuzz_split_exec_time_scaling
Line
Count
Source
958
2
{
959
9
    for (int i = 1; i < *argc; i++) {
960
8
        if (strncmp((*argv)[i], FUZZ_EXEC_TIME_FLAG,
961
8
                    strlen(FUZZ_EXEC_TIME_FLAG)) == 0)
962
1
            return;
963
8
    }
964
965
    /* Not rand(): unseeded, it gives every session the same answer. */
966
1
    unsigned char coin;
967
1
    FILE *urandom = fopen("/dev/urandom", "rb");
968
1
    if (urandom == NULL || fread(&coin, 1, 1, urandom) != 1)
969
0
        coin = (unsigned char)getpid();
970
1
    if (urandom != NULL)
971
1
        fclose(urandom);
972
973
1
    fuzz_split_argv = malloc((*argc + 2) * sizeof(char *));
974
1
    if (fuzz_split_argv == NULL)
975
0
        return;
976
1
    memcpy(fuzz_split_argv, *argv, *argc * sizeof(char *));
977
1
    fuzz_split_argv[*argc] = (coin & 1) ? FUZZ_EXEC_TIME_FLAG "1"
978
1
                                        : FUZZ_EXEC_TIME_FLAG "0";
979
1
    fuzz_split_argv[*argc + 1] = NULL;
980
981
    fprintf(stderr, "fuzz: this session runs with %s\n",
982
1
            fuzz_split_argv[*argc]);
983
1
    *argv = fuzz_split_argv;
984
1
    (*argc)++;
985
1
}
datetime.c:fuzz_split_exec_time_scaling
Line
Count
Source
958
2
{
959
9
    for (int i = 1; i < *argc; i++) {
960
8
        if (strncmp((*argv)[i], FUZZ_EXEC_TIME_FLAG,
961
8
                    strlen(FUZZ_EXEC_TIME_FLAG)) == 0)
962
1
            return;
963
8
    }
964
965
    /* Not rand(): unseeded, it gives every session the same answer. */
966
1
    unsigned char coin;
967
1
    FILE *urandom = fopen("/dev/urandom", "rb");
968
1
    if (urandom == NULL || fread(&coin, 1, 1, urandom) != 1)
969
0
        coin = (unsigned char)getpid();
970
1
    if (urandom != NULL)
971
1
        fclose(urandom);
972
973
1
    fuzz_split_argv = malloc((*argc + 2) * sizeof(char *));
974
1
    if (fuzz_split_argv == NULL)
975
0
        return;
976
1
    memcpy(fuzz_split_argv, *argv, *argc * sizeof(char *));
977
1
    fuzz_split_argv[*argc] = (coin & 1) ? FUZZ_EXEC_TIME_FLAG "1"
978
1
                                        : FUZZ_EXEC_TIME_FLAG "0";
979
1
    fuzz_split_argv[*argc + 1] = NULL;
980
981
    fprintf(stderr, "fuzz: this session runs with %s\n",
982
1
            fuzz_split_argv[*argc]);
983
1
    *argv = fuzz_split_argv;
984
1
    (*argc)++;
985
1
}
coerce.c:fuzz_split_exec_time_scaling
Line
Count
Source
958
2
{
959
9
    for (int i = 1; i < *argc; i++) {
960
8
        if (strncmp((*argv)[i], FUZZ_EXEC_TIME_FLAG,
961
8
                    strlen(FUZZ_EXEC_TIME_FLAG)) == 0)
962
1
            return;
963
8
    }
964
965
    /* Not rand(): unseeded, it gives every session the same answer. */
966
1
    unsigned char coin;
967
1
    FILE *urandom = fopen("/dev/urandom", "rb");
968
1
    if (urandom == NULL || fread(&coin, 1, 1, urandom) != 1)
969
0
        coin = (unsigned char)getpid();
970
1
    if (urandom != NULL)
971
1
        fclose(urandom);
972
973
1
    fuzz_split_argv = malloc((*argc + 2) * sizeof(char *));
974
1
    if (fuzz_split_argv == NULL)
975
0
        return;
976
1
    memcpy(fuzz_split_argv, *argv, *argc * sizeof(char *));
977
1
    fuzz_split_argv[*argc] = (coin & 1) ? FUZZ_EXEC_TIME_FLAG "1"
978
1
                                        : FUZZ_EXEC_TIME_FLAG "0";
979
1
    fuzz_split_argv[*argc + 1] = NULL;
980
981
    fprintf(stderr, "fuzz: this session runs with %s\n",
982
1
            fuzz_split_argv[*argc]);
983
1
    *argv = fuzz_split_argv;
984
1
    (*argc)++;
985
1
}
load.c:fuzz_split_exec_time_scaling
Line
Count
Source
958
2
{
959
9
    for (int i = 1; i < *argc; i++) {
960
8
        if (strncmp((*argv)[i], FUZZ_EXEC_TIME_FLAG,
961
8
                    strlen(FUZZ_EXEC_TIME_FLAG)) == 0)
962
1
            return;
963
8
    }
964
965
    /* Not rand(): unseeded, it gives every session the same answer. */
966
1
    unsigned char coin;
967
1
    FILE *urandom = fopen("/dev/urandom", "rb");
968
1
    if (urandom == NULL || fread(&coin, 1, 1, urandom) != 1)
969
0
        coin = (unsigned char)getpid();
970
1
    if (urandom != NULL)
971
1
        fclose(urandom);
972
973
1
    fuzz_split_argv = malloc((*argc + 2) * sizeof(char *));
974
1
    if (fuzz_split_argv == NULL)
975
0
        return;
976
1
    memcpy(fuzz_split_argv, *argv, *argc * sizeof(char *));
977
1
    fuzz_split_argv[*argc] = (coin & 1) ? FUZZ_EXEC_TIME_FLAG "1"
978
1
                                        : FUZZ_EXEC_TIME_FLAG "0";
979
1
    fuzz_split_argv[*argc + 1] = NULL;
980
981
    fprintf(stderr, "fuzz: this session runs with %s\n",
982
1
            fuzz_split_argv[*argc]);
983
1
    *argv = fuzz_split_argv;
984
1
    (*argc)++;
985
1
}
scan.c:fuzz_split_exec_time_scaling
Line
Count
Source
958
2
{
959
9
    for (int i = 1; i < *argc; i++) {
960
8
        if (strncmp((*argv)[i], FUZZ_EXEC_TIME_FLAG,
961
8
                    strlen(FUZZ_EXEC_TIME_FLAG)) == 0)
962
1
            return;
963
8
    }
964
965
    /* Not rand(): unseeded, it gives every session the same answer. */
966
1
    unsigned char coin;
967
1
    FILE *urandom = fopen("/dev/urandom", "rb");
968
1
    if (urandom == NULL || fread(&coin, 1, 1, urandom) != 1)
969
0
        coin = (unsigned char)getpid();
970
1
    if (urandom != NULL)
971
1
        fclose(urandom);
972
973
1
    fuzz_split_argv = malloc((*argc + 2) * sizeof(char *));
974
1
    if (fuzz_split_argv == NULL)
975
0
        return;
976
1
    memcpy(fuzz_split_argv, *argv, *argc * sizeof(char *));
977
1
    fuzz_split_argv[*argc] = (coin & 1) ? FUZZ_EXEC_TIME_FLAG "1"
978
1
                                        : FUZZ_EXEC_TIME_FLAG "0";
979
1
    fuzz_split_argv[*argc + 1] = NULL;
980
981
    fprintf(stderr, "fuzz: this session runs with %s\n",
982
1
            fuzz_split_argv[*argc]);
983
1
    *argv = fuzz_split_argv;
984
1
    (*argc)++;
985
1
}
colors.c:fuzz_split_exec_time_scaling
Line
Count
Source
958
2
{
959
9
    for (int i = 1; i < *argc; i++) {
960
8
        if (strncmp((*argv)[i], FUZZ_EXEC_TIME_FLAG,
961
8
                    strlen(FUZZ_EXEC_TIME_FLAG)) == 0)
962
1
            return;
963
8
    }
964
965
    /* Not rand(): unseeded, it gives every session the same answer. */
966
1
    unsigned char coin;
967
1
    FILE *urandom = fopen("/dev/urandom", "rb");
968
1
    if (urandom == NULL || fread(&coin, 1, 1, urandom) != 1)
969
0
        coin = (unsigned char)getpid();
970
1
    if (urandom != NULL)
971
1
        fclose(urandom);
972
973
1
    fuzz_split_argv = malloc((*argc + 2) * sizeof(char *));
974
1
    if (fuzz_split_argv == NULL)
975
0
        return;
976
1
    memcpy(fuzz_split_argv, *argv, *argc * sizeof(char *));
977
1
    fuzz_split_argv[*argc] = (coin & 1) ? FUZZ_EXEC_TIME_FLAG "1"
978
1
                                        : FUZZ_EXEC_TIME_FLAG "0";
979
1
    fuzz_split_argv[*argc + 1] = NULL;
980
981
    fprintf(stderr, "fuzz: this session runs with %s\n",
982
1
            fuzz_split_argv[*argc]);
983
1
    *argv = fuzz_split_argv;
984
1
    (*argc)++;
985
1
}
grep.c:fuzz_split_exec_time_scaling
Line
Count
Source
958
2
{
959
9
    for (int i = 1; i < *argc; i++) {
960
8
        if (strncmp((*argv)[i], FUZZ_EXEC_TIME_FLAG,
961
8
                    strlen(FUZZ_EXEC_TIME_FLAG)) == 0)
962
1
            return;
963
8
    }
964
965
    /* Not rand(): unseeded, it gives every session the same answer. */
966
1
    unsigned char coin;
967
1
    FILE *urandom = fopen("/dev/urandom", "rb");
968
1
    if (urandom == NULL || fread(&coin, 1, 1, urandom) != 1)
969
0
        coin = (unsigned char)getpid();
970
1
    if (urandom != NULL)
971
1
        fclose(urandom);
972
973
1
    fuzz_split_argv = malloc((*argc + 2) * sizeof(char *));
974
1
    if (fuzz_split_argv == NULL)
975
0
        return;
976
1
    memcpy(fuzz_split_argv, *argv, *argc * sizeof(char *));
977
1
    fuzz_split_argv[*argc] = (coin & 1) ? FUZZ_EXEC_TIME_FLAG "1"
978
1
                                        : FUZZ_EXEC_TIME_FLAG "0";
979
1
    fuzz_split_argv[*argc + 1] = NULL;
980
981
    fprintf(stderr, "fuzz: this session runs with %s\n",
982
1
            fuzz_split_argv[*argc]);
983
1
    *argv = fuzz_split_argv;
984
1
    (*argc)++;
985
1
}
parse.c:fuzz_split_exec_time_scaling
Line
Count
Source
958
2
{
959
9
    for (int i = 1; i < *argc; i++) {
960
8
        if (strncmp((*argv)[i], FUZZ_EXEC_TIME_FLAG,
961
8
                    strlen(FUZZ_EXEC_TIME_FLAG)) == 0)
962
1
            return;
963
8
    }
964
965
    /* Not rand(): unseeded, it gives every session the same answer. */
966
1
    unsigned char coin;
967
1
    FILE *urandom = fopen("/dev/urandom", "rb");
968
1
    if (urandom == NULL || fread(&coin, 1, 1, urandom) != 1)
969
0
        coin = (unsigned char)getpid();
970
1
    if (urandom != NULL)
971
1
        fclose(urandom);
972
973
1
    fuzz_split_argv = malloc((*argc + 2) * sizeof(char *));
974
1
    if (fuzz_split_argv == NULL)
975
0
        return;
976
1
    memcpy(fuzz_split_argv, *argv, *argc * sizeof(char *));
977
1
    fuzz_split_argv[*argc] = (coin & 1) ? FUZZ_EXEC_TIME_FLAG "1"
978
1
                                        : FUZZ_EXEC_TIME_FLAG "0";
979
1
    fuzz_split_argv[*argc + 1] = NULL;
980
981
    fprintf(stderr, "fuzz: this session runs with %s\n",
982
1
            fuzz_split_argv[*argc]);
983
1
    *argv = fuzz_split_argv;
984
1
    (*argc)++;
985
1
}
sockets.c:fuzz_split_exec_time_scaling
Line
Count
Source
958
2
{
959
9
    for (int i = 1; i < *argc; i++) {
960
8
        if (strncmp((*argv)[i], FUZZ_EXEC_TIME_FLAG,
961
8
                    strlen(FUZZ_EXEC_TIME_FLAG)) == 0)
962
1
            return;
963
8
    }
964
965
    /* Not rand(): unseeded, it gives every session the same answer. */
966
1
    unsigned char coin;
967
1
    FILE *urandom = fopen("/dev/urandom", "rb");
968
1
    if (urandom == NULL || fread(&coin, 1, 1, urandom) != 1)
969
0
        coin = (unsigned char)getpid();
970
1
    if (urandom != NULL)
971
1
        fclose(urandom);
972
973
1
    fuzz_split_argv = malloc((*argc + 2) * sizeof(char *));
974
1
    if (fuzz_split_argv == NULL)
975
0
        return;
976
1
    memcpy(fuzz_split_argv, *argv, *argc * sizeof(char *));
977
1
    fuzz_split_argv[*argc] = (coin & 1) ? FUZZ_EXEC_TIME_FLAG "1"
978
1
                                        : FUZZ_EXEC_TIME_FLAG "0";
979
1
    fuzz_split_argv[*argc + 1] = NULL;
980
981
    fprintf(stderr, "fuzz: this session runs with %s\n",
982
1
            fuzz_split_argv[*argc]);
983
1
    *argv = fuzz_split_argv;
984
1
    (*argc)++;
985
1
}
rd.c:fuzz_split_exec_time_scaling
Line
Count
Source
958
2
{
959
9
    for (int i = 1; i < *argc; i++) {
960
8
        if (strncmp((*argv)[i], FUZZ_EXEC_TIME_FLAG,
961
8
                    strlen(FUZZ_EXEC_TIME_FLAG)) == 0)
962
1
            return;
963
8
    }
964
965
    /* Not rand(): unseeded, it gives every session the same answer. */
966
1
    unsigned char coin;
967
1
    FILE *urandom = fopen("/dev/urandom", "rb");
968
1
    if (urandom == NULL || fread(&coin, 1, 1, urandom) != 1)
969
0
        coin = (unsigned char)getpid();
970
1
    if (urandom != NULL)
971
1
        fclose(urandom);
972
973
1
    fuzz_split_argv = malloc((*argc + 2) * sizeof(char *));
974
1
    if (fuzz_split_argv == NULL)
975
0
        return;
976
1
    memcpy(fuzz_split_argv, *argv, *argc * sizeof(char *));
977
1
    fuzz_split_argv[*argc] = (coin & 1) ? FUZZ_EXEC_TIME_FLAG "1"
978
1
                                        : FUZZ_EXEC_TIME_FLAG "0";
979
1
    fuzz_split_argv[*argc + 1] = NULL;
980
981
    fprintf(stderr, "fuzz: this session runs with %s\n",
982
1
            fuzz_split_argv[*argc]);
983
1
    *argv = fuzz_split_argv;
984
1
    (*argc)++;
985
1
}
sprintf.c:fuzz_split_exec_time_scaling
Line
Count
Source
958
2
{
959
9
    for (int i = 1; i < *argc; i++) {
960
8
        if (strncmp((*argv)[i], FUZZ_EXEC_TIME_FLAG,
961
8
                    strlen(FUZZ_EXEC_TIME_FLAG)) == 0)
962
1
            return;
963
8
    }
964
965
    /* Not rand(): unseeded, it gives every session the same answer. */
966
1
    unsigned char coin;
967
1
    FILE *urandom = fopen("/dev/urandom", "rb");
968
1
    if (urandom == NULL || fread(&coin, 1, 1, urandom) != 1)
969
0
        coin = (unsigned char)getpid();
970
1
    if (urandom != NULL)
971
1
        fclose(urandom);
972
973
1
    fuzz_split_argv = malloc((*argc + 2) * sizeof(char *));
974
1
    if (fuzz_split_argv == NULL)
975
0
        return;
976
1
    memcpy(fuzz_split_argv, *argv, *argc * sizeof(char *));
977
1
    fuzz_split_argv[*argc] = (coin & 1) ? FUZZ_EXEC_TIME_FLAG "1"
978
1
                                        : FUZZ_EXEC_TIME_FLAG "0";
979
1
    fuzz_split_argv[*argc + 1] = NULL;
980
981
    fprintf(stderr, "fuzz: this session runs with %s\n",
982
1
            fuzz_split_argv[*argc]);
983
1
    *argv = fuzz_split_argv;
984
1
    (*argc)++;
985
1
}
eval.c:fuzz_split_exec_time_scaling
Line
Count
Source
958
2
{
959
9
    for (int i = 1; i < *argc; i++) {
960
8
        if (strncmp((*argv)[i], FUZZ_EXEC_TIME_FLAG,
961
8
                    strlen(FUZZ_EXEC_TIME_FLAG)) == 0)
962
1
            return;
963
8
    }
964
965
    /* Not rand(): unseeded, it gives every session the same answer. */
966
1
    unsigned char coin;
967
1
    FILE *urandom = fopen("/dev/urandom", "rb");
968
1
    if (urandom == NULL || fread(&coin, 1, 1, urandom) != 1)
969
0
        coin = (unsigned char)getpid();
970
1
    if (urandom != NULL)
971
1
        fclose(urandom);
972
973
1
    fuzz_split_argv = malloc((*argc + 2) * sizeof(char *));
974
1
    if (fuzz_split_argv == NULL)
975
0
        return;
976
1
    memcpy(fuzz_split_argv, *argv, *argc * sizeof(char *));
977
1
    fuzz_split_argv[*argc] = (coin & 1) ? FUZZ_EXEC_TIME_FLAG "1"
978
1
                                        : FUZZ_EXEC_TIME_FLAG "0";
979
1
    fuzz_split_argv[*argc + 1] = NULL;
980
981
    fprintf(stderr, "fuzz: this session runs with %s\n",
982
1
            fuzz_split_argv[*argc]);
983
1
    *argv = fuzz_split_argv;
984
1
    (*argc)++;
985
1
}
zip.c:fuzz_split_exec_time_scaling
Line
Count
Source
958
2
{
959
9
    for (int i = 1; i < *argc; i++) {
960
8
        if (strncmp((*argv)[i], FUZZ_EXEC_TIME_FLAG,
961
8
                    strlen(FUZZ_EXEC_TIME_FLAG)) == 0)
962
1
            return;
963
8
    }
964
965
    /* Not rand(): unseeded, it gives every session the same answer. */
966
1
    unsigned char coin;
967
1
    FILE *urandom = fopen("/dev/urandom", "rb");
968
1
    if (urandom == NULL || fread(&coin, 1, 1, urandom) != 1)
969
0
        coin = (unsigned char)getpid();
970
1
    if (urandom != NULL)
971
1
        fclose(urandom);
972
973
1
    fuzz_split_argv = malloc((*argc + 2) * sizeof(char *));
974
1
    if (fuzz_split_argv == NULL)
975
0
        return;
976
1
    memcpy(fuzz_split_argv, *argv, *argc * sizeof(char *));
977
1
    fuzz_split_argv[*argc] = (coin & 1) ? FUZZ_EXEC_TIME_FLAG "1"
978
1
                                        : FUZZ_EXEC_TIME_FLAG "0";
979
1
    fuzz_split_argv[*argc + 1] = NULL;
980
981
    fprintf(stderr, "fuzz: this session runs with %s\n",
982
1
            fuzz_split_argv[*argc]);
983
1
    *argv = fuzz_split_argv;
984
1
    (*argc)++;
985
1
}
nmath.c:fuzz_split_exec_time_scaling
Line
Count
Source
958
2
{
959
9
    for (int i = 1; i < *argc; i++) {
960
8
        if (strncmp((*argv)[i], FUZZ_EXEC_TIME_FLAG,
961
8
                    strlen(FUZZ_EXEC_TIME_FLAG)) == 0)
962
1
            return;
963
8
    }
964
965
    /* Not rand(): unseeded, it gives every session the same answer. */
966
1
    unsigned char coin;
967
1
    FILE *urandom = fopen("/dev/urandom", "rb");
968
1
    if (urandom == NULL || fread(&coin, 1, 1, urandom) != 1)
969
0
        coin = (unsigned char)getpid();
970
1
    if (urandom != NULL)
971
1
        fclose(urandom);
972
973
1
    fuzz_split_argv = malloc((*argc + 2) * sizeof(char *));
974
1
    if (fuzz_split_argv == NULL)
975
0
        return;
976
1
    memcpy(fuzz_split_argv, *argv, *argc * sizeof(char *));
977
1
    fuzz_split_argv[*argc] = (coin & 1) ? FUZZ_EXEC_TIME_FLAG "1"
978
1
                                        : FUZZ_EXEC_TIME_FLAG "0";
979
1
    fuzz_split_argv[*argc + 1] = NULL;
980
981
    fprintf(stderr, "fuzz: this session runs with %s\n",
982
1
            fuzz_split_argv[*argc]);
983
1
    *argv = fuzz_split_argv;
984
1
    (*argc)++;
985
1
}
986
#endif
987
988
int LLVMFuzzerInitialize(int *argc, char ***argv)
989
48
{
990
48
#ifdef FUZZ_ENGINE_LIBFUZZER
991
48
    fuzz_split_exec_time_scaling(argc, argv);
992
48
#endif
993
994
    /* libFuzzer parses this itself; the alarm wrapper needs the value. */
995
312
    for (int i = 1; i < *argc; i++) {
996
264
        const char *arg = (*argv)[i];
997
264
        if (strncmp(arg, "-timeout=", 9) == 0)
998
48
            fuzz_alarm.timeout = atoi(arg + 9);
999
264
    }
1000
1001
48
    fuzz_init_job_t job = { argc, argv, 0 };
1002
48
    fuzz_run_on_r_thread(fuzz_do_target_init, &job);
1003
48
    return job.result;
1004
48
}
1005
1006
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
1007
143k
{
1008
143k
    fuzz_alarm_wrap();
1009
1010
143k
    fuzz_run_job_t job = { data, size, 0 };
1011
143k
    fuzz_run_on_r_thread(fuzz_do_target_run, &job);
1012
143k
    return job.result;
1013
143k
}
1014
1015
#endif /* FUZZ_COMMON_H */