[Bug 257368] ggate(d) misbehaving

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 24 Jul 2021 01:47:00 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257368

--- Comment #4 from johannes@jo-t.de ---
> Looks like the code is expecting to be able to send/receive pretty huge packets as is, instead of breaking it up into smaller chunks.

Ignore that, found the helper function that breaks it up.


Here's a truss of ggated:


debug: Received hdr packet.
 2008: write(1,"debug: Received hdr packet.\n",28) = 28 (0x1c)
debug: recv_thread: offset=16384 length=2147467264
 2008: write(1,"debug: recv_thread: offset=16384"...,51) = 51 (0x33)
 2008: mmap(0x0,2147487744,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) =
56795097997312 (0x33a7a3a42000)
 2008: mmap(0x0,6291456,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) =
56797253623808 (0x33a824206000)
 2008: munmap(0x33a824206000,6291456)            = 0 (0x0)
 2008: mmap(0x0,8384512,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) =
56797253255168 (0x33a8241ac000)
 2008: munmap(0x33a8241ac000,344064)             = 0 (0x0)
 2008: munmap(0x33a824800000,1748992)            = 0 (0x0)
 2008: _umtx_op(0x33a783f9f1b8,UMTX_OP_NWAKE_PRIVATE,0x1,0x0,0x0) = 0 (0x0)
 2008: _umtx_op(0x33a77e55dfd0,UMTX_OP_WAIT_UINT_PRIVATE,0x0,0x0,0x0) = 0 (0x0)
debug: disk_thread: offset=16384 length=2147467264
 2008: write(1,"debug: disk_thread: offset=16384"...,51) = 51 (0x33)
 2008: pread(7,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,2147467264,0x4000) =
2147467264 (0x7fffc000)
 2008: _umtx_op(0x33a783f9e2b8,UMTX_OP_NWAKE_PRIVATE,0x1,0x0,0x0) = 0 (0x0)
 2008: _umtx_op(0x33a794e63008,UMTX_OP_WAIT_UINT_PRIVATE,0x0,0x0,0x0) = 0 (0x0)
debug: send_thread: offset=16384 length=2147467264
 2008: write(1,"debug: send_thread: offset=16384"...,51) = 51 (0x33)
 2008: sendto(6,"\0\0\0\0\0\0\0@\0\^?\M^?\M-@\0\0"...,23,0,NULL,0) = 23 (0x17)
debug: Sent hdr packet.
 2008: write(1,"debug: Sent hdr packet.\n",24)   = 24 (0x18)
 2008: sendto(6,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,131072,0,NULL,0) = 131072
(0x20000)
 2008: sendto(6,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,131072,0,NULL,0) = 131072
(0x20000)
 2008: sendto(6,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,131072,0,NULL,0) = 131072
(0x20000)
 2008: recvfrom(8,0x33a796ff97b0,23,MSG_WAITALL,NULL,0x0) = 0 (0x0)
 2008: getpid()                                  = 2008 (0x7d8)
debug: Process 2008 exiting.
 2008: write(1,"debug: Process 2008 exiting.\n",29) = 29 (0x1d)
 2008: sendto(6,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,131072,0,NULL,0) = 131072
(0x20000)



We can see that ggated allocs a big chunk of mem and successfully reads data
into it and then tries to send it off, in chunks of 128kB. So far so good.
But then the receive thread notices that it did not read a full header and thus
exits and the whole process dies only having sent 4x128kB.

Smells like a race condition?

-- 
You are receiving this mail because:
You are the assignee for the bug.