FyroxEngine/Fyrox · critical
Attempt to spawn an object at pool record with payload!…
Error message
Attempt to spawn an object at pool record with payload! Record index is {free_index} What it means
Pool::spawn_with reuses a record popped from the free stack and asserts the record is truly empty (no payload). Finding a payload there means the free-list and record states are out of sync — an internal invariant violation indicating pool corruption (double-free, use-after-free of handles, or manual record tampering).
Solutions
- Audit recent pool operations (free/forget_ticket/unsafe access) for double-free or out-of-order release.
- Rebuild the pool's bookkeeping by recreating the pool instead of continuing with corrupted state.
- Report it upstream with a minimal reproducer if it occurs without unsafe code — it indicates a fyrox-core bug.
Example fix
// before
unsafe { pool.records_get_mut(idx).payload = Some(obj); } // corrupts free list
pool.spawn(obj); // panics on reused record
// after
let handle = pool.spawn(obj); // use the public API Defensive patterns
Strategy: validation
Validate before calling
// only safe API usage: assert!(pool.try_contains(handle) || pool.is_valid_handle(handle)); // never manipulate records/free stack directly
Prevention
- Use only public spawn/free APIs; never write record.payload via unsafe.
- Free each handle exactly once; track freed handles.
- If corruption is suspected, recreate the pool rather than continuing.
When it happens
Trigger: Calling spawn (or spawn_with directly) when the free stack contains an index whose record still holds a payload — normally only reachable through pool corruption or unsafe misuse.
Common situations: Bugs in code that manipulates the free stack or payloads directly; a double-free that pushed an index while the object was still alive; unsafe code writing payloads without updating the free stack.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Animation pool must be empty on load!
- An object at index must be returned to a pool it was taken…
- Attempt to replace object in pool using dangling handle!…
- Ticket index was invalid
- The handle must be valid!
AI-assisted analysis of FyroxEngine/Fyrox@76c91aad8e (2026-09-10).
Data as JSON: /api/errors/64e0e05a8440ddf9.
Report an issue: GitHub.
Appendix: source
Thrown at fyrox-core/src/pool/mod.rs:646
});
Ok(Handle::new(index, generation))
}
}
}
#[inline]
#[must_use]
/// Construct a value with the handle it would be given.
/// Note: Handle is _not_ valid until function has finished executing.
pub fn spawn_with<F: FnOnce(Handle<T>) -> T>(&mut self, callback: F) -> Handle<T> {
if let Some(free_index) = self.free_stack.pop() {
let record = self
.records_get_mut(free_index)
.expect("free stack contained invalid index");
if record.payload.is_some() {
panic!(
"Attempt to spawn an object at pool record with payload! Record index is {free_index}"
);
}
let generation = record.generation + 1;
let handle = Handle {
index: free_index,
generation,
type_marker: PhantomData,
};
let payload = callback(handle);
record.generation = generation;
record.payload.replace(payload);
handle
} else {
// No free records, create new oneView on GitHub (pinned to 76c91aad8e)