Repository navigation
fix(diagram): initialize operand id on unmatched PlantUML openers (#2818) - #2832
divakantpandey wants to merge 1 commit into
Conversation
…usData#2818) dg_puml_operand initialized *label at entry but only assigned *id on successful matches. When an opener character (':', '[', '(', '"') lacks a matching closer, dg_puml_operand returns early without writing *id, leaving caller stack variables uninitialized. In dg_puml_relation and dg_puml_decl, this caused the !rid.n / !id.n checks to evaluate uninitialized stack memory, passing garbage pointers into dg_element and dg_trim, which crashed the index worker with a segmentation fault on PlantUML sequence edge messages ('Alice ->: msg', '[-> Alice: msg'). Initialize *id at the top of dg_puml_operand alongside *label, and zero-initialize the caller operand variables in dg_puml_relation and dg_puml_decl. Fixes DeusData#2818 Signed-off-by: Divakant Pandey <divakant01@gmail.com>
|
Thanks for opening this — it has been seen, and it is queued. This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence. Current review status: working through a backlog. What that means for this PR, concretely:
Things that will genuinely speed it up whenever review does happen:
If this fixes a bug, a reproduction we can run is worth more than a description of the symptom. Thanks for contributing, and sorry in advance for the wait. |
|
Thank you very much, @divakantpandey, for jumping on #2818 so quickly and for the clear write-up -- your diagnosis matches the root cause exactly, and your test reproduces the crash on main. #2827 was opened a few hours earlier with the same one-line fix in dg_puml_operand, and it has now landed in 76dda7e with a test that also covers the unclosed-declaration path. Since both pull requests carry the same production change, we are closing this one as a duplicate rather than landing the fix twice; the extra zero-initializations in the callers are not needed once dg_puml_operand always writes both outputs. This is no reflection on your work -- it was simply a race on a fresh issue. Thank you again; #2822 and #2833 are in the queue. |
Fixes #2818
Problem
When indexing PlantUML sequence diagrams that contain messages to or from diagram edges (
Alice ->: msg,Alice <-: msg,[-> Alice: msg,[<- Alice: msg),dg_puml_operand()receives an opener character without a matching closer.dg_puml_operand()initialized*label = dg_s(NULL, 0);at its entry, but only wrote*idon success paths. On unmatched openers,if (!c) return i;returned early without writing*id. In callersdg_puml_relation()anddg_puml_decl(),lid,rid,id, andaidwere uninitialized stack variables, causingif (!rid.n)to read stack garbage and pass unmapped addresses intodg_element()anddg_trim(), crashing the index worker with SIGSEGV.Solution
• In
dg_puml_operand(), initialize*id = dg_s(NULL, 0);at entry alongside*label.• Zero-initialize
lid,llab,rid, andrlabindg_puml_relation(), andid,label,aid, andalabindg_puml_decl().Verification
• Added
diagrams_plantuml_edge_messages_issue2818intests/test_diagrams.c.• Verified failure toggle: reproduces deterministically under ASan+UBSan prior to fix (
AddressSanitizer: global-buffer-overflowindg_id_keyfromdg_element), passes cleanly after fix.•
./scripts/test.sh --suites diagrams: 19/19 passed.•
./scripts/test.sh --contracts-only: All static contract steps passed.•
./scripts/check-dco.sh upstream/main..HEAD: Valid DCO sign-off verified.•
./scripts/build.sh: Production binary builds cleanly.