Skip to content

Integer overflow in bufferTimeout #4185

@qrpnxz

Description

@qrpnxz

Through FluxBufferTimeout through BufferTimeoutWithBackpressureSubscriber:

this.prefetch = batchSize << 2;
this.replenishMark = batchSize << 1;

If batchSize (maxSize in bufferTimeout) is very big, prefetch and replenishMark can become negative. In my experience, this can cause a thread to silently hang. I would expect a large input to gracefully saturate these internal variables or at least signal an error.

Integer.MAX_VALUE would work well for ‘unbounded’ buffering if not for this; the brittle-looking Integer.MAX_VALUE >> 2 will do for now.

Versions affected: commits since PR #3332 as far as I know. Link above represents main as of time of writing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ❓need-triageThis issue needs triage, hasn't been looked at by a team member yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions