Skip to content

Instantly share code, notes, and snippets.

@obilaniu
obilaniu / hack.cpp
Created April 8, 2022 15:00
LD_PRELOAD'able patch for PyTorch 1.10.x INTERNAL ASSERT FAILED at "../aten/src/ATen/MapAllocator.cpp":263
// Anaconda: g++-7 -D_GLIBCXX_USE_CXX11_ABI=0 -Os -Wall -fPIC hack.cpp -c -o hack_abi_old.o
// Others: g++-7 -D_GLIBCXX_USE_CXX11_ABI=1 -Os -Wall -fPIC hack.cpp -c -o hack_abi_new.o
// Linker: g++-7 -fPIC -shared hack_abi_old.o hack_abi_new.o -o hack.so
// Strip: strip hack.so
// Use: export LD_PRELOAD=/absolute/path/to/hack.so # Before executing python
#include <atomic>
#include <string>
#include <random>
#include <stdint.h>