Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SofaCore] Link: case where Data parent is invalid #2211

Merged
merged 4 commits into from
Jul 9, 2021

Conversation

alxbilger
Copy link
Contributor

parentData == nullptr leads to a crash. I think it happens when the linked object could not be created for some reasons.


By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).


Reviewers will merge this pull-request only if

  • it builds with SUCCESS for all platforms on the CI.
  • it does not generate new warnings.
  • it does not generate new unit test failures.
  • it does not generate new scene test failures.
  • it does not break API compatibility.
  • it is more than 1 week old (or has fast-merge label).

@alxbilger alxbilger added pr: fix Fix a bug pr: status to review To notify reviewers to review this pull-request labels Jun 29, 2021
@alxbilger
Copy link
Contributor Author

@damienmarchal I would like to know your opinion about what to do in the case parentData==nullptr, because I am not sure about what I did.

alxbilger and others added 2 commits June 30, 2021 12:20
Co-authored-by: Guillaume Paran <guillaume.paran@sofa-framework.org>
@alxbilger
Copy link
Contributor Author

I tested different scenarios:
If ComponentA is defined before ComponentB:

  1. A Data of ComponentA referring to a Data of ComponentB is not linked properly: the numeric value is not the right one, and Data that depends on the first Data are not updated accordingly.
  2. A Data of ComponentB referring to a Data that does not exist (and will not exist) does not warn the user. The link is created (pointing to nothing) with a default numeric value.

Therefore, I suggest to restore the else statement with a warning to the user that the link does not have a parent. It seems that the case when a Data points to a Data that will be initialized later is not supported.
What do you think @damienmarchal ?

@guparan guparan added pr: status ready Approved a pull-request, ready to be squashed and removed pr: status to review To notify reviewers to review this pull-request labels Jul 8, 2021
@fredroy fredroy merged commit 10f16d3 into sofa-framework:master Jul 9, 2021
@guparan guparan added this to the v21.12 milestone Oct 1, 2021
@alxbilger alxbilger deleted the parse_invalid_parent branch June 28, 2022 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: fix Fix a bug pr: status ready Approved a pull-request, ready to be squashed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants