nasa / trick

Trick Simulation Environment. Trick provides a common set of simulation capabilities and utilities to build simulations automatically.
Other
26 stars 14 forks source link

No error on assignment to non-existent variables in input file #1708

Open keithvetter opened 2 months ago

keithvetter commented 2 months ago

On 10/31/2023 Alex put in a fix to keep bad/accidental/type-o input assignments from being accepted. The issue was #1288 or #1603.

We stumbled on a case where one can assign to a non-existent parameter and get no error. If the code being processed is C (not c++) , there is still an issue with swig 4.

To recreate, simply put the following line in the SIM_ball_L1 sim's RUN_test/input.py:

ball.state.input.fred = 777

The sim will run just fine with no errors despite the fact that fred does not exist.

This is serious issue for ES:

  1. A small type-o would slide through presently with no errors
  2. If one changes a structure in the model code and misses changing the corresponding input associated with the model, Trick will not complain.
  3. Bad input can proliferate in sims as the sim grows and is shared with others
  4. Engineers could be lead to believe results they are receiving go with the input they thought they used, but in reality, a malformed assignment could be doing nothing

I have a proposed small change to trick/libexec/trick/convert_swig to fix this. I will go over this change with the ES group to see if it works for them. If it works, I'll branch and submit a request for review.

hchen99 commented 2 months ago

Thanks @keithvetter

keithvetter commented 1 month ago

I tested the fix on the Gateway sim. There is an issue with a funky typedef:

typedef struct FSWGNCToSimCheaterTruth_struct {
   double  main_engine_thrust;            /* N       Thrust of main engine */
   double  main_engine_thrust_str[3];     /* N       Thrust vec in STR */

} FSWGNCToSimCheaterTruth;

The Name1 in typedef struct Name1 { } Name2; is confusing Trick. Since Name1 is valid syntax, despite not needing it, I need to figure out what to do. My simple fix is in jeopardy of complication because of this funky typedef.