Skip to content

Instantly share code, notes, and snippets.

@polachok
polachok / keybase.md
Created September 7, 2016 11:29
keybase

Keybase proof

I hereby claim:

  • I am polachok on github.
  • I am plhk (https://keybase.io/plhk) on keybase.
  • I have a public key ASASwe7c2tZcJuWggPQoUVWkTx23g7XgkUC955QQVCbk5Ao

To claim this, I am signing this object:

fatal error: concurrent map read and map write
goroutine 565633 [running]:
runtime.throw(0x1fb2020, 0x21)
/usr/local/go/src/runtime/panic.go:547 +0x90 fp=0xc8213895a0 sp=0xc821389588
runtime.mapaccess2_faststr(0x175d060, 0xc820a961b0, 0xc821b0f100, 0xf, 0xc8209e8a48, 0x6fc601)
/usr/local/go/src/runtime/hashmap_fast.go:307 +0x5b fp=0xc821389600 sp=0xc8213895a0
github.com/docker/libnetwork.(*sandbox).resolveName(0xc8208ce1e0, 0xc821b0f100, 0xf, 0x1dc7b28, 0x0, 0xc8214ad760, 0x1, 0x1, 0x1dd7200, 0x2, ...)
/go/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/sandbox.go:585 +0x383 fp=0xc8213896f0 sp=0xc821389600
github.com/docker/libnetwork.(*sandbox).ResolveName(0xc8208ce1e0, 0xc821b0f100, 0xf, 0x2, 0x0, 0x0, 0x0, 0x0)
static struct sock *cookie_v4_check_wrapper(struct sock *sk, struct sk_buff *skb) {
struct sock* (*old_func)(struct sock *sk, struct sk_buff *skb) = (void*)((unsigned long)cookie_v4_check_ptr + MCOUNT_INSN_SIZE);
tcp_synq_overflow(sk);
return old_func(sk, skb);
}
static void notrace
tcpsecrets_ftrace_handler(unsigned long ip, unsigned long parent_ip,
struct ftrace_ops *fops, struct pt_regs *regs)

14.88

Server Software:        nginx/1.4.6
Server Hostname:        185.50.25.2
Server Port:            80

Document Path:          /
Document Length:        612 bytes
@polachok
polachok / netmap.rs
Created May 28, 2016 23:56
Netmap wrapper API
extern crate netmap_sys;
use ::libc;
use std::mem;
use std::ptr;
use std::slice;
use std::iter::Iterator;
use std::ffi::{CStr,CString};
use self::netmap_sys::netmap;
use self::netmap_sys::netmap_user;
extern crate rustc_serialize;
use rustc_serialize::json;
#[derive(RustcDecodable, RustcEncodable, Debug)]
enum Message {
Type1(String),
Type2(u64),
}
fn main() {
. .
. .
. . . . .
. .. .... . . .... ... .
. .. ................. ........ ..
. . .
fn main() {
let mut sum: i64 = 0;
for _ in 0..200 {
sum = 0;
let mut x = vec![];
for i in 0..1000000 {
x.push(i);
}
root@c08fc12e0e0a:/bench# time ./test-c
9999010000
real 0m2.117s
user 0m1.463s
sys 0m0.652s
root@c08fc12e0e0a:/bench# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/5.3.0/lto-wrapper
@polachok
polachok / gist:ab0937985d57b0398ad8
Last active July 7, 2023 13:50
Building statically linked binaries with rust

glibc is not statically linkable (because reasons, mainly nss), so you have to link against another libc. Fortunately, rust developers made binary builds of std linked with musl libc available in beta and nightly channels. Which means that all you need is:

  • std linked with musl

    • http://static.rust-lang.org/dist/$(date -v -1d +'%Y-%m-%d')/rust-std-beta-x86_64-unknown-linux-musl.tar.gz
  • "normal" std for build scripts

    • http://static.rust-lang.org/dist/$(date -v -1d +'%Y-%m-%d')/rust-std-beta-x86_64-unknown-linux-gnu.tar.gz