Skip to content

Ring Buffer Race Condition Causing Null Pointer Crash #81

@ericraio

Description

@ericraio

Experienced crashes on Linux with null pointer dereference at ring_buffer.cpp:124 in RingBuffer::free_empty()

Fault address: 0x0000000000000008 (null pointer dereference)
Location: datastax-cpp-driver/src/ring_buffer.cpp:124
Function: RingBuffer::free_empty()
Error: assert(cur->write_pos_ == cur->read_pos_)

Thread NIO-SGLTN-1-#2
  └─ uv_run (libuv event loop)
     └─ EventLoop::internal_on_run
        └─ OpenSslSession::decrypt
           └─ CNIOBoringSSL_SSL_read
              └─ RingBufferBio::read
                 └─ RingBuffer::read
                    └─ RingBuffer::free_empty ← CRASH

Root Cause

The C++ DataStax driver's RingBuffer class lacks thread synchronization. When multiple Swift threads concurrently call cass_session_execute(), they race on the circular linked list in the ring buffer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions