Skip to content

Instantly share code, notes, and snippets.

@alk
alk / the-patch
Created October 22, 2026 17:14
libbacktrace patch demo-ing dl_events_subscribe goodness
diff --git a/dwarf.c b/dwarf.c
index 7cde3db..388498b 100644
--- a/dwarf.c
+++ b/dwarf.c
@@ -4533,42 +4533,40 @@ dwarf_fileline (struct backtrace_state *state, uintptr_t pc,
else
{
struct dwarf_data **pp;
pp = (struct dwarf_data **) (void *) &state->fileline_data;
// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*-
// #include "config_for_unittests.h"
#include "gtest/gtest.h"
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <unordered_map>
#include <errno.h>
#include <pthread.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define NUM_THREADS 8
diff --git a/src/common.h b/src/common.h
index cb45315..e9976c1 100644
--- a/src/common.h
+++ b/src/common.h
@@ -27,60 +27,65 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ---
From 4cd069d0ef876dc1053d09c9785a6cd451061f19 Mon Sep 17 00:00:00 2001
From: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Date: Mon, 22 May 2017 03:18:11 -0700
Subject: [PATCH] Use hidden visibility for TCMallocGetenvSafe
Because otherwise it might be unsafe to call it from ifunc
handler (when non-lazy symbol binding is in effect).
---
src/base/sysinfo.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
#include <sys/mman.h>
#include <sys/types.h>
#include <time.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main(void)
{
void *addr = mmap(0, (4 << 20) - 4096, PROT_NONE,
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <string.h>
#include <stdint.h>
#include <emmintrin.h>
static void setbytes(char *p, int c)
{
@alk
alk / goprof-test.go
Created February 20, 2016 22:12
Test program demonstrating skewed profile
package main
import (
"log"
"os"
"runtime/pprof"
"time"
)
func maybeStartProfile() func() {
@alk
alk / freelist2.cc
Created January 26, 2016 18:52
some freelist representation ideas
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <assert.h>
#include <memory.h>
struct FreeListEntry {
FreeListEntry *l, *r;
};
@alk
alk / maps-balancedness.rb
Last active February 22, 2016 11:40
maps-balancedness.rb
#!/usr/bin/ruby
# coding: utf-8
require 'json'
require 'pp'
require 'optparse'
require 'rubygems'
require 'restclient'