ITADN

flaky CI tests (SEGV crash in LMDB)

#105Openalltheseas 创建于 2025-12-17
A
alltheseascommented
CI tests intermittently fail with SEGV crashes in LMDB cursor operations during the ingester thread's execution. ## Error Output ``` LeakSanitizer:DEADLYSIGNAL ==13306==ERROR: LeakSanitizer: SEGV on unknown address (pc 0x558a1f87618b bp 0x00000000000a sp 0x7fdaf06feea0 T22) ==13306==The signal is caused by a READ memory access. ==13306==Hint: this fault was caused by a dereference of a high value address (see register values below). #0 mdb_cursor_open deps/lmdb/mdb.c:7678 #1 ndb_get_tsid src/nostrdb.c:3020 #2 ndb_lookup_tsid src/nostrdb.c:3066 #3 ndb_get_note_by_id src/nostrdb.c:3093 #4 ndb_ingester_json_controller src/nostrdb.c:3172 #5 ndb_json_parser_parse src/nostrdb.c:7650 #6 ndb_client_event_from_json src/nostrdb.c:8464 #7 ndb_ingester_process_event src/nostrdb.c:3499 #8 ndb_ingester_thread src/nostrdb.c:7067 ``` ## Behavior - **Non-deterministic:** The same code passes on retry - **Thread context:** Occurs in ingester thread (T22) - **Root cause hint:** "dereference of a high value address" suggests NULL or uninitialized pointer ## Reproduction Observed during CI run for PR #103. First run failed, immediate retry passed with no code changes. ## Analysis The crash occurs when `mdb_cursor_open()` receives an invalid `MDB_txn*` pointer. Possible causes: 1. **Race condition:** Transaction closed by another thread before cursor operation 2. **Use-after-end:** Transaction used after `mdb_txn_abort()` or `mdb_txn_commit()` 3. **Initialization timing:** Transaction not fully initialized when accessed The ingester thread creates read transactions for duplicate detection (`ndb_ingester_thread` at line 7067). If the transaction lifecycle doesn't align with usage, crashes occur. ## Proposed Mitigations 1. **Defensive checks (PR #104):** Add NULL guards before LMDB calls - prevents crashes but doesn't fix root cause 2. **Test isolation:** Ensure each test run uses a fresh database directory 3. **Transaction lifecycle audit:** Review ingester thread's transaction creation/abort pattern ## Environment - Platform: Linux (GitHub Actions runner) - Sanitizer: LeakSanitizer enabled (`-fsanitize=leak`)
2 条评论