Skip to content

rsession/server crashes (segfault) when downloading a file with no read permission #18864

Closed

Description

@samcofer

System details

RStudio Edition : Server
RStudio Version : All Unix/Linux versions since v1.2
OS Version      : Any Linux/Unix
R Version       : Any

Steps to reproduce the problem

  1. Open RStudio Server on Linux/Unix.
  2. Create a file with no read permission:
    echo "test" > ~/test-export.txt
    chmod 000 ~/test-export.txt
  3. In the Files pane, right-click test-export.txt → Export → Download.

Result: The session crashes with a segfault; the browser shows a 502 and the session enters a failed state.

Describe the problem in detail

In core::http::Response::setStreamFile(), when streamResponse_->initialize() fails (opening the file returns EACCES), setError() is called but streamResponse_ is left set. Response::isStreamResponse() therefore still returns true, so the async HTTP server routes the response to StreamWriter, which calls FileStreamResponse::nextBuffer(). That dereferences fileStream_ at Response.cpp:89 — but the file stream was never opened, so it is null → segfault.

Affects the Unix/Linux gzip streaming path. Windows uses a different code path.

Describe the behavior you expected

The download should fail gracefully with an HTTP error, without crashing the session.

  • I have read the guide for submitting good bug reports.
  • I have installed the latest version of RStudio, and confirmed that the issue still persists.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions