-
Notifications
You must be signed in to change notification settings - Fork 116
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
Missing definition of sail_cons with C backend #202
Comments
In fact I don't think it is possible to implement
Unfortunately you can't do that because
Then I believe this would work:
But it might be better if it just generated the code itself rather than resorting to macro mess. Although... it kind of looks like the code is supposed to do that so I'm not sure what is going on... |
Ah wait, it does generate a cons function, like this:
However it doesn't ever call it. Hmm. |
Aha on this line it's checking for
And now it works fine. I was unable to figure out where that extra |
Do you have an example program? |
This is currently how it works but reference counting could also work, and would likely be more efficient. |
Should be fixed by c9c8e61 |
There may be other bugs lurking with the list implementation - I don't think any of our written specs use lists, so at some point this bug got introduced and nobody noticed. I've added a regression test to make sure it doesn't repeat. |
On Fri, 27 Jan 2023, 16:20 Alasdair Armstrong, ***@***.***> wrote:
There may be other bugs lurking with the list implementation - I don't
think any of our written specs use lists,
And perhaps good in general to avoid them, if possible...?
… so at some point this bug got introduced and nobody noticed. I've added a
regression test to make sure it doesn't repeat.
—
Reply to this email directly, view it on GitHub
<#202 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABFMZZS22UYUGMVK7JJS3QLWUPYUNANCNFSM6AAAAAAUIWUSLE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Yes I think if we ever do a system verilog or other HDL translation for verification, we will have to forbid usage of linked lists in quite a few places |
That was fast! Unfortunately it segfaults for me now:
Bit of a strange backtrace. I will investigate on Monday! For reference, I'm using lists to store a list of memory accesses and register writes (similar to what RVFI-DII does but supporting more than one memory access per instruction). The alternative is to use platform callbacks, but years of writing Rust has given me a healthy suspicion of callbacks! Especially given that the current C backend is unfortunately fully global. |
Ok I got carried away and broke out address sanitiser (it's amazing; if you're not using it you're doing it wrong). Here's the much more helpful output...
The offending code:
Still not obvious to me what is going on tbh. I'll add some printf debugging. |
Oh wait here is the error:
You access |
Yep, I found that too! ...as well as quite a few more subtle errors. I wrote some more tests and ran them through valgrind which should hopefully squish most of the bugs. |
Unfortunately I still get segfaults with lists in the latest |
I can probably work with a larger test case as well if you have one |
Ah actually it was my mistake - I forgot to copy the new All seems to be working now! |
…_manifest, sail_lem_backend, sail_latex_backend, sail_doc_backend, sail_coq_backend, sail_c_backend, sail and libsail (0.16) CHANGES: ##### New documentation backend A new documentation backend for integrating with Asciidoctor has been added. ##### Automatic formatting (EXPERIMENTAL) The `sail -fmt` option can be used to automatically format Sail source. This currently misses some features and can produce ugly output in some known cases, so is not ready for serious usage yet. ##### Fixes Various bugfixes including: * Issue 203: rems-project/sail#203 * Issue 202: rems-project/sail#202 * Issue 188: rems-project/sail#188 * Issue 187: rems-project/sail#187 * Issue 277: rems-project/sail#277 Various mapping issues such as: * Issue 244: rems-project/sail#244 As well as other minor issues The `val cast` syntax and support for implict casts is now entirely removed, as mentioned in the previous release changes. The flags are still allowed (to avoid breaking Makefiles) but no longer do anything. The pattern completeness checker has been improved and is now context sensitive in some cases.
…_manifest, sail_lem_backend, sail_latex_backend, sail_doc_backend, sail_coq_backend, sail_c_backend, sail and libsail (0.16) CHANGES: ##### New documentation backend A new documentation backend for integrating with Asciidoctor has been added. ##### Automatic formatting (EXPERIMENTAL) The `sail -fmt` option can be used to automatically format Sail source. This currently misses some features and can produce ugly output in some known cases, so is not ready for serious usage yet. ##### Fixes Various bugfixes including: * Issue 203: rems-project/sail#203 * Issue 202: rems-project/sail#202 * Issue 188: rems-project/sail#188 * Issue 187: rems-project/sail#187 * Issue 277: rems-project/sail#277 Various mapping issues such as: * Issue 244: rems-project/sail#244 As well as other minor issues The `val cast` syntax and support for implict casts is now entirely removed, as mentioned in the previous release changes. The flags are still allowed (to avoid breaking Makefiles) but no longer do anything. The pattern completeness checker has been improved and is now context sensitive in some cases.
I cons'd a list... and when I compiled it to C it calls
sail_cons()
:However this gives a linker error and I can't find the definition of
sail_cons
anywhere. Am I supposed to write it myself?On a similar topic, how does garbage collection of lists work? As far as I can tell lists are singly linked and immutable in the FP tradition. So if you do something like this:
What happens? I can think of a few possibilities:
list_a
gets copied intolist_b
andlist_c
.The text was updated successfully, but these errors were encountered: