[CDRIVER-1407] /Socket/sendv testfailure on FreeBSD Created: 20/Jul/16  Updated: 03/May/17  Resolved: 20/Jan/17

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: None
Fix Version/s: TBD

Type: Bug Priority: Major - P3
Reporter: Hannes Magnusson Assignee: A. Jesse Jiryu Davis
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File poll-test.c    
Issue Links:
Related

 Description   

make debug TEST_ARGS="-l /Socket/sendv --no-fork"

consistently fails on FreeBSD 10.3 with the following backtrace

Assertion failed: (r == gFourMB), function sendv_test_client, file tests/test-mongoc-socket.c, line 318.
[New Thread 80200f800 (LWP 100862/test-libmongoc)]
 
Program received signal SIGABRT, Aborted.
[Switching to Thread 80200f800 (LWP 100862/test-libmongoc)]
0x00000008016dd35a in thr_kill () from /lib/libc.so.7
(gdb) bt
#0  0x00000008016dd35a in thr_kill () from /lib/libc.so.7
#1  0x00000008016dd346 in raise () from /lib/libc.so.7
#2  0x00000008016dd2c9 in abort () from /lib/libc.so.7
#3  0x0000000801743f91 in __assert () from /lib/libc.so.7
#4  0x0000000000467e04 in sendv_test_client (data_=0x7fffffffe038) at tests/test-mongoc-socket.c:318
#5  0x0000000801401855 in pthread_create () from /lib/libthr.so.3
#6  0x0000000000000000 in ?? ()
(gdb) f 4
#4  0x0000000000467e04 in sendv_test_client (data_=0x7fffffffe038) at tests/test-mongoc-socket.c:318
318                assert (r == gFourMB);
Current language:  auto; currently minimal
(gdb) p r
$1 = 130708
(gdb) p gFourMB
$2 = 4194304



 Comments   
Comment by Githook User [ 20/Jan/17 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-1407 fix socket test on FreeBSD

Fixes a timeout in /Socket/sendv test.

The test had wrongly assumed that a sendv timeout set socket->errno_,
but this errno was actually set from the initial call to accept or
connect. These functions do not set socket->errno_ during this test of
localhost connections on FreeBSD, the way they do on Mac and Linux.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/340e610e019f404105aae8e2c1c12f8c85fc4c72

Comment by A. Jesse Jiryu Davis [ 20/Jan/17 ]

Later in the /Socket/sendv test, both the client and the server threads execute the next step if and only if errno is set to EAGAIN or EINPROGRESS after a non-blocking call to sendmsg or recv. However, they have no right to expect that errno is set: the test has been passing on Linux and Mac because it was a previous call to accept() (in the server thread) or connect (in the client thread) that has set errno, and errno isn't cleared afterward.

On FreeBSD, since accept / connect don't set errno in this test, the test doesn't make progress when it checks errno later, and it times out.

Comment by A. Jesse Jiryu Davis [ 19/Jan/17 ]

The attached poll-test.c does roughly the same startup steps as /Socket/sendv. It starts a thread to listen on localhost:4321 and, on the main thread, connects to localhost 4321. On Mac it prints:

pthread_create returned 0
listening
accepting
connect returned -1, errno is 36
server accepted
poll returned 0, errno = 0
getsockopt returned 0, errno = 0, optval = 0
sendmsg returned 4, errno = 0

On FreeBSD 11:

pthread_create returned 0
listening
accepting
connect returned 0, errno is 0
server accepted
poll returned 0, errno = 0
getsockopt returned 0, errno = 0, optval = 0
sendmsg returned 4, errno = 0

On Mac, connect sets errno to EINPROGRESS, but not on FreeBSD. The difference in connect() behavior to localhost is I think the root cause of the test failure.

Comment by A. Jesse Jiryu Davis [ 17/Jan/17 ]

Reproduced on a FreeBSD-11 vagrant box.

Comment by Hannes Magnusson [ 19/Dec/16 ]

We don't have any FreeBSD instances to properly test and debug this on for the moment.

Generated at Wed Feb 07 21:12:25 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.