jsbsim icon indicating copy to clipboard operation
jsbsim copied to clipboard

fix uninitialized ThrottlePos in FGTurbine

Open roccoblues opened this issue 6 months ago • 4 comments

ThrottlePos is used in InitRunning() to calculate N2 before the first Calculate() initializes it from the engine.

We observed the uninitialized memory sometimes causing astronomical full consumption because ThrottlePos->N2->Thrust->fuel consumption.

roccoblues avatar Jun 12 '25 15:06 roccoblues

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 24.76%. Comparing base (1f7bceb) to head (b1a3ac0). Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/models/propulsion/FGTurbine.cpp 0.00% 1 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1297      +/-   ##
==========================================
- Coverage   24.76%   24.76%   -0.01%     
==========================================
  Files         169      169              
  Lines       19605    19606       +1     
==========================================
  Hits         4856     4856              
- Misses      14749    14750       +1     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Jun 12 '25 16:06 codecov[bot]

Just wondering whether InitRunning() should use this instead of 0.

ThrottlePos = in.ThrottlePos[EngineNumber];

seanmcleod70 avatar Jun 12 '25 17:06 seanmcleod70

Just wondering whether InitRunning() should use this instead of 0.

ThrottlePos = in.ThrottlePos[EngineNumber];

Yeah, looks correct to me. But I'm not deep enough into the codebase to have an informed opinion. 😄

I would keep it as a separate commit because that technically changes the behavior? In practice it probably doesn't matter.

roccoblues avatar Jun 12 '25 18:06 roccoblues

It rang a bell, just looked it up, based on this commit - https://github.com/JSBSim-Team/jsbsim/commit/a48cf0e6301de42cbb49e9442849caf7e44f8cb5 there is code that specifically sets the throttle position before the engine type specific InitRunning() is called.

seanmcleod70 avatar Jun 12 '25 18:06 seanmcleod70

PR merged. Thanks for your contribution.

bcoconni avatar Jul 15 '25 09:07 bcoconni