Skip to content
master
Go to file
Code

Latest commit

Close leaks coming from unnamed array types

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

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


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

```chapel
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:

```chapel
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;
foo(t);
//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
  `insertCallDestructors`.

  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
  scope.

- 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]

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

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time

README.rst

https://chapel-lang.org/images/cray-chapel-logo-200.png

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.

License

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.

Resources

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

Project homepage: https://chapel-lang.org
Installing Chapel: https://chapel-lang.org/download.html
Building from source: https://chapel-lang.org/docs/usingchapel/QUICKSTART.html
Sample computations: https://chapel-lang.org/hellos.html
Learning Chapel: https://chapel-lang.org/learning.html
Reporting bugs: https://chapel-lang.org/bugs.html
Online documentation: https://chapel-lang.org/docs/
GitHub: https://github.com/chapel-lang/chapel
Mailing lists: https://sourceforge.net/p/chapel/mailman
Facebook: https://www.facebook.com/ChapelLanguage
Twitter: https://twitter.com/ChapelLanguage
You can’t perform that action at this time.