[Bug 231848] accept4() doesn't return a socket address when threading is involved

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Bug 231848] accept4() doesn't return a socket address when threading is involved

bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=231848

            Bug ID: 231848
           Summary: accept4() doesn't return a socket address when
                    threading is involved
           Product: Base System
           Version: 11.2-STABLE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: threads
          Assignee: [hidden email]
          Reporter: [hidden email]

We've added threading support to socket_wrapper [1] which is a tool to create
artificial networks for testing.

We wrote several tests to make sure socket_wrapper works correctly. However
there are two tests which fail on FreeBSD but work correctly on Linux.

When running with socket_wrapper we tracked it down to accept4() not filling
out the passed sockaddr. socket_wrapper uses unix socket and we would expect
the unix socket path returned by accept4, which isn't the case.

If I change the echo_srv to write to a file and enable debugging of
socket_wapper this slows down the whole thing and the tests pass correclty.
This means accept4 correctly filling out the sockaddr structure. So this looks
like a race condition in the freebsd libc code.

You can find the code we are currently working on at [2].

git clone https://git.cryptomilk.org/users/asn/socket_wrapper.git
cd socket_wrapper
mkdir obj
cd obj
cmake -DCMAKE_BUILD_TYPE=Debug -DUINIT_TESTING=ON ..
make -j8

To run the whole test suite, you can use:
ctest --output-on-failure

Which should result in:

The following tests FAILED:
         20 - test_thread_echo_tcp_connect (Failed)
         21 - test_thread_echo_tcp_write_read (Failed)
         22 - test_thread_echo_tcp_sendmsg_recvmsg (Failed)

To run an individual test you can use:

ctest -V -R test_thread_echo_tcp_write_read


This will also print you how it is called, normally this is something like:

CMOCKA_TEST_ABORT=1 \
LD_PRELOAD=/home/vagrant/workspace/projects/socket_wrapper/obj/src/libsocket_wrapper.so
\
tests/test_thread_echo_tcp_write_read


The test could also be run without socket_wrapper using real sockets:

CMOCKA_TEST_ABORT=1 \
TORTURE_SERVER_ADDRESS_IPV4="127.0.0.1" \
TORTURE_SERVER_ADDRESS_IPV6="::1" \
TORTURE_SERVER_PORT=7777 \
tests/test_thread_echo_tcp_write_read


[1] https://cwrap.org/socket_wrapper.html
[2] https://git.cryptomilk.org/users/asn/socket_wrapper.git/log/?h=master-fix

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-threads
To unsubscribe, send any mail to "[hidden email]"