Closed thomasfire closed 1 year ago
Exceptions use deallocated memory in session.
Run experiment:
class KernelNestedFmtException(EnvExperiment): def build(self): self.setattr_device("core") @kernel def run(self): try: self.throw() except: try: raise RTIOUnderflow("{bar}") except: raise RTIOOverflow("{buzz}") def throw(self): raise CustomException("{foo}")
Exceptions would have their respective messages.
RTIOUnderflow has {buzz message. Moreover it has the same pointer as {buzz} message.
RTIOUnderflow
{buzz
{buzz}
https://github.com/m-labs/artiq/blob/b225717ddbd038f40af5d3b875a5cebcda622098/artiq/firmware/runtime/session.rs#L493-L503
The msg is allocated in the same point, and CSlice doesn't own the data, so it gets overwritten on next cycle.
Latest master. release-7 is not affected.
What's the situation on Zynq?
There should not be such problem, since message is written to the stream in the same scope as formatting being done
https://git.m-labs.hk/M-Labs/artiq-zynq/src/commit/48721ca9cb168cf609cb65e0a36ec839e7f0a1b6/src/runtime/src/comms.rs#L270-L282
Bug Report
One-Line Summary
Exceptions use deallocated memory in session.
Issue Details
Steps to Reproduce
Run experiment:
Expected Behavior
Exceptions would have their respective messages.
Actual (undesired) Behavior
RTIOUnderflow
has{buzz
message. Moreover it has the same pointer as{buzz}
message.Cause of problem
https://github.com/m-labs/artiq/blob/b225717ddbd038f40af5d3b875a5cebcda622098/artiq/firmware/runtime/session.rs#L493-L503
The msg is allocated in the same point, and CSlice doesn't own the data, so it gets overwritten on next cycle.
Your System (omit irrelevant parts)
Latest master. release-7 is not affected.