"cmd/compile/internal/staticinit"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
+ "cmd/internal/objabi"
"cmd/internal/src"
)
// __libfuzzer_extra_counters.
counter := staticinit.StaticName(types.Types[types.TUINT8])
counter.SetLibfuzzerExtraCounter(true)
+ // As well as setting SetLibfuzzerExtraCounter, we preemptively set the
+ // symbol type to SLIBFUZZER_EXTRA_COUNTER so that the race detector
+ // instrumentation pass (which does not have access to the flags set by
+ // SetLibfuzzerExtraCounter) knows to ignore them. This information is
+ // lost by the time it reaches the compile step, so SetLibfuzzerExtraCounter
+ // is still necessary.
+ counter.Linksym().Type = objabi.SLIBFUZZER_EXTRA_COUNTER
// counter += 1
incr := ir.NewAssignOpStmt(base.Pos, ir.OADD, counter, ir.NewInt(1))
r io.Reader
}
-func (cr *contextReader) Read(b []byte) (n int, err error) {
- if err := cr.ctx.Err(); err != nil {
- return 0, err
+func (cr *contextReader) Read(b []byte) (int, error) {
+ if ctxErr := cr.ctx.Err(); ctxErr != nil {
+ return 0, ctxErr
}
done := make(chan struct{})
// This goroutine may stay blocked after Read returns because the underlying
// read is blocked.
+ var n int
+ var err error
go func() {
n, err = cr.r.Read(b)
close(done)