Opened 5 years ago

Closed 5 years ago

#13291 closed defect (fixed)

Fix spawn test failures due to race condition with process exiting early

Reported by: teor Owned by:
Priority: Medium Milestone: Tor: 0.2.6.x-final
Component: Core Tor/Tor Version: Tor: unspecified
Severity: Keywords:
Cc: nickm Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

When a spawned process forks, fails, then exits very quickly, (this typically occurs when exec fails), there is a race condition between the SIGCHLD handler updating the process_handle's fields, and checking the process status in those fields. The update can occur before or after the tests check the process status.

This causes intermittent failures in the test spawn_background_fail(), typically when the machine is under load. I've created a patch that checks whether the process is running or not running (rather than just checking if it is running) to avoid this issue.

I'll submit a github branch once I have the bug number for the changes file name.

tor version: 2.6.0-alpha-dev

Child Tickets

Attachments (1)

continuous-testing.sh (173 bytes) - added by teor 5 years ago.
Test for intermittent errors by repeatedly running make test until it fails

Download all attachments as: .zip

Change History (4)

Changed 5 years ago by teor

Attachment: continuous-testing.sh added

Test for intermittent errors by repeatedly running make test until it fails

comment:1 Changed 5 years ago by teor

Status: newneeds_review

I've committed a fix to github at:

Branch: test-spawn-fail-race-condition
Repository: ​​https://github.com/teor2345/tor.git
Commit: 9b56f4c5922a33ab80a6e46626c8448599836cd5

tor tests now run without occasionally (due to the race condition) failing when comparing process status in spawn_background_fail() in test_util.c. This typically happens under load (like a simultaneous compile).

comment:2 Changed 5 years ago by nickm

Milestone: Tor: 0.2.6.x-final

comment:3 Changed 5 years ago by nickm

Resolution: fixed
Status: needs_reviewclosed

Looks good; I've parenthesized the macro arguments, removed end-of-line whitespace, noted when the bug appears to have been introduced, and merged. Thanks!

Note: See TracTickets for help on using tickets.