summaryrefslogtreecommitdiff
path: root/vm_dump.c
AgeCommit message (Collapse)Author
2025-12-06Fix `io_pwrite` fiber scheduler hook. (#15428)Samuel Williams
Fix io_pwrite fiber scheduler hook.
2025-11-17vm_dump.c: unbreak unwind on powerpc (#14650)Sergey Fedorov
2025-11-07Suppress sign-compare warningsNobuyoshi Nakada
2025-11-07Use RUBY_BOX environment variable instead of RUBY_NAMESPACESatoshi Tagomori
2025-11-07renaming internal data structures and functions from namespace to boxSatoshi Tagomori
2025-11-03Use CFUNC namespace only for IFUNC frames, its behavior should be unchangedSatoshi Tagomori
2025-10-13Add "Namespace detection information" section in bug reportsSatoshi Tagomori
* To show environments stack when the current namespace is unexpected or namespace detection is broken * It is displayed only when RUBY_BUGREPORT_NAMESPACE_ENV=1 is specified
2025-10-07Add a control frame column "n:xxxx" as namespace id in crash reportsSatoshi Tagomori
2025-10-07Stop displaying current namespace when it crashedSatoshi Tagomori
To avoid crashes during displaying crash reports.
2025-09-29Update current namespace management by using control frames and lexical contextsSatoshi Tagomori
to fix inconsistent and wrong current namespace detections. This includes: * Moving load_path and related things from rb_vm_t to rb_namespace_t to simplify accessing those values via namespace (instead of accessing either vm or ns) * Initializing root_namespace earlier and consolidate builtin_namespace into root_namespace * Adding VM_FRAME_FLAG_NS_REQUIRE for checkpoints to detect a namespace to load/require files * Removing implicit refinements in the root namespace which was used to determine the namespace to be loaded (replaced by VM_FRAME_FLAG_NS_REQUIRE) * Removing namespaces from rb_proc_t because its namespace can be identified by lexical context * Starting to use ep[VM_ENV_DATA_INDEX_SPECVAL] to store the current namespace when the frame type is MAGIC_TOP or MAGIC_CLASS (block handlers don't exist in this case)
2025-09-25Always use assert-free APIs when profiling and crashingAlan Wu
rb_profile_frames() is used by profilers in a way such that it can run on any instruction in the binary, and it crashed previously in the following situation in `RUBY_DEBUG` builds: ``` * thread #1, queue = 'com.apple.main-thread', stop reason = step over frame #0: 0x00000001002827f0 miniruby`vm_make_env_each(ec=0x0000000101866b00, cfp=0x000000080c91bee8) at vm.c:992:74 989 } 990 991 vm_make_env_each(ec, prev_cfp); -> 992 VM_FORCE_WRITE_SPECIAL_CONST(&ep[VM_ENV_DATA_INDEX_SPECVAL], VM_GUARDED_PREV_EP(prev_cfp->ep)); 993 } 994 } 995 else { (lldb) call rb_profile_frames(0, 100, $2, $3) /Users/alan/ruby/vm_core.h:1448: Assertion Failed: VM_ENV_FLAGS:FIXNUM_P(flags) ruby 3.5.0dev (2025-09-23T20:20:04Z master 06b7a70837) +PRISM [arm64-darwin25] -- Crash Report log information -------------------------------------------- See Crash Report log file in one of the following locations: * ~/Library/Logs/DiagnosticReports * /Library/Logs/DiagnosticReports for more details. Don't forget to include the above Crash Report log file in bug reports. -- Control frame information ----------------------------------------------- c:0008 p:---- s:0029 e:000028 CFUNC :lambda /Users/alan/ruby/vm_core.h:1448: Assertion Failed: VM_ENV_FLAGS:FIXNUM_P(flags) ruby 3.5.0dev (2025-09-23T20:20:04Z master 06b7a70837) +PRISM [arm64-darwin25] -- Crash Report log information -------------------------------------------- <snip> ``` There is a small window where the control frame is invalid and fails the assert. The double crash also shows that in `RUBY_DEBUG` builds, the crash reporter was previously not resilient to corrupt frame state. In release builds, it prints more info. Add unchecked APIs for the crash reporter and profilers so they work as well in `RUBY_DEBUG` builds as non-debug builds.
2025-05-05vm_dump.c: avoid `USE_MN_THREADS` is not defined warningJean Boussier
2025-05-05Fix `USE_MN_THREADS=0` builds on macOSJean Boussier
This was recently broken. Notes: Merged: https://github.com/ruby/ruby/pull/13258
2025-04-05[Bug #21150] macOS: unwinding coroutine workaround is only for arm64Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/13072
2025-02-21[Bug #21150] macOS: Temporary workaround at unwinding coroutineNobuyoshi Nakada
On arm64 macOS, libunwind (both of system library and homebrew llvm-18) seems not to handle our coroutine switching code. Notes: Merged: https://github.com/ruby/ruby/pull/12789
2025-01-07glibc and musl didn't provide A1-A7, FP and S3-S8 constants.Hiroshi SHIBATA
* https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/loongarch/sys/ucontext.h * https://git.musl-libc.org/cgit/musl/tree/arch/loongarch64/bits/signal.h Notes: Merged: https://github.com/ruby/ruby/pull/12515
2024-12-17Win32: Fix the macro for arm64 on mswinNobuyoshi Nakada
Visual C defines `_M_`-prefixed macros for the target architectures. Notes: Merged: https://github.com/ruby/ruby/pull/12367
2024-12-12Don't output memory map in crash report for ASANPeter Zhu
ASAN maps a large amount of memory, which makes the memory map section massive. Notes: Merged: https://github.com/ruby/ruby/pull/12309
2024-11-05Use rb_fiber_scheduler_get() instead of rb_fiber_scheduler_current()Yusuke Endoh
rb_fiber_scheduler_current() may return nil depending on whether the scheduler is being prevented for some reason, e.g., Fiber.blocking{}. Co-Authored-By: Samuel Williams <samuel.williams@oriontransfer.co.nz> Notes: Merged: https://github.com/ruby/ruby/pull/12001
2024-11-05Let vm_dump show whether the fiber scheduler is enabled or notYusuke Endoh
... just for the case. Notes: Merged: https://github.com/ruby/ruby/pull/12000
2024-09-26Added LARCH_REG_FP to dump resultsHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/11693
2024-09-26Use constants for register numbersHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/11693
2024-09-26Removed duplicated dumpsHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/11693
2024-09-26Import patches for old macOS from MacPortsNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/11690
2023-11-23windows-arm64 support (#8995)Pierrick Bouvier
* [win32] fix compilation for windows-arm64 Credits to MSYS2 Ruby package using this patch. * [win32] nm use full options Fix compilation error when using MSYS2 environment. Credits to MSYS2 Ruby package using this patch. * [win32] detect llvm-windres (used for windows-arm64) When adding preprocessor option for llvm-windres (using clang as parameter), it fails. Thus, do not add this. It's needed to be able to compile windows-arm64 version, because MSYS2 toolchain is LLVM based (instead of GCC/binutils). * [win32] pioinfo detection for windows-arm64 This fixes "unexpected ucrtbase.dll" for native windows-arm64 ruby binary. It does not solve issue with x64 version emulated on this platform. Value of pioinfo pointer can be found in ucrtbase.dll at latest adrp/add sequence before return of _isatty function. This works for both release and debug ucrt. Due to the nature of aarch64 ISA (vs x86 or x64), it's needed to disassemble instructions to retrieve offset value, which is a bit more complicated than matching specific string patterns. Details about adrp/add usage can be found in this blog post: https://devblogs.microsoft.com/oldnewthing/20220809-00/?p=106955 For instruction decoding, the Arm documentation was used as a reference.
2023-10-12Fix leaked symbols on FreeBSD [ci skip]Nobuyoshi Nakada
2023-09-26Dump backtraces to an arbitrary stream when using libprocstatNobuyoshi Nakada
2023-09-26Labels cannot at the end of blockNobuyoshi Nakada
2023-09-26Add a missing labelNobuyoshi Nakada
2023-09-25Abort dumping when output failedNobuyoshi Nakada
2023-09-25Dump backtraces to an arbitrary streamNobuyoshi Nakada
2023-07-27Clean up OPT_STACK_CACHING (#8132)Takashi Kokubun
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2023-07-17Remove __bp__ and speed-up bmethod calls (#8060)Alan Wu
Remove rb_control_frame_t::__bp__ and optimize bmethod calls This commit removes the __bp__ field from rb_control_frame_t. It was introduced to help MJIT, but since MJIT was replaced by RJIT, we can use vm_base_ptr() to compute it from the SP of the previous control frame instead. Removing the field avoids needing to set it up when pushing new frames. Simply removing __bp__ would cause crashes since RJIT and YJIT used a slightly different stack layout for bmethod calls than the interpreter. At the moment of the call, the two layouts looked as follows: ┌────────────┐ ┌────────────┐ │ frame_base │ │ frame_base │ ├────────────┤ ├────────────┤ │ ... │ │ ... │ ├────────────┤ ├────────────┤ │ args │ │ args │ ├────────────┤ └────────────┘<─prev_frame_sp │ receiver │ prev_frame_sp─>└────────────┘ RJIT & YJIT interpreter Essentially, vm_base_ptr() needs to compute the address to frame_base given prev_frame_sp in the diagrams. The presence of the receiver created an off-by-one situation. Make the interpreter use the layout the JITs use for iseq-to-iseq bmethod calls. Doing so removes unnecessary argument shifting and vm_exec_core() re-entry from the interpreter, yielding a speed improvement visible through `benchmark/vm_defined_method.yml`: patched: 7578743.1 i/s master: 4796596.3 i/s - 1.58x slower C-to-iseq bmethod calls now store one more VALUE than before, but that should have negligible impact on overall performance. Note that re-entering vm_exec_core() used to be necessary for firing TracePoint events, but that's no longer the case since 9121e57a5f50bc91bae48b3b91edb283bf96cb6b. Closes ruby/ruby#6428
2023-03-16Add thread and ractor counts to bug reportsAlan Wu
This is useful for crash triaging. It also helps to hint extension developers about the misuse of `rb_thread_call_without_gvl()`. Example: $ ./miniruby -e 'Ractor.new{Ractor.receive}; Thread.new{sleep}; Process.kill:SEGV,Process.pid' <snip> -- Threading information --------------------------------------------------- Total ractor count: 2 Ruby thread count for this ractor: 2 Notes: Merged: https://github.com/ruby/ruby/pull/7532
2023-02-23Move `dump_machine_register` definitionsNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/7361
2023-02-22Add support for LoongArch (#7343)小MAO钓鱼
* vm_dump.c: Dump machine registers on loongarch64 Linux. * coroutines: Support for native loongarch64 coroutines. --------- Co-authored-by: zangruochen <zangruochen@loongson.cn> Notes: Merged-By: nurse <naruse@airemix.jp>
2023-02-09Merge gc.h and internal/gc.hMatt Valentine-House
[Feature #19425] Notes: Merged: https://github.com/ruby/ruby/pull/7273
2022-12-24Fix backtrace beyond _singtramp on macOS arm64 (#7015)NARUSE, Yui
* move ptrauth_strip logic into vm_dump.c * don't use _sigtramp special logic on arm64 Notes: Merged-By: nurse <naruse@airemix.jp>
2022-10-20push dummy frame for loading processKoichi Sasada
This patch pushes dummy frames when loading code for the profiling purpose. The following methods push a dummy frame: * `Kernel#require` * `Kernel#load` * `RubyVM::InstructionSequence.compile_file` * `RubyVM::InstructionSequence.load_from_binary` https://bugs.ruby-lang.org/issues/18559 Notes: Merged: https://github.com/ruby/ruby/pull/6572
2022-07-21Expand tabs [ci skip]Takashi Kokubun
[Misc #18891] Notes: Merged: https://github.com/ruby/ruby/pull/6094
2022-06-03Prevent printing crash report in a loopAlan Wu
In the event that we are crashing due to a corrupt Ruby stack, we might re-enter rb_vm_bugreport() due to failed assertions in rb_backtrace_print_as_bugreport() or SDR(). In these cases we were printing the bug report ad infinitum with unbounded recusion. I seem to run into this every once in a while and the amount of log it prints out is pretty distracting. On CI environments it makes the log output unnecessarily big. Let's fix this. Notes: Merged: https://github.com/ruby/ruby/pull/5731
2022-05-24remove `NON_SCALAR_THREAD_ID` supportKoichi Sasada
`NON_SCALAR_THREAD_ID` shows `pthread_t` is non-scalar (non-pointer) and only s390x is known platform. However, the supporting code is very complex and it is only used for deubg print information. So this patch removes the support of `NON_SCALAR_THREAD_ID` and make the code simple. Notes: Merged: https://github.com/ruby/ruby/pull/5933
2022-04-23introduce struct `rb_native_thread`Koichi Sasada
`rb_thread_t` contained `native_thread_data_t` to represent thread implementation dependent data. This patch separates them and rename it `rb_native_thread` and point it from `rb_thraed_t`. Now, 1 Ruby thread (`rb_thread_t`) has 1 native thread (`rb_native_thread`). Notes: Merged: https://github.com/ruby/ruby/pull/5836
2022-04-20Enable C backtraces on Apple silicon (#5770)Jean byroot Boussier
Co-authored-by: Jean Boussier <jean.boussier@gmail.com> Notes: Merged-By: nurse <naruse@airemix.jp>
2022-04-09[DOC]Some link prefix replaceS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/5783
2022-03-30Prefix ccan headers (#4568)Nobuyoshi Nakada
* Prefixed ccan headers * Remove unprefixed names in ccan/build_assert * Remove unprefixed names in ccan/check_type * Remove unprefixed names in ccan/container_of * Remove unprefixed names in ccan/list Co-authored-by: Samuel Williams <samuel.williams@oriontransfer.co.nz> Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-03-24Add ISEQ_BODY macroPeter Zhu
Use ISEQ_BODY macro to get the rb_iseq_constant_body of the ISeq. Using this macro will make it easier for us to change the allocation strategy of rb_iseq_constant_body when using Variable Width Allocation. Notes: Merged: https://github.com/ruby/ruby/pull/5698
2022-01-25enable `RUBY_ON_BUG` on release buildKoichi Sasada
[Feature #18483] Notes: Merged: https://github.com/ruby/ruby/pull/5481
2021-10-10Shorten register names on arm64-darwin not to be truncatedNobuyoshi Nakada
2021-06-10Crash more nicely when the VM isn't fully set upAaron Patterson
If we crash but the VM isn't fully alive, we can get an infinite loop.