Skip to content

Instantly share code, notes, and snippets.

@azat
azat / test-dlsym.c
Created December 31, 2022 22:35
different behavior of dlsym since glibc 2.36
#define _GNU_SOURCE
#include <dlfcn.h>
#include <stdio.h>
int main()
{
void *p = dlsym(RTLD_NEXT, "__pthread_mutex_lock");
printf("__pthread_mutex_lock: %p (via RTLD_NEXT)\n", p);
return 0;
}
@azat
azat / test-asan.cpp
Created December 31, 2022 22:34
ASan does not work with glibc 2.36+
#include <pthread.h>
int main()
{
// something broken in ASan in interceptor for __pthread_mutex_lock
// and only since glibc 2.36, and for pthread_mutex_lock everything is OK
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
return __pthread_mutex_lock(&mutex);
}
@azat
azat / kazoo-logging.patch
Created December 28, 2022 09:34
Endless wait in kazoo after AUTH_FAILED on stop
diff --git a/kazoo/client.py b/kazoo/client.py
index 27b7c38..0c0ecc0 100644
--- a/kazoo/client.py
+++ b/kazoo/client.py
@@ -400,6 +400,7 @@ class KazooClient(object):
def _reset(self):
"""Resets a variety of client states for a new connection."""
+ self.logger.log(BLATHER, "Reseting the client")
self._queue = deque()
/// Test for RWF_NOWAIT, does it always non-block?
/// The answer is, it may sometimes, for example when there is some issues with the underlying disk.
/// Or maybe when it accessing page entries, that are blocked for a long time, need to take a look deeper.
#define _GNU_SOURCE /// for preadv2()
#include <sys/uio.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#include <stdio.h>
#include <cstdlib>
#include <memory>
struct NewDeleteOperators
{
NewDeleteOperators() = default;
static void* operator new(size_t size)
{
return ::malloc(size);
import publicsuffix2
import clickhouse_driver
ch = clickhouse_driver.Client(host='127.1')
pls = publicsuffix2.PublicSuffixList(idna=False)
def check_tld(tld):
print(tld)
host = 'foo.' + tld
ch_tld = ch.execute("SELECT cutToFirstSignificantSubdomainCustom(%(host)s, 'public_suffix_list')", params={
@azat
azat / bash_bug_wait_for.sh
Last active June 15, 2022 17:24
bash bug: wait_for: No record of process (had been fixed in bash 5.1+)
#!/usr/bin/env bash
#
# Reproducer for bash bug that had been fixed in bash 5.1+ [1], report [2]
#
# [1]: https://git.savannah.gnu.org/cgit/bash.git/commit/?h=bash-5.1&id=8868edaf2250e09c4e9a1c75ffe3274f28f38581
# [2]: https://lists.gnu.org/archive/html/bug-bash/2019-05/msg00110.html
#
function thread_worker()
#!/usr/bin/env bash
set -x
config_directives=(
--tcp_port=19000
--mlock_executable=true
)
benchmark_args=(
-d 0
From 64f9c91766cbcaa8a61e5b633ac78e354ac3355c Mon Sep 17 00:00:00 2001
From: Azat Khuzhin <[email protected]>
Date: Mon, 31 Jan 2022 19:14:53 +0300
Subject: [PATCH] fs/binfmt_elf: use ELF_ET_DYN_BASE for PIE (ET_DYN with
INTERP) binaries
Since 9630f0d60fec ELF_ET_DYN_BASE is not used as a load_bias anymore
and this breaks PIE binaries, since after this change data segment
became too nearby the stack:
#include <vector>
#include <memory>
#include <benchmark/benchmark.h>
#define LEN 1<<20
using AggregateDataPtr = char *;
struct AvgState {
uint64_t numerator{0};
uint64_t denominator{0};