xref: /aosp_15_r20/external/toolchain-utils/compiler_wrapper/kernel_bug.go (revision 760c253c1ed00ce9abd48f8546f08516e57485fe)
1// Copyright 2021 The ChromiumOS Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4package main
5
6import (
7	"bytes"
8	"strings"
9)
10
11// crbug.com/1166017
12
13const kernelBugRetryLimit = 25
14
15// GCC will sometimes fail to wait on subprocesses due to this kernel bug. It always fails the
16// compilation and prints "Unknown error 512" in that case.
17func containsTracesOfKernelBug(buf []byte) bool {
18	return bytes.Contains(buf, []byte("Unknown error 512"))
19}
20
21func errorContainsTracesOfKernelBug(err error) bool {
22	// We'll get errors that look like "waitid: errno 512." Presumably, this isn't specific to
23	// waitid, so just try to match the "errno 512" ending.
24	return err != nil && strings.HasSuffix(err.Error(), "errno 512")
25}
26