Skip to content

Commit adb65ab

Browse files
committed
Merge remote-tracking branch 'detsys/main' into sync-2.34
2 parents b5628e9 + 4dccfb8 commit adb65ab

10 files changed

Lines changed: 95 additions & 25 deletions

File tree

.version-determinate

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.18.0
1+
3.18.1

doc/manual/source/SUMMARY.md.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@
148148
- [Contributing](development/contributing.md)
149149
- [Determinate Nix Release Notes](release-notes-determinate/index.md)
150150
- [Changes between Nix and Determinate Nix](release-notes-determinate/changes.md)<!-- next -->
151+
- [Release 3.18.1 (2026-04-23)](release-notes-determinate/v3.18.1.md)
151152
- [Release 3.18.0 (2026-04-20)](release-notes-determinate/v3.18.0.md)
152153
- [Release 3.17.3 (2026-04-07)](release-notes-determinate/v3.17.3.md)
153154
- [Release 3.17.2 (2026-03-27)](release-notes-determinate/v3.17.2.md)

doc/manual/source/release-notes-determinate/changes.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changes between Nix and Determinate Nix
22

3-
This section lists the differences between upstream Nix 2.33 and Determinate Nix 3.18.0.<!-- differences -->
3+
This section lists the differences between upstream Nix 2.33 and Determinate Nix 3.18.1.<!-- differences -->
44

55
* In Determinate Nix, flakes are stable. You no longer need to enable the `flakes` experimental feature.
66

