/src/racket-fuzz/driver.c
Line | Count | Source |
1 | | /* SPDX-License-Identifier: (Apache-2.0 OR MIT) */ |
2 | | |
3 | | /* libFuzzer driver for Racket CS. |
4 | | |
5 | | Boots Racket CS once, loads "safe-eval.rkt", and calls one of its |
6 | | `fuzz-*` entry points on each input. An entry point returns 0 for |
7 | | every expected outcome, and for a bug either 1 or a description, |
8 | | which becomes a failed assertion here. |
9 | | |
10 | | Compile-time settings (all strings): |
11 | | FUZZ_ENTRY entry point name, such as "fuzz-eval" |
12 | | and either |
13 | | FUZZ_EMBEDDED defined: boot files and modules come from |
14 | | "embed-data.S", and no files are needed at run time |
15 | | or |
16 | | FUZZ_MODULE absolute path of "safe-eval.rkt" |
17 | | BOOT_DIR directory holding petite.boot, scheme.boot, racket.boot |
18 | | COLLECTS_DIR the "collects" directory |
19 | | CONFIG_DIR the "etc" directory |
20 | | and optionally |
21 | | FUZZ_ADDON_DIR the addon directory, so that Racket does not look |
22 | | for the home directory |
23 | | |
24 | | With RACKET_COVERAGE_COUNTERS defined (and a Racket CS built with it |
25 | | and with PLT_CS_COVERAGE_COUNTERS set), Scheme code also reports |
26 | | coverage: the Chez Scheme counters are registered with libFuzzer |
27 | | like clang's inline 8-bit counters. Code that a fuzzed program |
28 | | compiles gets no counters, since counters placed by hashing the |
29 | | program's own code would reward new programs, not new behavior of |
30 | | Racket. */ |
31 | | |
32 | | #ifndef _GNU_SOURCE |
33 | | # define _GNU_SOURCE /* for REG_RIP and dladdr */ |
34 | | #endif |
35 | | #include <assert.h> |
36 | | #include <signal.h> |
37 | | #include <stdint.h> |
38 | | #include <stdio.h> |
39 | | #include <stdlib.h> |
40 | | #include <string.h> |
41 | | |
42 | | #include "chezscheme.h" |
43 | | #include "racketcs.h" |
44 | | |
45 | | #ifndef __has_feature |
46 | | # define __has_feature(x) 0 |
47 | | #endif |
48 | | #if defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer) |
49 | | # include <sanitizer/lsan_interface.h> |
50 | | # define FUZZ_LSAN_DISABLE() __lsan_disable() |
51 | | # define FUZZ_LSAN_ENABLE() __lsan_enable() |
52 | | #else |
53 | 60 | # define FUZZ_LSAN_DISABLE() (void)0 |
54 | 60 | # define FUZZ_LSAN_ENABLE() (void)0 |
55 | | #endif |
56 | | |
57 | | #ifndef FUZZ_ENTRY |
58 | | # define FUZZ_ENTRY "fuzz-eval" |
59 | | #endif |
60 | | |
61 | | static ptr entry_proc; |
62 | | |
63 | | #ifdef FUZZ_EMBEDDED |
64 | | extern char fuzz_petite_boot[], fuzz_petite_boot_end[]; |
65 | | extern char fuzz_scheme_boot[], fuzz_scheme_boot_end[]; |
66 | | extern char fuzz_racket_boot[], fuzz_racket_boot_end[]; |
67 | | extern char fuzz_modules[], fuzz_modules_end[]; |
68 | | #endif |
69 | | |
70 | | /* Chez Scheme turns every memory fault into an "invalid memory |
71 | | reference" exception, and every exception that the harness counts |
72 | | as a bug ends in `report_bug` below, with no C stack trace of its |
73 | | own. For a fault in C code, |
74 | | the sanitizer's report and stack trace say much more, so send those |
75 | | faults to the handler that was in place before booting. A fault in |
76 | | Scheme code, which is outside any shared object or the executable, |
77 | | still goes to Chez Scheme, since the sanitizer cannot walk Scheme |
78 | | frames; "safe-eval.rkt" then prints the Racket context and describes |
79 | | the bug by where in Racket it happened. Racket does |
80 | | not rely on these signals in normal operation. */ |
81 | | static struct sigaction sanitizer_segv, sanitizer_bus, chez_segv, chez_bus; |
82 | | |
83 | | #if defined(__linux__) && (defined(__x86_64__) || defined(__aarch64__)) |
84 | | # include <dlfcn.h> |
85 | | # include <ucontext.h> |
86 | | |
87 | | static int fault_in_c_code(void *data) |
88 | 0 | { |
89 | 0 | ucontext_t *uc = (ucontext_t *)data; |
90 | 0 | Dl_info info; |
91 | 0 | # if defined(__x86_64__) |
92 | 0 | void *pc = (void *)uc->uc_mcontext.gregs[REG_RIP]; |
93 | | # else |
94 | | void *pc = (void *)uc->uc_mcontext.pc; |
95 | | # endif |
96 | 0 | return dladdr(pc, &info) != 0; |
97 | 0 | } |
98 | | |
99 | | static void call_handler(struct sigaction *sa, int sig, siginfo_t *si, void *data) |
100 | 0 | { |
101 | 0 | if (sa->sa_flags & SA_SIGINFO) |
102 | 0 | sa->sa_sigaction(sig, si, data); |
103 | 0 | else if ((sa->sa_handler != SIG_DFL) && (sa->sa_handler != SIG_IGN)) |
104 | 0 | sa->sa_handler(sig); |
105 | 0 | else { |
106 | | /* returning re-runs the faulting instruction, now with the |
107 | | default action */ |
108 | 0 | signal(sig, SIG_DFL); |
109 | 0 | } |
110 | 0 | } |
111 | | |
112 | | static void handle_fault(int sig, siginfo_t *si, void *data) |
113 | 0 | { |
114 | 0 | int is_segv = (sig == SIGSEGV); |
115 | 0 | if (fault_in_c_code(data)) |
116 | 0 | call_handler(is_segv ? &sanitizer_segv : &sanitizer_bus, sig, si, data); |
117 | 0 | else |
118 | 0 | call_handler(is_segv ? &chez_segv : &chez_bus, sig, si, data); |
119 | 0 | } |
120 | | |
121 | | static void split_fault_handlers(void) |
122 | 30 | { |
123 | 30 | struct sigaction act; |
124 | | |
125 | 30 | sigaction(SIGSEGV, NULL, &chez_segv); |
126 | 30 | sigaction(SIGBUS, NULL, &chez_bus); |
127 | | |
128 | 30 | act = chez_segv; |
129 | 30 | act.sa_flags |= SA_SIGINFO | (sanitizer_segv.sa_flags & SA_ONSTACK); |
130 | 30 | act.sa_sigaction = handle_fault; |
131 | 30 | sigaction(SIGSEGV, &act, NULL); |
132 | 30 | sigaction(SIGBUS, &act, NULL); |
133 | 30 | } |
134 | | #else |
135 | | static void split_fault_handlers(void) { } |
136 | | #endif |
137 | | |
138 | | |
139 | | #ifdef RACKET_COVERAGE_COUNTERS |
140 | | void __sanitizer_cov_8bit_counters_init(uint8_t *start, uint8_t *stop); |
141 | | void __sanitizer_cov_pcs_init(const uintptr_t *pcs_beg, const uintptr_t *pcs_end); |
142 | | |
143 | | /* libFuzzer wants a PC table entry, a (PC, flags) pair, for each |
144 | | counter; the PCs only need to be distinct. */ |
145 | | static void register_scheme_counters(void) |
146 | 30 | { |
147 | 30 | iptr len; |
148 | 30 | uint8_t *counters = Scoverage_counters(&len); |
149 | 30 | uintptr_t *pcs; |
150 | 30 | iptr i; |
151 | | |
152 | 30 | if (!counters) return; |
153 | | |
154 | 30 | pcs = malloc(2 * len * sizeof(uintptr_t)); |
155 | 31.4M | for (i = 0; i < len; i++) { |
156 | 31.4M | pcs[2 * i] = (uintptr_t)(counters + i); |
157 | 31.4M | pcs[2 * i + 1] = 0; |
158 | 31.4M | } |
159 | | |
160 | 30 | __sanitizer_cov_8bit_counters_init(counters, counters + len); |
161 | 30 | __sanitizer_cov_pcs_init(pcs, pcs + 2 * len); |
162 | 30 | } |
163 | | #endif |
164 | | |
165 | | static int initialized = 0; |
166 | | |
167 | | /* An error while booting or loading the harness ends the process with |
168 | | `exit`, often with status 0, which would look like a passing run. */ |
169 | | static void check_initialized(void) |
170 | 30 | { |
171 | | /* not a property: Racket failed to boot or to load the harness */ |
172 | 30 | if (!initialized) { |
173 | 0 | fprintf(stderr, "racket-fuzz: initialization failed\n"); |
174 | 0 | abort(); |
175 | 0 | } |
176 | 30 | } |
177 | | |
178 | | int LLVMFuzzerInitialize(int *argc, char ***argv) |
179 | 60 | { |
180 | 60 | racket_boot_arguments_t ba; |
181 | | |
182 | 60 | atexit(check_initialized); |
183 | | |
184 | 60 | memset(&ba, 0, sizeof(ba)); |
185 | 60 | #ifdef FUZZ_EMBEDDED |
186 | 60 | ba.boot1_data = fuzz_petite_boot; |
187 | 60 | ba.boot1_len = fuzz_petite_boot_end - fuzz_petite_boot; |
188 | 60 | ba.boot2_data = fuzz_scheme_boot; |
189 | 60 | ba.boot2_len = fuzz_scheme_boot_end - fuzz_scheme_boot; |
190 | 60 | ba.boot3_data = fuzz_racket_boot; |
191 | 60 | ba.boot3_len = fuzz_racket_boot_end - fuzz_racket_boot; |
192 | 60 | ba.collects_dir = ""; |
193 | 60 | ba.config_dir = NULL; |
194 | | #else |
195 | | ba.boot1_path = BOOT_DIR "/petite.boot"; |
196 | | ba.boot2_path = BOOT_DIR "/scheme.boot"; |
197 | | ba.boot3_path = BOOT_DIR "/racket.boot"; |
198 | | /* A list of paths, each ending in NUL, with an extra NUL at the end; |
199 | | `parse_coldirs` in "boot.c" reads past a single NUL. */ |
200 | | ba.collects_dir = COLLECTS_DIR "\0"; |
201 | | ba.config_dir = CONFIG_DIR; |
202 | | #endif |
203 | 60 | ba.exec_file = "racket-fuzz"; |
204 | 60 | ba.exit_after = 0; |
205 | | #ifdef FUZZ_ADDON_DIR |
206 | | /* Naming the addon directory keeps Racket from finding it through |
207 | | the home directory, which looks in "/etc/passwd" when HOME is not |
208 | | set; "-n" is what a NULL `argv` would mean */ |
209 | | { |
210 | | static char *args[] = { "-A", FUZZ_ADDON_DIR, "-n", NULL }; |
211 | | ba.argc = 3; |
212 | | ba.argv = args; |
213 | | } |
214 | | #endif |
215 | | |
216 | | /* Racket keeps what it allocates while booting until the process |
217 | | exits, often referenced only from the Scheme heap, which |
218 | | LeakSanitizer does not scan; so don't report those as leaks. |
219 | | Leaks from running an input are still reported. */ |
220 | 60 | FUZZ_LSAN_DISABLE(); |
221 | | |
222 | 60 | sigaction(SIGSEGV, NULL, &sanitizer_segv); |
223 | 60 | sigaction(SIGBUS, NULL, &sanitizer_bus); |
224 | | |
225 | 60 | racket_boot(&ba); |
226 | | |
227 | 60 | split_fault_handlers(); |
228 | | |
229 | 60 | #ifdef RACKET_COVERAGE_COUNTERS |
230 | 60 | register_scheme_counters(); |
231 | 60 | #endif |
232 | | |
233 | 60 | #ifdef FUZZ_EMBEDDED |
234 | 60 | racket_embedded_load_bytes(fuzz_modules, fuzz_modules_end - fuzz_modules, 0); |
235 | 60 | #endif |
236 | | |
237 | 60 | { |
238 | 60 | #ifdef FUZZ_EMBEDDED |
239 | | /* "embed-modules.rkt" declares the module as 'fuzz:safe-eval */ |
240 | 60 | ptr mod_path = Scons(Sstring_to_symbol("quote"), |
241 | 60 | Scons(Sstring_to_symbol("fuzz:safe-eval"), Snil)); |
242 | | #else |
243 | | ptr mod_path = Scons(Sstring_to_symbol("file"), |
244 | | Scons(Sstring(FUZZ_MODULE), Snil)); |
245 | | #endif |
246 | 60 | ptr vals = racket_dynamic_require(mod_path, Sstring_to_symbol(FUZZ_ENTRY)); |
247 | 60 | entry_proc = Scar(vals); |
248 | 60 | Slock_object(entry_proc); |
249 | 60 | } |
250 | | |
251 | 60 | FUZZ_LSAN_ENABLE(); |
252 | | |
253 | 60 | initialized = 1; |
254 | | |
255 | 60 | return 0; |
256 | 60 | } Line | Count | Source | 179 | 30 | { | 180 | 30 | racket_boot_arguments_t ba; | 181 | | | 182 | 30 | atexit(check_initialized); | 183 | | | 184 | 30 | memset(&ba, 0, sizeof(ba)); | 185 | 30 | #ifdef FUZZ_EMBEDDED | 186 | 30 | ba.boot1_data = fuzz_petite_boot; | 187 | 30 | ba.boot1_len = fuzz_petite_boot_end - fuzz_petite_boot; | 188 | 30 | ba.boot2_data = fuzz_scheme_boot; | 189 | 30 | ba.boot2_len = fuzz_scheme_boot_end - fuzz_scheme_boot; | 190 | 30 | ba.boot3_data = fuzz_racket_boot; | 191 | 30 | ba.boot3_len = fuzz_racket_boot_end - fuzz_racket_boot; | 192 | 30 | ba.collects_dir = ""; | 193 | 30 | ba.config_dir = NULL; | 194 | | #else | 195 | | ba.boot1_path = BOOT_DIR "/petite.boot"; | 196 | | ba.boot2_path = BOOT_DIR "/scheme.boot"; | 197 | | ba.boot3_path = BOOT_DIR "/racket.boot"; | 198 | | /* A list of paths, each ending in NUL, with an extra NUL at the end; | 199 | | `parse_coldirs` in "boot.c" reads past a single NUL. */ | 200 | | ba.collects_dir = COLLECTS_DIR "\0"; | 201 | | ba.config_dir = CONFIG_DIR; | 202 | | #endif | 203 | 30 | ba.exec_file = "racket-fuzz"; | 204 | 30 | ba.exit_after = 0; | 205 | | #ifdef FUZZ_ADDON_DIR | 206 | | /* Naming the addon directory keeps Racket from finding it through | 207 | | the home directory, which looks in "/etc/passwd" when HOME is not | 208 | | set; "-n" is what a NULL `argv` would mean */ | 209 | | { | 210 | | static char *args[] = { "-A", FUZZ_ADDON_DIR, "-n", NULL }; | 211 | | ba.argc = 3; | 212 | | ba.argv = args; | 213 | | } | 214 | | #endif | 215 | | | 216 | | /* Racket keeps what it allocates while booting until the process | 217 | | exits, often referenced only from the Scheme heap, which | 218 | | LeakSanitizer does not scan; so don't report those as leaks. | 219 | | Leaks from running an input are still reported. */ | 220 | 30 | FUZZ_LSAN_DISABLE(); | 221 | | | 222 | 30 | sigaction(SIGSEGV, NULL, &sanitizer_segv); | 223 | 30 | sigaction(SIGBUS, NULL, &sanitizer_bus); | 224 | | | 225 | 30 | racket_boot(&ba); | 226 | | | 227 | 30 | split_fault_handlers(); | 228 | | | 229 | 30 | #ifdef RACKET_COVERAGE_COUNTERS | 230 | 30 | register_scheme_counters(); | 231 | 30 | #endif | 232 | | | 233 | 30 | #ifdef FUZZ_EMBEDDED | 234 | 30 | racket_embedded_load_bytes(fuzz_modules, fuzz_modules_end - fuzz_modules, 0); | 235 | 30 | #endif | 236 | | | 237 | 30 | { | 238 | 30 | #ifdef FUZZ_EMBEDDED | 239 | | /* "embed-modules.rkt" declares the module as 'fuzz:safe-eval */ | 240 | 30 | ptr mod_path = Scons(Sstring_to_symbol("quote"), | 241 | 30 | Scons(Sstring_to_symbol("fuzz:safe-eval"), Snil)); | 242 | | #else | 243 | | ptr mod_path = Scons(Sstring_to_symbol("file"), | 244 | | Scons(Sstring(FUZZ_MODULE), Snil)); | 245 | | #endif | 246 | 30 | ptr vals = racket_dynamic_require(mod_path, Sstring_to_symbol(FUZZ_ENTRY)); | 247 | 30 | entry_proc = Scar(vals); | 248 | 30 | Slock_object(entry_proc); | 249 | 30 | } | 250 | | | 251 | 30 | FUZZ_LSAN_ENABLE(); | 252 | | | 253 | 30 | initialized = 1; | 254 | | | 255 | 30 | return 0; | 256 | 30 | } |
Line | Count | Source | 179 | 30 | { | 180 | 30 | racket_boot_arguments_t ba; | 181 | | | 182 | 30 | atexit(check_initialized); | 183 | | | 184 | 30 | memset(&ba, 0, sizeof(ba)); | 185 | 30 | #ifdef FUZZ_EMBEDDED | 186 | 30 | ba.boot1_data = fuzz_petite_boot; | 187 | 30 | ba.boot1_len = fuzz_petite_boot_end - fuzz_petite_boot; | 188 | 30 | ba.boot2_data = fuzz_scheme_boot; | 189 | 30 | ba.boot2_len = fuzz_scheme_boot_end - fuzz_scheme_boot; | 190 | 30 | ba.boot3_data = fuzz_racket_boot; | 191 | 30 | ba.boot3_len = fuzz_racket_boot_end - fuzz_racket_boot; | 192 | 30 | ba.collects_dir = ""; | 193 | 30 | ba.config_dir = NULL; | 194 | | #else | 195 | | ba.boot1_path = BOOT_DIR "/petite.boot"; | 196 | | ba.boot2_path = BOOT_DIR "/scheme.boot"; | 197 | | ba.boot3_path = BOOT_DIR "/racket.boot"; | 198 | | /* A list of paths, each ending in NUL, with an extra NUL at the end; | 199 | | `parse_coldirs` in "boot.c" reads past a single NUL. */ | 200 | | ba.collects_dir = COLLECTS_DIR "\0"; | 201 | | ba.config_dir = CONFIG_DIR; | 202 | | #endif | 203 | 30 | ba.exec_file = "racket-fuzz"; | 204 | 30 | ba.exit_after = 0; | 205 | | #ifdef FUZZ_ADDON_DIR | 206 | | /* Naming the addon directory keeps Racket from finding it through | 207 | | the home directory, which looks in "/etc/passwd" when HOME is not | 208 | | set; "-n" is what a NULL `argv` would mean */ | 209 | | { | 210 | | static char *args[] = { "-A", FUZZ_ADDON_DIR, "-n", NULL }; | 211 | | ba.argc = 3; | 212 | | ba.argv = args; | 213 | | } | 214 | | #endif | 215 | | | 216 | | /* Racket keeps what it allocates while booting until the process | 217 | | exits, often referenced only from the Scheme heap, which | 218 | | LeakSanitizer does not scan; so don't report those as leaks. | 219 | | Leaks from running an input are still reported. */ | 220 | 30 | FUZZ_LSAN_DISABLE(); | 221 | | | 222 | 30 | sigaction(SIGSEGV, NULL, &sanitizer_segv); | 223 | 30 | sigaction(SIGBUS, NULL, &sanitizer_bus); | 224 | | | 225 | 30 | racket_boot(&ba); | 226 | | | 227 | 30 | split_fault_handlers(); | 228 | | | 229 | 30 | #ifdef RACKET_COVERAGE_COUNTERS | 230 | 30 | register_scheme_counters(); | 231 | 30 | #endif | 232 | | | 233 | 30 | #ifdef FUZZ_EMBEDDED | 234 | 30 | racket_embedded_load_bytes(fuzz_modules, fuzz_modules_end - fuzz_modules, 0); | 235 | 30 | #endif | 236 | | | 237 | 30 | { | 238 | 30 | #ifdef FUZZ_EMBEDDED | 239 | | /* "embed-modules.rkt" declares the module as 'fuzz:safe-eval */ | 240 | 30 | ptr mod_path = Scons(Sstring_to_symbol("quote"), | 241 | 30 | Scons(Sstring_to_symbol("fuzz:safe-eval"), Snil)); | 242 | | #else | 243 | | ptr mod_path = Scons(Sstring_to_symbol("file"), | 244 | | Scons(Sstring(FUZZ_MODULE), Snil)); | 245 | | #endif | 246 | 30 | ptr vals = racket_dynamic_require(mod_path, Sstring_to_symbol(FUZZ_ENTRY)); | 247 | 30 | entry_proc = Scar(vals); | 248 | 30 | Slock_object(entry_proc); | 249 | 30 | } | 250 | | | 251 | 30 | FUZZ_LSAN_ENABLE(); | 252 | | | 253 | 30 | initialized = 1; | 254 | | | 255 | 30 | return 0; | 256 | 30 | } |
|
257 | | |
258 | | /* Reports a bug found by "safe-eval.rkt" as a failed assertion, which |
259 | | prints the description and aborts. A fuzzing service groups crashes |
260 | | by an assertion's message, so bugs with different descriptions are |
261 | | reported separately, although they all end here. */ |
262 | | static void report_bug(const char *what) |
263 | 0 | { |
264 | 0 | __assert_fail(what, "safe-eval.rkt", 0, FUZZ_ENTRY); |
265 | 0 | } |
266 | | |
267 | | static void check_result(ptr vals) |
268 | 294k | { |
269 | 294k | ptr r; |
270 | | |
271 | 294k | if (!Spairp(vals)) |
272 | 0 | report_bug("no result"); |
273 | 294k | r = Scar(vals); |
274 | 294k | if (Sstringp(r)) { |
275 | 0 | char buf[256]; |
276 | 0 | iptr i, len = Sstring_length(r); |
277 | 0 | if (len > (iptr)sizeof(buf) - 1) |
278 | 0 | len = sizeof(buf) - 1; |
279 | 0 | for (i = 0; i < len; i++) { |
280 | 0 | string_char c = Sstring_ref(r, i); |
281 | 0 | buf[i] = ((c >= 32) && (c < 127)) ? (char)c : '?'; |
282 | 0 | } |
283 | 0 | buf[len] = 0; |
284 | 0 | report_bug(buf); |
285 | 294k | } else if (!Sfixnump(r) || (Sfixnum_value(r) != 0)) { |
286 | 0 | static const char *properties[] = { |
287 | 0 | NULL, |
288 | 0 | "print round trip failed", |
289 | 0 | "exact number round trip failed", |
290 | 0 | "inexact number round trip failed", |
291 | 0 | "regexp-match and regexp-match-positions disagree", |
292 | 0 | "fasl round trip failed", |
293 | 0 | "fasl->s-exp raised a value that is not exn:fail", |
294 | 0 | "heap check failed", |
295 | 0 | "compiled and interpreted evaluation disagree", |
296 | 0 | "compiled evaluation under a compiler variant disagrees" |
297 | 0 | }; |
298 | 0 | iptr n = Sfixnump(r) ? Sfixnum_value(r) : 0; |
299 | 0 | if ((n > 0) && (n < (iptr)(sizeof(properties) / sizeof(properties[0])))) |
300 | 0 | report_bug(properties[n]); |
301 | 0 | else |
302 | 0 | report_bug("wrong result"); |
303 | 0 | } |
304 | 294k | } Line | Count | Source | 268 | 147k | { | 269 | 147k | ptr r; | 270 | | | 271 | 147k | if (!Spairp(vals)) | 272 | 0 | report_bug("no result"); | 273 | 147k | r = Scar(vals); | 274 | 147k | if (Sstringp(r)) { | 275 | 0 | char buf[256]; | 276 | 0 | iptr i, len = Sstring_length(r); | 277 | 0 | if (len > (iptr)sizeof(buf) - 1) | 278 | 0 | len = sizeof(buf) - 1; | 279 | 0 | for (i = 0; i < len; i++) { | 280 | 0 | string_char c = Sstring_ref(r, i); | 281 | 0 | buf[i] = ((c >= 32) && (c < 127)) ? (char)c : '?'; | 282 | 0 | } | 283 | 0 | buf[len] = 0; | 284 | 0 | report_bug(buf); | 285 | 147k | } else if (!Sfixnump(r) || (Sfixnum_value(r) != 0)) { | 286 | 0 | static const char *properties[] = { | 287 | 0 | NULL, | 288 | 0 | "print round trip failed", | 289 | 0 | "exact number round trip failed", | 290 | 0 | "inexact number round trip failed", | 291 | 0 | "regexp-match and regexp-match-positions disagree", | 292 | 0 | "fasl round trip failed", | 293 | 0 | "fasl->s-exp raised a value that is not exn:fail", | 294 | 0 | "heap check failed", | 295 | 0 | "compiled and interpreted evaluation disagree", | 296 | 0 | "compiled evaluation under a compiler variant disagrees" | 297 | 0 | }; | 298 | 0 | iptr n = Sfixnump(r) ? Sfixnum_value(r) : 0; | 299 | 0 | if ((n > 0) && (n < (iptr)(sizeof(properties) / sizeof(properties[0])))) | 300 | 0 | report_bug(properties[n]); | 301 | 0 | else | 302 | 0 | report_bug("wrong result"); | 303 | 0 | } | 304 | 147k | } |
Line | Count | Source | 268 | 147k | { | 269 | 147k | ptr r; | 270 | | | 271 | 147k | if (!Spairp(vals)) | 272 | 0 | report_bug("no result"); | 273 | 147k | r = Scar(vals); | 274 | 147k | if (Sstringp(r)) { | 275 | 0 | char buf[256]; | 276 | 0 | iptr i, len = Sstring_length(r); | 277 | 0 | if (len > (iptr)sizeof(buf) - 1) | 278 | 0 | len = sizeof(buf) - 1; | 279 | 0 | for (i = 0; i < len; i++) { | 280 | 0 | string_char c = Sstring_ref(r, i); | 281 | 0 | buf[i] = ((c >= 32) && (c < 127)) ? (char)c : '?'; | 282 | 0 | } | 283 | 0 | buf[len] = 0; | 284 | 0 | report_bug(buf); | 285 | 147k | } else if (!Sfixnump(r) || (Sfixnum_value(r) != 0)) { | 286 | 0 | static const char *properties[] = { | 287 | 0 | NULL, | 288 | 0 | "print round trip failed", | 289 | 0 | "exact number round trip failed", | 290 | 0 | "inexact number round trip failed", | 291 | 0 | "regexp-match and regexp-match-positions disagree", | 292 | 0 | "fasl round trip failed", | 293 | 0 | "fasl->s-exp raised a value that is not exn:fail", | 294 | 0 | "heap check failed", | 295 | 0 | "compiled and interpreted evaluation disagree", | 296 | 0 | "compiled evaluation under a compiler variant disagrees" | 297 | 0 | }; | 298 | 0 | iptr n = Sfixnump(r) ? Sfixnum_value(r) : 0; | 299 | 0 | if ((n > 0) && (n < (iptr)(sizeof(properties) / sizeof(properties[0])))) | 300 | 0 | report_bug(properties[n]); | 301 | 0 | else | 302 | 0 | report_bug("wrong result"); | 303 | 0 | } | 304 | 147k | } |
|
305 | | |
306 | | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) |
307 | 294k | { |
308 | 294k | ptr bstr = Smake_bytevector(size, 0); |
309 | | |
310 | 294k | memcpy(Sbytevector_data(bstr), data, size); |
311 | 294k | check_result(racket_apply(entry_proc, Scons(bstr, Snil))); |
312 | | |
313 | 294k | return 0; |
314 | 294k | } Line | Count | Source | 307 | 147k | { | 308 | 147k | ptr bstr = Smake_bytevector(size, 0); | 309 | | | 310 | 147k | memcpy(Sbytevector_data(bstr), data, size); | 311 | 147k | check_result(racket_apply(entry_proc, Scons(bstr, Snil))); | 312 | | | 313 | 147k | return 0; | 314 | 147k | } |
Line | Count | Source | 307 | 147k | { | 308 | 147k | ptr bstr = Smake_bytevector(size, 0); | 309 | | | 310 | 147k | memcpy(Sbytevector_data(bstr), data, size); | 311 | 147k | check_result(racket_apply(entry_proc, Scons(bstr, Snil))); | 312 | | | 313 | 147k | return 0; | 314 | 147k | } |
|