8000 C++ client: heap-use-after-free with long running fragment handlers (> resource linger timeout) · Issue #476 · aeron-io/aeron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
C++ client: heap-use-after-free with long running fragment handlers (> resource linger timeout) #476
Closed
@StephanDollberg

Description

@StephanDollberg

Hello,

I see the following potential heap-use-after-free:

user thread calls Subscription::poll which loads the image list:

const struct ImageList *imageList = std::atomic_load_explicit(&m_imageList, std::memory_order_acquire);

Conductor thread does a addImage or removeImage and adds the old image list (in use by the user thread) to the freelist. E.g.: from ClientConductor::onUnavailableImage

std::pair<struct ImageList *,int> result = subscription->removeImage(correlationId);

Meanwhile the user thread calls the first Image's fragment handler from Image::poll. If that fragment handler now takes longer than the resource linger timeout, the images and related resources that the user thread refers to will have been freed once the fragment handler returns. That will then probably crash in Image::poll after returning from the fragment handler when calling:

m_subscriberPosition.setOrdered(newPosition);

Let me know what you think. Coupling the correctness of the client to the time of the resource linger timeout seems off to me. Obviously, long running fragment handlers should be a rare occurrence but I don't want my program to crash if I have one on startup for example.

Thanks,
Stephan

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0