Skip to content

DocxReader.read segfaults in debug builds on a deeply nested real document (3.6.4 AND 3.7.0; release builds unaffected) #153

Description

@kiki830621

Problem

DocxReader.read in v3.6.4 segfaults on a real Word document in a debug build. The same document reads fine in a release build, and fine in both modes at the PR #141 cluster head (the 3.7.0 candidate).

Reproduction

Document: a Chinese-government review form (REC-O-01-…docx, deeply nested tables). Debug binary:

$ macdoc docx apply manifest.json --input <doc> --output out.docx
exit=139        # SIGSEGV

0  swift_retain + 32 in libswiftCore.dylib
1  static DocxReader.read(from:wireTreeBackedViews:) + 24908
     .build/checkouts/ooxml-swift/Sources/OOXMLSwift/IO/DocxReader.swift
2  Executor.apply(manifest:baselineURL:outputURL:warnHandler:)  (docx-workflow-swift)
3  MacDoc.Docx.Apply.run()

Release build of the same commit: exit 0. That asymmetry is the signature of a stack overflow — debug frames are several times larger — which fits a recursive descent over a deeply nested document.

Not present at the 3.7.0 candidate

A minimal probe against the PR #141 cluster head (001e95a) reads the same file in both modes:

OK tree-backed: body children=7
OK detached:    body children=7

So the reader/IO rework in the 3.7.0 cluster removes it. Whether that was deliberate or incidental is not established here — no test in the suite covers this document, so nothing would notice if it came back.

Why it stayed hidden

macdoc's dependency graph was frozen at v3.2.0 by a branch: "main" pin (macdoc#184). Catching the graph up to 3.6.4 is what surfaced this; before that, macdoc never ran any 3.6.x reader.

Suggested handling

Surfaced while implementing macdoc#184 (dependency catch-up). Refs PsychQuant/macdoc#184

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions