diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-05-25 19:35:52 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-05-29 16:05:23 -0700 |
| commit | 33dc5d611f578ace9833a80dc006a34b09da18af (patch) | |
| tree | 2351fd7d197530493dbd27034ae9e1546c2e299c /src/platform | |
| parent | fe5336ec1f9f27045f2c27ac253285c8447aa653 (diff) | |
| download | nng-33dc5d611f578ace9833a80dc006a34b09da18af.tar.gz nng-33dc5d611f578ace9833a80dc006a34b09da18af.tar.bz2 nng-33dc5d611f578ace9833a80dc006a34b09da18af.zip | |
fixes #484 crashes in websocket transport
fixes #490 posix_epdesc use-after-free bug
fixes #489 Sanitizer based testing would help
fixes #492 Numerous memory leaks found with sanitizer
This introduces support for compiler-based sanitizers when using
clang or gcc (and not on Windows). See NNG_SANITIZER for possible
settings such as "thread" or "address".
Furthermore, we have fixed the issues we found with both the
thread and address sanitizers. We believe that the thread issues
pointed to a low frequency use-after-free responsible for rare
crashes in some of the tests.
The tests generally have their timeouts doubled when running under
a sanitizer, to account for the extra long times that the sanitizer
can cause these to take.
While here, we also changed the compat_ws test to avoid a particularly
painful and time consuming DNS lookup, and we made the nngcat_unlimited
test a bit more robust by waiting before sending traffic.
Diffstat (limited to 'src/platform')
| -rw-r--r-- | src/platform/posix/posix_epdesc.c | 6 | ||||
| -rw-r--r-- | src/platform/posix/posix_pollq_epoll.c | 7 | ||||
| -rw-r--r-- | src/platform/posix/posix_pollq_kqueue.c | 2 |
3 files changed, 7 insertions, 8 deletions
diff --git a/src/platform/posix/posix_epdesc.c b/src/platform/posix/posix_epdesc.c index dfb750d4..69026051 100644 --- a/src/platform/posix/posix_epdesc.c +++ b/src/platform/posix/posix_epdesc.c @@ -469,11 +469,7 @@ nni_epdesc_connect_cb(nni_posix_pfd *pfd, int events, void *arg) nni_mtx_lock(&ed->mtx); if ((ed->closed) || ((aio = nni_list_first(&ed->connectq)) == NULL) || (pfd != ed->pfd)) { - // Spurious completion. Ignore it, but discard the PFD. - if (ed->pfd == pfd) { - ed->pfd = NULL; - } - nni_posix_pfd_fini(pfd); + // Spurious completion. Just ignore it. nni_mtx_unlock(&ed->mtx); return; } diff --git a/src/platform/posix/posix_pollq_epoll.c b/src/platform/posix/posix_pollq_epoll.c index a8d8693a..9c1ae682 100644 --- a/src/platform/posix/posix_pollq_epoll.c +++ b/src/platform/posix/posix_pollq_epoll.c @@ -93,6 +93,10 @@ nni_posix_pfd_init(nni_posix_pfd **pfdp, int fd) if ((pfd = NNI_ALLOC_STRUCT(pfd)) == NULL) { return (NNG_ENOMEM); } + nni_mtx_init(&pfd->mtx); + nni_cv_init(&pfd->cv, &pq->mtx); + + nni_mtx_lock(&pfd->mtx); pfd->pq = pq; pfd->fd = fd; pfd->cb = NULL; @@ -101,9 +105,8 @@ nni_posix_pfd_init(nni_posix_pfd **pfdp, int fd) pfd->closing = false; pfd->closed = false; - nni_mtx_init(&pfd->mtx); - nni_cv_init(&pfd->cv, &pq->mtx); NNI_LIST_NODE_INIT(&pfd->node); + nni_mtx_unlock(&pfd->mtx); // notifications disabled to begin with ev.events = 0; diff --git a/src/platform/posix/posix_pollq_kqueue.c b/src/platform/posix/posix_pollq_kqueue.c index 36ced3ff..c118d528 100644 --- a/src/platform/posix/posix_pollq_kqueue.c +++ b/src/platform/posix/posix_pollq_kqueue.c @@ -276,9 +276,9 @@ nni_posix_pollq_destroy(nni_posix_pollq *pq) { if (pq->kq >= 0) { close(pq->kq); - pq->kq = -1; } nni_thr_fini(&pq->thr); + pq->kq = -1; nni_posix_pollq_reap(pq); |
