Skip to content

fix: close fd 0 when mmap fails - #1924

Merged
jpnurmi merged 6 commits into
getsentry:masterfrom
fallintoplace:fix/close-fd-zero-mmap-failure
Aug 4, 2026
Merged

fix: close fd 0 when mmap fails#1924
jpnurmi merged 6 commits into
getsentry:masterfrom
fallintoplace:fix/close-fd-zero-mmap-failure

Conversation

@fallintoplace

Copy link
Copy Markdown
Contributor

When stdin is closed, open() can return file descriptor 0. The failure cleanup in sentry__mmap_file only closed descriptors greater than 0, which leaked the file descriptor if a later step failed.

Close every non-negative descriptor and add a Linux regression test that exercises the empty-file failure path with stdin closed.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0bcad10. Configure here.

Comment thread tests/unit/test_modulefinder.c
jpnurmi added 2 commits August 4, 2026 10:50
```
tests/unit/test_modulefinder.c: In function ‘test_sentry_mmap_file_closes_fd_zero_on_failure’:
tests/unit/test_modulefinder.c:95:19: error: implicit declaration of function ‘sentry__mmap_file’; did you mean ‘sentry_attach_file’? [-Wimplicit-function-declaration]
   95 |     bool mapped = sentry__mmap_file(&mmap, tmp_path);
      |                   ^~~~~~~~~~~~~~~~~
```
@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 75.93%. Comparing base (4c610f3) to head (cf43bd2).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1924      +/-   ##
==========================================
+ Coverage   75.87%   75.93%   +0.06%     
==========================================
  Files          93       93              
  Lines       22183    22183              
  Branches     3951     3951              
==========================================
+ Hits        16831    16845      +14     
+ Misses       4467     4453      -14     
  Partials      885      885              
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jpnurmi jpnurmi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@jpnurmi
jpnurmi merged commit f5a6771 into getsentry:master Aug 4, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants