Commit 78cebc7
issue: 4409403 Fix heap corruption since c73d96a
This commit fixes a critical race condition in timer management for TCP
sockets that was introduced in commit c73d96a.
The heap corruption was caused by a race condition between the timer
thread and socket destruction. Sockets could be deleted by the event
handler thread while still being referenced by the timer thread in the
timer collections, resulting in heap corruption when the timer thread
attempted to access the deleted memory.
In the original implementation, sockets were removed from timer
collections and deleted asynchronously without proper synchronization
with the timer processing thread.
Fix:
- Remove sockets from timer collections while still holding the socket
lock, guaranteeing the timer thread cannot access sockets marked for
deletion
- Create a simplified deletion path that doesn't attempt to access timer
collections again after socket cleanup
Additionally, as an unrelated improvement, this patch fixes a lock leak
in the early return path of sockinfo_tcp::clean_socket_obj() where a
lock was acquired but not released when a socket was already marked as
cleaned.
The heap corruption stemmed from a fundamental architectural change that
separated socket objects from their timer management without providing
proper synchronization for the distributed socket lifecycle.
Signed-off-by: Tomer Cabouly <[email protected]>1 parent f590cf8 commit 78cebc7
File tree
3 files changed
+18
-10
lines changed- src/core
- event
- sock
3 files changed
+18
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
159 | | - | |
| 159 | + | |
160 | 160 | | |
161 | | - | |
| 161 | + | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
| 164 | + | |
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| |||
421 | 421 | | |
422 | 422 | | |
423 | 423 | | |
424 | | - | |
425 | | - | |
426 | 424 | | |
427 | 425 | | |
428 | 426 | | |
| |||
441 | 439 | | |
442 | 440 | | |
443 | 441 | | |
| 442 | + | |
| 443 | + | |
444 | 444 | | |
445 | 445 | | |
446 | 446 | | |
| |||
703 | 703 | | |
704 | 704 | | |
705 | 705 | | |
706 | | - | |
| 706 | + | |
707 | 707 | | |
708 | | - | |
| 708 | + | |
709 | 709 | | |
710 | 710 | | |
711 | 711 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
| 170 | + | |
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
595 | 595 | | |
596 | 596 | | |
597 | 597 | | |
| 598 | + | |
598 | 599 | | |
599 | 600 | | |
600 | 601 | | |
601 | 602 | | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
602 | 610 | | |
603 | 611 | | |
604 | 612 | | |
605 | 613 | | |
606 | 614 | | |
607 | 615 | | |
608 | 616 | | |
609 | | - | |
| 617 | + | |
610 | 618 | | |
611 | 619 | | |
612 | 620 | | |
| |||
0 commit comments