From: "steakknife (Barry Allard)" Date: 2022-11-12T01:49:02+00:00 Subject: [ruby-core:110715] [Ruby master Feature#19125] Support SafeStack Issue #19125 has been reported by steakknife (Barry Allard). ---------------------------------------- Feature #19125: Support SafeStack https://bugs.ruby-lang.org/issues/19125 * Author: steakknife (Barry Allard) * Status: Open * Priority: Normal ---------------------------------------- ## LLVM's current SafeStack support limitations - ucontext.h not yet supported (needs LLVM enhancement or workarounds) - `sigaltstack()` cannot use the unsafe stack - Mark-and-sweep GC's that modify live pointers must look in both unsafe and safe stacks ## Environment - CentOS 9 Stream x86_64 - 96 threads - 96 GiB RAM - 140 GiB SSD storage ## Reproduction ``` sudo dnf install -y yum-utils sudo yum-config-manager --enable crb sudo dnf install -y \ make bc binutils-gold mold patch git bison xz autoconf automake m4 libtool pkg-config perl-interpreter \ gmp-devel openssl-devel readline-devel libyaml-devel gdbm-devel zlib-devel libffi-devel \ ncurses-devel readline-devel glibc-static glibc-devel llvm-toolset LINKER=mold FLAGS='-fsanitize=safe-stack' LINKFLAGS='-fuse-ld=$LINKER -fsanitize=safe-stack' export \ CC=clang \ CXX=clang++ \ LD=$LINKER \ CPPFLAGS="$FLAGS" \ CFLAGS="$FLAGS" \ CXXFLAGS="$FLAGS" \ DCFLAGS="$FLAGS" \ XCFLAGS="$FLAGS" \ MJIT_CFLAGS="$FLAGS" \ DLDFLAGS="$FLAGS $LINKFLAGS" \ LDFLAGS="$FLAGS $LINKFLAGS" \ XLDFLAGS="$FLAGS $LINKFLAGS $EXE_LINKFLAGS" ./configure --disable-install-doc --enable-shared && \ make -j && \ make test && \ sudo make install ``` ### Output ``` assembling coroutine/amd64/Context.S compiling enc/ascii.c compiling enc/us_ascii.c compiling enc/unicode.c compiling enc/utf_8.c compiling enc/trans/newline.c ./revision.h unchanged compiling version.c linking miniruby generating encdb.h ./miniruby: [BUG] Segmentation fault at 0x00000000029bb878 ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux] -- Control frame information ----------------------------------------------- c:0001 p:0000 s:0003 E:001b00 (none) [FINISH] -- Machine register context ------------------------------------------------ RIP: 0x00007fdf8090163d RBP: 0x00007fdf8084c6a8 RSP: 0x00007fffbb98d178 RAX: 0x00000000015329a0 RBX: 0x0000000001488ed0 RCX: 0x0000000000000000 RDX: 0x00000000015329b0 RDI: 0x0000000001488ed0 RSI: 0x000000000000148a R8: 0x0000000000000010 R9: 0x0000000000000038 R10: 0x0000000000000000 R11: 0x0000000000000032 R12: 0x20bb8da71463ef00 R13: 0x00007fdf8084c6b0 R14: 0x0000000001442800 R15: 0xffffffffffffffe8 EFL: 0x0000000000010246 -- C level backtrace information ------------------------------------------- malloc(): unaligned tcache chunk detected ./miniruby: invalid symbol in encoding UTF-8 :"\\xA1E\\x9B\\u0001\\u0000\\u0000\\u0000\\u0000\\u0016\\x90" (EncodingError) make: *** [uncommon.mk:841: .rbconfig.time] Error 1 make: *** Waiting for unfinished jobs.... ./miniruby: [BUG] Segmentation fault at 0x0000000000000000 ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux] -- Control frame information ----------------------------------------------- c:0001 p:0000 s:0003 E:001e70 (none) [FINISH] -- Machine register context ------------------------------------------------ RIP: 0x0000000000493e61 RBP: 0x00000000005b3d1b RSP: 0x00007ffd03d522e0 RAX: 0xabb58d6d7c82b2a0 RBX: 0x00000000019b4a30 RCX: 0x0000000000000312 RDX: 0x00007fcd5cb0bfb8 RDI: 0x00000000019b4a30 RSI: 0x0000000000003d1b R8: 0x0000000000000000 R9: 0x0000000000000038 R10: 0x0000000000000000 R11: 0x0000000000000032 R12: 0x0000000000000044 R13: 0x0000000000000065 R14: 0x00007fcd5cb0bfb8 R15: 0x00000000019ada90 EFL: 0x0000000000010206 -- C level backtrace information ------------------------------------------- corrupted size vs. prev_size make: *** [uncommon.mk:1129: encdb.h] Aborted (core dumped) make: *** [uncommon.mk:1178: builtin_binary.inc] Aborted (core dumped) ``` -- https://bugs.ruby-lang.org/ Unsubscribe: