Uncaught AssertionError from CopybookParser.parseTree on copybooks with duplicated clauses (8 crash paths, JVM -ea independent)
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 54/100
調査の方向性
Start with ParserVisitor.scala at visitGroup and visitPrimitive (the issue identifies lines 506–509 and 796–800), then inspect the grammar rules that admit repeated clauses. Add parser tests for the listed duplicate clauses and for the duplicated SIGN control case. Done means malformed copybooks produce SyntaxErrorException consistently with and without JVM assertions enabled.
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
CopybookParser.parseTree(...) — the public parser entry point used by the spark-cobol data source — throws an uncaught java.lang.AssertionError when a copybook contains a duplicated clause on the same data entry (e.g. two PICTURE, two OCCURS, two REDEFINES, duplicate VALUE).
- Class: CWE-617 (Reachable Assertion). Availability impact only (no memory-safety).
- Affected:
za.co.absa.cobrix:cobol-parser_2.13:2.11.2(Maven Central latest, 2026-10-12); the same asserts are still onmaster@ 2026-10-23 at the same lines. - Always-on: the crash is not a debug-only invariant failure — it fires with the default JVM flags (
-da) too.
Three factors combine:
- The ANTLR grammar admits any number of these clauses (
( ... )*repetition), so the invalid input passes syntax validation and reaches the visitor. - The visitor enforces its "at most one / exactly one" invariants only with
scala.Predef.assert(ParserVisitor.scalaL506–509visitGroup; L796–800visitPrimitive). No semantic check rejects duplicates with the library's ownSyntaxErrorException. scala.Predef.assertis@elidable(ASSERTION)and the published artifact has the calls compiled in, so they fire regardless of-ea/-da. Nothing catches between the visitor and the public API, so theErrorescapesparseTree(...).
Confirmed crash paths (all deterministic, identical with and without -ea — 8 crash paths × 2 modes = 16/16; row 5 is the control, see below):
| # | data entry | duplicated clause | result | failure location |
|---|---|---|---|---|
| 1 | primitive | PIC X(2) PIC X(5) |
AssertionError |
visitPrimitive :800 |
| 2 | primitive | COMP COMP-3 (USAGE ×2) |
AssertionError |
visitPrimitive :797 |
| 3 | primitive | OCCURS 2 TIMES OCCURS 3 TIMES |
AssertionError |
visitPrimitive :798 |
| 4 | primitive | REDEFINES FOO REDEFINES BAR |
AssertionError |
visitPrimitive :796 |
| 5 | primitive | SIGN LEADING SEPARATE SIGN TRAILING SEPARATE | SyntaxErrorException (control — grammar rejects, every tested flavor) | — (:799 assert unreachable) |
| 6 | group | REDEFINES A1 REDEFINES A2 |
AssertionError |
visitGroup :506 |
| 7 | group | COMP-3 PACKED-DECIMAL (usageGroup ×2) |
AssertionError |
visitGroup :507 |
| 8 | group | OCCURS 2 TIMES OCCURS 3 TIMES |
AssertionError |
visitGroup :508 |
| 9 | group | VALUE 'A' VALUE 'B' |
AssertionError |
visitGroup :509 |
Row 5 is the control: duplicated SIGN clauses are rejected with the library's intended error
type (SyntaxErrorException) in every flavor tested — adjacent, with SEPARATE CHARACTER,
reversed order, SIGN IS form, with another clause in between, and triple — in both -ea
and default JVM modes. It shows the error model that the other 8 paths bypass, and makes
the :799 (ctx.separateSign.size() < 2) assert unreachable from the accepted language —
that dead assert can be fixed or dropped together with the others.
Escape path / stack:
java.lang.AssertionError: assertion failed
at scala.Predef$.assert(Predef.scala:264)
at za.co.absa.cobrix.cobol.parser.antlr.ParserVisitor.visitPrimitive(ParserVisitor.scala:800)
at za.co.absa.cobrix.cobol.parser.antlr.copybookParser$PrimitiveContext.accept(copybookParser.java:3559)
...
at za.co.absa.cobrix.cobol.parser.antlr.ANTLRParser$.parse(ANTLRParser.scala:88)
at za.co.absa.cobrix.cobol.parser.CopybookParser$.parseTree(CopybookParser.scala:336)
Found by coverage-guided fuzzing (Jazzer 0.30 around parseTree) and minimized. A plain java.lang.Error aborts the calling Spark job, and re-reading the same input re-crashes deterministically (no retry tolerance).
Code snippet that caused the issue
import za.co.absa.cobrix.cobol.parser.CopybookParser
// duplicated PICTURE clause on one data entry (row 1)
val copybook =
""" 01 REC1.
| 05 MES PIC X(2) PIC X(5).
|""".stripMargin
CopybookParser.parseTree(copybook)
// java.lang.AssertionError: assertion failed
// at za.co.absa.cobrix.cobol.parser.antlr.ParserVisitor.visitPrimitive(ParserVisitor.scala:800)
Reachable the same way from Spark:
spark.read
.format("cobol")
.option("copybook_contents", copybook) // copybook with a duplicated clause
.load(path)
The other 7 crash cases from the table (rows 2–4 and 6–9; each is a single duplicated clause) all reproduce identically — e.g. 05 F PIC X COMP COMP-3., 05 G PIC 9 OCCURS 2 TIMES OCCURS 3 TIMES., 05 A REDEFINES X REDEFINES Y., group-level REDEFINES/usage/OCCURS/VALUE duplicates, etc. A standalone Java probe covering all 9 cases was used (runs only against the published Maven artifacts, no rebuild).
Expected behavior
A malformed copybook should be rejected with the library's own za.co.absa.cobrix.cobol.parser.exceptions.SyntaxErrorException (as already happens for genuine syntax errors via the ANTLR error listener, and for semantic errors such as in checkBounds), with a clear message like "duplicate clause X on data entry Y" — not an uncaught java.lang.AssertionError.
The behaviour must be identical with and without -ea.
Context
- Cobrix version:
za.co.absa.cobrix:cobol-parser_2.13:2.11.2(Maven Central latest, published 2026-10-12); same issue onmaster@ 2026-10-23 - Spark version: n/a for the standalone repro (parser-level); also reachable via
spark-cobol - Scala version: 2.13.18 (
scala-library; artifact built for 2.13) - Operating system: Linux x86_64 (OpenJDK 21.0.13 Temurin)
CVSS v3.1 (suggested, copybook from a not-fully-trusted feed): AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H → 6.5 (Medium).
Copybook (if possible)
(rows 6–9: each line is its own one-entry copybook; the error fires on the line the probe focuses on — shown together for compactness)
Primary crashing copybook (realistic multi-field layout; note 10 MES carries two PICTURE clauses):
01 MESSAGE.
05 MESCAGE-TOP.
10 MESSAGE-TYPE PIC X(2).
10 MES PIC X PIC X(1).
10 MESSAGE-DATA PIC X(10).
Minimal header-only group variants (rows 6–9):
01 R.
05 A REDEFINES X REDEFINES Y.
05 B COMP-3 PACKED-DECIMAL.
05 C OCCURS 2 TIMES OCCURS 3 TIMES.
05 D VALUE 'A' VALUE 'B'.
Attachments: standalone probe PocAssertFamily.java (9 cases, prints crash location per case), full probe output for -ea and -da (identical for the 8 crash cases, 16/16), and the fuzzer crash input + Java reproducer. Data file is not needed to reproduce (the crash is parse-level and data-independent), but a small one can be attached if useful.
poc_results.txt
PocAssertFamily.java
Crash_cc10fa3d5bfb9296bd39fee83dd200380925f302.java
crash-cc10fa3d5bfb9296bd39fee83dd200380925f302.txt
- 主要言語
- Scala
- スター
- 170
- フォーク
- 96
- 平均マージ
- 7日 5時間
- マージ済み PR(30日)
- 4
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
AbsaOSS/cobrix のほかの issue
-
enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
question
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
-
question
難易度 5/5 1週間以上 初心者へのやさしさ 42/100
-
question
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
似ている issue
-
requires-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
apache/datafusion-comet#7583 ·
メンテナーはふだん 2 日以内に返信
-
A-api C-bug S-ready-for-human
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
ergoplatform/ergo#2932 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
lichess-org/lila#22454 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
chipsalliance/rocket-chip#3845 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100