This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
ivopts vs. garbage collection
- From: Ian Lance Taylor <iant at golang dot org>
- To: GCC Development <gcc at gcc dot gnu dot org>
- Cc: Lynn Boger <laboger at linux dot vnet dot ibm dot com>
- Date: Wed, 6 Jan 2016 07:17:41 -0800
- Subject: ivopts vs. garbage collection
- Authentication-results: sourceware.org; auth=none
The bug report https://golang.org/issue/13662 describes a case in
which ivopts appears to be breaking garbage collection for the Go
compiler. There is an array allocated in memory, and there is a loop
over that array. The ivopts optimization is taking the only pointer
to the array and subtracting 8 from it before entering the loop.
There are function calls in between this subtraction and the actual
use of the array. During those function calls, a garbage collection
occurs. Since the only pointer to the array no longer points to the
actual memory being used, the array is unexpectedly freed.
That all seems clear enough, although I'm not sure how best to fix it.
What I'm wondering in particular is whether Java does anything to
avoid this kind of problem. I don't see anything obvious. Thanks for
any pointers.
Ian