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

Improve error message in common re_renderer crash #3070

Merged
merged 3 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions crates/re_renderer/src/allocator/cpu_write_gpu_read_belt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ where
///
/// Do *not* make this public as we need to guarantee that the memory is *never* read from!
#[inline(always)]
fn as_slice(&mut self) -> &mut [u8] {
fn as_mut_byte_slice(&mut self) -> &mut [u8] {
// TODO(andreas): Is this access slow given that it internally goes through a trait interface? Should we keep the pointer around?
&mut self.write_view[self.unwritten_element_range.start * std::mem::size_of::<T>()
..self.unwritten_element_range.end * std::mem::size_of::<T>()]
Expand All @@ -61,7 +61,7 @@ where
#[inline]
pub fn extend_from_slice(&mut self, elements: &[T]) {
let bytes = bytemuck::cast_slice(elements);
self.as_slice()[..bytes.len()].copy_from_slice(bytes);
self.as_mut_byte_slice()[..bytes.len()].copy_from_slice(bytes);
self.unwritten_element_range.start += elements.len();
}

Expand All @@ -84,7 +84,15 @@ where
/// Panics if the data no longer fits into the buffer.
#[inline]
pub fn push(&mut self, element: T) {
self.as_slice()[..std::mem::size_of::<T>()].copy_from_slice(bytemuck::bytes_of(&element));
assert!(
self.unwritten_element_range.start < self.unwritten_element_range.end,
"CpuWriteGpuReadBuffer<{}> is full ({} elements written)",
std::any::type_name::<T>(),
self.unwritten_element_range.start,
);

self.as_mut_byte_slice()[..std::mem::size_of::<T>()]
.copy_from_slice(bytemuck::bytes_of(&element));
self.unwritten_element_range.start += 1;
}

Expand Down
1 change: 1 addition & 0 deletions scripts/fetch_crashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,5 @@ def count_uniques(backtrace):
"```\n"
f' {backtrace.decode("utf-8")}\n'
"```\n"
"-------------------------------------------------------------------------------\n"
)