Skip to content

Don't use TMM to allocate argv#1980

Merged
sharmeye merged 6 commits intomasterfrom
command-line-arguments
Dec 4, 2025
Merged

Don't use TMM to allocate argv#1980
sharmeye merged 6 commits intomasterfrom
command-line-arguments

Conversation

@brendan-nasa
Copy link
Copy Markdown
Contributor

argv is not supposed to be sim-readable/writable => shouldn't use TMM allocator

  • Change argv in Trick::CommandLineArguments from using TMM_declare_var_1d("char*") to a std::vector<std::string>
  • c_int continues to return a char** via std::vector::data
  • declared static to ensure the char** outlives function

Additionally:

  • fix #includes in CommandLineArguments.cpp

@brendan-nasa brendan-nasa requested a review from hchen99 October 16, 2025 19:13
@coveralls
Copy link
Copy Markdown

coveralls commented Oct 16, 2025

Coverage Status

coverage: 55.798% (-0.002%) from 55.8%
when pulling 415fa11 on command-line-arguments
into b07fbb8 on master.

Comment thread trick_source/sim_services/CommandLineArguments/command_line_c_intf.cpp Outdated
Comment thread trick_source/sim_services/CommandLineArguments/CommandLineArguments.cpp Outdated
Comment thread trick_source/sim_services/CommandLineArguments/CommandLineArguments.cpp Outdated
@hchen99
Copy link
Copy Markdown
Contributor

hchen99 commented Oct 16, 2025

Looks good overall. Just a couple of small comments.

Comment thread trick_source/sim_services/CommandLineArguments/CommandLineArguments.cpp Outdated
@sharmeye sharmeye merged commit 3674388 into master Dec 4, 2025
18 checks passed
@ddj116
Copy link
Copy Markdown
Contributor

ddj116 commented Dec 5, 2025

Noting here that our Ramtares CI system that forward-tests our workflow with the bleeding edge of Trick's origin/master is consistently failing with this type of error at sim startup:

Traceback (most recent call last):
  File "RUN_AOA/input.py", line 8, in <module>
    exec(open("Modified_data/input_files/default_AOA.py").read())
  File "<string>", line 8, in <module>
  File "<string>", line 98, in __init__
IndexError: list index out of range
|L   0|2025/12/04,22:02:15.849387|blade17-fsl.fsl.jsc.nasa.gov| |T 0|0.000000| �[00m
SIMULATION TERMINATED IN
  PROCESS: 0
  ROUTINE: IPPython.cpp:148
  DIAGNOSTIC: Input Processor error

We had a successful test at b6061e7 which is the direct parent of 3674388 so there appears to be something about this PR that is causing this.

This isn't currently breaking us as our production branches are hanging out at much older 16828a9 and will be for some time, just posting here in case others in the Trick community are seeing something similar. Will update this thread with info as we dig in.

@excaliburtb
Copy link
Copy Markdown
Contributor

for context: they are doing this:
args = [str(arg) for arg in trick.command_line_args_get_argv()]

this stops working in newest swig anyway:
however, i tried the following:
args = [str(trick.command_line_args_get_argv()[ii]) for ii in range(trick.command_line_args_get_argc())]

which should work but also doesn't work:

print(trick.command_line_args_get_argc())
print(trick.command_line_args_get_argv()[0])
print(trick.command_line_args_get_argv()[1])

produces:

2
Traceback (most recent call last):
  File "RUN_test/input.py", line 30, in <module>
    print(trick.command_line_args_get_argv()[0])
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
SystemError: <built-in function swig_ref___getitem__> returned NULL without setting an exception

@brendan-nasa
Copy link
Copy Markdown
Contributor Author

Thanks for the logs, y'all. I'll take a look

@sharmeye
Copy link
Copy Markdown
Contributor

sharmeye commented Dec 5, 2025

It's always the PRs you least expect

@sharmeye sharmeye deleted the command-line-arguments branch January 14, 2026 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants