-
Notifications
You must be signed in to change notification settings - Fork 148
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
Static check of file descriptor argument to tasks like $fgetc #668
Comments
The above code doesn't create registers. An interface assigned with file_descriptors_vec <- replicateM(mkRegU); I would avoid using
If you declare a vector with no assignment on the same line, and then assign individually to the elements, BSC is smart enough to detect which elements of a vector have been unassigned and will give you an error if you attempt to access them. For example:
But if If you ever need to explicitly create a vector with uninitialized entires, you can use
Anyway, does replacing Maybe the Bluesim implementation of Some other notes, if you don't mind me commenting: I used Also note that you can use a
|
Thanks for your fast and detailed explanation! I agree, a better error message could be helpful. Could this be implemented as a basic compile-time check, without simulation runtime overhead? |
It would be interesting to see the behavior when generated to Verilog and run through various simulators, to see if they segfault as well, or if they do some kind of check. (It occurs to me that Bluesim could keep track of the file descriptors that it has opened, from calls to One simple check that BSC could do is to check whether the expression for a file descriptor argument contains a don't-care value ( A more robust check would be to see whether the argument comes ultimately from an But certainly we could do the don't-care check. |
Hello together,
I would like to report a behavior, which I don't fully understand, yet.
Task: I am reading 9 binary file(s) (zero.bin .... eight.bin) in bluesim. In the below code example, I am just reading one file to keep it simple.
Problem: When keeping track of the file descriptors, a Vector of Regs crashes bluesim with a segfault when reading (not opening) the first byte of the first file.
Easy functional workaround: Instead, use a register containing a vector of file descriptors.
Minimal Code example below:
Variables:
Open File(s). Here we open just one file and use only the first index of our vector.
Read the file from the first index of the Vector.
Output:
Stackdump from journalctl (project paths shortened):
The text was updated successfully, but these errors were encountered: