Skip to content

Instantly share code, notes, and snippets.

@jthemphill
jthemphill / bisect_for_multiple_files.py
Last active November 2, 2024 22:59
Version of bisect for if an E2E test passes as long as at least one of multiple affected files is not compiled
import asyncio
import json
import pathlib
import random
import signal
import typing
"""
vite.config.ts has these lines:
@jthemphill
jthemphill / bisect_react_compiler_vite.py
Last active October 30, 2024 17:39
Figure out which files are causing `babel-plugin-react-compiler` to output bad code and crash Vite's Rollup build
import asyncio
import sys
import typing
"""
vite.config.ts has these lines:
function djb2Hash(str: string): number {
let hash = 5381
cmake_minimum_required(VERSION 3.12)
# A reproduction of the example given in
# https://cmake.org/cmake/help/latest/command/target_link_libraries.html#linking-object-libraries
project(CMakeTest)
# Object Libraries may be used as the <target> (first) argument of target_link_libraries to specify dependencies of their sources on other libraries. For example, the code
add_library(A SHARED a.c)
target_compile_definitions(A PUBLIC A)
import collections
horiz_edges = [
[">", "<", ">", ">"],
["<", " ", "<", ">"],
[">", ">", "<", " "],
["<", " ", ">", "<"],
[" ", " ", ">", ">"],
]
assert len(horiz_edges) == 5
use rayon::prelude::*;
use std::io::BufRead;
fn edit_distance(s1: &str, s2: &str) -> usize {
if s1.len() > s2.len() {
return edit_distance(s2, s1);
}
let mut distances: Vec<usize> = (0..=s1.len()).collect();
for (i2, c2) in s2.chars().enumerate() {
@jthemphill
jthemphill / debugging.md
Created November 4, 2021 20:07
HHVM watchman deadlock GDB debugging session

Summary

  • The thread that holds s_sharedDataMutex is calling WatchmanConnection::close()
  • WatchmanConnection::close() needs to run something in the EventBaseThread
  • The EventBaseThread is in a callback that's trying to get s_sharedDataMutex
  • This is a deadlock.

Event Base Thread

@jthemphill
jthemphill / gist:487b41c21c35fa026f71fe82939d0413
Created November 4, 2021 20:07
HHVM watchman deadlock quickstack
2021-11-02 13:41:47 837839: Setting mount namespace failed. Errno: 22
2021-11-02 13:41:47 837906: Target pid: 425995 (inside container: 425995)
2021-11-02 13:41:47 841508: Reading process symbols..
2021-11-02 13:41:48 189050: Gathering stack traces..
2021-11-02 13:41:48 233281: Printing stack traces..
2021-11-02 13:41:48 233298: Total Traced Time: 35.196 milliseconds
2021-11-02 13:41:48 233306: Average Traced Time Per LWP: 0.109 milliseconds
2021-11-02 13:41:48 233310: Longest Traced LWP: LWP 4047257, 0.528 milliseconds
Thread 323 (LWP 4122695):
@jthemphill
jthemphill / facts.tla
Created March 22, 2021 21:33
TLA+ spec for HHVM's live type-to-file reverse index
------------------------------- MODULE facts -------------------------------
EXTENDS Integers
CONSTANTS
NumFiles,
NumTypes,
NumRequests,
FinalClock
// % g++ --std=c++14 accidentalcopy.cc -o accidentalcopy
// % ./accidentalcopy
// This prints the output:
//
// 42 = 42
// 42 = 42
// accidentalcopy(13656,0x117fc45c0) malloc: *** error for object 0x7fd967402b20: pointer being freed was not allocated
// accidentalcopy(13656,0x117fc45c0) malloc: *** set a breakpoint in malloc_error_break to debug
#include <iostream>
.section __TEXT,__text,regular,pure_instructions
.globl __ZN10slow_iters5tests8iter_any17h9958878595c8e553E
.p2align 4, 0x90
__ZN10slow_iters5tests8iter_any17h9958878595c8e553E:
.cfi_startproc
pushq %rbp
Lcfi0:
.cfi_def_cfa_offset 16
Lcfi1:
.cfi_offset %rbp, -16