Skip to content

Commit d2fd0c0

Browse files
arg0dzx2c4
authored andcommitted
device: allocate new buffer in receive death spiral
Note: this bug is "hidden" by avoiding "death spiral" code path by 6228659 ("device: handle broader range of errors in RoutineReceiveIncoming"). If the code reached "death spiral" mechanism, there would be multiple double frees happening. This results in a deadlock on iOS, because the pools are fixed size and goroutine might stop until somebody makes space in the pool. This was almost 100% repro on the new ARM Macbooks: - Build with 'ios' tag for Mac. This will enable bounded pools. - Somehow call device.IpcSet at least couple of times (update config) - device.BindUpdate() would be triggered - RoutineReceiveIncoming would enter "death spiral". - RoutineReceiveIncoming would stall on double free (pool is already full) - The stuck routine would deadlock 'device.closeBindLocked()' function on line 'netc.stopping.Wait()' Signed-off-by: Kristupas Antanavičius <[email protected]> Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent 5f6bbe4 commit d2fd0c0

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

device/receive.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ func (device *Device) RoutineReceiveIncoming(recv conn.ReceiveFunc) {
104104
if deathSpiral < 10 {
105105
deathSpiral++
106106
time.Sleep(time.Second / 3)
107+
buffer = device.GetMessageBuffer()
107108
continue
108109
}
109110
return

0 commit comments

Comments
 (0)