Commit e7b8f0c
committed
Fix listener publication race in socket driver
That commit fixed the close-time double-unlink/use-after-free race in
generic_unix listener teardown. This change addresses a separate race in
listener registration, where a listener could become visible to the
event loop before socket_data published the corresponding pointer. Both
fixes are needed; this patch complements the earlier teardown fix rather
than replacing it.
Fix a race in the generic_unix socket driver where newly created
listeners were registered in the global listener list before the
corresponding socket_data->{active,passive}_listener pointer was
published.
If the event loop processed the listener in that window, the callback
could consume, free, or replace the listener before the socket driver
stored the pointer. The later assignment then left socket_data
pointing at stale listener memory, which could surface as random hangs
or corruption in gen_tcp tests, including timeouts waiting for the
server helper process to start.
Publish the listener pointer before calling sys_register_listener
in all affected paths:
active UDP receive listener setup
active TCP receive listener setup
passive recv/recvfrom listener setup
accept listener setup
This complements the earlier close-path fix by removing another
generic_unix listener lifecycle race.
Signed-off-by: Peter M <petermm@gmail.com>1 parent 34a3287 commit e7b8f0c
1 file changed
+12
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
258 | | - | |
| 258 | + | |
| 259 | + | |
259 | 260 | | |
| 261 | + | |
260 | 262 | | |
261 | 263 | | |
262 | 264 | | |
| |||
340 | 342 | | |
341 | 343 | | |
342 | 344 | | |
343 | | - | |
| 345 | + | |
| 346 | + | |
344 | 347 | | |
| 348 | + | |
345 | 349 | | |
346 | 350 | | |
347 | 351 | | |
| |||
1017 | 1021 | | |
1018 | 1022 | | |
1019 | 1023 | | |
1020 | | - | |
| 1024 | + | |
| 1025 | + | |
1021 | 1026 | | |
| 1027 | + | |
1022 | 1028 | | |
1023 | 1029 | | |
1024 | 1030 | | |
| |||
1119 | 1125 | | |
1120 | 1126 | | |
1121 | 1127 | | |
1122 | | - | |
| 1128 | + | |
| 1129 | + | |
1123 | 1130 | | |
| 1131 | + | |
1124 | 1132 | | |
1125 | 1133 | | |
1126 | 1134 | | |
| |||
0 commit comments