forked from M-Labs/artiq
1
0
Fork 0

firmware: fix crash on exception with host message (#2017)

This commit is contained in:
Egor Savkin 2022-12-07 10:41:43 +08:00 committed by GitHub
parent 3c7a394eff
commit 454ae39c5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 12 deletions

View File

@ -452,6 +452,9 @@ fn process_kern_message(io: &Io, aux_mutex: &Mutex,
let exceptions_with_channel: Vec<Option<eh::eh_artiq::Exception>> = exceptions.iter()
.map(|exception| {
if let Some(exn) = exception {
if exn.message.len() == usize::MAX { // host string
Some(exn.clone())
} else {
let msg = str::from_utf8(unsafe { slice::from_raw_parts(exn.message.as_ptr(), exn.message.len()) })
.unwrap()
.replace("{rtio_channel_info:0}", &format!("{}:{}", exn.param[0], resolve_channel_name(exn.param[0] as u32)));
@ -462,8 +465,9 @@ fn process_kern_message(io: &Io, aux_mutex: &Mutex,
column: exn.column,
function: exn.function,
message: unsafe { CSlice::new(msg.as_ptr(), msg.len()) },
param: exn.param
param: exn.param,
})
}
} else { None }
})
.collect();