Go Saito
42d23084b7
fix pointer dereference after realloc
...
In src/vm.c: mrb_funcall_with_block
stack_extend may realloc mrb->c->stbase, if argv points on mruby's stack,
then it points invalid address after stack_extend.
e.g. src/class.c: mrb_instance_new
This code:
```ruby
class A
def initialize(a0,a1,a2,a3,a4)
a0.is_a? Array
end
end
def f(a0,a1,a2,a3,a4)
A.new(a0,a1,a2,a3,a4)
f(a0,a1,a2,a3,a4)
end
f(0,1,2,3,4)
```
is expected to get exception
```
stack level too deep. (limit=(0x40000 - 128)) (SystemStackError)
```
but get segfault.
Signed-off-by: Go Saito <gos@iij.ad.jp >
2015-02-23 11:25:21 +09:00
Kouhei Sutou
8cb40fcda7
Fix ensure with yield context on break and return
...
How to reproduce:
class A
def x
yield
ensure
y
end
def y
end
end
# Work
A.new.x do
end
# Not work
# trace:
# [2] /tmp/a.rb:5:in A.x
# [0] /tmp/a.rb:15
# /tmp/a.rb:5: undefined method 'y' for main (NoMethodError)
A.new.x do
break
end
# trace:
# [2] /tmp/a.rb:5:in A.call
# [0] /tmp/a.rb:19
# /tmp/a.rb:5: undefined method 'y' for main (NoMethodError)
lambda do
A.new.x do
return
end
end.call
`self` in ensure is broken when yield and break/return are used.
2015-02-05 22:40:25 +09:00
Xuejie "Rafael" Xiao
d63e45a014
Use setter macro instead of directly setting values
2015-01-26 10:52:06 +08:00
Yukihiro "Matz" Matsumoto
09c6ca936c
preserve ICLASS in ci->target_class; fix #2657 ; ensuring #1467 #1470 #1493 still works
2014-11-28 20:35:06 +09:00
sdottaka
820f6d147f
Fix an error when calling a method implemented in C by super() with arguments. This fix makes the following code workable:
...
Expected:
class MRBTime < Time; def self.new; super(2012, 4, 21); end; end
MRBTime.new # => Sat Apr 21 00:00:00 2012
Actual:
class MRBTime < Time; def self.new; super(2012, 4, 21); end; end
MRBTime.new # => can't convert nil into Integer (TypeError)
2014-11-19 13:29:22 +09:00
Jan Berdajs
aff2be4b40
fix typo (i->idx)
2014-10-15 14:11:00 +02:00
cremno
26bbc81e12
get rid of shadowing variables
...
Mostly by renaming the shadowing variable.
If a shadowing variable was deleted,
the shadowed one can be used instead.
2014-09-03 10:00:37 +02:00
Yukihiro "Matz" Matsumoto
7ac68809d3
remove ci->nreg initialization from cipush()
2014-09-01 15:38:25 +09:00
dycoon
77b2ec30ff
add write barrier to env on pop call info poped. #2525
2014-08-28 09:14:40 +09:00
cremno
bdaa12de1d
use MRB_STRINGIZE
...
It's defined in mruby/version.h which gets included in mruby.h, so it's
safe to use.
2014-08-26 00:32:06 +02:00
Kouhei Sutou
e75e2083fd
Fix a bug that class variable can't be referenced from class method
...
Class method defined in singleton class should be evaluated in class
context not singleton class context.
fix #2515
2014-08-09 15:06:17 +09:00
go kikuta
513f24e908
removed non-need space
2014-08-07 23:11:10 +09:00
Yukihiro "Matz" Matsumoto
206f89e209
add MRB_API modifiers to mruby API functions
2014-08-04 00:47:08 +09:00
Yukihiro "Matz" Matsumoto
1b5584b3c8
check if block is given in eval_under(); fix #2486
2014-07-23 02:08:37 +09:00
Yukihiro "Matz" Matsumoto
4501598f27
use SystemStackError instead of RuntimeError
2014-07-12 21:29:46 +09:00
Yukihiro "Matz" Matsumoto
0cf86dea0e
rename SET_FIXNUM_VALUE to SET_INT_VALUE since it sets mrb_int value
2014-07-09 06:40:19 +09:00
David Turnbull
249f05e7d7
Clean up value.h and mrb_value boxing
2014-07-09 06:32:11 +09:00
Patrick Pokatilo
73c086b4c7
Sacrifice some micro-optimization to remove duplicate code
2014-06-26 22:22:21 +02:00
ksss
f092ef6b14
OP_ENTER: Rewrite split aspec use macros
2014-06-25 13:54:11 +09:00
Yukihiro "Matz" Matsumoto
58e87996b9
should not add extra stack space to callinfo->nregs; maybe related to #2375
2014-06-10 00:32:45 +09:00
yui-knk
72305efe61
Remove space.
2014-06-03 16:29:42 +09:00
Yukihiro "Matz" Matsumoto
6bf1ee78c8
add internal function mrb_toplevel_run_keep() to keep stack contents; close #2326
2014-05-30 15:25:58 +09:00
Yukihiro "Matz" Matsumoto
a11f994e01
direct invocation of instance_eval
2014-05-21 18:00:48 +09:00
Yukihiro "Matz" Matsumoto
74da72409e
direct invocation of module_eval; ref #2298
2014-05-21 14:49:06 +09:00
Yukihiro "Matz" Matsumoto
a6f26514a5
break in blocks cannot cross C function boundaries; fix #2298
2014-05-21 09:00:30 +09:00
ksss
6a7f133d02
include/mruby/opcode.h fix operation doc
...
src/vm.c fix operation doc
[ci skip]
2014-05-16 20:44:54 +09:00
Yukihiro "Matz" Matsumoto
2be348a0f1
mv opcode.h -> include/mruby/opcode.h and remove duplication from mruby-eval gem
2014-05-14 23:14:08 +09:00
Carson McDonald
f0fed9dbec
Consolidate muliptlication into one place
2014-05-13 11:46:47 -04:00
Yukihiro "Matz" Matsumoto
4e357a4963
protect argument array from GC in OP_ENTER
2014-05-13 16:01:30 +09:00
Yukihiro "Matz" Matsumoto
b4657182da
convert &arg using to_proc; fix #2242
2014-05-13 09:13:33 +09:00
ksss
7dbfe19fc6
OP_ENTER fix segmentation fault
2014-05-10 09:43:32 +09:00
ksss
06a67df950
OP_ENTER clean block object in register
2014-05-09 08:04:36 +09:00
ksss
0c3226db04
OP_ENTER fix variable assignment
2014-05-06 23:30:02 +09:00
cremno
cf8df563c0
add function for checked mrb_int subtraction
2014-05-05 15:28:26 +02:00
cremno
0f39304265
add function for checked mrb_int addition
2014-05-05 15:24:22 +02:00
sasaki takeru
b59ac841af
Don't reset ridx,eidx. And fix for #1949
2014-05-04 22:39:51 +09:00
sasaki takeru
bf214c4913
goto STOP if ridx==0
2014-05-02 11:05:31 +09:00
Carson McDonald
03796274da
On overflow, clear new stack space before mrb_raise
2014-05-01 10:50:50 -04:00
kyab
a13775eb22
Add doubling stack extend, as fix for #2016
2014-04-29 18:42:52 +09:00
Yukihiro "Matz" Matsumoto
88c0d0cf9a
clear all stack everytime to prevent GC crash; ref #2109
2014-04-29 10:38:38 +09:00
Yukihiro "Matz" Matsumoto
f8c465dd44
clear ci->proc to prevent GC crash
2014-04-29 10:32:05 +09:00
Yukihiro "Matz" Matsumoto
220f3124b9
should care about the case that given arguments are less then mandatory formal arguments and optional arguments exist; close #2144
2014-04-28 13:34:14 +09:00
mirichi
ad60f81032
The correct is to compare the MRB_STACK_GROWTH.
2014-04-26 19:37:53 +09:00
Yukihiro "Matz" Matsumoto
e76be4e2ab
check length before calling stack_copy(); based on a patch from @mirich; close #2129
2014-04-26 12:07:51 +09:00
mirichi
fa1a1e6db8
Refactoring OP_CALL
2014-04-25 21:49:29 +09:00
Yukihiro "Matz" Matsumoto
83c1399af0
eliminate plain int except for a few cases like arena_index
2014-04-25 04:01:57 +09:00
mirichi
4ab801c045
fixed.
2014-04-23 19:39:14 +09:00
mirichi
e6c757b5c1
bug fixed
2014-04-22 23:10:40 +09:00
mirichi
8195224072
reduce the init size of stack
2014-04-22 22:02:03 +09:00
mirichi
b523018803
OP_SEND refactoring
2014-04-22 20:04:10 +09:00