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

Crash "free(): invalid pointer" in sock.read() in a separate task #3674

Closed
ttaubert opened this issue Oct 6, 2012 · 11 comments
Closed

Crash "free(): invalid pointer" in sock.read() in a separate task #3674

ttaubert opened this issue Oct 6, 2012 · 11 comments
Labels
A-concurrency Area: Concurrency I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

Comments

@ttaubert
Copy link
Contributor

ttaubert commented Oct 6, 2012

I compiled a little tcp listener example that spawns tasks per connection. The sock.read() call fails when it receives data - just use telnet to connect, type something and hit enter:

extern mod std;

use std::uv;
use std::net::{ip, tcp};

fn main() {
  let iotask = uv::global_loop::get();
  let addr = ip::v4::parse_addr("127.0.0.1");

  tcp::listen(addr, 4000u, 128u, iotask,
    |kill_ch| {
      #info("server is listening");
    },

    |new_conn, kill_ch| {
      let port = comm::Port::<()>();
      let chan = port.chan();

      do task::spawn_sched(task::ManualThreads(1u)) {
        let accept_result = tcp::accept(new_conn);
        chan.send(());

        if accept_result.is_err() {
          let err_data = result::unwrap_err(accept_result);
          kill_ch.send(Some(err_data));
        } else {
          let sock = result::unwrap(accept_result);
          let read_result = sock.read(0);
          if read_result.is_ok() {
            io::println("success");
          } else {
            kill_ch.send(None);
          }
        }
      }

      chan.recv();
    }
  );
}

This used to work with Rust 0.3 but crashes now with the following message:

*** glibc detected *** ./test: free(): invalid pointer: 0x00007f94c41027a8 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x7ec96)[0x7f94cd920c96]
/home/tim/workspace/rust-memcached/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/librustrt.so(+0x36e6d)[0x7f94cdeade6d]
/home/tim/workspace/rust-memcached/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/librustrt.so(upcall_call_shim_on_c_stack+0x87)[0x7f94cde97cd7]
/home/tim/workspace/rust-memcached/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-4782a756585a81-0.4.so(+0x63210)[0x7f94cdf44210]
/home/tim/workspace/rust-memcached/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/librustrt.so(+0x36e6d)[0x7f94cdeade6d]
/home/tim/workspace/rust-memcached/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/librustrt.so(upcall_call_shim_on_rust_stack+0xcf)[0x7f94cde97fff]
/home/tim/workspace/rust-memcached/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-4782a756585a81-0.4.so(+0x60a95)[0x7f94cdf41a95]
/home/tim/workspace/rust-memcached/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/librustrt.so(+0x3af77)[0x7f94cdeb1f77]
/home/tim/workspace/rust-memcached/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/librustrt.so(+0x4099f)[0x7f94cdeb799f]
/home/tim/workspace/rust-memcached/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/librustrt.so(+0x458b8)[0x7f94cdebc8b8]
/home/tim/workspace/rust-memcached/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/librustrt.so(+0x37d12)[0x7f94cdeaed12]
/home/tim/workspace/rust-memcached/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/librustrt.so(+0x36e6d)[0x7f94cdeade6d]
/home/tim/workspace/rust-memcached/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/librustrt.so(upcall_call_shim_on_c_stack+0x87)[0x7f94cde97cd7]
/home/tim/workspace/rust-memcached/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-4782a756585a81-0.4.so(+0x78b6e)[0x7f94cdf59b6e]
/home/tim/workspace/rust-memcached/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-4782a756585a81-0.4.so(+0x7ea0e)[0x7f94cdf5fa0e]
/home/tim/workspace/rust-memcached/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-4782a756585a81-0.4.so(+0xe8710)[0x7f94cdfc9710]
/home/tim/workspace/rust-memcached/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libcore-c3ca5d77d81b46c1-0.4.so(_ZN7private11weaken_task17_a2f0b02d17df416d3_04E+0xd2)[0x7f94ce150fe2]
/home/tim/workspace/rust-memcached/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-4782a756585a81-0.4.so(+0x7e4b9)[0x7f94cdf5f4b9]
/home/tim/workspace/rust-memcached/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libcore-c3ca5d77d81b46c1-0.4.so(+0x76322)[0x7f94ce136322]
/home/tim/workspace/rust-memcached/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libcore-c3ca5d77d81b46c1-0.4.so(+0xb6000)[0x7f94ce176000]
/home/tim/workspace/rust-memcached/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/librustrt.so(_Z18task_start_wrapperP10spawn_args+0x24)[0x7f94cde960e4]
@ttaubert
Copy link
Contributor Author

Any update here? This is blocking even the simplest server app.

@brson
Copy link
Contributor

brson commented Oct 10, 2012

Is this on a 32-bit system by chance? uv is completely broken there due to FFI bugs.

@brson
Copy link
Contributor

brson commented Oct 10, 2012

Oh, it's obviously a 64-bit system based on the logs. Hm.

@erickt
Copy link
Contributor

erickt commented Oct 10, 2012

@ttaubert: It's working on OSX lion for me, and I have heard that it's working on an ubuntu 12.04 x86_64 box. What platform are you running into this on, and is it still occurring on the latest incoming branch?

@ttaubert
Copy link
Contributor Author

Thanks for the quick response, I'm on Ubuntu 12.04 as well. Will try the latest incoming branch and report back.

@ttaubert
Copy link
Contributor Author

The provided test file still crashes for me with the latest incoming.

@erickt
Copy link
Contributor

erickt commented Oct 10, 2012

@ttaubert any chance you can hop in our irc channel #rust on irc.mozilla.org? You can use this link if you don't already have a client set up.

@ttaubert
Copy link
Contributor Author

So in the middle of trying to reproduce this it suddenly stopped occuring. I have no idea why. Closing for now.

@brson brson reopened this Oct 23, 2012
@brson
Copy link
Contributor

brson commented Oct 23, 2012

There's been another report of this error.

@brson
Copy link
Contributor

brson commented Mar 31, 2013

Won't be fixed in 0.6

@graydon
Copy link
Contributor

graydon commented May 29, 2013

Closing this one as WONTFIX, the underlying APIs here are going to be removed when we shift to the new scheduler (shortly), and we have no reports (yet) of such issues in the new scheduler. Sorry, limited time :(

@graydon graydon closed this as completed May 29, 2013
RalfJung pushed a commit to RalfJung/rust that referenced this issue Jun 29, 2024
Implement LLVM x86 bmi intrinsics

This implements the intrinsics for both the bmi1 and bmi2 ISA extensions. All of these intrinsics live inside the same namespace as far as LLVM is concerned, which is why it is arguably better to bundle the implementations of these two extensions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-concurrency Area: Concurrency I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Projects
None yet
Development

No branches or pull requests

4 participants