Skip to content

Instantly share code, notes, and snippets.

@Neopallium
Last active September 17, 2018 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Neopallium/ba133e7430d9398e0c7e3fccc3302000 to your computer and use it in GitHub Desktop.
Save Neopallium/ba133e7430d9398e0c7e3fccc3302000 to your computer and use it in GitHub Desktop.
actix-web channel linked list corruption
[package]
name = "hello-world"
version = "0.1.0"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
workspace = "../"
[dependencies]
env_logger = "0.5"
futures = "0.1"
actix = "0.7"
actix-web = { features=['rust-tls', 'session'], default-features = false, git = "https://github.com/actix/actix-web" }
rustls = "0"
lazy_static = "1.0"
bytes = "0.4"
serde_json = "1.0"
serde = "1.0"
serde_derive = "1.0"
rust-crypto = "^0.2"
uuid = { version = "0.6", features = ["v4"] }
==19734== Memcheck, a memory error detector
==19734== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==19734== Using Valgrind-3.12.0.SVN and LibVEX; rerun with -h for copyright info
==19734== Command: ../target/debug/hello-world
==19734==
INFO 2018-09-17T17:39:59Z: actix_web::server::server: Starting 1 http workers
INFO 2018-09-17T17:39:59Z: actix_web::server::server: Starting server on http://127.0.0.1:8080
==19734== Thread 2 arbiter:7be3aca2-b195-48f2-a23c-b9d6b8baa06f:actor:
==19734== Invalid write of size 8
==19734== at 0x213F84: _$LT$actix_web..server..channel..Node$LT$T$GT$$GT$::remove::hf358e1221d497de5 (channel.rs:233)
==19734== by 0x2146EF: _$LT$actix_web..server..channel..HttpChannel$LT$T$C$$u20$H$GT$$u20$as$u20$core..ops..drop..Drop$GT$::drop::h45ebdbb9e369b12c (channel.rs:82)
==19734== by 0x18BA50: core::ptr::drop_in_place::h368f744d4371d7aa (ptr.rs:59)
==19734== by 0x192043: core::ptr::drop_in_place::hc0ba917e4dc285dc (ptr.rs:59)
==19734== by 0x7CC156: core::ptr::drop_in_place::h939b95fe9df03a3a (ptr.rs:59)
==19734== by 0x7CC849: core::ptr::drop_in_place::hf324c43baf641c76 (ptr.rs:59)
==19734== by 0x7CBC8D: core::ptr::drop_in_place::h227c4c82d189fd9e (ptr.rs:59)
==19734== by 0x7CC1D0: core::ptr::drop_in_place::h96e1610965dd8c14 (ptr.rs:59)
==19734== by 0x7C6FF5: core::mem::drop::ha70028a77dd84009 (mem.rs:763)
==19734== by 0x775A4F: tokio_current_thread::scheduler::release_node::h0450ee80266f39b2 (scheduler.rs:385)
==19734== by 0x7759AD: _$LT$$LT$tokio_current_thread..scheduler..Scheduler$LT$U$GT$$GT$..tick..Bomb$LT$$u27$a$C$$u20$U$GT$$u20$as$u20$core..ops..drop..Drop$GT$::drop::_$u7b$$u7b$closure$u7d$$u7d$::h931dd8ac29a72934 (scheduler.rs:274)
==19734== by 0x76E632: _$LT$tokio_current_thread..Borrow$LT$$u27$a$C$$u20$U$GT$$GT$::enter::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::hc2575af273f23ca3 (lib.rs:747)
==19734== Address 0x5dbc0a8 is 1,512 bytes inside a block of size 1,568 free'd
==19734== at 0x4C2CDDB: free (vg_replace_malloc.c:530)
==19734== by 0x1D4BE1: alloc_system::platform::_$LT$impl$u20$core..alloc..GlobalAlloc$u20$for$u20$alloc_system..System$GT$::dealloc::hed62c73cb949843f (lib.rs:166)
==19734== by 0x1E4A23: __rg_dealloc (main.rs:9)
==19734== by 0x1E4E61: alloc::alloc::dealloc::h25fdbb1fdafe78ca (alloc.rs:96)
==19734== by 0x1ECF31: alloc::alloc::box_free::hea2ad5953959f9e4 (alloc.rs:206)
==19734== by 0x192062: core::ptr::drop_in_place::hc0ba917e4dc285dc (ptr.rs:59)
==19734== by 0x7CC156: core::ptr::drop_in_place::h939b95fe9df03a3a (ptr.rs:59)
==19734== by 0x7CC849: core::ptr::drop_in_place::hf324c43baf641c76 (ptr.rs:59)
==19734== by 0x7CBC8D: core::ptr::drop_in_place::h227c4c82d189fd9e (ptr.rs:59)
==19734== by 0x7CC1D0: core::ptr::drop_in_place::h96e1610965dd8c14 (ptr.rs:59)
==19734== by 0x7C6FF5: core::mem::drop::ha70028a77dd84009 (mem.rs:763)
==19734== by 0x775A4F: tokio_current_thread::scheduler::release_node::h0450ee80266f39b2 (scheduler.rs:385)
==19734== Block was alloc'd at
==19734== at 0x4C2BBAF: malloc (vg_replace_malloc.c:299)
==19734== by 0x1D4B94: alloc_system::platform::_$LT$impl$u20$core..alloc..GlobalAlloc$u20$for$u20$alloc_system..System$GT$::alloc::hea6985ab706ec696 (lib.rs:139)
==19734== by 0x1E49BC: __rg_alloc (main.rs:9)
==19734== by 0x1E4DFA: alloc::alloc::alloc::h4044d77f5a653074 (alloc.rs:78)
==19734== by 0x1E4D79: alloc::alloc::exchange_malloc::h490b1183ada46177 (alloc.rs:188)
==19734== by 0x187EBB: new<actix_web::server::channel::HttpChannel<tokio_tcp::stream::TcpStream, actix_web::application::HttpApplication<()>>> (boxed.rs:96)
==19734== by 0x187EBB: actix::arbiter::Arbiter::spawn::_$u7b$$u7b$closure$u7d$$u7d$::h9c4f01e4fc52e575 (arbiter.rs:190)
==19734== by 0x1EDC50: _$LT$std..thread..local..LocalKey$LT$T$GT$$GT$::try_with::hf24337cf1d51ef8e (local.rs:294)
==19734== by 0x1ED260: _$LT$std..thread..local..LocalKey$LT$T$GT$$GT$::with::hc2293651653403d2 (local.rs:248)
==19734== by 0x187CE8: actix::arbiter::Arbiter::spawn::h6692e698b629dbb6 (arbiter.rs:188)
==19734== by 0x1C4E1F: _$LT$actix_web..server..http..SimpleHandler$LT$Io$GT$$u20$as$u20$actix_web..server..http..IoStreamHandler$LT$H$C$$u20$Io$GT$$GT$::handle::h253493697437c0fa (http.rs:697)
==19734== by 0x1B0018: _$LT$alloc..boxed..Box$LT$$LP$dyn$u20$actix_web..server..http..IoStreamHandler$LT$H$C$$u20$Io$GT$$u20$$u2b$$u20$$u27$static$RP$$GT$$u20$as$u20$actix_web..server..http..IoStreamHandler$LT$H$C$$u20$Io$GT$$GT$::handle::hb500d63392b97b60 (http.rs:786)
==19734== by 0x1C48BD: _$LT$actix_web..server..http..HttpServiceHandler$LT$H$GT$$u20$as$u20$actix_web..server..server..ServiceHandler$GT$::handle::hed4cce45d8a16070 (http.rs:634)
==19734==
==19734== Invalid write of size 8
==19734== at 0x213F8C: _$LT$actix_web..server..channel..Node$LT$T$GT$$GT$::remove::hf358e1221d497de5 (channel.rs:233)
==19734== by 0x2146EF: _$LT$actix_web..server..channel..HttpChannel$LT$T$C$$u20$H$GT$$u20$as$u20$core..ops..drop..Drop$GT$::drop::h45ebdbb9e369b12c (channel.rs:82)
==19734== by 0x18BA50: core::ptr::drop_in_place::h368f744d4371d7aa (ptr.rs:59)
==19734== by 0x192043: core::ptr::drop_in_place::hc0ba917e4dc285dc (ptr.rs:59)
==19734== by 0x7CC156: core::ptr::drop_in_place::h939b95fe9df03a3a (ptr.rs:59)
==19734== by 0x7CC849: core::ptr::drop_in_place::hf324c43baf641c76 (ptr.rs:59)
==19734== by 0x7CBC8D: core::ptr::drop_in_place::h227c4c82d189fd9e (ptr.rs:59)
==19734== by 0x7CC1D0: core::ptr::drop_in_place::h96e1610965dd8c14 (ptr.rs:59)
==19734== by 0x7C6FF5: core::mem::drop::ha70028a77dd84009 (mem.rs:763)
==19734== by 0x775A4F: tokio_current_thread::scheduler::release_node::h0450ee80266f39b2 (scheduler.rs:385)
==19734== by 0x7759AD: _$LT$$LT$tokio_current_thread..scheduler..Scheduler$LT$U$GT$$GT$..tick..Bomb$LT$$u27$a$C$$u20$U$GT$$u20$as$u20$core..ops..drop..Drop$GT$::drop::_$u7b$$u7b$closure$u7d$$u7d$::h931dd8ac29a72934 (scheduler.rs:274)
==19734== by 0x76E632: _$LT$tokio_current_thread..Borrow$LT$$u27$a$C$$u20$U$GT$$GT$::enter::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::hc2575af273f23ca3 (lib.rs:747)
==19734== Address 0x5dbc0b0 is 1,520 bytes inside a block of size 1,568 free'd
==19734== at 0x4C2CDDB: free (vg_replace_malloc.c:530)
==19734== by 0x1D4BE1: alloc_system::platform::_$LT$impl$u20$core..alloc..GlobalAlloc$u20$for$u20$alloc_system..System$GT$::dealloc::hed62c73cb949843f (lib.rs:166)
==19734== by 0x1E4A23: __rg_dealloc (main.rs:9)
==19734== by 0x1E4E61: alloc::alloc::dealloc::h25fdbb1fdafe78ca (alloc.rs:96)
==19734== by 0x1ECF31: alloc::alloc::box_free::hea2ad5953959f9e4 (alloc.rs:206)
==19734== by 0x192062: core::ptr::drop_in_place::hc0ba917e4dc285dc (ptr.rs:59)
==19734== by 0x7CC156: core::ptr::drop_in_place::h939b95fe9df03a3a (ptr.rs:59)
==19734== by 0x7CC849: core::ptr::drop_in_place::hf324c43baf641c76 (ptr.rs:59)
==19734== by 0x7CBC8D: core::ptr::drop_in_place::h227c4c82d189fd9e (ptr.rs:59)
==19734== by 0x7CC1D0: core::ptr::drop_in_place::h96e1610965dd8c14 (ptr.rs:59)
==19734== by 0x7C6FF5: core::mem::drop::ha70028a77dd84009 (mem.rs:763)
==19734== by 0x775A4F: tokio_current_thread::scheduler::release_node::h0450ee80266f39b2 (scheduler.rs:385)
==19734== Block was alloc'd at
==19734== at 0x4C2BBAF: malloc (vg_replace_malloc.c:299)
==19734== by 0x1D4B94: alloc_system::platform::_$LT$impl$u20$core..alloc..GlobalAlloc$u20$for$u20$alloc_system..System$GT$::alloc::hea6985ab706ec696 (lib.rs:139)
==19734== by 0x1E49BC: __rg_alloc (main.rs:9)
==19734== by 0x1E4DFA: alloc::alloc::alloc::h4044d77f5a653074 (alloc.rs:78)
==19734== by 0x1E4D79: alloc::alloc::exchange_malloc::h490b1183ada46177 (alloc.rs:188)
==19734== by 0x187EBB: new<actix_web::server::channel::HttpChannel<tokio_tcp::stream::TcpStream, actix_web::application::HttpApplication<()>>> (boxed.rs:96)
==19734== by 0x187EBB: actix::arbiter::Arbiter::spawn::_$u7b$$u7b$closure$u7d$$u7d$::h9c4f01e4fc52e575 (arbiter.rs:190)
==19734== by 0x1EDC50: _$LT$std..thread..local..LocalKey$LT$T$GT$$GT$::try_with::hf24337cf1d51ef8e (local.rs:294)
==19734== by 0x1ED260: _$LT$std..thread..local..LocalKey$LT$T$GT$$GT$::with::hc2293651653403d2 (local.rs:248)
==19734== by 0x187CE8: actix::arbiter::Arbiter::spawn::h6692e698b629dbb6 (arbiter.rs:188)
==19734== by 0x1C4E1F: _$LT$actix_web..server..http..SimpleHandler$LT$Io$GT$$u20$as$u20$actix_web..server..http..IoStreamHandler$LT$H$C$$u20$Io$GT$$GT$::handle::h253493697437c0fa (http.rs:697)
==19734== by 0x1B0018: _$LT$alloc..boxed..Box$LT$$LP$dyn$u20$actix_web..server..http..IoStreamHandler$LT$H$C$$u20$Io$GT$$u20$$u2b$$u20$$u27$static$RP$$GT$$u20$as$u20$actix_web..server..http..IoStreamHandler$LT$H$C$$u20$Io$GT$$GT$::handle::hb500d63392b97b60 (http.rs:786)
==19734== by 0x1C48BD: _$LT$actix_web..server..http..HttpServiceHandler$LT$H$GT$$u20$as$u20$actix_web..server..server..ServiceHandler$GT$::handle::hed4cce45d8a16070 (http.rs:634)
==19734==
INFO 2018-09-17T17:40:21Z: actix_web::server::server: SIGINT received, exiting
INFO 2018-09-17T17:40:21Z: actix_web::server::worker: Shutting down http worker, 0 connections
==19734==
==19734== HEAP SUMMARY:
==19734== in use at exit: 87,692 bytes in 446 blocks
==19734== total heap usage: 3,783 allocs, 3,337 frees, 2,018,665 bytes allocated
==19734==
==19734== LEAK SUMMARY:
==19734== definitely lost: 0 bytes in 0 blocks
==19734== indirectly lost: 0 bytes in 0 blocks
==19734== possibly lost: 6,528 bytes in 24 blocks
==19734== still reachable: 81,164 bytes in 422 blocks
==19734== suppressed: 0 bytes in 0 blocks
==19734== Rerun with --leak-check=full to see details of leaked memory
==19734==
==19734== For counts of detected and suppressed errors, rerun with: -v
==19734== ERROR SUMMARY: 12 errors from 2 contexts (suppressed: 0 from 0)
//*
#![feature(alloc_system, allocator_api)]
extern crate alloc_system;
use alloc_system::System;
#[global_allocator]
static A: System = System;
// */
extern crate actix;
extern crate actix_web;
extern crate env_logger;
extern crate futures;
use futures::Future;
use actix_web::{
server, App, http::Method, fs::StaticFiles,
HttpMessage, HttpRequest, HttpResponse,
AsyncResponder, FutureResponse
};
fn index(_req: &HttpRequest) -> &'static str {
"Hello world!"
}
fn put_file(req: HttpRequest) -> FutureResponse<HttpResponse> {
req.body()
.limit(100 * 1024 * 1024)
.from_err()
.and_then(|body| {
let msg = format!("Body length = {}\n", body.len());
Ok(HttpResponse::Ok().body(msg).into())
}).responder()
}
fn shutdown_sys(_req: &HttpRequest) -> &'static str {
actix::System::current().stop();
"Stop!"
}
fn main() {
::std::env::set_var("RUST_LOG", "actix_web=info");
env_logger::init();
let sys = actix::System::new("hello-world");
server::new(|| {
App::new()
// enable logger
.resource("/hello", |r| r.f(|_| "Hello world!"))
.resource("/", |r| r.f(index))
.resource("/put", |r| {
r.method(Method::POST).with(put_file)
})
.resource("/stop", |r| r.f(shutdown_sys))
.handler("/file/", StaticFiles::new("/home/bobby/projects/rust/examples/hello-world/").unwrap()
.show_files_listing().index_file("index.html"))
}).workers(1).bind("127.0.0.1:8080")
.unwrap()
.start();
println!("Started http server: 127.0.0.1:8080");
let _ = sys.run();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment