summaryrefslogtreecommitdiff
path: root/core/jj.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-22 23:13:39 -0300
committerGabriel Schneider <[email protected]>2026-11-22 23:25:20 -0300
commit1ae5ae5e9201a6a942628ca57a6339bc90372317 (patch)
tree2237127f212157bf36d444f8e0594486d237bd3c /core/jj.zig
parent18e674964e5db67d35e1cf5ded128757ced22a98 (diff)
downloadpardes-1ae5ae5e9201a6a942628ca57a6339bc90372317.tar.gz
pardes-1ae5ae5e9201a6a942628ca57a6339bc90372317.zip
tests: what a rollback puts back of the memory the core points to, and a read of a terminal kept on the fast path (pardes-term-join-12, items 1 and 2): round 11's gate aborted in its second soak ("double free or corruption (!prev)", seed 0 at 80 ms, not reproduced alone, 1 of 3 soaks), and its core, kept by systemd-coredump, says where: a client's core at its end (`Replica.deinit` <- `Soak.close`) freeing a jj `Ask` from `jj.Session.deinit`, freed before: not the rows cache round 11 suspected; the class: `jj.Session` (`Pardes.changes`) hashes itself and has no `replica` annotation, so the rollback copy never walked it (rollback.zig `unwalked`): it saved the session's bytes in the core and nothing they point to, and a write in place into that heap (jj.zig `edited` splices every pinned `Changes.lines` and `Heat.lines` at every edit of the file) stays through a put-back that frees what the speculation made; core/jj.zig "a client's own line opened over pinned changes, rolled back by the session's key first ...": a client's `o` in a file with `Changes ::@` pinned, the session's own key first, the `o` applied again: on `trmpwtso` it aborts (a use of the freed lanes, paintLanes index 926155716 of 6), and with a DebugAllocator as the epoch's child (a local diagnostic, never committed) both frees are named: allocated at jj.spliceValues under the client's speculation, freed at rollback.Epoch.discard when the copy is put back, freed again at jj.spliceValues as the `o` is applied again over the answers buffer that still holds what the put-back freed; core/replica.zig "bytes: a terminal's rows read before an idle client's copy are the copy's ...": rows read between steps (a draw's), the copy taken idle (`ready`), a key of the client's on top and the session's first: on `trmpwtso` the rows are dropped (`toConfirmed`'s `shell_rows = .{}`) and left in the epoch until the client ends, a grid's worth of text at every such rollback; core/replica.zig "bytes: a client's key that reads a terminal's rows, the session's output before it in the session's order ...": a `G` over a shell's rows, the program's output first: the output rolls it back (its count moved: never a neutral unit), the `G` is read again over the fed rows and kept on the fast path with the session's cursor: passes on `trmpwtso` (item 2's question: on the one road a kept speculation's read of an emulator is never stale, so "this input read an emulator" needs no fact of its own); shell-test filtered: 11/12 (the jj test's abort), 11/12 (the rows test: expected the cache's address, found it dropped), 12/12
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/jj.zig')
-rw-r--r--core/jj.zig30
1 files changed, 30 insertions, 0 deletions
diff --git a/core/jj.zig b/core/jj.zig
index a0dfec10..3d4ca17d 100644
--- a/core/jj.zig
+++ b/core/jj.zig
@@ -2552,6 +2552,36 @@ test "the lanes ride with the text: a line typed in a nested block is nobody's,
try testing.expectEqual(pardes.tape.digestOf(a.core), pardes.tape.digestOf(r.core()));
}
+test "a client's own line opened over pinned changes, rolled back by the session's key first: the lanes it spliced under its copy are the copy's again, freed once; the client ends equal" {
+ var repo = try Stack.repo(null) orelse return error.SkipZigTest;
+ defer repo.deinit(testing.allocator);
+ const R = pardes.replica;
+ const a = try R.Authority.init(testing.allocator, .{ .cols = 80, .rows = 24 }, .{});
+ defer a.deinit();
+ const r = try R.Replica.init(testing.allocator, 1, try a.unit(0, 0));
+ defer r.deinit();
+ var line: [4200]u8 = undefined;
+ r.confirm(try a.local(.{ .command = try std.fmt.bufPrint(&line, "Look {s}", .{repo.file}) }));
+ r.confirm(try a.local(.{ .command = "Changes ::@" }));
+ r.confirm(try a.local(.{ .command = "Look a.zig:4" }));
+ r.settle();
+ const serial = a.core.panes[a.core.view().active].?.serial;
+ // The client opens a line below: an edit of the file, whose step splices
+ // the pinned lines' values (jj.edited) under the copy it takes.
+ const typed = try testing.allocator.dupe(u8, try r.input(.{ .key = .{ .cp = 'o', .text = "o" } }));
+ defer testing.allocator.free(typed);
+ try testing.expectEqual(@as(usize, 1), r.applied);
+ // The session's own key comes first: the copy put back, the `o` applied
+ // again over it, then confirmed.
+ r.confirm(try a.local(.{ .key = .{ .cp = 'k', .text = "k" } }));
+ r.settle();
+ r.confirm(try a.take(typed));
+ r.settle();
+ try testing.expect(r.diverged == null);
+ try testing.expectEqualSlices(Line, answered(a.core, serial).?.lines, answered(r.core(), serial).?.lines);
+ try testing.expectEqual(pardes.tape.digestOf(a.core), pardes.tape.digestOf(r.core()));
+}
+
/// Two functions four changes wrote: `fn` both, `f2` and `f3` rewrote
/// f's line, `g2` g's: f three changes, g two.
const Churned = struct {