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

Discharge fails if any indices have been invalidated. #469

Closed
UnsignedByte opened this issue Oct 17, 2024 · 4 comments · Fixed by #471
Closed

Discharge fails if any indices have been invalidated. #469

UnsignedByte opened this issue Oct 17, 2024 · 4 comments · Fixed by #471
Labels
bug Something isn't working C: Internals Component: Compiler internals

Comments

@UnsignedByte
Copy link
Collaborator

Discharge works with DenseIndexInfos, meaning if any parameters/events/ports have been invalidated before discharge this throws an error. The culprit is here:

for (idx, _) in data.comp.params().iter() {
let sexp = self
.sol
.declare_fun(self.fmt_param(idx, comp), vec![], int)
.unwrap();
self.overflow_assert(sexp);
self.param_map.push(idx, sexp);
}
// Declare all events
for (idx, _) in data.comp.events().iter() {
let sexp = self
.sol
.declare_fun(self.fmt_event(idx, comp), vec![], int)
.unwrap();
self.overflow_assert(sexp);
self.ev_map.push(idx, sexp);
}

This causes issues because .ports and .events automatically only iterate over valid indices. We can solve this in two ways:

  • Some sort of "cleanup" pass that removes invalid indices (likely having to reconstruct the entire IR)
  • Change .push to extend the DenseIndexInfo by default. This does not work in the case of discharge though, where SExpr is not Default.
@UnsignedByte UnsignedByte added bug Something isn't working C: Internals Component: Compiler internals labels Oct 17, 2024
@UnsignedByte
Copy link
Collaborator Author

Just realized that insert already accomplishes this for Default stores.

@UnsignedByte
Copy link
Collaborator Author

Even larger issue now is that Exprs can exist that refer to invalid parameters that have been deleted... Classic dangling pointers.

@rachitnigam
Copy link
Member

Yup, arena allocators are hard... Maybe time to switch to a crate for this or something.

@UnsignedByte
Copy link
Collaborator Author

How exactly would this solve the Expr dangling pointer issue? I looked at a few arena allocators (such as kioku) but I am not sure exactly how they might be relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working C: Internals Component: Compiler internals
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants