Skip to content

[MISRA-CERT-09] Unbounded recursion not detected or rejected (MISRA Rule 17.2) #271

Closed

Description

@godofecht

Description

The type checker has a call graph (built for @rt_safe in src/flow/type_checker.py line 1014) but does not detect direct or indirect recursion. Stack overflow from unbounded recursion is a safety hazard.

MISRA C bans direct and indirect recursion in safety-critical code.

The existing _compute_rt_unsafe_functions call graph could be extended to detect cycles.

Standards

  • MISRA C:2024 Rule 17.2 (Required): Functions shall not call themselves, either directly or indirectly.
  • CERT C MEM05-C: Avoid large stack allocations in functions that are called recursively.

Fix

  1. Add a --no-recursion flag (or --profile safety) that makes the type checker reject any call graph cycle as an error.
  2. Reuse _compute_rt_unsafe_functions infrastructure: after building the call graph, run a cycle detection (DFS) and report all recursive functions.
  3. Document that recursion is allowed in default profile but banned in flight/safety profiles.

Audit ID: MISRA-CERT-09

Severity: High | Category: Type checker - control flow safety

Activity

  1. added
    enhancement
    MISRA
    CERT
    on Aug 9, 2026
  2. added 2 commits that reference this issue on Aug 10, 2026
  3. godofecht commented on Aug 10, 2026

    @godofecht
    ContributorAuthor

    Fixed in PR #404: Under --profile safety/flight, the type checker builds a direct call graph and runs DFS to detect cycles. Direct and mutual recursion are rejected at type-check time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CERTMISRAcompilerenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions