summaryrefslogtreecommitdiff
path: root/error.c
AgeCommit message (Collapse)Author
2025-04-19Fix style [ci skip]Nobuyoshi Nakada
2025-01-31[DOC] Improve Errno and SystemCallError.newNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12683
2025-01-02[DOC] Exclude 'Class' and 'Module' from RDoc's autolinkingNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12496
2024-12-24[DOC] Adjust documentation related to backtraces (#12420)Victor Shepelev
Notes: Merged-By: zverok <[email protected]>
2024-12-22Fix extra 'warning:' prefix for chilled Symbol#to_szverok
Notes: Merged: https://github.com/ruby/ruby/pull/12423
2024-12-19[DOC] Link to special `fatal` class through `rdoc-ref`Stan Lo
Notes: Merged: https://github.com/ruby/ruby/pull/12391
2024-12-15Suppress -Wsuggest-attribute=formatTakashi Kokubun
2024-12-12Fix LoadError's linking issueStan Lo
Original issue: https://github.com/ruby/rdoc/issues/1128 The problem is caused by the `# :stopdoc:` directive in `bundled_gems.rb`, which's scope covers the redefinition of `LoadError`. Since the goal of `# :stopdoc:` is to hide the documentation of `Gem::BUNDLED_GEMS`, we can use `# :nodoc:` on it instead. Notes: Merged: https://github.com/ruby/ruby/pull/12317
2024-12-12Implement rb_bug_without_diePeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/12309
2024-12-12Add `rb_warn_reserved_name_at`Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12315
2024-11-27Make rb_bug_without_die staticPeter Zhu
It's not used outside of error.c. Notes: Merged: https://github.com/ruby/ruby/pull/12183
2024-11-25error.c: call `va_end` before jumpingJean Boussier
The man page is clear that every `va_start` call MUST be succeeded by the corresponding `va_end` call. So `rb_raise` can't call `rb_exc_raise` before `va_end`, otherwise `va_end` is never called. Co-Authored-By: Étienne Barrié <[email protected]>
2024-11-13Mark strings returned by Symbol#to_s as chilled (#12065)Jean byroot Boussier
* Use FL_USER0 for ELTS_SHARED This makes space in RString for two bits for chilled strings. * Mark strings returned by `Symbol#to_s` as chilled [Feature #20350] `STR_CHILLED` now spans on two user flags. If one bit is set it marks a chilled string literal, if it's the other it marks a `Symbol#to_s` chilled string. Since it's not possible, and doesn't make much sense to include debug info when `--debug-frozen-string-literal` is set, we can't include allocation source, but we can safely include the symbol name in the warning message, making it much easier to find the source of the issue. Co-Authored-By: Étienne Barrié <[email protected]> --------- Co-authored-by: Étienne Barrié <[email protected]> Co-authored-by: Jean Boussier <[email protected]>
2024-11-07Respect RUBY_CRASH_REPORT path when RUBY_ASSERT() failsAlan Wu
Previously, it always used stderr. Slight shuffle of the first line of the crash due to reusing code from rb_bug(): ```diff -Assertion Failed: /ruby/object.c:649:rb_obj_itself:false +/ruby/object.c:649: Assertion Failed: rb_obj_itself:false ``` Tested locally to confirm that it writes to the file given with RUBY_CRASH_REPORT. Follow-up for [Feature #19790]. Notes: Merged: https://github.com/ruby/ruby/pull/12019 Merged-By: XrXr
2024-11-06`Warning[:strict_unused_block]`Koichi Sasada
to show unused block warning strictly. ```ruby class C def f = nil end class D def f = yield end [C.new, D.new].each{|obj| obj.f{}} ``` In this case, `D#f` accepts a block. However `C#f` doesn't accept a block. There are some cases passing a block with `obj.f{}` where `obj` is `C` or `D`. To avoid warnings on such cases, "unused block warning" will be warned only if there is not same name which accepts a block. On the above example, `C.new.f{}` doesn't show any warnings because there is a same name `D#f` which accepts a block. We call this default behavior as "relax mode". `strict_unused_block` new warning category changes from "relax mode" to "strict mode", we don't check same name methods and `C.new.f{}` will be warned. [Feature #15554] Notes: Merged: https://github.com/ruby/ruby/pull/12005
2024-10-21Show where mutated chilled strings were allocatedÉtienne Barrié
[Feature #20205] The warning now suggests running with --debug-frozen-string-literal: ``` test.rb:3: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information) ``` When using --debug-frozen-string-literal, the location where the string was created is shown: ``` test.rb:3: warning: literal string will be frozen in the future test.rb:1: info: the string was created here ``` When resurrecting strings and debug mode is not enabled, the overhead is a simple FL_TEST_RAW. When mutating chilled strings and deprecation warnings are not enabled, the overhead is a simple warning category enabled check. Co-authored-by: Jean Boussier <[email protected]> Co-authored-by: Nobuyoshi Nakada <[email protected]> Co-authored-by: Jean Boussier <[email protected]> Notes: Merged: https://github.com/ruby/ruby/pull/11893
2024-10-09Fix spellingJohn Bampton
Notes: Merged: https://github.com/ruby/ruby/pull/11835
2024-09-27[DOC] Improve description of `LoadError#path` and `SyntaxError#path`David Rodríguez
Notes: Merged: https://github.com/ruby/ruby/pull/11684 Merged-By: nobu <[email protected]>
2024-09-25doc: Remove description of experimental warnings related pattern matching ↵masatoshi_moritsuka
from documentation Ruby 3.2.0 has been released and all experimental warnings about pattern matching have been removed. Experimental warnings about pattern matching are no longer output, so I remove description about it from documentation as well. cf. https://bugs.ruby-lang.org/issues/18585 cf. db6b23c76cbc7888cd9a9912790c2068703afdd0 cf. https://twitter.com/k_tsj/status/1606956336037900289?s=20&t=-_PSYLhYPtYsB9FZhtXl5A Notes: Merged: https://github.com/ruby/ruby/pull/7052
2024-07-19Make rb_check_frozen_inline() static inline againAlan Wu
Since 730e3b2ce01915c4a98b79bb281b2c38a9ff1131 ("Stop exposing `rb_str_chilled_p`"), we noticed a speed loss on a few benchmarks that are string operations heavy. This is partially due to routines no longer having the options to inline rb_check_frozen_inline() in non-LTO builds. Make it an inlining candidate again to recover speed. Testing this patch on my machine, the fannkuchredux benchmark gets a 1.15 speed-up with YJIT and 1.03 without YJIT. Notes: Merged: https://github.com/ruby/ruby/pull/11211
2024-06-26[DOC] Doc for exceptions (#11008)Burdette Lamar
2024-06-25Show the detail info in the first lineNobuyoshi Nakada
2024-06-11Don't call `Warning.warn` unless the category is enabledAaron Patterson
The warning category should be enabled if we want to call `Warning.warn`. This commit speeds up the following benchmark: ```ruby eval "def test; " + 1000.times.map { "' '.chomp!" }.join(";") + "; end" def run_benchmark count i = 0 while i < count start = Process.clock_gettime(Process::CLOCK_MONOTONIC) yield ms = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start puts "itr ##{i}: #{(ms * 1000).to_i}ms" i += 1 end end run_benchmark(25) do 250.times do test end end ``` On `master` this runs at about 92ms per iteration. With this patch, it is 7ms per iteration. [Bug #20573]
2024-06-05[DOC] Doc for module Errno (#10913)Burdette Lamar
2024-06-02Stop exposing `rb_str_chilled_p`Jean Boussier
[Feature #20205] Now that chilled strings no longer appear as frozen, there is no need to offer an API to check for chilled strings. We however need to change `rb_check_frozen_internal` to no longer be a macro, as it needs to check for chilled strings.
2024-05-30[DEBUG] More info when SyntaxError#path changedNobuyoshi Nakada
2024-05-28Stop marking chilled strings as frozenÉtienne Barrié
They were initially made frozen to avoid false positives for cases such as: str = str.dup if str.frozen? But this may cause bugs and is generally confusing for users. [Feature #20205] Co-authored-by: Jean Boussier <[email protected]>
2024-05-26Debug unexpectedly changed pathNobuyoshi Nakada
2024-05-08[PRISM] Use correct warning encodingKevin Newton
2024-03-19Implement chilled stringsÉtienne Barrié
[Feature #20205] As a path toward enabling frozen string literals by default in the future, this commit introduce "chilled strings". From a user perspective chilled strings pretend to be frozen, but on the first attempt to mutate them, they lose their frozen status and emit a warning rather than to raise a `FrozenError`. Implementation wise, `rb_compile_option_struct.frozen_string_literal` is no longer a boolean but a tri-state of `enabled/disabled/unset`. When code is compiled with frozen string literals neither explictly enabled or disabled, string literals are compiled with a new `putchilledstring` instruction. This instruction is identical to `putstring` except it marks the String with the `STR_CHILLED (FL_USER3)` and `FL_FREEZE` flags. Chilled strings have the `FL_FREEZE` flag as to minimize the need to check for chilled strings across the codebase, and to improve compatibility with C extensions. Notes: - `String#freeze`: clears the chilled flag. - `String#-@`: acts as if the string was mutable. - `String#+@`: acts as if the string was mutable. - `String#clone`: copies the chilled flag. Co-authored-by: Jean Boussier <[email protected]>
2024-03-18Update set_backtrace documentationJean Boussier
Followup: https://github.com/ruby/ruby/pull/10017 [Feature #13557]
2024-03-14`Exception#set_backtrace` accept arrays of `Backtrace::Location`Jean Boussier
[Feature #13557] Setting the backtrace with an array of strings is lossy. The resulting exception will return nil on `#backtrace_locations`. By accepting an array of `Backtrace::Location` instance, we can rebuild a `Backtrace` instance and have a fully functioning Exception. Co-Authored-By: Étienne Barrié <[email protected]>
2024-03-14[Feature #20293] Add `Warning.categories`Nobuyoshi Nakada
2024-03-06Move FL_SINGLETON to FL_USER1Jean Boussier
This frees FL_USER0 on both T_MODULE and T_CLASS. Note: prior to this, FL_SINGLETON was never set on T_MODULE, so checking for `FL_SINGLETON` without first checking that `FL_TYPE` was `T_CLASS` was valid. That's no longer the case.
2024-02-23YJIT: Lazily push a frame for specialized C funcs (#10080)Takashi Kokubun
* YJIT: Lazily push a frame for specialized C funcs Co-authored-by: Maxime Chevalier-Boisvert <[email protected]> * Fix a comment on pc_to_cfunc * Rename rb_yjit_check_pc to rb_yjit_lazy_push_frame * Rename it to jit_prepare_lazy_frame_call * Fix a typo * Optimize String#getbyte as well * Optimize String#byteslice as well --------- Co-authored-by: Maxime Chevalier-Boisvert <[email protected]>
2024-02-08Optional detail info at assertion failureNobuyoshi Nakada
2024-01-13Fix typoNobuyoshi Nakada
2024-01-13[DOC] Documentize known_errorsNobuyoshi Nakada
2024-01-12[DOC] Mark up the class name `fatal`Nobuyoshi Nakada
2024-01-02Fix Exception#detailed_message for GC compactionPeter Zhu
Before this commit, the test fails with RGENGC_CHECK_MODE enabled: TestException#test_detailed_message_under_gc_compact_stress [test/ruby/test_exception.rb:1466]: <"\e[1mfoo (\e[1;4mRuntimeError\e[m\e[1m)\e[m\n" + "\e[1mbar\e[m\n" + "\e[1mbaz\e[m"> expected but was <"\e[1mfoo (\e[1;4mRuntimeError\e[m\e[1m)\e[m\n" + "\e[1m\x00\x00\x00\x00\x00\x00\x00\e[m">.
2023-12-21[DOC] Fix NoMethodError example of rendering (#9309)Victor Shepelev
Fix NoMethodError example of rendering
2023-12-15rb_bug_for_fatal_signal: exit with the right signalJean Boussier
`die()` calls `abort()` which always exit as it `SIGABRT` was received. This isn't very friendly with systems that automatically collect crashes as the `%s` parameter will be changed.
2023-12-09[DOC] Small fixes for documentation renderingVictor Shepelev
Mostly just fixing RDoc's incorrect treatment of `+`
2023-12-07Free everything at shutdownAdam Hess
when the RUBY_FREE_ON_SHUTDOWN environment variable is set, manually free memory at shutdown. Co-authored-by: Nobuyoshi Nakada <[email protected]> Co-authored-by: Peter Zhu <[email protected]>
2023-12-05Fix parameter types for rb_ivar_foreach() callbacksAlan Wu
For this public API, the callback is declared to take `(ID, VALUE, st_data_t)`, but it so happens that using `(st_data_t, st_data_t, st_data_t)` also type checks, because the underlying type is identical. Use it as declared and get rid of some casts.
2023-11-21Refactor NameError::message and make it embededJean Boussier
These aren't particularly common, but avoiding the malloc churn for small types is always nice, and this commit also modernize and cleanup the TypedData API usage.
2023-11-07Implement embedded TypedData objectsPeter Zhu
This commit adds a new flag RUBY_TYPED_EMBEDDABLE that allows the data of a TypedData object to be embedded after the object itself. This will improve cache locality and allow us to save the 8 byte data pointer. Co-Authored-By: Jean Boussier <[email protected]>
2023-09-25[Feature #19790] Rename BUGREPORT_PATH as CRASH_REPORTNobuyoshi Nakada
2023-09-25Add `--bugreport-path` optionNobuyoshi Nakada
It has precedence over the environment variable `RUBY_BUGREPORT_PATH`.
2023-09-25Test bug_reportNobuyoshi Nakada