fix: close the tail items from the targeted re-audit

Resolves the 13 rows still partial in docs/rewrite/notes/review-rv4-
codex.md (details in final-Z5.md):
- Escaped config strings are decoded to raw bytes at every OS boundary:
  Flatpak cwd/argv to D-Bus, screen-file paths, the default config
  template, GHOSTTY_RESOURCES_DIR/TERMINFO/shell integration/
  bindtextdomain consumers, custom shader loading, list-themes hyperlinks.
- osbytes escapes literal U+FDD0 on non-Unix too (bijective everywhere);
  the GTK paste dialog only decodes text that was actually encoded.
- shadertoy: whole-array uses of iChannelTime rebuild a plain float[4]
  from the std140-padded members (naga-validated, MSL offsets checked).
- libghostty-vt: the OSC parser holds caller-allocated storage inline
  and command payloads borrow from it, so ghostty_osc_end performs no
  global allocations (verified from Rust and C).
- crash: aarch64 Linux minidump context fixed; macOS fatal signals record
  siginfo, registers and a fault-safe stack walk.
- tripwire: selectionString map allocation-failure cleanup test ported.
- libghostty-vt emits the versioned soname libghostty-vt.so.0 at build
  time (no patchelf needed at install).

Test Plan:
- cargo test --workspace (3342 passed)
- just check-macos; just check-macos x86_64-apple-darwin;
  just check-windows; just check-wasm
- cargo check --target aarch64-unknown-linux-gnu -p ghostty-crash
This commit is contained in:
ddidderr committed 2026-10-12 08:45:21 +02:00
1 parent 5bfc7bd856
commit 1a13e8b556
49 files changed
+1785 -557

No files matched your search

+47 -1
View File
@@ -368,6 +368,24 @@ pub enum SemanticContentSet {
pub use crate::string_map::StringMap;
/// Failure of [`Screen::try_selection_string_map`].
#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
pub enum SelectionStringError {
#[error("out of memory")]
OutOfMemory,
}
/// Failure points of `selection_string` (Zig: `selectionString_tw`).
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum SelectionStringPoint {
CopyMap,
}
crate::tripwire_module!(
selection_string_tw,
SelectionStringPoint,
SelectionStringError
);
#[derive(Debug, Clone, Copy)]
pub struct SelectionString {
/// The selection to convert to a string.
@@ -2572,10 +2590,38 @@ impl Screen {
/// Same as `selection_string` but also returns a map from every byte of
/// the string to the pin it came from (Zig: `SelectionString.map`).
///
/// Panics if the map cannot be built, like any other Rust allocation
/// failure; use [`Screen::try_selection_string_map`] to handle it.
pub fn selection_string_map(&self, opts: SelectionString) -> StringMap {
self.try_selection_string_map(opts)
.expect("selection string map allocation failed")
}
/// Fallible [`Screen::selection_string_map`] (Zig `selectionString` with
/// `opts.map` set, which can return `error.OutOfMemory` when copying the
/// map). Nothing is leaked on failure: the string and pin list built so
/// far are dropped (Zig: `errdefer alloc.free(map_string)`).
pub fn try_selection_string_map(
&self,
opts: SelectionString,
) -> Result<StringMap, SelectionStringError> {
let mut pins = Vec::new();
let string = self.selection_string_impl(opts, Some(&mut pins));
StringMap { string, map: pins }
// Duplicate the string and take the pins for the map (Zig: `dupeZ`
// then `pins.toOwnedSlice`).
let mut map_string = String::new();
map_string
.try_reserve_exact(string.len())
.map_err(|_| SelectionStringError::OutOfMemory)?;
map_string.push_str(&string);
selection_string_tw::check(SelectionStringPoint::CopyMap)?;
pins.shrink_to_fit();
Ok(StringMap {
string: map_string,
map: pins,
})
}
fn selection_string_impl(
+25 -3
View File
@@ -685,9 +685,31 @@ fn screen_set_attribute_splits_page_on_out_of_space_at_max_styles() {
assert!(page_was_split);
}
// "selectionString map allocation failure cleanup" is skipped: it relies on
// Zig tripwire allocation-failure injection (selectionString_tw), which has
// no Rust counterpart.
#[test]
fn screen_selection_string_map_allocation_failure_cleanup() {
use crate::tripwire::ResetMode;
// If building the StringMap fails, the already-built string must be
// dropped and the error returned (Zig: errdefer free(map_string)).
let mut s = init(10, 5, 0);
s.test_write_string("hello").unwrap();
let sel = sel_active(&s, (0, 0), (4, 0), false);
selection_string_tw::error_always(
SelectionStringPoint::CopyMap,
SelectionStringError::OutOfMemory,
);
let result = s.try_selection_string_map(SelectionString { sel, trim: true });
assert!(matches!(result, Err(SelectionStringError::OutOfMemory)));
selection_string_tw::end(ResetMode::Reset).unwrap();
// And it works again once the tripwire is reset.
let map = s
.try_selection_string_map(SelectionString { sel, trim: true })
.unwrap();
assert_eq!(map.string, "hello");
assert_eq!(map.map.len(), 5);
}
fn setup_prompt(cols: u16, click: Click) -> Screen {
let mut s = init(cols, 5, 0);
@@ -13,14 +13,14 @@ use crate::{
screen::SemanticClick,
};
fn sp(a: A) -> Cmd {
fn sp(a: A) -> Cmd<'static> {
Cmd::init(a)
}
fn sp_opts(a: A, o: &str) -> Cmd {
fn sp_opts(a: A, o: &str) -> Cmd<'_> {
Cmd {
action: a,
options_unvalidated: o.as_bytes().to_vec(),
options_unvalidated: o.as_bytes().into(),
}
}