Skip to content
Go to file

Latest commit

Close leaks coming from unnamed array types

This PR improves the memory management for runtime type values returned from

Resolves #14309
Resolves #15611
Resolves #14318
Resolves Cray/chapel-private#1171

The main issue was if you have a code like this:

proc foo(type t) { /* bla */ }

foo([1..3] int);

The argument to `foo` is parsed as a forall expression. Within the relevant
`chpl__forallexpr` function created for that expression, we call
`chpl__ensureDomainExpr` on the range which creates a domain. But we never free
the memory for that domain. 

The following did not leak even before this PR:

proc foo(type t) { /* bla */ }

foo([{1..3}] int);
// doesn't leak because we create the domain in the calling scope and as such it
// is cleaned here

type t = [1..3] int;
//doesn't leak because parser is able to tell that this is actually an array
//type and creates the domain in this scope

This is done by two changes in `callDestructors:

- A new function `insertAutoDestroyPrimsForLoopExprTemps` that is called before

  This function looks at `CallExpr`s that call a forall expression function, and
  depending on the temp that stores the return value and the argument to the
  function adds a `PRIM_AUTO_DESTROY_RUNTIME_TYPE` for that temp in the calling

- Improve `lowerAutoDestroyRuntimeType` by iterating over all the fields of the
  runtime type instead of hardcoding the `dom` field. This allows `eltType`
  field to be cleaned, too. 

[Reviewed by @mppf]

- [x] asan `release/examples`
- [x] asan all leaky tests
- [x] `--memleaks` all leaky tests
- [x] standard
- [x] gasnet


Failed to load latest commit information.
Latest commit message
Commit time


The Chapel Language

What is Chapel?

Chapel is a modern programming language designed for productive parallel computing at scale. Chapel's design and implementation have been undertaken with portability in mind, permitting Chapel to run on multicore desktops and laptops, commodity clusters, and the cloud, in addition to the high-end supercomputers for which it was originally undertaken.


Chapel is developed and released under the terms of the Apache 2.0 license, though it also makes use of third-party packages under their own licensing terms. See the LICENSE file in this directory for details.


For more information about Chapel, please refer to the following resources:

Project homepage:
Installing Chapel:
Building from source:
Sample computations:
Learning Chapel:
Reporting bugs:
Online documentation:
Mailing lists:
You can’t perform that action at this time.