kenz-gelsoft / gecko-dev

Read-only Git mirror of the Mercurial gecko repositories at https://hg.mozilla.org. How to contribute: https://firefox-source-docs.mozilla.org/contributing/contribution_quickref.html
https://firefox-source-docs.mozilla.org/setup/index.html
Other
13 stars 2 forks source link

Investigate IPDLTest_CrossProcess.TestShmem failure(2) #51

Open kenz-gelsoft opened 2 weeks ago

kenz-gelsoft commented 2 weeks ago

continue from https://github.com/kenz-gelsoft/gecko-dev/issues/49 as original issue became too long and noisy.

kenz-gelsoft commented 2 weeks ago

I think there are some reason recvmsg() called when unexpected state.

Try debugging incoming message side.

kenz-gelsoft commented 2 weeks ago

caller tree

kenz-gelsoft commented 2 weeks ago

IPCChannel initialization

after fork()

reverse connection established like this

for threads

kenz-gelsoft commented 2 weeks ago

Firefox IPC code relies heavily on many kind of IPC primitives including both pipes and signals.

So it may be problematic that Haiku's libevent port's signal handling relies on pipe not like other portedunix variants.

https://github.com/libevent/libevent/blob/f6e426c299acd80e85fef24c426fea45d36ace8d/signal.c#L183

kqueue on BSDs

I hoped ports for BSDs have had patches for firefox when they didn't support kqueue, but they had kqueue before libevent was born.

kenz-gelsoft commented 1 week ago

So it may be problematic that Haiku's libevent port's signal handling relies on pipe not like other portedunix variants.

Try disabling signal handling itself, but it didn't help at all.

libevent-2.1.12.patch.txt

kenz-gelsoft commented 1 week ago
    // Read from pipe.
    // recvmsg() returns 0 if the connection has closed or EAGAIN if no data
    // is waiting on the pipe.
    ssize_t bytes_read = HANDLE_EINTR(recvmsg(pipe_, &msg, MSG_DONTWAIT));
