summaryrefslogtreecommitdiffhomepage
path: root/src/error.c
AgeCommit message (Collapse)Author
2019-09-29Allow rethrowing `MRB_TT_BREAK`dearblue
2019-09-24`Exception#initialize` should not allow two or more argumentsKOBAYASHI Shuji
2019-09-14Add a macro `mrb_frozen_p` that points to `MRB_FROZEN_P`.Yukihiro "Matz" Matsumoto
2019-09-08Fix `mrb_vformat()` crashes with `MRB_INT16`dearblue
If `MRB_INT16` is specified, the variable length argument `mrb_int` is converted to `int`.
2019-08-18Prohibit changes to iseq in principledearblue
2019-08-05Use new specifiers/modifiers of `mrb_vfromat()`KOBAYASHI Shuji
The binary sizes (gems are only `mruby-bin-mruby`) are reduced slightly in my environment than before the introduction of new specifiers/modifiers (5116789a) with this change. ------------+-------------------+-------------------+-------- BINARY | BEFORE (5116789a) | AFTER (This PR) | RATIO ------------+-------------------+-------------------+-------- mruby | 593416 bytes | 593208 bytes | -0.04% libmruby.a | 769048 bytes | 767264 bytes | -0.23% ------------+-------------------+-------------------+-------- BTW, I accidentally changed `tasks/toolchains/visualcpp.rake` at #4613, so I put it back.
2019-08-03Change second argument to `%l` of `mrb_vformat()` to `size_t` from `mrb_int`KOBAYASHI Shuji
- `size_t` is more commonly used. - `len` argument of `mrb_str_new()` is `size_t`. NOTE: The test for `%l` is temporarily disabled because adding a new type to `mrbgems/mruby-test/vformat.c` causes an error (memory error?) on Visual Studio 2017 in AppVeyor.
2019-08-03Fix `mrb_vformat("%f")` with `MRB_USE_FLOAT`KOBAYASHI Shuji
It potentially not work when `mrb_float` is `float` because `float` variable in variable length arguments is promoted to `double`. Also I fixed build with `MRB_WITHOUT_FLOAT`.
2019-08-02Change the `mrb_vformat` specifier `%d` for `int`KOBAYASHI Shuji
It potentially breaks, for example, in the case of `mrb_int` is 64-bit and more smaller type is passed by `%d`. In fact, the problem could become apparent when I used `%d` to `backtrace_location::lineno` in `src/backtrace.c:mrb_unpack_backtrace()` on AppVeyor. Therefore, change `%d` for `int` (not `mrb_int`) so that it can be used mostly without casting.
2019-08-01Add new specifiers/modifiers to format string of `mrb_vfromat()`KOBAYASHI Shuji
Format sequence syntax: %[modifier]specifier Modifiers: ----------+------------------------------------------------------------ Modifier | Meaning ----------+------------------------------------------------------------ ! | Convert to string by corresponding `inspect` instead of | corresponding `to_s`. ----------+------------------------------------------------------------ Specifiers: ----------+----------------+-------------------------------------------- Specifier | Argument Type | Note ----------+----------------+-------------------------------------------- c | char | d,i | mrb_int | f | mrb_float | l | char*, mrb_int | Arguments are string and length. n | mrb_sym | s | char* | Argument is NUL terminated string. t | mrb_value | Convert to type (class) of object. v,S | mrb_value | C | struct RClass* | T | mrb_value | Convert to real type (class) of object. Y | mrb_value | Same as `!v` if argument is `true`, `false` | | or `nil`, otherwise same as `T`. % | - | Convert to percent sign itself (no argument | | taken). ----------+----------------+-------------------------------------------- This change will increase the binary size, but replacing all format strings with new specifiers/modifiers will decrease the size because it reduces inline expansion of `mrb_obj_value()`, etc. at the caller.
2019-04-09Extract frozen checking to functionKOBAYASHI Shuji
2019-04-01Avoid keeping pointers from `mrb_sym2name_len()`; fix #4342Yukihiro "Matz" Matsumoto
The addresses for packed inline symbols reference `mrb->symbuf` that could be overridden by the later call of `mrb_sym2name_len`. Since file names in call stack information are kept as symbols, keeping the address in the C structures could cause problems like #4342. This changes small incompatible changes in function prototypes: * `mrb_parser_get_filename`: return value changed to `mrb_sym`. * `mrb_debug_get_filename`: add `mrb_state*` as a first argument. * `mrb_debug_get_line`: ditto. I believe above functions are almost internal, and no third-party mrbgem use them.
2019-02-27Add newline to warning by `mrb_warn()`KOBAYASHI Shuji
2018-11-19Use type checking `mrb_to_str` instead of converting `mrb_str_to_str`.Yukihiro "Matz" Matsumoto
2018-05-23Check if the exception is frozen; fix #4025Yukihiro "Matz" Matsumoto
`exc_debug_info()` and `mrb_keep_backtrace()` raise `FrozenError` if the exception is frozen and lead to infinite loop.
2018-01-25Check `arena_idx` before accessing; fix #3934Yukihiro "Matz" Matsumoto
2017-12-04Remove temporary objects from GC arena in `mrb_vformat()'; #3863Yukihiro "Matz" Matsumoto
2017-12-04Pop exception objects from the bottom of GC arena; fix #3863Yukihiro "Matz" Matsumoto
2017-11-02don't overwrite backtrace info.Tomoyuki Sahara
2017-09-27fix: src\kernel.c(874): warning C4244: 'function': conversion from 'mrb_int' ↵Tomasz Dąbrowski
to 'int', possible loss of data
2017-09-27fix: src\error.c(76): warning C4244: '=': conversion from 'mrb_int' to ↵Tomasz Dąbrowski
'int', possible loss of data
2017-08-12Reduce integer type mismatch warnings in VC.Yukihiro "Matz" Matsumoto
2017-08-11Should not call `to_str` in `mrb_vformat`; fix #3773Yukihiro "Matz" Matsumoto
2017-07-12Use "$!" specifier of `mrb_get_args`.Yukihiro "Matz" Matsumoto
2017-07-05Put a space between error position and error message.Yukihiro "Matz" Matsumoto
For readability's sake.
2017-06-14The out-of-memory error should not be an instance of RuntimeError.Yukihiro "Matz" Matsumoto
And arena-overflow error as well. They should not be caught by `rescue` by default.
2017-05-31Restore MRB_API function `mrb_exc_backtrace(mrb, exc)`; ref 9644ad5Yukihiro "Matz" Matsumoto
2017-05-23Simplify backtrace mechanism; fix #3633 #3634 #3644Yukihiro "Matz" Matsumoto
Instead of preserving a backtrace in `mrb_state`, `mrb_exc_set` keeps packed backtrace in an exception object. `#backtrace` unpacks it to an array of strings.
2017-05-23Support the case when the backtrace is not an array.Yukihiro "Matz" Matsumoto
2017-05-23Update comments regarding Exception#to_strYukihiro "Matz" Matsumoto
2017-04-25Avoid use of `snprintf()` when DISABLE_STDIO is set; fix #3632Yukihiro "Matz" Matsumoto
ref #3492 #3515 #3517
2017-04-18Call exc_debug_info() in mrb_exc_set(); ref #3610Yukihiro "Matz" Matsumoto
Otherwise line number information is lacked from exceptions raised in VM, e.g. "super called outside of method".
2017-03-19Fixed some compiler errors regarding PRId.Yukihiro "Matz" Matsumoto
2017-03-19Use MRB_PRId instead of "%d"; fix #3515Yukihiro "Matz" Matsumoto
2017-03-19Remove cname duplication from exc_inspect().Yukihiro "Matz" Matsumoto
2017-03-19Avoid possible infinite recursion in mrb_print_error(); ref #3517Yukihiro "Matz" Matsumoto
2017-03-18Save/restore GC arena index to avoid arena overflow error.Yukihiro "Matz" Matsumoto
2017-03-18Avoid mrb_check_string_type() in raising exception; fix #3506Yukihiro "Matz" Matsumoto
The change may reduce flexibility, but I believe no one wants that level of flexibility here.
2017-03-02Create NoMethodError instance using `mrb_obj_new()`.Yukihiro "Matz" Matsumoto
2017-02-15Do not funcall() Exception#set_backtrace from runtime.Yukihiro "Matz" Matsumoto
This change reduce flexibility but makes mruby simpler and faster.
2017-02-15Preallocate SystemStackError; ref #3421Yukihiro "Matz" Matsumoto
2017-01-23Backtrace list must be an array of strings; fix #3408Yukihiro "Matz" Matsumoto
2017-01-12Merge pull request #3393 from clayton-shopify/fix-exc-initializeYukihiro "Matz" Matsumoto
Fix broken MRB_INT64
2017-01-11Fix 36fc1f14 not checking in the right locationBouke van der Bijl
2017-01-11Use mrb_int for argc.Clayton Smith
2017-01-11Exception#initialize to take arbitrary number of args; ref #3384Yukihiro "Matz" Matsumoto
2016-11-28pre-allocate arena overflow errorYukihiro "Matz" Matsumoto
2016-11-27Added Exception check in mrb_exc_set(); close #3292Yukihiro "Matz" Matsumoto
PR #3293 just checks for NoMethodError.
2016-03-06Fix segmentation fault by backtrace and GCKouhei Sutou
GitHub: fix #3122 It reverts #3126. #3126 fixes the segmentation fault but generates broken backtrace. This change fixes the segmentation fault and generates correct backtrace. The strategy of this change is "generating backtrace while irep is alive". /tmp/test.rb: def gen e0 = nil begin 1.times { raise 'foobar' } rescue => e e0 = e end e0 end e = gen GC.start gen GC.start puts e.backtrace.join("\n") Run: % bin/mruby /tmp/test.rb /tmp/test.rb:5:in Object.gen /home/kou/work/ruby/mruby.kou/mrblib/numeric.rb:77:in Integral#times /tmp/test.rb:4:in Object.gen /tmp/test.rb:13 FYI: % ruby -v /tmp/test.rb ruby 2.3.0p0 (2015-12-25) [x86_64-linux-gnu] /tmp/test.rb:5:in `block in gen' /tmp/test.rb:4:in `times' /tmp/test.rb:4:in `gen' /tmp/test.rb:13:in `<main>'
2015-12-29Support backtrace after method callsKouhei Sutou
GitHub: fix #2902, #2917 The current implementation traverses stack to retrieve backtrace. But stack will be changed when some operations are occurred. It means that backtrace may be broken after some operations. This change (1) saves the minimum information to retrieve backtrace when exception is raised and (2) restores backtrace from the minimum information when backtrace is needed. It reduces overhead for creating backtrace Ruby objects. The space for the minimum information is reused by multiple exceptions. So memory allocation isn't occurred for each exception.