Skip to content

Parser hangs on first pass (transform_timeout) - 20 cases #2451

@krystophny

Description

@krystophny

Summary

Fortfront hangs during first pass transformation on 20 test cases from GCC testsuite. These are distinct from roundtrip_timeout (which hangs on second pass).

Standard vs Lazy Fortran Behavior

This issue affects: BOTH standard and lazy Fortran (.f90 and .lf files)

Parser hangs are independent of file type - they occur during AST construction regardless of whether type inference is needed.

Standard Fortran (.f90):

  • Parser hangs during first pass (parse → AST construction)
  • Affects files with complex intrinsic calls and array expressions
  • Should parse and emit code without modification

Lazy Fortran (.lf):

  • Same parser hang during first pass
  • Type inference never runs (parser doesn't complete)
  • Same root cause as standard Fortran parsing

CRITICAL: This is a parser correctness issue, not a type inference issue. Both .f90 and .lf files would hang on the same constructs.

Frequency

20 cases (1.3% of all failures)

Root Cause Analysis

Based on test patterns, likely causes:

  • Intrinsic function calls with complex arguments: maxloc, minloc, spread, reshape with masks/dimensions
  • Deeply nested allocatable components: Deep copy operations with nested allocatable types
  • Complex array expressions: Array slices with multiple dimensions and function calls

ISO Standard Compliance

NON-COMPLIANT with ISO/IEC 1539-1:2018:

  • Section 16.9 specifies all intrinsic function definitions and their requirements (e.g., 16.9.94 MAXLOC, 16.9.160 RESHAPE, 16.9.195 SPREAD). Parser must handle references to these intrinsics with keyword arguments and complex expressions.
  • Section 9.7.3.3: Parser must handle complex array constructor expressions
  • Section 6.5.3.2: Parser must handle arbitrarily deep type definitions

Evidence (Fresh GCC Roundtrip Testing)

From logs/gfortran_verify_issues.jsonl:

  • Status: timeout (first pass timeout)
  • Duration: All cases timeout during first fortfront invocation
  • Common keywords: any, dim, mask, minloc, maxloc, reshape, pointer_attr

Top keywords across 20 cases:

  • any (frequent)
  • dim (array dimension operations)
  • mask (masked array operations)
  • minloc/maxloc (intrinsics with complex arguments)
  • reshape, spread (array manipulation)
  • pointer_attr (pointer/allocatable deep structures)

Independent Test Case

! Minimal reproducer for parser hang with complex intrinsic calls
program test_complex_intrinsic
    implicit none
    integer :: arr(3,3), result(2)
    
    arr = reshape([1,2,3,4,5,6,7,8,9], [3,3])
    result = maxloc(arr, dim=1, mask=arr > 5)
    print *, result
end program

Test Case Requirements

Create independent minimal examples that trigger the hang (DO NOT copy GCC files):

  1. Complex intrinsic calls (maxloc, minloc with dim and mask)
  2. Array constructor with reshape
  3. Nested allocatable type definitions

References

  • Discovery: gfortran roundtrip testing
  • Status: timeout (20 cases, first pass)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions