Skip to content

ctf: remove sequence bit length calculation as it cannot be known#410

Open
arfio wants to merge 1 commit into
eclipse-tracecompass:masterfrom
arfio:ctf2-fix-sequence-length
Open

ctf: remove sequence bit length calculation as it cannot be known#410
arfio wants to merge 1 commit into
eclipse-tracecompass:masterfrom
arfio:ctf2-fix-sequence-length

Conversation

@arfio

@arfio arfio commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

What it does

Remove the check for maximum size, as we do not yet know the size of the member fields at this point, so it is impossible to calculate the maximum number of bits that the sequence will take. Fixes #379

How to test

Open the issue attached trace.

Follow-ups

N/A

Review checklist

  • As an author, I have thoroughly tested my changes and carefully followed the instructions in this template

Summary by CodeRabbit

  • Bug Fixes
    • Improved validation logic in sequence declarations to more efficiently detect overflow conditions and validate capacity constraints, providing better error detection for edge cases.

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7721d06d-65a6-4ec9-b1ff-8ffde3ad2e1f

📥 Commits

Reviewing files that changed from the base of the PR and between 580df59 and bb7acb3.

📒 Files selected for processing (1)
  • ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/SequenceDeclaration.java

📝 Walkthrough

Walkthrough

In SequenceDeclaration#createDefinition, the sequence-length validation is split into two separate guards: an immediate throw when length exceeds Integer.MAX_VALUE, and a conditional maxBits multiplication plus input.canRead(...) check that is skipped entirely when the element type's maximum size is itself Integer.MAX_VALUE.

Changes

Sequence Length Overflow Fix

Layer / File(s) Summary
Split length overflow and canRead guards
ctf/.../event/types/SequenceDeclaration.java
Replaces the single compound overflow check with a dedicated length > Integer.MAX_VALUE early throw, followed by a conditional block that computes maxBits and calls input.canRead(...) only when fElemType.getMaximumSize() != Integer.MAX_VALUE, preventing integer overflow for unbounded element types.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 A sequence too long once made the parser groan,
With MAX_VALUE overflow, it crashed on its own.
Now length is checked first, a swift early throw,
And maxBits only multiplies when safe to go.
No more array disasters — the rabbit hops free! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: removing sequence bit length calculation in the CTF parser's SequenceDeclaration.
Linked Issues check ✅ Passed The changes address issue #379 by refactoring the sequence-length validation to prevent Integer.MAX_VALUE overflow when calculating maxBits for sequences.
Out of Scope Changes check ✅ Passed All changes are confined to SequenceDeclaration.java and directly address the maxBits overflow issue reported in issue #379; no extraneous modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@arfio arfio force-pushed the ctf2-fix-sequence-length branch from bebaaa8 to 84fdf02 Compare June 12, 2026 03:44
Signed-off-by: Arnaud Fiorini <fiorini.arnaud@gmail.com>
@arfio arfio force-pushed the ctf2-fix-sequence-length branch from 84fdf02 to bb7acb3 Compare June 16, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CTF2 error read dynamic length arrays

1 participant