mirror of
https://github.com/edera-dev/sprout.git
synced 2026-11-04 22:02:20 +00:00
fix(main): skip entries whose context can't be finalized
A value that refers to itself, such as a BLS entry with "options $options", never stops changing when the context is finalized. After the iteration limit, finalizing failed and every entry was lost, although the BLS generator already skips broken entries. Skip just that entry with a warning. A value that refers to itself twice doubles in length every iteration, so it could use up all memory before the limit was reached. Fail once a value grows past 64 KiB.
This commit is contained in:
1 parent
aed9903180
commit
cd38f0271d
2 files changed
+26
-6
No files matched your search
+17
-6
@@ -260,15 +260,24 @@ fn run() -> Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
for entry in &mut entries {
|
||||
// Entries whose context can't be finalized are skipped, as one broken entry
|
||||
// should not prevent booting any of the other entries.
|
||||
entries.retain_mut(|entry| {
|
||||
let mut context = entry.context().fork();
|
||||
// Insert the values from the entry configuration into the
|
||||
// sprout context to use with the entry itself.
|
||||
context.insert(&entry.declaration().values);
|
||||
let context = context
|
||||
.finalize()
|
||||
.context("unable to finalize context")?
|
||||
.freeze();
|
||||
let context = match context.finalize() {
|
||||
Ok(context) => context.freeze(),
|
||||
Err(error) => {
|
||||
warn!(
|
||||
"skipping entry {}, unable to finalize context: {:#}",
|
||||
entry.name(),
|
||||
error
|
||||
);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
// Provide the new context to the bootable entry.
|
||||
entry.swap_context(context);
|
||||
// Restamp the title and sort key with any values.
|
||||
@@ -282,7 +291,9 @@ fn run() -> Result<()> {
|
||||
entry.mark_default();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
true
|
||||
});
|
||||
|
||||
// Sort the entries by their sort key, finalizing the order to show entries. This happens
|
||||
// in reverse order so that entries that would come last show up first in the menu.
|
||||
|
||||
Reference in new issue
Block a user