Benoit DalozeandClaude Opus 5.5 9ba7257f44 Add a signal fence in rb_ec_clear_vm_stack()
Since the fix for Bug #21441, ec->cfp is set to NULL before clearing
the VM stack so that thread_profile_frames() called from a signal
handler returns early instead of walking a stack that is no longer set
on the ec. But these are plain stores to distinct fields of the same
struct, so the compiler is free to reorder them.

With Apple clang 21 and GCC 16 on macOS arm64, and with clang 18 and
GCC 13 on Linux aarch64, both stores of rb_ec_set_vm_stack() were
combined into a single stp emitted before the store to ec->cfp
(vm_stack is at offset 0, vm_stack_size at 0x8 and cfp at 0x10):

    stp xzr, xzr, [x0]        ; ec->vm_stack = NULL, vm_stack_size = 0
    str xzr, [x0, #0x10]      ; ec->cfp = NULL
    ret

So a signal in between would see a non-NULL ec->cfp with a NULL
ec->vm_stack. Stopping there in lldb when a thread terminates and
calling rb_profile_frames() segfaults in thread_profile_frames(), as
end_cfp is computed from the NULL ec->vm_stack and the loop walks past
the control frames. With this change, ec->cfp is already NULL at that
point and rb_profile_frames() returns 0.

Like in vm_push_frame(), use atomic_signal_fence() to keep the store to
ec->cfp first. With it, all these compilers emit the store to ec->cfp no
later than the stores clearing the stack. The rest of vm.o is unchanged
with Apple clang 21, GCC 16 and GCC 13 on aarch64. Clang 21 and 18:

    stp xzr, xzr, [x0, #0x8]  ; ec->vm_stack_size = 0, cfp = NULL
    str xzr, [x0]             ; ec->vm_stack = NULL
    ret

GCC 16 and 13:

    str xzr, [x0, #0x10]      ; ec->cfp = NULL
    stp xzr, xzr, [x0]        ; ec->vm_stack = NULL, vm_stack_size = 0
    ret

With GCC 13 on x86_64, the store to ec->cfp is already emitted first
without the fence, and vm.o is identical with and without it:

    endbr64
    movq $0x0, 0x10(%rdi)     ; ec->cfp = NULL
    movq $0x0, (%rdi)         ; ec->vm_stack = NULL
    movq $0x0, 0x8(%rdi)      ; ec->vm_stack_size = 0
    ret

[Bug #22477]

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 12:35:42 -07:00
…
…
2025-12-02 08:56:21 +09:00
2026-06-15 09:50:20 -07:00
2026-08-10 12:11:15 -07:00
2026-10-21 23:03:43 -07:00
2025-12-18 16:12:47 +00:00
2026-10-09 16:07:24 -07:00
…
2025-12-19 17:09:10 -05:00
2025-12-09 22:48:06 -08:00
2025-04-09 19:13:58 +09:00
2025-01-02 11:03:04 -05:00
2025-12-10 10:23:37 +09:00
2024-04-07 16:44:42 +09:00
2025-05-11 23:32:50 +09:00
2025-05-11 23:32:50 +09:00
2024-02-21 23:37:20 +09:00
2024-02-21 23:37:20 +09:00
2025-12-12 14:03:37 -08:00
2025-12-21 14:05:55 -05:00
2025-12-09 16:45:38 +09:00
2024-09-08 23:40:18 +09:00
…
2025-01-24 10:44:24 -05:00
2024-04-27 21:55:28 +09:00
…
2025-10-30 21:47:12 +09:00
2026-07-09 16:36:24 -07:00
2025-09-06 07:17:52 +09:00
2025-05-25 15:22:43 +09:00
2025-12-25 11:47:08 +09:00
2025-06-12 09:30:09 +02:00
2025-08-30 22:41:23 +09:00
2025-01-09 19:24:27 +09:00
2025-01-30 18:19:53 +09:00
2025-12-15 17:28:35 -05:00
2026-06-10 12:59:53 -07:00
2026-01-20 10:49:33 -08:00
2026-10-09 16:06:33 -07:00
…
2025-12-18 15:59:49 -08:00
2026-10-01 12:02:09 -07:00
2025-10-31 20:49:59 +09:00
2025-10-31 20:49:59 +09:00
2026-10-09 16:07:16 -07:00
…
…
2024-11-08 17:39:19 -08:00
2025-10-23 13:08:26 +09:00
2025-07-28 12:22:42 +02:00
2024-11-13 10:29:07 +01:00
…
2025-02-23 10:37:36 +09:00
2026-10-22 19:36:04 -07:00
2025-12-10 10:23:37 +09:00
2024-03-19 09:26:49 +01:00

Actions Status: MinGW Actions Status: Ubuntu Actions Status: Windows Travis Status

日本語

What is Ruby?

Ruby is an interpreted object-oriented programming language often used for web development. It also offers many scripting features to process plain text and serialized files, or manage system tasks. It is simple, straightforward, and extensible.

Features of Ruby

  • Simple Syntax
  • Normal Object-oriented Features (e.g. class, method calls)
  • Advanced Object-oriented Features (e.g. mix-in, singleton-method)
  • Operator Overloading
  • Exception Handling
  • Iterators and Closures
  • Garbage Collection
  • Dynamic Loading of Object Files (on some architectures)
  • Highly Portable (works on many Unix-like/POSIX compatible platforms as well as Windows, macOS, etc.) cf. https://docs.ruby-lang.org/en/master/maintainers_md.html#label-Platform+Maintainers

How to get Ruby

For a complete list of ways to install Ruby, including using third-party tools like rvm, see:

https://www.ruby-lang.org/en/downloads/

You can download release packages and the snapshot of the repository. If you want to download whole versions of Ruby, please visit https://www.ruby-lang.org/en/downloads/releases/.

Download with Git

The mirror of the Ruby source tree can be checked out with the following command:

$ git clone https://github.com/ruby/ruby.git

There are some other branches under development. Try the following command to see the list of branches:

$ git ls-remote https://github.com/ruby/ruby.git

You may also want to use https://git.ruby-lang.org/ruby.git (actual master of Ruby source) if you are a committer.

How to build

See Building Ruby

Ruby home page

https://www.ruby-lang.org/

Documentation

Mailing list

There is a mailing list to discuss Ruby. To subscribe to this list, please send the following phrase:

join

in the mail subject (not body) to the address ruby-talk-request@ml.ruby-lang.org.

Copying

See the file COPYING.

Feedback

Questions about the Ruby language can be asked on the Ruby-Talk mailing list or on websites like https://stackoverflow.com.

Bugs should be reported at https://bugs.ruby-lang.org. Read "Reporting Issues" for more information.

Contributing

See "Contributing to Ruby", which includes setup and build instructions.

The Author

Ruby was originally designed and developed by Yukihiro Matsumoto (Matz) in 1995.

matz@ruby-lang.org

Languages
Ruby 57.2%
C 29.4%
Rust 8%
C++ 2.6%
Yacc 0.9%
Other 1.8%