| 404 | } |
| 405 | |
| 406 | func (p *Process) checkForProblems(logfd *os.File) error { |
| 407 | fd, err := os.Open(logfd.Name()) |
| 408 | if err != nil { |
| 409 | return err |
| 410 | } |
| 411 | defer fd.Close() |
| 412 | |
| 413 | raceConditionStart := []byte("WARNING: DATA RACE") |
| 414 | raceConditionSep := []byte("==================") |
| 415 | panicConditionStart := []byte("panic:") |
| 416 | panicConditionSep := []byte("[") // fallback if we don't already know our ID |
| 417 | if p.id.String() != "" { |
| 418 | panicConditionSep = []byte(p.id.String()[:5]) |
| 419 | } |
| 420 | sc := bufio.NewScanner(fd) |
| 421 | race := false |
| 422 | _panic := false |
| 423 | |
| 424 | for sc.Scan() { |
| 425 | line := sc.Bytes() |
| 426 | if race || _panic { |
| 427 | if bytes.Contains(line, panicConditionSep) { |
| 428 | _panic = false |
| 429 | continue |
| 430 | } |
| 431 | fmt.Printf("%s\n", line) |
| 432 | if bytes.Contains(line, raceConditionSep) { |
| 433 | race = false |
| 434 | } |
| 435 | } else if bytes.Contains(line, raceConditionStart) { |
| 436 | fmt.Printf("%s\n", raceConditionSep) |
| 437 | fmt.Printf("%s\n", raceConditionStart) |
| 438 | race = true |
| 439 | if err == nil { |
| 440 | err = errors.New("Race condition detected") |
| 441 | } |
| 442 | } else if bytes.Contains(line, panicConditionStart) { |
| 443 | _panic = true |
| 444 | if err == nil { |
| 445 | err = errors.New("Panic detected") |
| 446 | } |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | return err |
| 451 | } |
| 452 | |
| 453 | func (p *Process) eventLoop() { |
| 454 | since := 0 |