bryancall opened a new pull request, #14062:
URL: https://github.com/apache/trafficserver/pull/14062
stek_share starts its STEK updater thread with `TSThreadCreate`, which
creates the thread detached, and its shutdown hook then called
`pthread_join` on it. Joining a detached thread is undefined behavior.
glibc returns EINVAL without waiting, so shutdown never waited for the
updater, and ASAN builds abort `traffic_server` on exit with
"AddressSanitizer: Joining detached thread". The stek_share test did not
notice, because nothing checked how the nodes exited.
This keeps the `TSThread` handle that `TSThreadCreate` returns and waits on
it with `TSThreadWait`. The updater now sleeps on a condition variable that
shutdown signals, so shutdown does not wait out its 10 second poll. The
updater is also stopped before the raft server and state machine are torn
down, since it calls into both. The unused asynchronous cancel setup is
removed.
### Testing
The stek_share Uranium test now sends SIGTERM to all five nodes, requires
each to exit with status 0, and checks that each logged "Stopping STEK
updater thread".
ASAN build of preset `ci-fedora-urtest` in the fedora:45 CI image, on an
isolated network. The red runs use master's stek_share sources with the new
test:
| Build | Result |
|---|---|
| master | 0 of 10 passed. Every run: a node exited with status 1, "Joining
detached thread" on 5 of 5 nodes, the updater stop logged on 0 of 5 |
| master, `ASAN_OPTIONS=detect_invalid_join=0` | 0 of 5 passed. No sanitizer
report and every node exited 0, as in a build without ASAN, but none logged the
updater stop |
| this PR | 10 of 10 passed. No sanitizer report, the updater stop logged on
5 of 5 nodes |
| this PR, `detect_invalid_join=0` | 3 of 3 passed |
### Known follow-ups, not in this PR
- `TSThreadWait` checks its completion flag with `if` rather than `while`
around `ink_cond_wait`, so a spurious wakeup could return early. That is
a core API fix for a separate PR.
- Because raft is now shut down after the updater stops, a leader that is
inside a blocking `append_log` when shutdown starts makes shutdown wait
for it, up to `client_req_timeout` (3 seconds by default).
- The config reload path in `message_handler` still shuts down and resets
raft while the updater may be using it, the same race this fixes for
shutdown.
- The test catches a shutdown that never wakes the updater, or that joins
it, but not one that wakes it without waiting for it, or that stops it
after raft is torn down.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]