Skip to content

Infinite recursion in a test with a bounded loop #5889

@runarorama

Description

@runarorama

This test hangs, pegging CPU at 100% and growing memory usage to over 10 GB, but only when run with the test command in UCM:

test> data.Array.Raw.map.tests.props = test.verify do
  use Nat * + < ==
  use Raw fromList map toList
  use data.Array.Raw read size
  labeled "identity mapping" do
    n = natIn 0 50
    xs = listOf nat do n
    arr = fromList xs
    result = map id arr
    ensure (size result == size arr)
    go i =
      if i < size arr then
        ensureEqual (read result i) (read arr i)
        go (i + 1)
      else ()
    go 0

Note that it completes normally when run as a watch expression, or via the run command.

This version completes normally even under test:

test> data.Array.Raw.map.tests.props = test.verify do
  use Nat * + < ==
  use Raw fromList map toList
  use data.Array.Raw read size
  labeled "identity mapping" do
    n = natIn 0 50
    xs = listOf nat do n
    arr = fromList xs
    result = map id arr
    ensure (size result == size arr)
    ensureEqual (toList result) (toList arr)

To reproduce:

  1. Clone the @runarorama/rational branch from @unison/base.
  2. debug.clear-cache
  3. test data.Array.Raw.map.tests

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions