DRAFT: fix undefined casting behavior through new SGRawValue type#1303
Closed
heshpdx wants to merge 2 commits into
Closed
DRAFT: fix undefined casting behavior through new SGRawValue type#1303heshpdx wants to merge 2 commits into
heshpdx wants to merge 2 commits into
Conversation
First attempt. There is a build error with the latest code.
Closed
heshpdx
commented
Jul 15, 2025
| else { | ||
| if (!setter) property->setAttribute(SGPropertyNode::WRITE, false); | ||
| if (!getter) property->setAttribute(SGPropertyNode::READ, false); | ||
| tied_properties.push_back(PropertyState(property, nullptr)); |
Contributor
Author
There was a problem hiding this comment.
This line is causing the segfault in the TestPlanet CI test.
The issue has to do with BindingInstance in PropertyState being set to nullptr. In FGFDMExec.cpp line 796, a special 'Unbind()' assumes that all of the properties under 'atmosphere' have a BindingInstance set to that model. This is new code not in the SPEC CPU codebase.
Member
|
Thanks for the PR. I have a number of comments:
|
Member
This is mostly addressed in the PR #1304 so that we can focus on the actual issue in this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We are seeing undefined behavior due to the casting of enums as integers, and that comes from calling the casted function pointers to tie property values.
This PR is a proof-of-concept of how to fix the issue using
std::functionwith lambdas to wrap the casting. We should figure out if this is the best approach for changing the code. Right now this patch fixes the first error exposed by the LLVM optimizer, but there are 25+ more files of changes we would have to take on to make it clean.#834