[Chapel Merge] Deallocate the RTT memory returned from empty for

Branch: refs/heads/master
Revision: 6e5534e
Author: e-kayrakli
Log Message:

Merge pull request #16628 from e-kayrakli/empty-for-expr-leak

Deallocate the RTT memory returned from empty for expressions

Resolves https://github.com/chapel-lang/chapel/issues/15609

This PR adds a PRIM_AUTO_DESTROY_RUNTIME_TYPE for the chpl__initCopy
overload that takes an iterator argument. The new primitive is added to the
code path where we don’t allocate any data to be copied.

This comes up in the following case:

var AAA = for i in 1..0 do [1,2,3];

which leaks without this PR. The leak is coming from the domain of [1,2,3] not
being freed because of the missing PRIM_AUTO_DESTROY_RUNTIME_TYPE added by
this PR.

This closes leaks in:

arrays/ferguson/from/iterator/for-yields-no-arrays.chpl
arrays/shapes/skyline.when-empty.chpl

[Reviewed by @vasslitvinov]

Test:

  • [x] asan
  • [x] standard
  • [x] gasnet

Modified Files:
M modules/internal/ChapelArray.chpl

Compare: https://github.com/chapel-lang/chapel/compare/88806c41a416...6e5534e4df12