aboutsummaryrefslogtreecommitdiffstats
path: root/internal
Commit message (Collapse)AuthorAgeFilesLines
* Add `--bugreport-path` optionNobuyoshi Nakada2023-09-251-0/+2
| | | | It has precedence over the environment variable `RUBY_BUGREPORT_PATH`.
* Dump backtraces to an arbitrary streamNobuyoshi Nakada2023-09-251-2/+2
|
* Add rb_hash_free for the GC to usePeter Zhu2023-09-241-0/+1
|
* Stop exposing FrozenCore in headersNobuyoshi Nakada2023-09-191-2/+1
| | | | | Revert commit "Directly allocate FrozenCore as an ICLASS", 813a5f4fc46a24ca1695d23c159250b9e1080ac7.
* Fix crash in WeakMap during compactionPeter Zhu2023-09-061-0/+11
| | | | | WeakMap can crash during compaction because the st_insert could allocate memory.
* Introduce rb_gc_remove_weakPeter Zhu2023-09-051-0/+1
| | | | | | If we're during incremental marking, then Ruby code can execute that deallocates certain memory buffers that have been called with rb_gc_mark_weak, which can cause use-after-free bugs.
* Use end of char boundary in start_with?John Hawthorn2023-09-011-0/+9
| | | | | | | | | | | | | | | | Previously we used the next character following the found prefix to determine if the match ended on a broken character. This had caused surprising behaviour when a valid character was followed by a UTF-8 continuation byte. This commit changes the behaviour to instead look for the end of the last character in the prefix. [Bug #19784] Co-authored-by: ywenc <ywenc@github.com> Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
* Prevent rb_gc_mark_values from pinning objectsMatt Valentine-House2023-08-311-0/+1
| | | | | | | | | | | | | | | | This is an internal only function not exposed to the C extension API. It's only use so far is from rb_vm_mark, where it's used to mark the values in the vm->trap_list.cmd array. There shouldn't be any reason why these cannot move. This commit allows them to move by updating their references during the reference updating step of compaction. To do this we've introduced another internal function rb_gc_update_values as a partner to rb_gc_mark_values. This allows us to refactor rb_gc_mark_values to not pin
* Introduce `at_char_boundary` functionNobuyoshi Nakada2023-08-261-0/+6
|
* Implement weak references in the GCPeter Zhu2023-08-251-0/+2
| | | | | | | | | | | | [Feature #19783] This commit adds support for weak references in the GC through the function `rb_gc_mark_weak`. Unlike strong references, weak references does not mark the object, but rather lets the GC know that an object refers to another one. If the child object is freed, the pointer from the parent object is overwritten with `Qundef`. Co-Authored-By: Jean Boussier <byroot@ruby-lang.org>
* Move SCRIPT_LINES__ away from parse.yNobuyoshi Nakada2023-08-252-2/+2
|
* do not redefine a typedef卜部昌平2023-08-251-2/+2
| | | | duplicated typedef declaration was not allowed in C99.
* do not redefine a typedef卜部昌平2023-08-251-1/+2
| | | | duplicated typedef declaration was not allowed in C99.
* Check that __builtin_mul_overflow can handle long longJeremy Evans2023-08-241-2/+6
| | | | | | Fixes [Bug #17646] Patch from xtkoba (Tee KOBAYASHI)
* Move the PC regardless of the leaf flag (#8232)Takashi Kokubun2023-08-161-1/+0
| | | Co-authored-by: Alan Wu <alansi.xingwu@shopify.com>
* Fix range of `--backtrace-limit`Nobuyoshi Nakada2023-08-111-1/+1
| | | | Also an option command line should have precedence over `RUBYOPT`.
* Move `posix_signal` declaration internal with prefix `ruby_`Nobuyoshi Nakada2023-07-171-0/+4
|
* Implement Process.warmupJean Boussier2023-07-171-0/+1
| | | | | | | | | | | | [Feature #18885] For now, the optimizations performed are: - Run a major GC - Compact the heap - Promote all surviving objects to oldgen Other optimizations may follow.
* YJIT: Make ratio_in_yjit always available (#8064)Takashi Kokubun2023-07-131-0/+5
|
* Remove unused references to the transient heapPeter Zhu2023-07-132-5/+0
|
* Remove RARRAY_CONST_PTR_TRANSIENTPeter Zhu2023-07-131-2/+2
| | | | RARRAY_CONST_PTR now does the same things as RARRAY_CONST_PTR_TRANSIENT.
* Set backtrace length limit at lastNobuyoshi Nakada2023-07-131-0/+1
| | | | | Command line options should have higher precedence than the same options in shebang and `RUBYOPT`.
* Shrink `ruby_cmdline_options_t` a bitNobuyoshi Nakada2023-07-131-1/+2
|
* [Feature #19730] Remove transient heapPeter Zhu2023-07-133-76/+0
|
* Stop allocating unused backref strings at `defined?`Nobuyoshi Nakada2023-06-271-0/+1
|
* Use `rb_reg_nth_defined` instead of `rb_match_nth_defined`Nobuyoshi Nakada2023-06-271-1/+0
|
* Declare `RHASH_AR_TABLE` and `RHASH_ST_TABLE` return non-nullNobuyoshi Nakada2023-06-231-0/+2
|
* Prefer `0` over `NULL` as function pointersNobuyoshi Nakada2023-06-231-1/+1
| | | SunC warns use of `NULL`, pointer to data as function pointers.
* Allow setting the name of a class or module. (#7483)Samuel Williams2023-06-211-0/+16
| | | | Introduce `Module#set_temporary_name` for setting identifiers for otherwise anonymous modules/classes.
* Directly allocate FrozenCore as an ICLASSPeter Zhu2023-06-141-1/+2
| | | | | It's a bad idea to overwrite the flags as the garbage collector may have set other flags.
* Fix duplicate symbol errors when statically linking ripperNobuyoshi Nakada2023-06-121-0/+5
|
* [Feature #19719] Universal Parseryui-knk2023-06-123-10/+193
| | | | | | | | | Introduce Universal Parser mode for the parser. This commit includes these changes: * Introduce `UNIVERSAL_PARSER` macro. All of CRuby related functions are passed via `struct rb_parser_config_struct` when this macro is enabled. * Add CI task with 'cppflags=-DUNIVERSAL_PARSER' for ubuntu.
* Remove RHASH_TRANSIENT_FLAGPeter Zhu2023-06-081-4/+0
| | | | Hashes are no longer allocated on the transient heap.
* Add deprecations for public `struct rb_io` members. (#7916)Samuel Williams2023-06-081-0/+99
| | | * Add deprecations for public struct rb_io members.
* Implement Struct on VWAPeter Zhu2023-06-052-7/+12
| | | | | | | | | | | | | | | | | | | | | The benchmark results show that this feature has either a positive or no impact on performance. The memory usage is also mostly unchanged, except in hexapdf, where there is a decrease in RSS. -------------- ----------- ---------- --------- ----------- ---------- --------- -------------- ------------- bench master (ms) stddev (%) RSS (MiB) branch (ms) stddev (%) RSS (MiB) branch 1st itr master/branch activerecord 70.8 2.2 56.0 71.7 2.2 56.0 0.99 0.99 erubi_rails 20.5 13.6 94.7 20.5 14.3 94.2 0.93 1.00 hexapdf 2541.0 0.7 212.8 2544.4 0.7 203.4 1.00 1.00 liquid-c 65.6 0.3 38.9 65.3 0.3 38.9 1.01 1.01 liquid-compile 63.7 0.3 34.6 61.1 0.2 34.6 1.04 1.04 liquid-render 163.1 0.1 37.1 163.3 0.1 37.1 1.00 1.00 mail 139.3 0.1 50.5 137.0 0.1 50.1 0.99 1.02 psych-load 2065.7 0.1 36.9 2068.2 0.1 37.3 1.00 1.00 railsbench 2034.6 0.5 103.9 2031.9 0.5 103.8 1.02 1.00 ruby-lsp 65.3 3.1 89.8 66.2 3.0 89.7 1.01 0.99 sequel 73.2 1.0 40.3 73.4 1.0 40.3 1.00 1.00 -------------- ----------- ---------- --------- ----------- ---------- --------- -------------- -------------
* Revert "Revert "Fix cvar caching when class is cloned""eileencodes2023-06-051-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 10621f7cb9a0c70e568f89cce47a02e878af6778. This was reverted because the gc integrity build started failing. We have figured out a fix so I'm reopening the PR. Original commit message: Fix cvar caching when class is cloned The class variable cache that was added in ruby#4544 changed the behavior of class variables on cloned classes. As reported when a class is cloned AND a class variable was set, and the class variable was read from the original class, reading a class variable from the cloned class would return the value from the original class. This was happening because the IC (inline cache) is stored on the ISEQ which is shared between the original and cloned class, therefore they share the cache too. To fix this we are now storing the `cref` in the cache so that we can check if it's equal to the current `cref`. If it's different we don't want to read from the cache. If it's the same we do. Cloned classes don't share the same cref with their original class. This will need to be backported to 3.1 in addition to 3.2 since the bug exists in both versions. We also added a marking function which was missing. Fixes [Bug #19379] Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
* Revert "Fix cvar caching when class is cloned"Aaron Patterson2023-06-011-4/+0
| | | | This reverts commit 77d1b082470790c17c24a2f406b4fec5d522636b.
* Fix cvar caching when class is clonedeileencodes2023-06-011-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | The class variable cache that was added in https://github.com/ruby/ruby/pull/4544 changed the behavior of class variables on cloned classes. As reported when a class is cloned AND a class variable was set, and the class variable was read from the original class, reading a class variable from the cloned class would return the value from the original class. This was happening because the IC (inline cache) is stored on the ISEQ which is shared between the original and cloned class, therefore they share the cache too. To fix this we are now storing the `cref` in the cache so that we can check if it's equal to the current `cref`. If it's different we don't want to read from the cache. If it's the same we do. Cloned classes don't share the same cref with their original class. This will need to be backported to 3.1 in addition to 3.2 since the bug exists in both versions. We also added a marking function which was missing. Fixes [Bug #19379] Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
* Use a real Ruby mutex in rb_io_close_wait_list (#7884)KJ Tsanaktsidis2023-06-011-4/+3
| | | | | | | | | | | | | | | | | | | | | | Because a thread calling IO#close now blocks in a native condvar wait, it's possible for there to be _no_ threads left to actually handle incoming signals/ubf calls/etc. This manifested as failing tests on Solaris 10 (SPARC), because: * One thread called IO#close, which sent a SIGVTALRM to the other thread to interrupt it, and then waited on the condvar to be notified that the reading thread was done. * One thread was calling IO#read, but it hadn't yet reached the actual call to select(2) when the SIGVTALRM arrived, so it never unblocked itself. This results in a deadlock. The fix is to use a real Ruby mutex for the close lock; that way, the closing thread goes into sigwait-sleep and can keep trying to interrupt the select(2) thread. See the discussion in: https://github.com/ruby/ruby/pull/7865/
* Revert "Hide most of the implementation of `struct rb_io`. (#6511)"NARUSE, Yui2023-06-011-118/+1
| | | | | | | | | This reverts commit 18e55fc1e1ec20e8f3166e3059e76c885fc9f8f2. fix [Bug #19704] https://bugs.ruby-lang.org/issues/19704 This breaks compatibility for extension libraries. Such changes need a discussion.
* Hide most of the implementation of `struct rb_io`. (#6511)Samuel Williams2023-05-301-1/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | * Add rb_io_path and rb_io_open_descriptor. * Use rb_io_open_descriptor to create PTY objects * Rename FMODE_PREP -> FMODE_EXTERNAL and expose it FMODE_PREP I believe refers to the concept of a "pre-prepared" file, but FMODE_EXTERNAL is clearer about what the file descriptor represents and aligns with language in the IO::Buffer module. * Ensure that rb_io_open_descriptor closes the FD if it fails If FMODE_EXTERNAL is not set, then it's guaranteed that Ruby will be responsible for closing your file, eventually, if you pass it to rb_io_open_descriptor, even if it raises an exception. * Rename IS_EXTERNAL_FD -> RUBY_IO_EXTERNAL_P * Expose `rb_io_closed_p`. * Add `rb_io_mode` to get IO mode. --------- Co-authored-by: KJ Tsanaktsidis <ktsanaktsidis@zendesk.com>
* Fix busy-loop when waiting for file descriptors to closeKJ Tsanaktsidis2023-05-261-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | When one thread is closing a file descriptor whilst another thread is concurrently reading it, we need to wait for the reading thread to be done with it to prevent a potential EBADF (or, worse, file descriptor reuse). At the moment, that is done by keeping a list of threads still using the file descriptor in io_close_fptr. It then continually calls rb_thread_schedule() in fptr_finalize_flush until said list is empty. That busy-looping seems to behave rather poorly on some OS's, particulary FreeBSD. It can cause the TestIO#test_race_gets_and_close test to fail (even with its very long 200 second timeout) because the closing thread starves out the using thread. To fix that, I introduce the concept of struct rb_io_close_wait_list; a list of threads still using a file descriptor that we want to close. We call `rb_notify_fd_close` to let the thread scheduler know we're closing a FD, which fills the list with threads. Then, we call rb_notify_fd_close_wait which will block the thread until all of the still-using threads are done. This is implemented with a condition variable sleep, so no busy-looping is required.
* Fix crash when replacing ST hash with AR hashPeter Zhu2023-05-231-1/+0
| | | | | | | | | With VWA, AR hashes are much larger than ST hashes. Hash#replace attempts to directly copy the contents of AR hashes into ST hashes so there will be memory corruption caused by writing past the end of memory. This commit changes it so that if a ST hash is being replaced with an AR hash it will insert each element into the ST hash.
* Put `rb_fork` back into process.cNobuyoshi Nakada2023-05-211-14/+0
| | | | | Now, calling `rb_fork` directly breaks the PID cache and the timer thread, so must use `rb_fork_ruby` or similar instead.
* Add Fiber#kill, similar to Thread#kill. (#7823)Samuel Williams2023-05-181-0/+4
|
* Move ar_hint to ar_table_structPeter Zhu2023-05-171-10/+4
| | | | This allows Hashes with ST tables to fit int he 80 byte size pool.
* Implement Hash ST tables on VWAPeter Zhu2023-05-171-8/+19
|
* Implement Hash AR tables on VWAPeter Zhu2023-05-171-34/+6
|
* Add `rb_sys_fail_sprintf` macroNobuyoshi Nakada2023-05-121-0/+6
|
* [Bug #19635] Preserve `errno`Nobuyoshi Nakada2023-05-121-2/+18
| | | | | | | | The following functions are turned into macros and no longer can be used as expressions in core. - rb_sys_fail - rb_sys_fail_str - rb_sys_fail_path