aboutsummaryrefslogtreecommitdiffstats
path: root/error.c
Commit message (Collapse)AuthorAgeFilesLines
* Free everything at shutdownAdam Hess2023-12-071-0/+8
| | | | | | | when the RUBY_FREE_ON_SHUTDOWN environment variable is set, manually free memory at shutdown. Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> Co-authored-by: Peter Zhu <peter@peterzhu.ca>
* Fix parameter types for rb_ivar_foreach() callbacksAlan Wu2023-12-051-2/+2
| | | | | | | | 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.
* Refactor NameError::message and make it embededJean Boussier2023-11-211-50/+51
| | | | | | 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.
* Implement embedded TypedData objectsPeter Zhu2023-11-071-1/+1
| | | | | | | | 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 <byroot@ruby-lang.org>
* [Feature #19790] Rename BUGREPORT_PATH as CRASH_REPORTNobuyoshi Nakada2023-09-251-7/+7
|
* Add `--bugreport-path` optionNobuyoshi Nakada2023-09-251-2/+9
| | | | It has precedence over the environment variable `RUBY_BUGREPORT_PATH`.
* Test bug_reportNobuyoshi Nakada2023-09-251-2/+3
|
* Invoke the command when RUBY_BUGREPORT_PATH starts with `|`Nobuyoshi Nakada2023-09-251-14/+53
|
* Test bug_reportNobuyoshi Nakada2023-09-251-0/+12
|
* Extract `expand_report_argument`Nobuyoshi Nakada2023-09-251-39/+56
|
* Redirect to RUBY_BUGREPORT_PATH fileNobuyoshi Nakada2023-09-251-5/+175
|
* Dump backtraces to an arbitrary streamNobuyoshi Nakada2023-09-251-4/+4
|
* [DOC] Kernel#{proc,lambda} don't issue warnings anymoreAlan Wu2023-09-081-1/+0
| | | | They've been raising since 3.0.0.
* Fix crash in NoMethodError for dummy framesPeter Zhu2023-08-021-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [Bug #19793] Dummy frames are created at the top level when requiring another file. While requiring a file, it will try to convert using encodings. Some of these encodings will not respond to to_str. If method_missing is redefined on Object, then it will call method_missing and attempt raise an error. However, the iseq is invalid as it's a dummy frame so it will write an invalid iseq to the created NoMethodError. The following script crashes: ``` GC.stress = true class Object public :method_missing end File.write("/tmp/empty.rb", "") require "/tmp/empty.rb" ``` With the following backtrace: ``` frame #0: 0x00000001000fa8b8 miniruby`RVALUE_MARKED(obj=4308637824) at gc.c:1638:12 frame #1: 0x00000001000fb440 miniruby`RVALUE_BLACK_P(obj=4308637824) at gc.c:1763:12 frame #2: 0x00000001000facdc miniruby`gc_writebarrier_incremental(a=4308637824, b=4308332208, objspace=0x000000010180b000) at gc.c:8822:9 frame #3: 0x00000001000faad8 miniruby`rb_gc_writebarrier(a=4308637824, b=4308332208) at gc.c:8864:17 frame #4: 0x000000010016aff0 miniruby`rb_obj_written(a=4308637824, oldv=36, b=4308332208, filename="../iseq.c", line=1279) at gc.h:804:9 frame #5: 0x0000000100162a60 miniruby`rb_obj_write(a=4308637824, slot=0x0000000100d09888, b=4308332208, filename="../iseq.c", line=1279) at gc.h:837:5 frame #6: 0x0000000100165b0c miniruby`iseqw_new(iseq=0x0000000100d09880) at iseq.c:1279:9 frame #7: 0x0000000100165a64 miniruby`rb_iseqw_new(iseq=0x0000000100d09880) at iseq.c:1289:12 frame #8: 0x00000001000d8324 miniruby`name_err_init_attr(exc=4309777920, recv=4304780496, method=827660) at error.c:1830:35 frame #9: 0x00000001000d1b80 miniruby`name_err_init(exc=4309777920, mesg=4308332496, recv=4304780496, method=827660) at error.c:1869:12 frame #10: 0x00000001000d1bd4 miniruby`rb_nomethod_err_new(mesg=4308332496, recv=4304780496, method=827660, args=4308332448, priv=0) at error.c:1957:5 frame #11: 0x000000010039049c miniruby`rb_make_no_method_exception(exc=4304914512, format=4308332496, obj=4304780496, argc=1, argv=0x000000016fdfab00, priv=0) at vm_eval.c:959:16 frame #12: 0x00000001003b3274 miniruby`raise_method_missing(ec=0x0000000100b06f40, argc=1, argv=0x000000016fdfab00, obj=4304780496, last_call_status=MISSING_NOENTRY) at vm_eval.c:999:15 frame #13: 0x00000001003945d4 miniruby`rb_method_missing(argc=1, argv=0x000000016fdfab00, obj=4304780496) at vm_eval.c:944:5 ... frame #23: 0x000000010038f5e4 miniruby`rb_vm_call_kw(ec=0x0000000100b06f40, recv=4304780496, id=2865, argc=1, argv=0x000000016fdfab00, me=0x0000000100cbfcf0, kw_splat=0) at vm_eval.c:326:12 frame #24: 0x00000001003c18e4 miniruby`call_method_entry(ec=0x0000000100b06f40, defined_class=4304927952, obj=4304780496, id=2865, cme=0x0000000100cbfcf0, argc=1, argv=0x000000016fdfab00, kw_splat=0) at vm_method.c:2720:20 frame #25: 0x00000001003c440c miniruby`check_funcall_exec(v=6171896792) at vm_eval.c:589:12 frame #26: 0x00000001000dec00 miniruby`rb_vrescue2(b_proc=(miniruby`check_funcall_exec at vm_eval.c:587), data1=6171896792, r_proc=(miniruby`check_funcall_failed at vm_eval.c:596), data2=6171896792, args="Pȗ") at eval.c:919:18 frame #27: 0x00000001000deab0 miniruby`rb_rescue2(b_proc=(miniruby`check_funcall_exec at vm_eval.c:587), data1=6171896792, r_proc=(miniruby`check_funcall_failed at vm_eval.c:596), data2=6171896792) at eval.c:900:17 frame #28: 0x000000010039008c miniruby`check_funcall_missing(ec=0x0000000100b06f40, klass=4304923536, recv=4304780496, mid=3233, argc=0, argv=0x0000000000000000, respond=-1, def=36, kw_splat=0) at vm_eval.c:666:15 frame #29: 0x000000010038fa60 miniruby`rb_check_funcall_default_kw(recv=4304780496, mid=3233, argc=0, argv=0x0000000000000000, def=36, kw_splat=0) at vm_eval.c:703:21 frame #30: 0x000000010038fb04 miniruby`rb_check_funcall(recv=4304780496, mid=3233, argc=0, argv=0x0000000000000000) at vm_eval.c:685:12 frame #31: 0x00000001001c469c miniruby`convert_type_with_id(val=4304780496, tname="String", method=3233, raise=0, index=-1) at object.c:3061:15 frame #32: 0x00000001001c4a4c miniruby`rb_check_convert_type_with_id(val=4304780496, type=5, tname="String", method=3233) at object.c:3153:9 frame #33: 0x00000001002d59f8 miniruby`rb_check_string_type(str=4304780496) at string.c:2571:11 frame #34: 0x000000010014b7b0 miniruby`io_encoding_set(fptr=0x0000000100d09ca0, v1=4304780496, v2=4, opt=4) at io.c:11655:19 frame #35: 0x0000000100139a58 miniruby`rb_io_set_encoding(argc=1, argv=0x000000016fdfb450, io=4308334032) at io.c:13497:5 frame #36: 0x00000001003c0004 miniruby`ractor_safe_call_cfunc_m1(recv=4308334032, argc=1, argv=0x000000016fdfb450, func=(miniruby`rb_io_set_encoding at io.c:13487)) at vm_insnhelper.c:3271:12 ... frame #43: 0x0000000100390b08 miniruby`rb_funcall(recv=4308334032, mid=16593, n=1) at vm_eval.c:1137:12 frame #44: 0x00000001002a43d8 miniruby`load_file_internal(argp_v=6171899936) at ruby.c:2500:5 ... ```
* [DOC] Update warning categoriesNobuyoshi Nakada2023-08-011-8/+14
| | | | | - Fix indentations of labeled lists. - Mention performance category.
* [Bug #19635] Preserve `errno`Nobuyoshi Nakada2023-05-121-0/+2
| | | | | | | | 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
* Add RB_WARN_CATEGORY_DEFAULT_BITSJean Boussier2023-04-141-1/+1
| | | | | | | | | | Followup: ac123f167a364c3d7a43eca78d564e41f6dbb91e RB_WARN_CATEGORY_ALL_BITS is exposed in a public header, so it makes sense for it to be updated to contain all valid bits. Instead we introduce RB_WARN_CATEGORY_DEFAULT_BITS to list the categories that are enabled by default.
* Emit a performance warning when a class reached max variationsJean Boussier2023-04-131-0/+4
| | | | | | | [Feature #19538] This new `peformance` warning category is disabled by default. It needs to be specifically enabled via `-W:performance` or `Warning[:performance] = true`
* Disable all warning categories other than `RB_WARN_CATEGORY_ALL_BITS`Nobuyoshi Nakada2023-04-131-2/+2
|
* Stop exporting symbols for MJITTakashi Kokubun2023-03-061-3/+3
|
* Adjust indent [ci skip]Nobuyoshi Nakada2023-02-201-11/+11
|
* error.c: Use "undefined local variable or method `...' for main"Yusuke Endoh2023-02-201-2/+7
| | | | ... for the toplevel.
* error.c: Update the message format for NoMethodErrorYusuke Endoh2023-02-201-3/+5
| | | | | | | | | | | | | | | | | | | | | | * If the receiver is a Class, use "... for class <class name>". * If the receiver is a Module, use "... for module <module name>". * If the receiver is an extended object (i.e., has a singleton class), use "... for <rb_any_to_s(receiver)>". * Otherwise, use "... for an instance of <class name>". Examples: ``` 42.time #=> undefined method `time' for an instance of Integer (NoMethodError) class Foo privatee #=> undefined local variable or method 'privatee' for class Foo (NoMethodError) end def (o=Object.new).foo end o.bar #=> undefined method `bar' for #<Object: 0xdeadbeef(any_to_s)> (NoMethodError) ```
* Stop using receiver#inspect for "undefined method" errorsYusuke Endoh2023-02-201-19/+52
| | | | | | | | | | | | | | | | ``` 42.time #=> undefined method `time' for object Integer (NoMethodError) class Foo privatee #=> undefined local variable or method 'privatee' for class Foo (NoMethodError) end s = "" def s.foo = nil s.bar #=> undefined method `bar' for extended object String (NoMethodError) ``` [Feature #18285]
* Docs: Fix rendering of SyntaxError#pathzverok2022-12-231-2/+6
|
* [Bug #19242] Prohibit circular causes to be loadedNobuyoshi Nakada2022-12-201-0/+4
|
* Introduce `IO.new(..., path:)` and promote `File#path` to `IO#path`. (#6867)Samuel Williams2022-12-081-4/+2
|
* Reuse NIL_OR_UNDEF_P macroS-H-GAMELINKS2022-12-021-1/+1
|
* [Feature #19138] Add `SyntaxError#path`Nobuyoshi Nakada2022-12-011-10/+28
|
* Using UNDEF_P macroS-H-GAMELINKS2022-11-161-16/+16
|
* Fix and improve coroutines for Darwin (macOS) ppc/ppc64. (#5975)Sergey Fedorov2022-10-191-1/+1
|
* Fix possible use of undefined macros on very old macOS [ci skip]Nobuyoshi Nakada2022-10-171-2/+7
|
* Reuse `with_warning_string_from` macroS.H2022-10-101-12/+6
|
* Split `with_warning_string_from` for the last named parameterNobuyoshi Nakada2022-09-301-1/+3
|
* Revert "Revert "error.c: Let Exception#inspect inspect its message""Yusuke Endoh2022-09-231-2/+10
| | | | | | This reverts commit b9f030954a8a1572032f3548b39c5b8ac35792ce. [Bug #18170]
* syserr_initialize: delete redundant strerror() declaration卜部昌平2022-09-211-3/+0
| | | | | This line issues a warning on clang. strerror is of course a part of ISO C since its dawn. We practically have never needed it.
* Introduce with_warn_vsprintf macroS-H-GAMELINKS2022-08-121-27/+22
|
* Expand tabs [ci skip]Takashi Kokubun2022-07-211-341/+341
| | | | [Misc #18891]
* Fix a typo (thanks @Maumagnaguagno !)Yusuke Endoh2022-07-131-1/+1
|
* Specify usable escape sequences in Exception#detailed_messageYusuke Endoh2022-07-131-0/+22
| | | | | | | | | | | | | | An error message is primarily rendered in a terminal emulator, but is also shown in a browser by converting it to a HTML fragment. However, the conversion would be unreasonably difficult if the message includes any escape sequence (such as cursor move or screen clear). This change adds a guideline about escape sequences in `Exception#detailed_message`: * Use widely-supported escape sequences: bold, underline, and basic eight foreground colors (except white and black). * Make the message readable if all escape sequences are ignored.
* Include JIT information in crash reportsChris Seaton2022-06-201-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Since enabling YJIT or MJIT drastically changes what could go wrong at runtime, it's good to be front and center about whether they are enabled when dumping a crash report. Previously, `RUBY_DESCRIPTION` and the description printed when crashing can be different when a JIT is on. Introduce a new internal data global, `rb_dynamic_description`, and set it to be the same as `RUBY_DESCRIPTION` during initialization; use it when crashing. * version.c: Init_ruby_description(): Initialize and use `rb_dynamic_description`. * error.c: Change crash reports to use `rb_dynamic_description`. * ruby.c: Call `Init_ruby_description()` earlier. Slightly more work for when we exit right after printing the description but that was deemed acceptable. * include/ruby/version.h: Talk about how JIT info is not in `ruby_description`. * test/-ext-/bug_reporter/test_bug_reporter.rb: Remove handling for crash description being different from `RUBY_DESCRIPTION`. * test/ruby/test_rubyoptions.rb: ditto Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> Co-authored-by: Alan Wu <alanwu@ruby-lang.org>
* Allow to just warn as bool expected, without an exceptionNobuyoshi Nakada2022-06-201-1/+1
|
* [DOC] RDoc now accepts other than magic numbers at `rb_attr`Nobuyoshi Nakada2022-06-081-1/+1
|
* Revert "error.c: Let Exception#inspect inspect its message"Yusuke Endoh2022-06-071-10/+2
| | | | This reverts commit 9d927204e7b86eb00bfd07a060a6383139edf741.
* error.c: Let Exception#inspect inspect its messageYusuke Endoh2022-06-071-2/+10
| | | | | | | | | | | | ... only when the message string has a newline. `p StandardError.new("foo\nbar")` now prints `#<StandardError: "foo\nbar">' instead of: #<StandardError: bar> [Bug #18170]
* Use RBOOLNobuyoshi Nakada2022-06-051-6/+1
|
* No fallback to default valuesNobuyoshi Nakada2022-05-211-3/+2
|
* Factor a "highlight" symbol outYusuke Endoh2022-02-221-7/+4
|
* Let Exception#full_message pass highlight keywords to #detailed_messageYusuke Endoh2022-02-221-0/+7
| | | | .. even when the argument is not explicitly passed.
* The default highlight arguments of Exception#detailed_message is falseYusuke Endoh2022-02-221-5/+10
|