Tomoyuki Sahara
f6896751b4
don't overwrite backtrace info.
2017-11-02 15:44:05 +09:00
Tomasz Dąbrowski
971a4f9122
fix: src\kernel.c(874): warning C4244: 'function': conversion from 'mrb_int' to 'int', possible loss of data
2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski
7a2391b120
fix: src\error.c(76): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data
2017-09-27 22:22:04 +02:00
Yukihiro "Matz" Matsumoto
8bf492f127
Reduce integer type mismatch warnings in VC.
2017-08-12 09:35:35 +09:00
Yukihiro "Matz" Matsumoto
3e075a7b6c
Should not call to_str in mrb_vformat; fix #3773
2017-08-11 09:21:47 +09:00
Yukihiro "Matz" Matsumoto
a18904a4c2
Use "$!" specifier of mrb_get_args.
2017-07-12 14:49:55 +09:00
Yukihiro "Matz" Matsumoto
2ef5d22b60
Put a space between error position and error message.
...
For readability's sake.
2017-07-05 18:34:27 +09:00
Yukihiro "Matz" Matsumoto
b32ad1307f
The out-of-memory error should not be an instance of RuntimeError.
...
And arena-overflow error as well. They should not be caught by
`rescue` by default.
2017-06-14 01:01:36 +09:00
Yukihiro "Matz" Matsumoto
ff7df939ba
Restore MRB_API function mrb_exc_backtrace(mrb, exc); ref 9644ad5
2017-05-31 23:15:17 +09:00
Yukihiro "Matz" Matsumoto
9644ad51b4
Simplify backtrace mechanism; fix #3633 #3634 #3644
...
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-23 23:50:42 +09:00
Yukihiro "Matz" Matsumoto
497b19ce22
Support the case when the backtrace is not an array.
2017-05-23 23:50:42 +09:00
Yukihiro "Matz" Matsumoto
bb0b52a568
Update comments regarding Exception#to_str
2017-05-23 23:50:42 +09:00
Yukihiro "Matz" Matsumoto
88cd807379
Avoid use of snprintf() when DISABLE_STDIO is set; fix #3632
...
ref #3492 #3515 #3517
2017-04-25 10:41:50 +09:00
Yukihiro "Matz" Matsumoto
05fceb5992
Call exc_debug_info() in mrb_exc_set(); ref #3610
...
Otherwise line number information is lacked from exceptions
raised in VM, e.g. "super called outside of method".
2017-04-18 10:28:49 +09:00
Yukihiro "Matz" Matsumoto
cea6a16cf4
Fixed some compiler errors regarding PRId.
2017-03-19 23:42:49 +09:00
Yukihiro "Matz" Matsumoto
ef105b5ca4
Use MRB_PRId instead of "%d"; fix #3515
2017-03-19 20:43:25 +09:00
Yukihiro "Matz" Matsumoto
8d1468eab4
Remove cname duplication from exc_inspect().
2017-03-19 08:05:19 +09:00
Yukihiro "Matz" Matsumoto
e6b5c75ec5
Avoid possible infinite recursion in mrb_print_error(); ref #3517
2017-03-19 07:20:44 +09:00
Yukihiro "Matz" Matsumoto
6ea26aafd5
Save/restore GC arena index to avoid arena overflow error.
2017-03-18 17:37:24 +09:00
Yukihiro "Matz" Matsumoto
b2916f1b5c
Avoid mrb_check_string_type() in raising exception; fix #3506
...
The change may reduce flexibility, but I believe no one wants
that level of flexibility here.
2017-03-18 02:34:56 +09:00
Yukihiro "Matz" Matsumoto
fdd92750fe
Create NoMethodError instance using mrb_obj_new().
2017-03-02 10:56:23 +09:00
Yukihiro "Matz" Matsumoto
1e57fefbcf
Do not funcall() Exception#set_backtrace from runtime.
...
This change reduce flexibility but makes mruby simpler and faster.
2017-02-15 12:01:52 +09:00
Yukihiro "Matz" Matsumoto
8efa7b00df
Preallocate SystemStackError; ref #3421
2017-02-15 11:59:47 +09:00
Yukihiro "Matz" Matsumoto
324887d0d6
Backtrace list must be an array of strings; fix #3408
2017-01-23 16:23:48 +09:00
Yukihiro "Matz" Matsumoto
41eff635bf
Merge pull request #3393 from clayton-shopify/fix-exc-initialize
...
Fix broken MRB_INT64
2017-01-12 15:31:32 +09:00
Bouke van der Bijl
6be5160eb6
Fix 36fc1f14 not checking in the right location
2017-01-11 09:10:12 -05:00
Clayton Smith
bc4c90de07
Use mrb_int for argc.
2017-01-11 09:05:02 -05:00
Yukihiro "Matz" Matsumoto
7523cdf340
Exception#initialize to take arbitrary number of args; ref #3384
2017-01-11 10:29:55 +09:00
Yukihiro "Matz" Matsumoto
9fc62d28d0
pre-allocate arena overflow error
2016-11-28 09:52:57 +09:00
Yukihiro "Matz" Matsumoto
36fc1f1431
Added Exception check in mrb_exc_set(); close #3292
...
PR #3293 just checks for NoMethodError.
2016-11-27 22:17:51 +09:00
Kouhei Sutou
f1eb3aea11
Fix segmentation fault by backtrace and GC
...
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>'
2016-03-06 11:58:54 +09:00
Kouhei Sutou
a561bdb25f
Support backtrace after method calls
...
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.
2015-12-29 20:36:12 +09:00
Kouhei Sutou
1eeeecb08a
Fix indent
2015-12-29 14:20:10 +09:00
Yukihiro "Matz" Matsumoto
5c405dea3d
include changed from by quotes ("") to by brackets (<>); close #3032
2015-11-27 17:48:23 +09:00
Yukihiro "Matz" Matsumoto
4440566b95
DISABLE_STDIO/ENABLE_DEBUG macros to rename; close #3014
...
changes:
* rename DISABLE_STDIO -> MRB_DISABLE_STDIO
* rename ENABLE_DEBUG -> MRB_ENABLE_DEBUG_HOOK
* no more opposite macro definitions (e.g. ENABLE_STDIO, DISABLE_DEBUG).
* rewrite above macro references throughout the code.
* update documents
2015-11-17 07:30:34 +09:00
furunkel
3ab2f9371e
Clean up GC code
2015-10-19 22:29:43 +02:00
cremno
938ed044f4
use mrb_str_cat_str() instead of mrb_str_append()
...
If the argument is always a string, then mrb_str_cat_str() can be
directly called instead of indirectly by mrb_str_append().
mrb_any_to_s(), mrb_obj_as_string(), mrb_inspect() always return a
string.
2015-07-16 03:56:31 +02:00
Yukihiro "Matz" Matsumoto
9c311ddc93
refactor mrb_bob_missing to share raising NoMethodError code; fix #2878
...
Note: arguments of mrb_no_method_error() has changed. You need to replace
3rd and 4th argument (say n, argv) to mrb_ary_new_from_values(mrb, n, argv).
2015-07-13 11:07:59 +09:00
take_cheeze
6498d90f1b
Move "src/mrb_throw.h" to "include/mruby/throw.h".
...
Related to #2760 .
2015-05-25 21:19:24 +09:00
cremno
dc479392ef
fix type of mrb_exc_new()'s len parameter
...
mrb_str_new() takes size_t, so should mrb_exc_new().
2015-05-18 22:18:53 +02:00
Tatsuhiko Kubo
5fac7a73cb
Use mrb_exc_new_str_lit().
2015-01-03 23:34:13 +09:00
Tatsuhiko Kubo
3202938099
Add a missing space after ",".
2014-08-27 19:13:40 +09:00
Yukihiro "Matz" Matsumoto
206f89e209
add MRB_API modifiers to mruby API functions
2014-08-04 00:47:08 +09:00
take_cheeze
3c96602574
Use MRB_TT_EXCEPTION in exception object.
2014-07-21 23:09:13 +09:00
Yukihiro "Matz" Matsumoto
4501598f27
use SystemStackError instead of RuntimeError
2014-07-12 21:29:46 +09:00
Yukihiro "Matz" Matsumoto
919af61766
initialize nomem_err->mesg->c before exposing to Ruby world; close #2428
2014-06-27 22:39:39 +09:00
Yukihiro "Matz" Matsumoto
4ce0a7653b
reduce mrb_funcall in exception allocation
2014-06-27 22:10:21 +09:00
Yukihiro "Matz" Matsumoto
bccd43da71
indent ISO section comments
2014-06-04 11:33:56 +09:00
Yukihiro "Matz" Matsumoto
d62ce565c6
use pre-allocated RuntimeError for out-of-memory
2014-06-04 11:33:15 +09:00
take_cheeze
acec9d1ff1
Implement NoMethodError#args.
2014-06-02 22:38:02 +09:00