Skip to content

Instantly share code, notes, and snippets.

View lambdageek's full-sized avatar
🪣

Aleksey Kliger (λgeek) lambdageek

🪣
View GitHub Profile
@lambdageek
lambdageek / FreerChurch.hs
Created October 26, 2016 08:16
Church encoded Freer monad
{-# language GADTs, RankNTypes #-}
module FreerChurch where
import Control.Monad.Free.Church
import Data.Functor.Identity
-- | Oleg's Freer Monad (http://okmij.org/ftp/Computation/free-monad.html) but Chruch encoded
--
-- Think of it like @FFree@
--
@lambdageek
lambdageek / before-after.c
Last active November 15, 2016 21:31
BEFORE_AFTER_BLOCK macro
#include <stdio.h>
#define EMPTY /* empty */
#define CONCAT_HELPER(x,y) x ## y
#define CONCAT(x,y) CONCAT_HELPER(x,y)
#define LABEL_MAKER(id) CONCAT(id,__LINE__)
#define BEFORE_AFTER_BLOCK(decl, before_block, after_block) \
@lambdageek
lambdageek / build-log.txt
Created June 15, 2017 15:27
GC during pthread_create
CSC [build-darwin] PEAPI.dll
* Assertion at mono-threads.c:1032, condition `info' not met
Native stacktrace:
0 mono 0x000000010192417e mono_handle_native_crash + 270
1 libsystem_platform.dylib 0x00007fff96477b3a _sigtramp + 26
2 ??? 0x00007f954ff0012c 0x0 + 140279267983660
3 mono 0x0000000102508a1e abort + 14
@lambdageek
lambdageek / ClassicalLogic.hs
Created October 13, 2017 03:51
Some statements of classical logic
-- | Some statements of classical logic
{-# language RankNTypes, ScopedTypeVariables, EmptyDataDecls, EmptyCase, TypeApplications #-}
module ClassicalLogic where
-- | Falsehood
data Void
-- | The elimination rule for falsehood
absurd :: Void -> a
absurd void = case void of { }
@lambdageek
lambdageek / bear-make.sh
Created October 16, 2017 18:19
How to run bear on OSX
#! /bin/bash
# This is how to run [Bear](https://github.com/rizsotto/Bear) on OSX Sierra or later without
# turning off System Integrity Protection on an autotools project
# Need to copy make and bash to a non-protected directory
XCODE_PATH=`xcode-select -p`
SIP_BYPASS=`pwd`/sip-bypass
MonoObjectHandle
mono_runtime_try_invoke_handle (MonoMethod *method, MonoObjectHandle obj, void **params, MonoObjectHandleOut exc, MonoError* error)
{
MONO_REQ_GC_UNSAFE_MODE;
HANDLE_FUNCTION_ENTER ()
g_assert (exc != NULL);
if (mono_runtime_get_no_exec ())
From dbb849d0228276062fff1acf3a2d49b7ff065b5d Mon Sep 17 00:00:00 2001
From: Aleksey Kliger <[email protected]>
Date: Wed, 3 Jan 2018 17:38:07 -0500
Subject: [PATCH] Print some info if we are asked to look up a method token
that's outside the range of the PPDB.
---
mono/metadata/debug-mono-ppdb.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
@lambdageek
lambdageek / grep.sh
Created February 15, 2018 22:14
recursive grep looking for stack allocated MonoType
find . -type d \( -path \*/SCCS -o -path \*/RCS -o -path \*/CVS -o -path \*/MCVS -o -path \*/.src -o -path \*/.svn -o -path \*/.git -o -path \*/.hg -o -path \*/.bzr -o -path \*/_MTN -o -path \*/_darcs -o -path \*/\{arch\} \) -prune -o \! -type d \( -name .\#\* -o -name \*.hi -o -name \*.o -o -name \*\~ -o -name \*.bin -o -name \*.lbin -o -name \*.so -o -name \*.a -o -name \*.ln -o -name \*.blg -o -name \*.bbl -o -name \*.elc -o -name \*.lof -o -name \*.glo -o -name \*.idx -o -name \*.lot -o -name \*.fmt -o -name \*.tfm -o -name \*.class -o -name \*.fas -o -name \*.lib -o -name \*.mem -o -name \*.x86f -o -name \*.sparcf -o -name \*.dfsl -o -name \*.pfsl -o -name \*.d64fsl -o -name \*.p64fsl -o -name \*.lx64fsl -o -name \*.lx32fsl -o -name \*.dx64fsl -o -name \*.dx32fsl -o -name \*.fx64fsl -o -name \*.fx32fsl -o -name \*.sx64fsl -o -name \*.sx32fsl -o -name \*.wx64fsl -o -name \*.wx32fsl -o -name \*.fasl -o -name \*.ufsl -o -name \*.fsl -o -name \*.dxl -o -name \*.lo -o -name \*.la -o -name \*.gmo -o -name \*.m
@lambdageek
lambdageek / gist:4188cae9ee8e8fe2ecff8700642e45e6
Created April 4, 2018 23:06
Blocking_and_Suspended back to Blocking?
Suppose victim is in BLOCKING and suspend count is 2.
Old technique
BLOCKING|susp=2
abort_blocking() -> returns AbortBlockingWait
BLOCKING_AND_SUSPENDED|susp=2
waits on resume semaphore
... (suspend initiator calls resume)
BLOCKING_AND_SUSPENDED|susp=1
@lambdageek
lambdageek / centrinel-report-v3.json
Created May 3, 2018 22:55
centrinel-report V3 file example
{"centrinel_report_version": "3", "messages": [
{"workingDirectory":"/Users/alekseyk/work/mono/mono/metadata","translationUnit":"appdomain.c","message":{"tag":"NormalMessages","isAbnormal":false,"messages":[{"errorLevel":"WARNING","position":"(\"appdomain.c\": line 2491)","tag":"nakedPointerMessage","nakedPointerMessage":{"inDefintion":false,"victims":[{"type":"MonoAppDomain *","position":{"tag":"arg","index":0,"var":"ad","position":"appdomain.c:2492: (column 61)","next":{"tag":"decl","fname":"ves_icall_System_AppDomain_GetIDFromDomain"}}}]}},{"errorLevel":"WARNING","position":"(\"appdomain.c\": line 2004)","tag":"nakedPointerMessage","nakedPointerMessage":{"inDefintion":false,"victims":[{"type":"MonoAppDomain *","position":{"tag":"arg","index":0,"var":"appdomain_raw","position":"appdomain.c:2005: (column 44)","next":{"tag":"decl","fname":"mono_domain_from_appdomain"}}}]}},{"errorLevel":"WARNING","position":"(\"appdomain.c\": line 801)","tag":"nakedPointerMessage","nakedPointerMessage":{"inDefintion":false,"v