Skip to content

Shell: let ports set script memory limits - #4

Merged
schikani merged 1 commit into
tinydesk-project:mainfrom
aquasock:configurable-script-limits
Oct 7, 2026
Merged

schikani merged 1 commit into
tinydesk-project:mainfrom
aquasock:configurable-script-limits

Conversation

@aquasock

@aquasock aquasock commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Ports can now set TDSH_MAX_VARS, TDSH_VAR_NAME_MAX, TDSH_VAR_VALUE_MAX and TDSH_SCRIPT_TASK_STACK from their build. Defaults remain 64 variables, 32-byte names, 256-byte values and a 32 KB worker stack. Each script still receives its own session and variable copy.

The header and README explain the memory cost and require the same overrides in every component using tdsh.h, including C++ consumers. The README includes a smaller-table build example.

Addresses #2. TinyTang uses 48 variables and 128-byte values, saving 10,768 bytes per BL616 session.

Validation:

  • Linux x86_64: Shell 8/8 and TinyDesk 10/10 tests pass without compiler warnings with defaults and with 48 variables/128-byte values. Boundary, inheritance, isolation, cleanup and stack-request probes also pass.
  • Linux suites retain the default 32 KB stack; 16 KB pthread runs fail in the script tests. On BL616/FreeRTOS, the 16 KB worker stack passed repeated desktop core launches and switches, with 5,656 bytes spare and no allocation refusals after testing.
  • clang-format 16.0.6 passes.

TinyTang's Terminal restart and catalog-allocation fixes are separate port changes. The script-loading allocation-error message remains a separate follow-up.

Reproducible checks: https://github.com/aquasock/TinyTang/blob/4633b4d/tools/tests/test_script_limits.sh

@schikani

schikani commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

Thanks, this looks good: it builds without warnings and the host tests pass with the defaults and with your 48-variable / 128-byte example.

One small thing before I merge it: TDSH_VAR_NAME_MAX also sizes function names, not only variable names (tdsh_script.c and the parser use it for both). When I set it to 12 (names up to 11 characters), the uScript test failed with invalid function declaration because one of its function names is longer than that; with 16 it passed.

Could you add a sentence to the README section and the tdsh.h comment saying that TDSH_VAR_NAME_MAX also limits function names in scripts, including the final NUL? That way a port that shrinks it knows why its scripts suddenly stop parsing.

@schikani
schikani merged commit 7cffa85 into tinydesk-project:main Oct 7, 2026
4 checks passed
schikani added a commit that referenced this pull request Oct 7, 2026
Function names in scripts use the same buffer size as variable names,
so a port that lowers TDSH_VAR_NAME_MAX also shortens the longest
function name a script can declare. Follow-up to #4.
@schikani

schikani commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

Merged, thanks! I've added the note that TDSH_VAR_NAME_MAX also limits function names in a follow-up commit (999ec24), so nothing more is needed here.

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.

2 participants