kenz-gelsoft commented 1 week ago
[IPDLUnitTest 10216, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages: pipe=3, fds=8,: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:364
[IPDLUnitTest 10216, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages2: num_fds=1: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:381
[Parent 10194, IPC I/O Parent] WARNING: ChannelImpl::Send0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:830
[Parent 10194, IPC I/O Parent] WARNING: ChannelImpl::Send: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:860
[Parent 10194, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:577
[IPDLUnitTest 10216, IPC I/O Child] WARNING: ChannelImpl::Send0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:830
[IPDLUnitTest 10216, IPC I/O Child] WARNING: ChannelImpl::Send: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:860
[Parent 10194, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages4: errno=-2147483637, written=140: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/commo[IPDLUnitTest 10216, IPC I/O Child] WARNING: ChannelImpl::ProcessOutgoingMessages: handles=0, fds=: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:677
[Parent 10194, IPC I/O Parent] WARNING: ChannelImpl::Send0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:830
[Parent 10194, IPC I/O Parent] WARNING: ChannelImpl::Send: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:860
-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:711
[Parent 10194, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:577
[Parent 10194, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages: handles=0, fds=: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:677
[Parent 10194, IPC I/O Parent] WARNING: corrected_sendmsg: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:115
[IPDLUnitTest 10216, IPC I/O Child] WARNING: Message needs unreceived descriptors channel:1114df5a0180 message-type:65531 header()->num_handles:1 num_fds:1 fds_i:1: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:494

failure:

success:

kenz-gelsoft commented 1 week ago

    if (msg.msg_controllen > 0) {
      // On OSX, CMSG_FIRSTHDR doesn't handle the case where controllen is 0
      // and will return a pointer into nowhere.
      for (struct cmsghdr* cmsg = CMSG_FIRSTHDR(&msg); cmsg;
           cmsg = CMSG_NXTHDR(&msg, cmsg)) {
        if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) {
          const unsigned payload_len = cmsg->cmsg_len - CMSG_LEN(0);
          DCHECK(payload_len % sizeof(int) == 0);
          wire_fds = reinterpret_cast<int*>(CMSG_DATA(cmsg));
          num_wire_fds = payload_len / 4;
kenz-gelsoft commented 1 week ago

https://searchfox.org/mozilla-esr128/source/ipc/chromium/src/chrome/common/ipc_channel_posix.cc#568

control buffer is local

is not a problem as this will be copied to kernel memory on call

kenz-gelsoft commented 1 week ago

https://github.com/haiku/haiku/blob/091140b15a920488f0456eeee4a5c00b5194ed6f/src/add-ons/kernel/network/stack/ancillary_data.cpp#L16

kenz-gelsoft commented 1 week ago

something wrong

shmem52.txt

kenz-gelsoft commented 1 week ago

shmem54.txt

[Parent 28715, IPC I/O Parent] WARNING: corrected_sendmsg: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:115
[Parent 28715, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages4: errno=-2147483637, written=148: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:728

p>c written=148

[IPDLUnitTest 28737, IPC I/O Child] WARNING: ChannelImpl::OnFileCanReadWithoutBlocking: fd=3: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:888
[Parent 28715, IPC I/O Parent] WARNING: ChannelImpl::ProcessIncomingMessages7: len=84: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:
[IPD
[Parent 28715, IPC I/O Parent] WARNING: ChannelImpl::ProcessIncomingMessages9: in_buf=84 len=84: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:478
nel_posix.cc:301
[IPDLUnitTest 28737, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages: pipe=3, fds=: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:369
[IPDLUnitTest 28737, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages5: num_fds=0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:386
[IPDLUnitTest 28737, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages7: len=148: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:431
[IPDLUnitTest 28737, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages9: in_buf=148 len=148: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:478
[Parent 28715, IPC I/O Parent] WARNING: ChannelImpl::Send0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:847
[Parent 28715, IPC I/O Parent] WARNING: ChannelImpl::Send: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:877
[Parent 28715, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:594
[Parent 28715, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages: handles=1, fds=24,: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome
[IPDLUnitTest 28737, IPC I/O Chil
[Parent 28715, IPC I/O Parent] WARNING: corrected_sendmsg: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/comm
[IPDLUnitTest 28737, IPC I/O Child] WARNING: ChannelImpl::ProcessOutgoingMessages0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:594
[Parent 28715, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages4: errno=-2147483637, written=116: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_po

p>c written=148+116=264

[IPDLUnitTe
[Parent 28715, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages6: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common
[IPDLUnitTest 28737, IPC I/O Child] WARNING: ChannelImpl::ProcessOutgoingMessages4: errno=-2147483637, written=116: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:728
[Parent 28715, IPC I/O Parent] WARNING: ChannelImpl::Send0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:847
[Parent 28715, IPC I/O Parent] WARNING: ChannelImpl::Send: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:877
[Parent 28715, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:594
[Parent 28715, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages: handles=1, fds=26,: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:694
[Parent 28715, IPC I/O Parent] WARNING: corrected_sendmsg: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:115
[Parent 28715, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages4: errno=-2147483637, written=116: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:728

p>c written=264+116=380

[Parent 28715, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages6: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:815
[Parent 28715, IPC I/O Parent] WARNING: ChannelImpl::Send0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:847
[Parent 28715, IPC I/O Parent] WARNING: ChannelImpl::Send: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:877
Couldn't convert chrome URL: chrome://branding/locale/brand.properties
[Parent 28715, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages: handles=0, fds=: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:694
[Parent 28715, IPC I/O Parent] WARNING: corrected_sendmsg: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:115
[IPDLUnitTest 28737, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages3: bytes_read=372 errno=-2147483637: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.

[Parent 28715, IPC I/O Parent] WARNING: ChannelImpl::Send0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:847 [Parent 28715, IPC I/O Parent] WARNING: ChannelImpl::Send: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:877 [Parent 28715, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:594 chrome/common/ipc_channel_posix.cc:492 [Parent 28715, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages: handles=0, fds=: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:694

[IPDLUnitTest 28737, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages7: len=116: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:431 [IPDLUnitTest 28737, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages9: in_buf=116 len=116: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:478 [IPDLUnitTest 28737, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages10: num_handles=1 num_fds=1 fds_i=1: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:492 [IPDLUnitTest 28737, IPC I/O Child] WARNING: Message needs unreceived descriptors channel:11c78a921180 message-type:65531 header()->num_handles:1 num_fds:1 fds_i:1: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:511

[IPDLUnitTest 28737, IPC I/O Child] WARNING: ChannelImpl::CloseLocked: pipe_=3: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:968 /common/ipc_channel_posix.cc:301

kenz-gelsoft commented 1 week ago
[IPDLUnitTest 29917, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages: pipe=3, fds=: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:369
[Parent 29895, IPC I/O Parent] WARNING: ChannelImpl::Send0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:847
[Parent 29895, IPC I/O Parent] WARNING: ChannelImpl::Send: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:877
[IPDLUnitTest 29917, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages9: in_buf=148 len=148: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/
[Parent 29895, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages: handles=0, fds=: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:694
[Parent 29895, IPC I/O Parent] WARNING: corrected_sendmsg: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:115
[Parent 29895, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages4: errno=-2147483637, written=148: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:728

p>c written=148

[Parent 29895, IPC I/O Parent] WARNING: ChannelImpl::ProcessIncomingMessages3: bytes_read=84 errno=-2147483637: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:301
[Parent 29895, IPC I/O Parent] WARNING: ChannelImpl::ProcessIncomingMessages: pipe=24, fds=: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/comm
[IPDLUnitTest 29917, IPC I/O
[Parent 29895, IPC I/O Parent] WARNING: ChannelImpl::ProcessIncomingMessages5: num_fds=0: file /boot/home/src/gecko-dev/ip
[IPDLUnitTest 29917, IPC I/O Child] WARNING: ChannelIm
[Parent 29895, IPC I/O Parent] WARNING: ChannelImpl::ProcessIncomingMessages7: len=84: file /boot/home/src/gecko-dev
[IPDLUnitTest 29917, IPC I/O Child] WARNING: ChannelImpl:
[Parent 29895, IPC I/O Parent] WARNING: ChannelImpl::ProcessIncomingMessages9: in_buf=84 len=84: file /boot/home/src/gecko-dev/ip
[IPDLUnitTest 29917, IPC I/O Child] WARNING: corrected_sendmsg: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:115
[IPDLUnitTest 29917, IPC I/O Child] WARNING: ChannelImpl::ProcessOutgoingMessages4: errno=-2147483637, written=148: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:728
[IPDLUnitTest 29917, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages3: bytes_read=148 errno=-2147483637: file /boot/home/src/gecko-de

child read=148


[Parent 29895, IPC I/O Parent] WARNING: ChannelImpl::Send:
[IPDLUnitTest 29917, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages: pipe
[Parent 29895, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages0: file /boot/home/s
[IPDLUnitTest 29917, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages5: num_fds=0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:386
[IPDLUnitTest 29917, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages7: len=148: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:431
[IPDLUnitTest 29917, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages9: in_buf=148 len=148: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:478
[Parent 29895, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages4: errno=-2147483637, written=116: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:728

p>c written=116

[Parent 29895, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages6: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:815
[IPDLUnitTest 29917, IPC I/O Child] WARNING: ChannelImpl::Send0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:847
[Parent 29895, IPC I/O Parent] WARNING: ChannelImpl::Send0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:847
877
[IPDLUnitTest 29917, IPC I/O Child] WARNING: ChannelImpl::ProcessOutgoingMessages0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:594
[Parent 29895, IPC I/O Parent] WARNING: ChannelImpl::Send: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:877
[Parent 29895, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channe
[IPDLUnitTest 2
[Parent 29895, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages: handles=1, fds=26,: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:694
[Parent 29895, IPC I/O Parent] WARNING: corrected_sendmsg: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:115

[IPDLUnitTest 29917, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages3: bytes_read=232 errno=-2147483637: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.

child read=232

[Parent
[IPDLUnitTest 29917, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages: pipe=3, fds=8,: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:369
[IPDLUnitTest 29917, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages5: num_fds=1: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:386
[IPDLUnitTest 29917, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages7: len=116: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:431
[IPDLUnitTest 29917, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages9: in_buf=116 len=116: file /boot/home/src/gecko-dev/ipc/chromium
[Parent 29895, IPC I/O Parent] WARNING: Chan
[IPDLUnitTest 29917, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages10: num_handles=1 nu
[Parent 29895, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:594
[IPDLUnitTest 29917, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages7: len=116: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:431
[IPDLUnitTest 29917, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages9: in_buf=116 len=116: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posi
[Parent 2
[IPDLUnitTest 29917, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages10: num_handles=1 num_fds=1 fds_i=1: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:492

[Parent 29895, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages4: errno=-2147483637, written=140: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:728

p>c write=140

[IPDLUnitTest 29917, IPC I/O Child] WARNING: Message needs unreceived descriptors channel:10852c5fc180 message-type:65531 header()->num_handles:1 num_fds:1 fds_i:1: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:511

[IPDLUnitTest 29917, IPC I/O Child] WARNING: ChannelImpl::CloseLocked: pipe_=3: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_c
kenz-gelsoft commented 1 week ago

shmem56.txt

It looks there are meny I/O Child thread simaltanously. Are there any synchronizing problem?

[IPDLUnitTest 33719, IPC I/O Child] WARNING: ChannelImpl::OnFileCanReadWithoutBlocking: fd=3: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:894
[IPDLUnitTest 33719, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:272
[IPDLUnitTest 33719, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages3: bytes_read=148 errno=-2147483637: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:301
[IPDLUnitTest 33719, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages: pipe=3, fds=: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:37
[P
[IPDLUnitTest 33719, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages5: num_fds=0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_pos
[Parent 33
[IPDLUnitTest 33719, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages7: len=148: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:437
[IPDLUnitTest 33719, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages9: in_buf=148 len=148: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:484
[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::Send0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:853
[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::Send: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:883
[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:600
[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages: handles=1, fds=24,: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:700
[Parent 33697, IPC I/O Parent] WARNING: corrected_sendmsg: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:115
[IPDLUnitTest 33719, IPC I/O Child] WARNING: ChannelImpl::Send0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:853
[IPDLUnitTest 33719, IPC I/O Child] WARNING: ChannelImpl::Send: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:883
[IPDLUnitTest 33719, IPC I/O Child] WARNING: ChannelImpl::ProcessOutgoingMessages0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:600
[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::Send0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:853
/chrome/common/ipc_channel_posix.cc:700
[IPDLUnitTest 33719, IPC I/O Child] WARNING: corrected_sendmsg: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc
[Pare
[IPDLUnitTest 33719, IPC I/O Child] WARNING: ChannelImpl::ProcessOutgoingMessages4: errno=-2147483637, written=116: file /boot/home/src/gecko-dev/ipc/chromium/s
[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages: handles=1, fds=26,: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:700
[Parent 33697, IPC I/O Parent] WARNING: corrected_sendmsg: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:115
[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages4: errno=-2147483637, written=116: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:734
[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages6: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:821
[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::Send0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:853
[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::Send: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:883
[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:600
[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages: handles=0, fds=: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:700
[Parent 33697, IPC I/O Parent] WARNING: corrected_sendmsg: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:115
[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages4: errno=-2147483637, written=140: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:734
[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::Send0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:853
[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::Send: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:883
[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:600
[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages: handles=0, fds=: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:700
[Parent 33697, IPC I/O Parent] WARNING: corrected_sendmsg: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:115
[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages4: errno=-2147483637, written=148: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:734
[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::ProcessIncomingMessages7: len=148: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:437
[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::ProcessIncomingMessages9: in_buf=148 len=148: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:484
[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::Send0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:853
[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::Send: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:883
[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:600
[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages: handles=0, fds=: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:700
[Parent 33697, IPC I/O Parent] WARNING: corrected_sendmsg: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:115
[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::ProcessOutgoingMessages4: errno=-2147483637, written=116: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:734
[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::Send0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:853
[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::Send: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:883

It seems multiple entries with same leven and type lives in single msghdr.

[IPDLUnitTest 33719, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages10: num_handles=1 num_fds=1 fds_i=0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_chann[Parent 33697, IPC I/O Parent] WARNING: ChannelImpl::ProcessIncomingMessages5: num_fds=0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:392 [IPDLUnitTest 33719, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages7: len=116: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:437 [IPDLUnitTest 33719, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages9: in_buf=116 len=116: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:484

[IPDLUnitTest 33719, IPC I/O Child] WARNING: ChannelImpl::ProcessIncomingMessages10: num_handles=1 num_fds=1 fds_i=1: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:498 [IPDLUnitTest 33719, IPC I/O Child] WARNING: Message needs unreceived descriptors channel:1106a53bb180 message-type:65531 header()->num_handles:1 num_fds:1 fds_i:1: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:517

[IPDLUnitTest 33719, IPC I/O Child] WARNING: ChannelImpl::CloseLocked: pipe_=3: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:974

kenz-gelsoft commented 1 week ago

I believe finally worked around this in

49f2c4c4fb52ed194241893dcdf92e840a7e1aee

especially here

https://github.com/kenz-gelsoft/gecko-dev/commit/49f2c4c4fb52ed194241893dcdf92e840a7e1aee#diff-53c180d030335b5786f59f1fee7f920440c13dff8cafe18082f86a70ea99bb27R357

kenz-gelsoft commented 1 week ago

it should support three or more cmsgs with fd case

[Parent 52237, IPC I/O Parent] WARNING: ChannelImpl::ProcessIncomingMessages3.5: level=-1 type=1 msgflags=0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:348
[Child 52628, Main Thread] WARNING: corrected_sendmsg: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:115
[Parent 52237, IPC I/O Parent] WARNING: ChannelImpl::ProcessIncomingMessages3.6: paylen=4: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:354
[Child 52628, Main Thread] WARNING: ChannelImpl::ProcessOutgoingMessages4: errno=0, written=116: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:741
[Parent 52237, IPC I/O Parent] WARNING: ChannelImpl::ProcessIncomingMessages3.5: level=-1 type=1 msgflags=0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:348
[Child 52628, Main Thread] WARNING: ChannelImpl::ProcessOutgoingMessages6: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:828
[Parent 52237, IPC I/O Parent] WARNING: ChannelImpl::ProcessIncomingMessages3.6: paylen=4: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:354
[Child 52628, Main Thread] WARNING: ChannelImpl::Send0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:860
[Parent 52237, IPC I/O Parent] WARNING: ChannelImpl::ProcessIncomingMessages3.5: level=-1 type=1 msgflags=0: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:348
[Child 52628, Main Thread] WARNING: ChannelImpl::Send: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:890
[Parent 52237, IPC I/O Parent] WARNING: ChannelImpl::ProcessIncomingMessages3.6: paylen=4: file /boot/home/src/gecko-dev/ipc/chromium/src/chrome/common/ipc_channel_posix.cc:354
kenz-gelsoft commented 1 week ago

@waddlesplash Hello.

I finally identified how Haiku's sendmsg/recvmsg differs to other OSes.

When we sendmsg() with FD multiple times before recvmsg(), Haiku's recvmsg() will receive multiple cmsghdr entries that are SOL_SOCKET and SCM_RIGHT.

Firefox code expects just one cmsghdr entry with same level and type per single msghdr. (This implies sent FDs should be merged into single cmsghdr.) So that code lost FDs in 2nd or later cmsghdr entires in that msghdr.

This leads to the "Message needs unreceived descriptor..." error.

Now I could worked around this with change like this

24f71e6daa9803350956d46298e5632840bb556b...1be7f9426c920000d50010ac5dbbe5b0140b161a

On my side, workaround is OK for now, do you think this is a bug of Haiku, or not?

waddlesplash commented 1 week ago

(This implies sent FDs should be merged into single cmsghdr.)

Ah, interesting!

I guess if every other OS merges the cmsghdrs on recvmsg, then we should too. I glanced at the POSIX specification (here and here) but didn't immediately see anything indicating they had to be merged.

I can look at adjusting Haiku to behave differently sometime this week. (Meanwhile, is there a stable version of the Wayland server with the fixes necessary for Firefox available? Or is it still just the WIP commits?)

kenz-gelsoft commented 1 week ago

(Meanwhile, is there a stable version of the Wayland server with the fixes necessary for Firefox available? Or is it still just the WIP commits?)

This is WIP branch of X512's work.

https://github.com/X547/wayland-server/tree/work

I just requested him to continue work on publishing this in https://github.com/kenz-gelsoft/gecko-dev/issues/33#issuecomment-2409907175.

kenz-gelsoft commented 1 week ago

(This implies sent FDs should be merged into single cmsghdr.)

Ah, interesting!

I guess if every other OS merges the cmsghdrs on recvmsg, then we should too. I glanced at the POSIX specification (here and here) but didn't immediately see anything indicating they had to be merged.

I can look at adjusting Haiku to behave differently sometime this week.

Thanks. I didn't look into other OS's implementations on this too. So my assumption may be false. But now we know what doesn't work well in some detail, so correct fix should be found easily...

kenz-gelsoft commented 1 week ago

I guess if every other OS merges the cmsghdrs on recvmsg, then we should too. I glanced at the POSIX specification (here and here) but didn't immediately see anything indicating they had to be merged.

I can look at adjusting Haiku to behave differently sometime this week.

I read the recvmsg() manpages of some OSes, there is recvmmsg() to retrieve multiple message at a call. This implies readmsg() should not return multiple sendmsg() results at a time.

I suspect it has a bug returning all or multiple control messages at once.

Contiguous buffer to multiple control messages is ok. But should not be reached with CMSG_NXTHDR().

kenz-gelsoft commented 1 week ago

We shouldn't loop on container here as we support only SCM_RIGHT, we need to take the first element for a message.

https://github.com/haiku/haiku/blob/fb993aa0637c5a2f4a2735d305ed5b497e1fef23/src/add-ons/kernel/network/stack/net_socket.cpp#L249

waddlesplash commented 1 week ago

This implies readmsg() should not return multiple sendmsg() results at a time.

It is allowed to for SOCK_STREAM type sockets, which this is. It must return only one for SOCK_DGRAM, though.

kenz-gelsoft commented 1 week ago

Their difference is partial message can be sent/received on SOCK_STREAM with streaming usage of packets, and complete message(es) must be packed into single packet on SOCK_DGRAM, I read.

without MSG_WAITALL flag, it won't contain multiple messages.

   The recvmsg() function shall return the total length of the
   message. For message-based sockets, such as SOCK_DGRAM and
   SOCK_SEQPACKET, the entire message shall be read in a single
   operation. If a message is too long to fit in the supplied
   buffers, and MSG_PEEK is not set in the flags argument, the
   excess bytes shall be discarded, and MSG_TRUNC shall be set in
   the msg_flags member of the msghdr structure. For stream-based
   sockets, such as SOCK_STREAM, message boundaries shall be
   ignored. In this case, data shall be returned to the user as soon
   as it becomes available, and no data shall be discarded.

   If the MSG_WAITALL flag is not set, data shall be returned only
   up to the end of the first message.

https://www.man7.org/linux/man-pages/man3/recvmsg.3p.html

Firefox's code has logic for partial message, but I didn't hit them in debugging on Haiku.

Dumping pending iovecs and control msgs with synthesized msghdr can be work, but not compatible, I think.

waddlesplash commented 1 week ago

Not only partial messages but multiple messages can be sent/received at once.

We build the msghdr in the kernel at the time of recvmsg, so we can just alter the logic there to create only one, I think.

kenz-gelsoft commented 1 week ago

Sorry for disturbing you without evidence or confidence on this. I will stop guessing.

If I found something certainly, I will share it.