Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,8 @@
**Fixes**:

- Name `sentry-logs` and `sentry-metrics` telemetry batcher threads so they can be identified in debuggers, profilers, and crash reports. ([#1937](https://github.com/getsentry/sentry-native/pull/1937))

**Fixes**:

- Linux: close descriptor `0` on failed module file mapping when that descriptor was returned by `open`, avoiding a file descriptor leak. ([#1924](https://github.com/getsentry/sentry-native/pull/1924))
- `sentry_attachment_set_filename`, `sentry_attachment_set_type`, and `sentry_attachment_set_content_type` now flush the scope, so changes applied after `sentry_attach_file`/`sentry_attach_bytes` also apply to hard-crash events instead of only to normal events. ([#1934](https://github.com/getsentry/sentry-native/pull/1934))

**Fixes**:

- Crashpad: fix a crash when calling `sentry_init` before C++ dynamic initializers have run. ([#1930](https://github.com/getsentry/sentry-native/issues/1930), [mini_chromium#8](https://github.com/getsentry/mini_chromium/pull/8))

## 0.16.1
Expand Down
2 changes: 1 addition & 1 deletion src/modulefinder/sentry_modulefinder_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ sentry__mmap_file(sentry_mmap_t *rv, const char *path)
return true;

fail:
if (fd > 0) {
if (fd >= 0) {
close(fd);
}
rv->ptr = NULL;
Expand Down
2 changes: 2 additions & 0 deletions src/modulefinder/sentry_modulefinder_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ void sentry__module_mapping_push(
sentry_module_t *module, const sentry_parsed_module_t *parsed);

#ifdef SENTRY_UNITTEST
bool sentry__mmap_file(sentry_mmap_t *rv, const char *path);

bool sentry__procmaps_read_ids_from_elf(
sentry_value_t value, const sentry_module_t *module);

Expand Down
30 changes: 30 additions & 0 deletions tests/unit/test_modulefinder.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

#ifdef SENTRY_PLATFORM_LINUX
# include "modulefinder/sentry_modulefinder_linux.h"
# include <fcntl.h>
# include <stdlib.h>
# include <unistd.h>
#endif

SENTRY_TEST(module_finder)
Expand Down Expand Up @@ -74,6 +77,33 @@ SENTRY_TEST(module_addr)
#endif
}

SENTRY_TEST(mmap_file_closes_fd_zero_on_failure)
{
#if !defined(SENTRY_PLATFORM_LINUX) || defined(SENTRY_PLATFORM_ANDROID)
SKIP_TEST();
#else
char tmp_path[] = "/tmp/sentry-native-mmap-XXXXXX";
int tmp_fd = mkstemp(tmp_path);
Comment thread
cursor[bot] marked this conversation as resolved.
TEST_ASSERT(tmp_fd >= 0);
close(tmp_fd);

int saved_stdin = dup(STDIN_FILENO);
TEST_ASSERT(saved_stdin >= 0);
close(STDIN_FILENO);

sentry_mmap_t mmap = { 0 };
bool mapped = sentry__mmap_file(&mmap, tmp_path);
int fd_flags = fcntl(STDIN_FILENO, F_GETFD);

dup2(saved_stdin, STDIN_FILENO);
close(saved_stdin);
unlink(tmp_path);

TEST_CHECK(!mapped);
TEST_CHECK(fd_flags == -1);
#endif
}

SENTRY_TEST(procmaps_parser)
{
#if !defined(SENTRY_PLATFORM_LINUX) || __SIZEOF_POINTER__ != 8
Expand Down
1 change: 1 addition & 0 deletions tests/unit/tests.inc
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ XX(minidump_stream_types)
XX(minidump_structures_packed)
XX(minidump_system_info)
XX(minidump_thread_structure)
XX(mmap_file_closes_fd_zero_on_failure)
XX(module_addr)
XX(module_finder)
XX(mpack_newlines)
Expand Down