From 26fbed3bc58600adc092ab41e094e0fcae60f3b2 Mon Sep 17 00:00:00 2001 From: Saya Andy Date: Thu, 30 Jul 2026 12:23:33 +0700 Subject: cgit: don't initialize notes when there is no repository prepare_repo_env() calls load_display_notes() unconditionally, even when setup_git_directory_gently() has just reported that repo.path is not a repository. init_notes() then resolves the default notes ref and dereferences the repository's hash algorithm, which is still NULL: EXC_BAD_ACCESS (code=1, address=0x18) get_oid_basic(str="refs/notes/commits", len=18) at object-name.c:688 -> if (len == r->hash_algo->hexsz && !get_oid_hex(str, oid)) { A typo in repo.path therefore took out the request. On Linux this segfaults; on macOS nothing consumes the Mach exception, so the faulting instruction is retried forever and the worker process spins at 100% CPU instead of dying. Only load the notes once a repository has been opened. prepare_repo_cmd() reports the failure immediately afterwards, so such a request now renders "Failed to open : No such file or directory". Signed-off-by: Saya Andy --- cgit.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'cgit.c') diff --git a/cgit.c b/cgit.c index ca318e8..5bf52f8 100644 --- a/cgit.c +++ b/cgit.c @@ -587,9 +587,12 @@ static void prepare_repo_env(int *nongit) /* Setup the git directory and initialize the notes system. Both of these * load local configuration from the git repository, so we do them both while - * the HOME variables are unset. */ + * the HOME variables are unset. Initializing the notes system requires an + * actual repository, as it would otherwise dereference the not yet known + * hash algorithm. */ setup_git_directory_gently(nongit); - load_display_notes(NULL); + if (!*nongit) + load_display_notes(NULL); } static int prepare_repo_cmd(int nongit) -- cgit v1.3.1+13