artiq icon indicating copy to clipboard operation
artiq copied to clipboard

List elements not lifetime-tracked

Open pca006132 opened this issue 3 years ago • 2 comments

Bug Report

One-Line Summary

Lifetime for list elements is not tracked, which can also cause memory corruption.

Issue Details

List lifetime should also consider the lifetime of its elements. Otherwise, by assigning objects to a list and access them, we would not be able to track their lifetime.

Using an example similar to #1677:

@kernel
def bar(ls):
    a = [1, 2, 3]
    b = [ls]
    b[0][0] = a

This should not compile, as the following equivalent code does not compile:

@kernel
def bar(ls):
    a = [1, 2, 3]
    ls[0] = a

The expected output and actual output are similar to #1677.

Your System (omit irrelevant parts)

  • ARTIQ version: current master.

pca006132 avatar May 20 '21 04:05 pca006132

This should not compile

NAC3 seems to be happy with it. Is it what you expected?

@kernel
def bar(ls: list[list[int32]]):
    a = [1, 2, 3]
    b = [ls]
    b[0][0] = a

@kernel
def run() -> int32:
    bar([[2, 1], [1, 4]])
    return 0

sbourdeauducq avatar Oct 03 '21 09:10 sbourdeauducq

This should not compile

NAC3 seems to be happy with it. Is it what you expected?

@kernel
def bar(ls: list[list[int32]]):
    a = [1, 2, 3]
    b = [ls]
    b[0][0] = a

@kernel
def run() -> int32:
    bar([[2, 1], [1, 4]])
    return 0

We have not yet implemented escape analysis in nac3.

pca006132 avatar Oct 03 '21 09:10 pca006132