Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiler: Function return values (?) not life-time-tracked #1497

Open
dnadlinger opened this issue Jul 27, 2020 · 2 comments
Open

compiler: Function return values (?) not life-time-tracked #1497

dnadlinger opened this issue Jul 27, 2020 · 2 comments

Comments

@dnadlinger
Copy link
Collaborator

dnadlinger commented Jul 27, 2020

Escape the confines of the ARTIQ compiler escape analysis with this one neat trick - infinite memory corruption at your fingertips!

@kernel
def leak(a):
    return a

class LeakTest(EnvExperiment):
    def build(self):
        self.setattr_device("core")

    @kernel
    def run(self):
        # Fails to compile as it should:
        #     return [1, 2, 3]
        # However…
        return leak([1, 2, 3])

(This kernel shouldn't compile, but does on e4b1642.)

@dnadlinger
Copy link
Collaborator Author

@pathfinder49 One to add to the list…

@dnadlinger
Copy link
Collaborator Author

Reopening, as fix was reverted in ae999db (see commit message for details).

@dnadlinger dnadlinger reopened this Jul 30, 2020
dnadlinger added a commit to dnadlinger/artiq that referenced this issue Jan 20, 2021
This is a use-after-free issue (by the time __modinit sends back
the return value, the array allocated on the stack of the interior
function is already dead) allowed only by mistake, presumably due
to GitHub issue m-labs#1497 or a similar bug.
dnadlinger added a commit to dnadlinger/artiq that referenced this issue Oct 8, 2023
Function calls in general can still be used to hide escaping
allocations from the compiler (issue m-labs#1497), but these calls in
particular always allocate, so we can easily and accurately handle
them.
sbourdeauducq pushed a commit that referenced this issue Oct 9, 2023
Function calls in general can still be used to hide escaping
allocations from the compiler (issue #1497), but these calls in
particular always allocate, so we can easily and accurately handle
them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant