Swap ownership, fsync race, RowsView memory, renderer regex stack
- A session never unlinks a journal it does not own: Detach, ResetJournal and NotifyFilenameChanged skip removal when this session was locked out or another session holds the lock, and PruneSwapDir skips held journals. A second session used to delete the first session's live journal on save or close. - The writer thread's periodic fsync now runs under mtx_. It fsynced fds that the main thread could close concurrently (or that had been reused); an in-flight fsync also kept a just-closed journal's flock alive, so the owner's own cleanup saw its journal as held. - Compaction locks the compacted file before renaming it into place and keeps using it, so the journal is never unlocked in between; a failed lock on the truncating reopen marks the session locked out. - Unnamed-buffer journals include the pid, so sessions no longer share (and delete) each other's unnamed-N.swp. - RowsView keeps only the previous generation of cached rows: keeping all of them made C-u 2000 M-d on a 1 MiB line use ~2 GB. - Renderers run regex match highlighting through ForEachRegexMatch, which uses the large-stack worker for lines over 512 bytes; some patterns overflowed the main stack well under the previous 10,000 byte limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rcVQiiWyTzoNrsvLSaAfB
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "ErrorRecovery.h"
|
||||
#include "PieceTable.h"
|
||||
#include "RegexGuard.h"
|
||||
#include "UndoTree.h"
|
||||
#include "syntax/HighlighterEngine.h"
|
||||
#include "syntax/HighlighterRegistry.h"
|
||||
@@ -880,3 +881,20 @@ TEST(Audit_Commands_FilesystemErrorsDoNotThrow)
|
||||
(void) ed.ProcessPendingOpens();
|
||||
ASSERT_EQ(h.Text(), std::string("precious\n"));
|
||||
}
|
||||
|
||||
|
||||
// Renderer regex highlighting on a long line with a deeply recursive pattern
|
||||
// (overflowed an 8 MiB stack at under 10,000 bytes) runs off the main stack.
|
||||
TEST(Audit_ForEachRegexMatch_LongLine)
|
||||
{
|
||||
std::string line;
|
||||
while (line.size() < 200000)
|
||||
line += "word, more words; and so on. ";
|
||||
std::size_t n = 0, total = 0;
|
||||
kte::ForEachRegexMatch(line, std::regex("(\\w|\\s|[.,;])+"), [&](std::size_t, std::size_t len) {
|
||||
++n;
|
||||
total += len;
|
||||
});
|
||||
ASSERT_EQ(n, (std::size_t) 1);
|
||||
ASSERT_EQ(total, line.size());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user