2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 22:15:20 +00:00

fix: Accessing fctx->state without holding lock

Move lock earlier in the call sequence to address access without lock report.

```
1559        /*
1560         * Caller must be holding the fctx lock.
1561         */
      	
CID 468796: (#1 of 1): Data race condition (MISSING_LOCK)
1. missing_lock: Accessing fctx->state without holding lock fetchctx.lock. Elsewhere, fetchctx.state is written to with fetchctx.lock held 2 out of 2 times.
1562        REQUIRE(fctx->state == fetchstate_done);
1563
1564        FCTXTRACE("sendevents");
1565
1566        LOCK(&fctx->lock);
1567
```

Closes #4902

Merge branch '4902-accessing-fctx-state-without-holding-lock' into 'main'

Closes #4902

See merge request isc-projects/bind9!9427
This commit is contained in:
Mark Andrews
2024-08-29 12:46:12 +00:00

View File

@@ -1556,15 +1556,12 @@ fctx_sendevents(fetchctx_t *fctx, isc_result_t result) {
unsigned int new_spillat = 0; /* initialized to silence
* compiler warnings */
/*
* Caller must be holding the fctx lock.
*/
LOCK(&fctx->lock);
REQUIRE(fctx->state == fetchstate_done);
FCTXTRACE("sendevents");
LOCK(&fctx->lock);
/*
* Keep some record of fetch result for logging later (if required).
*/