Skip to content

Instantly share code, notes, and snippets.

@msullivan
msullivan / gist:5872576
Created June 26, 2013 23:08
backtrace from servo crash
#0 0x00007fffec2f9c73 in ?? () from /usr/lib/x86_64-linux-gnu/libdrm_nouveau.so.1
#1 0x00007fffec2fa17f in nouveau_pushbuf_flush () from /usr/lib/x86_64-linux-gnu/libdrm_nouveau.so.1
#2 0x00007fffe6d6a8bb in ?? () from /usr/lib/x86_64-linux-gnu/dri/libgallium.so
#3 0x00007fffeccd3bc4 in dri_unbind_context () from /usr/lib/x86_64-linux-gnu/dri/nouveau_dri.so
#4 0x00007fffeccd02d5 in ?? () from /usr/lib/x86_64-linux-gnu/dri/nouveau_dri.so
#5 0x00007ffff21bc08d in glXMakeCurrentReadSGI () from /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1
#6 0x00007ffff60d7318 in SkNativeSharedGLContext::createGLContext() () from /home/sully/src/servo/build/src/support/azure/rust-azure/libazure-b845d856dcd50f0-0.1.so
#7 0x00007ffff60d7421 in SkNativeSharedGLContext::init(int, int) () from /home/sully/src/servo/build/src/support/azure/rust-azure/libazure-b845d856dcd50f0-0.1.so
#8 0x00007ffff600d855 in AzCreateSkiaSharedGLContext () from /home/sully/src/servo/build/src/support/azure/rust-azure/libazure-b845d856dcd50f0-0.1.so
rust: ~"names_bytes = 28"
rust: ~"bools_bytes = 38"
rust: ~"numbers_count = 15"
rust: ~"string_offsets_count = 413"
rust: ~"string_table_bytes = 1370"
rust: ~"term names: ~[~\"xterm\", ~\"X11 terminal emulator\"]"
rust: ~"am set"
rust: ~"xenl set"
rust: ~"km set"
rust: ~"mir set"
#[allow(default_methods)]
trait Speak {
fn say(&self, s:&str);
fn hi(&self) { hello(self); }
}
fn hello<S:Speak>(s:&S) {
s.say("hello");
}
@msullivan
msullivan / pwn-smlnj.sml
Last active October 10, 2015 20:17
sml array indexing fail
(* Running `fail ()` at the repl will cause it to say:
unexpected exception (bug?) in SML/NJ: Representation [Representation] *)
fun fail () =
let fun idx a i =
case (Array.sub (a, i))
of NONE => raise Fail "owt"
| SOME x => x
val a = Array.array (1, SOME (42, 1337))
in idx a 0 end
val state : unit cont ref =
ref (callcc (fn escape : unit cont cont =>
(callcc (fn k => throw escape k);
raise AmbFail)))
fun amb [] = throw (!state) ()
| amb (x::xs) =
let val old = !state
in callcc (fn escape =>
(callcc (fn k => (state := k; throw escape x));
@msullivan
msullivan / gist:3502543
Created August 28, 2012 19:05
monadic reify/reflect for eerrors
(* The type of the error monad *)
datatype 'a Error = Success of 'a | Failure of exn
(* Possible definitions of reify/reflect in terms of actual
* effectful constructs *)
fun reify thunk = (Success (thunk ())
handle e => Failure e)
val reify : (unit -> 'a) -> 'a Error = reify
fun reflect (Success x) = x
fn seq_range(lo: uint, hi: uint) -> @[uint] {
build(|push|
for uint::range(lo, hi) |i| {
push(i);
}
);
}
fn build<A>(builder: fn(push: fn(+A))) -> ~[A] {
let mut vec = ~[];
builder(|x| vec::push(vec, x));
return vec;
}
\lstdefinelanguage{rust}{
keywords={let, mut, fn, for, do, return},
keywordstyle=\color{blue}\bfseries,
ndkeywords={int},
ndkeywordstyle=\color{darkgray}\bfseries,
identifierstyle=\color{black},
sensitive=false,
comment=[l]{//},
morecomment=[s]{/*}{*/},
commentstyle=\color{purple}\ttfamily,
{-# LANGUAGE GeneralizedNewtypeDeriving, GADTs #-}
data SameType a b where
Refl :: SameType a a
coerce :: SameType a b -> a -> b
coerce Refl = id
trans :: SameType a b -> SameType b c -> SameType a c
trans Refl Refl = Refl