Commit 15f79be
committed
Fix SIGABRT when destroying OdCDS handles on worker threads
The OdCdsApiHandleImpl destructor can be invoked on worker threads when
filters are removed (e.g., during VHDS filter updates). When the last
reference to an OdCdsApiSharedPtr is destroyed on a worker thread, the
subscription cleanup code attempts to run on the wrong thread, causing
an assertion failure or SIGABRT since subscription operations must
execute on the main thread.
This fix adds a destructor to OdCdsApiHandleImpl that checks if destruction
is happening on a worker thread. If so, it dispatches the OdCdsApiSharedPtr
destruction to the main thread dispatcher via a lambda, ensuring the
subscription is properly cleaned up on the thread where it was created.
The fix follows the same pattern used elsewhere in Envoy (e.g.,
ThreadLocal::SlotImpl destructor) for cross-thread cleanup operations.
Note: A longer-term optimization could cache and reuse OdCDS handles in
ClusterManager with reference counting and deferred cleanup, avoiding
unnecessary subscription teardown/recreation during filter rotations.
This is tracked by the existing TODO in allocateOdCdsApi().
Signed-off-by: William Dauchy <[email protected]>1 parent 6602938 commit 15f79be
File tree
2 files changed
+74
-0
lines changed- source/common/upstream
- test/common/upstream
2 files changed
+74
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
481 | 482 | | |
482 | 483 | | |
483 | 484 | | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
484 | 503 | | |
485 | 504 | | |
486 | 505 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| 11 | + | |
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
| 16 | + | |
| 17 | + | |
13 | 18 | | |
14 | 19 | | |
15 | 20 | | |
| |||
275 | 280 | | |
276 | 281 | | |
277 | 282 | | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
278 | 333 | | |
279 | 334 | | |
280 | 335 | | |
0 commit comments