Skip to content

Instantly share code, notes, and snippets.

@marmistrz
marmistrz / PKGBUILD
Created July 4, 2017 09:17
golem PKGBUILD
# WARNING: this barely works.
# Notes:
# pyethereum in AUR is very out of date, should be updated
# pyethereum-git depends on many orphaned packages, and doesn't work either
# Thus, pyethereum had to be installed from pip
# python2-docker - 2.x has been released, incompatible, so had to install from pip
# Docker: https://wiki.archlinux.org/index.php/Docker
@marmistrz
marmistrz / pi.py
Created July 12, 2017 15:38
pi.py
#!/usr/bin/env python
from random import random
from math import sqrt
from sys import argv, exit
argc = len(argv)
if argc != 2:
print("Usage: ./pi.py num_steps")
exit(1)
@marmistrz
marmistrz / strace.log
Created July 12, 2017 15:56
randmockery strace
execve("target/debug/randmockery", ["target/debug/randmockery", "../determinism/python/pi.py", "1000"], 0x7ffe5b207460 /* 48 vars */) = 0
brk(NULL) = 0x563b4d620000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=143065, ...}) = 0
mmap(NULL, 143065, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f2d199dc000
close(3) = 0
open("/usr/lib/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\340\r\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=14384, ...}) = 0
#include <stdint.h>
#include <assert.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/wait.h>
#define VAL 42424242
diff --git a/Modules/_randommodule.c b/Modules/_randommodule.c
index 747a547342..206b48840a 100644
--- a/Modules/_randommodule.c
+++ b/Modules/_randommodule.c
@@ -208,6 +208,10 @@ random_seed_urandom(RandomObject *self)
if (_PyOS_URandomNonblock(key, sizeof(key)) < 0) {
return -1;
}
+ for (int i = 0; i < N; ++i) {
+ printf("%d ", key[i]);
#include <stdio.h>
#include <stdlib.h>
#include <sys/ptrace.h>
#include <sys/reg.h>
#include <sys/syscall.h>
#include <sys/wait.h>
#include <unistd.h>
void wait_sigtrap() {
#!/usr/bin/env python
from math import sqrt
from sys import argv, exit
from os import getpid, system
from random import random
argc = len(argv)
if argc != 2:
print("Usage: ./pi.py num_steps")
$ ./example2
getrandom request: 0x00007fe7a66b69a0 0x0000000000000018
getrandom request: 0x00007fff0556eeb0 0x00000000000009c0
getrandom request: 0x00007fff0556e740 0x00000000000009c0
*** stack smashing detected ***: python terminated
======= Backtrace: =========
/usr/lib/libc.so.6(+0x72bdd)[0x7fe7a6729bdd]
/usr/lib/libc.so.6(__fortify_fail+0x38)[0x7fe7a67b6158]
/usr/lib/libc.so.6(__fortify_fail+0x0)[0x7fe7a67b6120]
/usr/lib/python3.6/lib-dynload/_random.cpython-36m-x86_64-linux-gnu.so(+0x1285)[0x7fe7a4518285]
@marmistrz
marmistrz / cargo test
Created July 25, 2017 08:07
nix cargo test
Doc-tests nix
running 19 tests
test src/sys/ioctl/mod.rs - sys::ioctl (line 126) ... FAILED
test src/sys/ioctl/mod.rs - sys::ioctl (line 183) ... FAILED
test src/sys/ioctl/mod.rs - sys::ioctl (line 171) ... FAILED
test src/pty.rs - pty::posix_openpt (line 87) ... FAILED
test src/sys/ioctl/mod.rs - sys::ioctl (line 220) ... FAILED
test src/sys/ioctl/mod.rs - sys::ioctl (line 56) ... FAILED
test src/sys/ioctl/mod.rs - sys::ioctl (line 67) ... FAILED
@marmistrz
marmistrz / PKGBUILD
Created August 9, 2017 09:33
mypy hotfix PKGBUILD
# Maintainer: icasdri <icasdri at gmail dot com>
# Maintainer: hexchain <i@hexchain.org>
# Contributor: marmistrz <marmistrz.dev at zoho dot eu>
_pypi_name=mypy
pkgname=${_pypi_name}
pkgver=0.521
pkgrel=2
pkgdesc='Optional static typing for Python 2 and 3'
url="https://github.com/python/mypy"