folly/io/async/tests: always detach event base in tests, fixes UBSAN tests
authorNathan Bronson <ngbronson@fb.com>
Fri, 9 Dec 2016 20:42:28 +0000 (12:42 -0800)
committerFacebook Github Bot <facebook-github-bot-bot@fb.com>
Fri, 9 Dec 2016 20:47:59 +0000 (12:47 -0800)
commitc80831a5b097f4b6c0e64fdc36efec5f0d676a11
treeb4e04a667363c9b7a135ac6531706fe365eb15e6
parent108473868b7d543fcb4f7108cbcc75dc871cd833
folly/io/async/tests: always detach event base in tests, fixes UBSAN tests

Summary:
In AsyncSSLSocket tests the shared_ptr structure means that the
AsyncSSLSocket-s outlive the stack-allocated EventBase on which they were
created.  Previously there were scattered calls to detachEventBase on the
last interesting callback, but several calls were missing.  This diff
switches to a model where the SSLServerAcceptCallbackBase is responsible
for detaching the sockets.

This diff also fixes a low-firing race between shutdown
of the TestSSLAsyncCacheServer Main thread and a call to
EmptyReadCallback::readEOF.  Most uses of EmptyReadCallback don't attach
the TCP socket, so they can't actually tolerate a call to readError
or readEOF.

These use-after-destruction problems were discovered by UBSAN.

Reviewed By: djwatson

Differential Revision: D4301416

fbshipit-source-id: 127fb5e506d0694c5ca81d7a38c704d69f4ab3eb
folly/io/async/test/AsyncSSLSocketTest.cpp
folly/io/async/test/AsyncSSLSocketTest.h