Skip to content

[2675] Integer overflow during value conversion - #2684

Open
ylussaud wants to merge 1 commit into
eclipse-syson:mainfrom
ylussaud:ylu/fix/2675
Open

ylussaud wants to merge 1 commit into
eclipse-syson:mainfrom
ylussaud:ylu/fix/2675

Conversation

@ylussaud

@ylussaud ylussaud commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Bug: #2675

PLEASE READ ALL ITEMS AND CHECK ONLY RELEVANT CHECKBOXES BELOW

Auto review

  • Have you reviewed this PR? Please do a first quick review, It is very useful to detect typos and missing copyrights, check comments, check your code... The reviewer will thank you for that :)

Project management

  • Has the pull request been added to the relevant milestone?
  • Have the queue: and review-window: labels been added to the pull request? (In case of doubt, start with the labels queue: triage and review-window: unscheduled)
  • Have the relevant issues been added to the pull request?
  • Have the relevant labels been added to the issues? (package:, type:)
  • Have the relevant issues been added to the same project milestone as the pull request?

Changelog and release notes

  • Has the CHANGELOG.adoc + doc/content/modules/user-manual/pages/release-notes/YYYY.MM.0.adoc been updated to reference the relevant issues?
  • Have the relevant API breaks been described in the CHANGELOG.adoc?
  • Are the new / upgraded dependencies mentioned in the relevant section of the CHANGELOG.adoc?
  • In case of a change with a visual impact, are there any screenshots in the doc/content/modules/user-manual/pages/release-notes/YYYY.MM.0.adoc?
  • In case of a key change, has the change been added to Key highlights section in doc/content/modules/user-manual/pages/release-notes/YYYY.MM.0.adoc?

Documentation

  • Have you included an update of the documentation in your pull request? Please ask yourself if an update (installation manual, user manual, developer manual...) is needed and add one accordingly.

Tests

  • Is the code properly tested? Any pull request (fix, enhancement or new feature) should come with a test (or several). It could be unit tests, integration tests or cypress tests depending on the context. Only doc and releng pull request do not need for tests.

Bug: eclipse-syson#2675
Signed-off-by: Yvan Lussaud <yvan.lussaud@obeo.fr>
@AxelRICHARD AxelRICHARD added this to the 2026.12.0 milestone Nov 26, 2026
@AxelRICHARD AxelRICHARD added queue: scheduled A reviewer and review window have been allocated for this PR review-window: week 3 The PR is scheduled for review in the third week of the iteration labels Nov 26, 2026
@AxelRICHARD AxelRICHARD linked an issue Nov 26, 2026 that may be closed by this pull request
/**
* The {@link Diagnostic} {@link List}.
*/
private List<Diagnostic> diagnostics;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the difference between diagnostics and internalDiagnostics?
why diagnostics was useless until now?

<ownedRelationship xsi:type="sysml:OwningMembership">
<ownedRelatedElement xsi:type="sysml:AttributeUsage" declaredName="x">
<ownedRelationship xsi:type="sysml:FeatureValue">
<ownedRelatedElement xsi:type="sysml:LiteralInteger"/>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omit the overflowing initializer

Import package P { attribute x = 9223372036854775807; attribute y = 7; }. The importer warns about the overflow, then gives x a value of 0. y keeps its value of 7.

  • Cause — Recovery leaves a LiteralInteger inside the initializer. Its unset primitive value reads as 0, and this fixture expects that literal to be retained.
  • Fix — Omit the failed initializer while keeping the attribute and its siblings. Assert in the regression test that x has no initializer and y still has value 7.
  • If skipped — The imported model contains a numeric value the author never supplied. Downstream consumers can use or export it as an ordinary zero.

literalReal:
{start(_localctx, literalRational__());} (
(realValue {set(literalRational_Value(), fromString(eDouble(), currentContextText(_localctx)));})
(realValue {setFromContext(literalRational_Value(), _localctx);})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exclude hidden notes from real-number conversion

Import package P { attribute x = 1 //* note */ .2; }. The grammar accepts the hidden note between the numeric tokens, but the importer warns and gives x a value of 0.0. Removing the note gives 1.2.

  • Cause — The source interval already included hidden tokens before this PR. The new recovery path sends the note text to the converter and then imports the default value when conversion fails.
  • Fix — Build the conversion string from the numeric rule's default-channel tokens and add this case to the parser fixtures with an expected value of 1.2.
  • If skipped — A note can change an otherwise representable number in the imported model.

} catch (Exception e) {
String message = ctx.getStart().getLine() + ":" + ctx.getStart().getCharPositionInLine() + " Unable to set " + attribute.getEContainingClass().getName() + "." + attribute.getName()
+ " to " + text;
this.diagnostics.add(new BasicDiagnostic(Diagnostic.ERROR, null, 0, message, null));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Report conversion failures through the configured error listeners

Run the generated parser directly, with the same internal diagnostic setup used by SerializerRoundTripTestSupport:

var parser = new SysMLParser(new CommonTokenStream(
        new SysMLLexer(CharStreams.fromString("2147483648"))));
parser.setInternalDiagnostics(new ArrayList<>());
parser.literalInteger();

The conversion error is caught, then reporting it throws a NullPointerException. Through SysMLModelParser, the diagnostic is returned, but its getData() is empty even though the line and column are known.

  • Cause — The catch block writes to a separate list that only the wrapper initializes, and puts the location in the message string.
  • Fix — Dispatch the diagnostic through the existing error listeners with the literal's start token, line, and column. Dispatch directly so conversion failures do not trigger syntax recovery.
  • If skipped — Direct parser callers still abort on overflow, and callers that read structured diagnostic locations have to parse the message to locate the literal.

@AxelRICHARD AxelRICHARD added queue: in-review The PR is being reviewed, the PR author must not update the PR and removed queue: scheduled A reviewer and review window have been allocated for this PR labels Nov 27, 2026

This branch has not been deployed

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

Labels

queue: in-review The PR is being reviewed, the PR author must not update the PR review-window: week 3 The PR is scheduled for review in the third week of the iteration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[parser] Integer overflow during value conversion

2 participants