From 991110ce9de9f08b90471c43b8143754becc0c67 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 14 Aug 2020 14:07:37 +0200 Subject: pkg/csource: add comment re ignoring cpp errors Clarify why we ignore cpp errors. --- pkg/csource/common.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'pkg/csource') diff --git a/pkg/csource/common.go b/pkg/csource/common.go index a4adf3a56..f1e8a21b4 100644 --- a/pkg/csource/common.go +++ b/pkg/csource/common.go @@ -42,8 +42,15 @@ func createCommonHeader(p, mmapProg *prog.Prog, replacements map[string]string, stdout := new(bytes.Buffer) cmd.Stderr = stderr cmd.Stdout = stdout + // Note: we ignore error because we pass -nostdinc so there are lots of errors of the form: + // error: no include path in which to search for stdlib.h + // This is exactly what we want: we don't want these to be included into the C reproducer. + // But the downside is that we can miss some real errors, e.g.: + // error: missing binary operator before token "SYZ_SANDBOX_ANDROID" + // 3776 | #if not SYZ_SANDBOX_ANDROID + // Potentially we could analyze errors manually and ignore only the expected ones. if err := cmd.Run(); len(stdout.Bytes()) == 0 { - return nil, fmt.Errorf("cpp failed: %v\n%v\n%v", err, stdout.String(), stderr.String()) + return nil, fmt.Errorf("cpp failed: %v %v: %v\n%v\n%v", cmd.Path, cmd.Args, err, stdout.String(), stderr.String()) } src, err := removeSystemDefines(stdout.Bytes(), defines) -- cgit mrf-deployment