Fix asan test crashes
authorSarang Masti <mssarang@fb.com>
Thu, 28 May 2015 23:12:21 +0000 (16:12 -0700)
committerNoam Lerner <noamler@fb.com>
Wed, 3 Jun 2015 16:51:27 +0000 (09:51 -0700)
Summary: We need to prevent the socket from being deleted while in the loopCallback.

Test Plan: --  fbconfig '--sanitize' 'address' 'folly/io/async/test' && fbmake runtests

Reviewed By: davejwatson@fb.com

Subscribers: trunkagent, folly-diffs@, yfeldblum, chalfant

FB internal diff: D2109031

Tasks: 7250307

Signature: t1:2109031:1432918801:77f0352254925d3f33f1e004c8bba89cde63e2cf

Blame Revision: D2102601

folly/io/async/AsyncSocket.h

index 85d7275ddb86ef900dde4f799d1d64055a164487..9e3a224b55d0f5678d838f0913482da18bd7e423 100644 (file)
@@ -556,6 +556,7 @@ class AsyncSocket : virtual public AsyncTransportWrapper {
    public:
     explicit ImmediateReadCB(AsyncSocket* socket) : socket_(socket) {}
     void runLoopCallback() noexcept override {
+      DestructorGuard dg(socket_);
       socket_->checkForImmediateRead();
     }
    private: