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

Re-assigning a closed TcpStream and reading causes a segmentation fault #12668

Closed
rapha opened this issue Mar 3, 2014 · 1 comment
Closed

Comments

@rapha
Copy link
Contributor

rapha commented Mar 3, 2014

$ cat segv.rs    
use std::io::{Acceptor, Listener, net};

fn main() {
  let address = net::ip::SocketAddr { ip: net::ip::Ipv4Addr(127, 0, 0, 1), port: 1234 };
  std::task::spawn(proc() {
    let mut socket = std::io::TcpListener::bind(address).listen().accept();
    socket.write([0]).unwrap();
    println!("server: done");
  });
  let socket = std::io::TcpStream::connect(address);
  std::task::spawn(proc() {
    loop {
      let mut socket = socket; // Here is the problem! Fixed if assignment happens outside loop.
      println!("client: about to read");
      socket.read_byte().unwrap();
      println!("client: read successfully");
    }
  });
}
$ rustc segv.rs && ./segv
client: about to read
server: done
client: read successfully
client: about to read
Segmentation fault: 11
$
@huonw
Copy link
Member

huonw commented Mar 3, 2014

Thanks for the report; this is a rather annoying bug that's filed as #12041.

(It's just the proc + loop interaction, nothing specific to TcpStream etc.)

@huonw huonw closed this as completed Mar 3, 2014
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 25, 2022
fix: Simplify macro statement expansion handling

I only meant to fix rust-lang/rust-analyzer#12644 but that somehow turned into a rewrite of the statement handling ... at least this fixes a few more issues in the IDE layer now
flip1995 pushed a commit to flip1995/rust that referenced this issue Apr 18, 2024
Pin `remark-lint-maximum-line-length` version

Pins the remark versions to the ones from before the most recent set of updates which errors on [some line lengths](remarkjs/remark-lint#318) that aren't clear how to resolve

Currently blocking CI

changelog:  none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants