-
Notifications
You must be signed in to change notification settings - Fork 129
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
Panic on large data transfer #277
Comments
I encountered the same panic, it only happens if the receiver was created in a different process, so a workaround is to create the channel in the process the receiver will be used: use ipc_channel::ipc;
fn main() {
let args: Vec<String> = std::env::args().collect();
if args.len() == 2 {
child(args[1].clone());
} else {
parent(args[0].clone());
}
}
fn parent(executable: String) {
let (server, server_name) = ipc::IpcOneShotServer::new().unwrap();
let mut child = std::process::Command::new(executable)
.arg(server_name)
.stdout(std::process::Stdio::piped())
.spawn()
.unwrap();
let (_, (tx, workaround_tx)): (_, (ipc::IpcSender<String>, ipc::IpcSender<ipc::IpcSender<String>>)) = server.accept().unwrap();
let (tx_send, rx) = ipc::channel().unwrap();
workaround_tx.send(tx_send).unwrap();
let payload = "a".repeat(70000);
tx.send(payload.clone()).unwrap();
let received = rx.recv().unwrap();
assert_eq!(payload, received);
child.wait().unwrap();
}
fn child(server_name: String) {
let one_shot_sender = ipc::IpcSender::connect(server_name).unwrap();
let (workaround_tx_send, workaround_rx) = ipc::channel().unwrap();
let (tx_send, rx) = ipc::channel().unwrap();
one_shot_sender.send((tx_send, workaround_tx_send)).unwrap();
let tx: ipc::IpcSender<String> = workaround_rx.recv().unwrap();
let payload: String = rx.recv().unwrap();
tx.send(payload).unwrap();
} |
YaLTeR
added a commit
to YaLTeR/bxt-rs
that referenced
this issue
May 31, 2022
Workaround for a panic on Windows: servo/ipc-channel#277
YaLTeR
added a commit
to YaLTeR/bxt-rs
that referenced
this issue
Jun 2, 2022
Workaround for a panic on Windows: servo/ipc-channel#277
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I get this strange panic when sending large messages to a child process. I was able to recreate the problem in this minimal example. The program runs correctly for smaller payload sizes, e.g. 60000.
Tested on:
The text was updated successfully, but these errors were encountered: