Aliasing analysis fails
Look at this code:
noinline
int[10000], int[10000] foo (int len)
{
a = with {
} : genarray( [len], 2);
if( _eq_SxS_( len, 10000)) {
c = a;
} else {
c = with {
} : genarray( [len], 4);
}
return (a, c);
}
int main()
{
a,c = foo (10000);
b = {iv-> _add_SxS_( _sel_VxA_(iv, a),1)};
return _add_SxS_( _sel_VxA_([2], b), _sel_VxA_([2], c));
}
The function foo creates a potential alias here. However, it seems the aliasing analysis does not pick this up.
What happens is that the mem phase decides that the increment in main can be done in place! After the selection into c
, the runtime system attempts a free for a second time:
-sbs-Bodos-IMac-> sac2c MEMORY-error-cuda-managed.sac ; a.out
a.out(38071,0x10ca1edc0) malloc: *** error for object 0x7fe95d800000: pointer being freed was not allocated
a.out(38071,0x10ca1edc0) malloc: *** set a breakpoint in malloc_error_break to debug
Abort
-sbs-Bodos-IMac-> sac2c -V
sac2c 1.3.3-MijasCosta-578-g3920
build-type: RELEASE
built-by: "sbs" at 2021-04-13T19:54:17