Bug 239803 - Problem with concurrent transfer of file descriptors
Summary: Problem with concurrent transfer of file descriptors
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 12.0-STABLE
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs mailing list
Depends on:
Reported: 2019-08-12 16:07 UTC by knizhnik@garret.ru
Modified: 2019-08-12 16:07 UTC (History)
0 users

See Also:

Reporduce the problem with file description corruption (3.75 KB, text/plain)
2019-08-12 16:07 UTC, knizhnik@garret.ru
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description knizhnik@garret.ru 2019-08-12 16:07:53 UTC
Created attachment 206476 [details]
Reporduce the problem with file description corruption

Transferring file descriptors to another process without waiting confirmations leads to unexpected behavior: descriptor is successfully transferred but attempt to read from is reported as EOF (recv returns 0).

Attached example reproduces the problem (please build it with -pthread option).
If number of client threads is set to 1, then problem is not reproduced.
Another way to fix the problem is to wait confirmation about descriptor delivery and close socket only after it.

It is seems to be critical that socket should not be closed before confirmation of the transfer: if we wait confirmation but close socket before, then the problem is still persists.

The bug is reproduced at several versions of FreeBSD including 12.0-stable and also recent Mac-OS/X.

There was bug report with similar symptoms:

But looks likes r343784 is not fixing it.