@@ -183,3 +183,6 @@ This section lists the differences between upstream Nix 2.33 and Determinate Nix
183183
* Determinate Nix can upload crash info to Sentry. [DeterminateSystems/nix-src#418](https://github.com/DeterminateSystems/nix-src/pull/418)
184184

185185
* Determinate Nix provides the pre-build hook with a JSON serialization of the derivation. [DeterminateSystems/nix-src#424](https://github.com/DeterminateSystems/nix-src/pull/424)
186+
187+
<!-- Determinate Nix version 3.18.1 -->
188+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Release 3.18.1 (2026-04-23)
2+
3+
* Based on [upstream Nix 2.33.4](../release-notes/rl-2.33.md).
4+
5+
## What's Changed
6+
7+
### Sentry integration improvements
8+
9+
This release includes fixes for a couple of issues with the Sentry integration:
10+
11+
* Ensures the chroot helper starts before the Sentry thread, allowing chroot stores to work again
12+
* Resets Mach exception ports on macOS, so that exec'd programs do not communicate with Determinate Nix's `crashpad_handler`
13+
14+
Additionally, Determinate Nix now includes the Nix command and subcommand to Sentry reports to make it easier to discern where an issue happened.
15+
Not that this does _not_ include any command-line arguments other than the command (such as `nix-daemon` and `nix`) and subcommand (such as `flake show`).
16+
17+
PRs:
18+
* [DeterminateSystems/nix-src#433](https://github.com/DeterminateSystems/nix-src/pull/433)
19+
* [DeterminateSystems/nix-src#432](https://github.com/DeterminateSystems/nix-src/pull/432)
20+
* [DeterminateSystems/nix-src#436](https://github.com/DeterminateSystems/nix-src/pull/436)
21+
22+
23+
**Full Changelog**: [v3.18.0...v3.18.1](https://github.com/DeterminateSystems/nix-src/compare/v3.18.0...v3.18.1)

maintainers/upload-debug-info-to-sentry.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env nix
2-
#!nix shell --inputs-from . nixpkgs#sentry-cli --command python3
2+
#!nix shell --inputs-from . nixpkgs#sentry-cli nixpkgs#python3 nixpkgs#binutils --command python3
33

44
import argparse
55
import json
@@ -130,7 +130,8 @@ def main():
130130
for lib in libs:
131131
build_id = get_build_id(lib)
132132
if build_id is None:
133-
print(f" {lib} (no build ID)", file=sys.stderr)
133+
print(f" {lib} (no build ID, uploading binary)", file=sys.stderr)
134+
debug_files.append(lib)
134135
continue
135136

136137
local = find_debug_file_in_dirs(build_id, args.debug_dir)
@@ -141,7 +142,8 @@ def main():
141142

142143
debuginfo = fetch_debuginfo(build_id)
143144
if debuginfo is None:
144-
print(f" {lib} ({build_id}, no debug info in cache)", file=sys.stderr)
145+
print(f" {lib} ({build_id}): no separate debug info, uploading binary", file=sys.stderr)
146+
debug_files.append(lib)
145147
continue
146148
print(f" {lib} ({build_id}): member={debuginfo['member']}", file=sys.stderr)
147149
nar_path = download_nar(build_id, debuginfo["archive"])

packaging/sentry-native.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,6 @@ stdenv.mkDerivation rec {
4949
"out"
5050
"dev"
5151
];
52+
53+
separateDebugInfo = true;
5254
}

src/libutil/current-process.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#ifdef __APPLE__
1414
# include <mach-o/dyld.h>
15+
# include <mach/mach.h>
1516
#endif
1617

1718
#ifdef __linux__
@@ -116,6 +117,15 @@ void restoreProcessContext(bool restoreMounts)
116117
}
117118
}
118119
#endif
120+
121+
#ifdef __APPLE__
122+
/* Reset the Mach exception ports. Otherwise, if a crashpad_handler is attached to this process, it will be
123+
inherited across execve() and receive spurious crash reports from unrelated programs (e.g. in `nix run`).
124+
FIXME: it would be better to have Sentry tell crashpad_handler to quit, but it doesn't appear to have an API for
125+
that. */
126+
task_set_exception_ports(
127+
mach_task_self(), EXC_MASK_ALL | EXC_MASK_CRASH, MACH_PORT_NULL, EXCEPTION_DEFAULT, THREAD_STATE_NONE);
128+
#endif
119129
}
120130

121131
//////////////////////////////////////////////////////////////////////

src/nix/main.cc

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,15 @@ void mainWrapped(int argc, char ** argv)
387387
{
388388
savedArgv = argv;
389389

390+
/* The chroot helper needs to be run before any threads have been
391+
started (including Sentry's worker thread). */
392+
#ifndef _WIN32
393+
if (argc > 0 && argv[0] == chrootHelperName) {
394+
chrootHelper(argc, argv);
395+
return;
396+
}
397+
#endif
398+
390399
bool sentryEnabled = false;
391400

392401
#if HAVE_SENTRY
@@ -411,6 +420,7 @@ void mainWrapped(int argc, char ** argv)
411420
sentry_options_set_auto_session_tracking(options, false);
412421
sentry_options_set_handler_path(options, CRASHPAD_HANDLER_PATH);
413422
sentry_init(options);
423+
sentry_set_tag("nix_command", argc > 0 ? std::string(baseNameOf(argv[0])).c_str() : "");
414424
sentryEnabled = true;
415425
}
416426

@@ -423,15 +433,6 @@ void mainWrapped(int argc, char ** argv)
423433
if (!sentryEnabled)
424434
registerCrashHandler();
425435

426-
/* The chroot helper needs to be run before any threads have been
427-
started. */
428-
#ifndef _WIN32
429-
if (argc > 0 && argv[0] == chrootHelperName) {
430-
chrootHelper(argc, argv);
431-
return;
432-
}
433-
#endif
434-
435436
/* Set the build hook location
436437
437438
For builds we perform a self-invocation, so Nix has to be
@@ -581,16 +582,17 @@ void mainWrapped(int argc, char ** argv)
581582

582583
printTalkative("Nix %s", version());
583584

585+
std::vector<std::string> subcommand;
586+
MultiCommand * command = &args;
587+
while (command) {
588+
if (command && command->command) {
589+
subcommand.push_back(command->command->first);
590+
command = dynamic_cast<MultiCommand *>(&*command->command->second);
591+
} else
592+
break;
593+
}
594+
584595
if (args.helpRequested) {
585-
std::vector<std::string> subcommand;
586-
MultiCommand * command = &args;
587-
while (command) {
588-
if (command && command->command) {
589-
subcommand.push_back(command->command->first);
590-
command = dynamic_cast<MultiCommand *>(&*command->command->second);
591-
} else
592-
break;
593-
}
594596
showHelp(subcommand, args);
595597
return;
596598
}
@@ -627,6 +629,11 @@ void mainWrapped(int argc, char ** argv)
627629
evalSettings.pureEval = false;
628630
}
629631

632+
#if HAVE_SENTRY
633+
if (sentryEnabled)
634+
sentry_set_tag("nix_subcommand", concatStringsSep(" ", subcommand).c_str());
635+
#endif
636+
630637
try {
631638
args.command->second->run();
632639
} catch (eval_cache::CachedEvalError & e) {

tests/functional/sentry.sh

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,36 @@ if ! [[ -d $sentryDir ]]; then
1515
skipTest "not built with sentry support"
1616
fi
1717

18+
waitForCrashDump() {
19+
local i
20+
for ((i = 0; i < 10; i++)); do
21+
envelopes=("$sentryDir"/pending/*.dmp)
22+
if [[ -e "${envelopes[0]}" ]]; then
23+
return 0
24+
fi
25+
sleep 0.1
26+
done
27+
return 1
28+
}
29+
1830
for type in segfault assert logic-error; do
1931
if [[ $type = logic-error && $(uname) = Darwin ]]; then continue; fi
2032

2133
rm -rf "$sentryDir"
2234

2335
(! nix __crash "$type")
2436

25-
envelopes=("$sentryDir"/pending/*.dmp)
26-
if [[ ! -e "${envelopes[0]}" ]]; then
37+
if ! waitForCrashDump; then
2738
fail "No crash dump found in $sentryDir after crash"
2839
fi
2940
done
41+
42+
rm -rf "$sentryDir"
43+
44+
if nix shell --file ./simple.nix --command bash -c 'kill -SEGV $$'; then
45+
fail "Command did not segfault"
46+
fi
47+
48+
if waitForCrashDump; then
49+
fail "Unexpected crash dump"
50+
fi

tests/functional/shell.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ path=$(nix eval --raw -f shell-hello.nix hello)
6565

6666
# Note: we need the sandbox paths to ensure that the shell is
6767
# visible in the sandbox.
68+
export NIX_SENTRY_ENDPOINT=file://$TEST_ROOT/sentry-endpoint # test whether Sentry is disabled in the chroot helper
6869
nix shell --sandbox-build-dir /build-tmp \
6970
--sandbox-paths '/nix? /bin? /lib? /lib64? /usr?' \
7071
--store "$TEST_ROOT/store0" -f shell-hello.nix hello -c hello | grep 'Hello World'

0 commit comments

Comments
 (0)