Commit Graph

6391 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto a2a272ca8e Merge pull request #2730 from kou/fix-no-expression-case
Fix a bug that no expression case doesn't return valid value
2015-02-24 22:07:36 +09:00
Kouhei Sutou 4b4ddd5a28 Fix a bug that no expression case doesn't return valid value
Here is a script that reproduces this problem:

     x = case
         when true; 1
         end
     p x # => main # 1 is expected
2015-02-24 20:53:12 +09:00
Yukihiro "Matz" Matsumoto 68f60714dc Merge pull request #2729 from kou/fix-if-and-no-value-returned-case
Fix a bug that if and no return value case can't return true clause value
2015-02-24 14:29:47 +09:00
Yukihiro "Matz" Matsumoto d0bc006a73 Merge pull request #2728 from govm/fix-dereference-invalid-argv
fix pointer dereference after realloc
2015-02-24 14:28:14 +09:00
Kouhei Sutou 584d6de3c2 Fix a bug that if and no return value case can't return true clause value
Here is a script that reproduce this problem:

     x = if true
           1
         else
           case 2
           when 3
           end
           4
         end
     p x # => nil # 1 is expected
2015-02-24 00:16:41 +09:00
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
Yukihiro "Matz" Matsumoto 44d8a40bac add a prototype declaration for mrb_fiber_resume(); ref #1269 2015-02-19 11:38:05 +09:00
Yukihiro "Matz" Matsumoto 0609abb3f7 new API function mrb_fiber_resume(); ref #1269 2015-02-19 10:02:43 +09:00
Yukihiro "Matz" Matsumoto 80c343aec9 add description comment to mrb_fiber_yield() 2015-02-19 10:02:02 +09:00
Yukihiro "Matz" Matsumoto 9248cdd6cc silence warnings in fmt_fp.c 2015-02-16 14:50:01 +09:00
Yukihiro "Matz" Matsumoto a88a20d51f Merge pull request #2723 from cremno/use-musl-fmt_fp
re-implement mrb_float_to_str()
2015-02-16 14:42:01 +09:00
cremno 6f893b5183 re-implement mrb_float_to_str()
The new implementation is backwards incompatible, but I couldn't find
any usage outside mruby and I also couldn't think of a different and
good name.

All ISO C99 printf conversion specifiers for floating point numbers and
an optional precision are supported.

It is largely based on code from the MIT licensed musl libc
(http://www.musl-libc.org/) and its floating point printing is exact
(unlike the current code behind Float#to_s).
2015-02-13 09:33:03 +01:00
Yukihiro "Matz" Matsumoto 1fa081a646 Merge pull request #2722 from sgnr/disable-stdio-enable-backtraces
Make backtraces work again under DISABLE_STDIO
2015-02-13 12:31:26 +09:00
Yukihiro "Matz" Matsumoto a32ec182dd Merge pull request #2721 from kou/add-more-debug-flags
Add more debug flags for GCC based compilers
2015-02-13 12:28:42 +09:00
Simon Génier 40e4eb599c DISABLE_STDIO does not disable backtraces. 2015-02-12 13:18:59 -05:00
Kouhei Sutou a88cda8ac6 Add more debug flags for GCC based compilers
We can use `#define`-ed macros in GDB with `-g3` flag.

We can run code step by step in GDB with `-O0` flag.
2015-02-10 19:00:30 +09:00
Yukihiro "Matz" Matsumoto 789177c8fe Merge pull request #2719 from suzukaze/delete-temp-variable
Delete temp variable
2015-02-07 17:50:54 +09:00
Jun Hiroe ac131c9052 Remove eql_p variable in mrb_struct_eql func 2015-02-07 01:46:56 +09:00
Jun Hiroe 7dff6ab75a Remove eql_p variable in mrb_struct_equal func 2015-02-07 01:46:45 +09:00
Yukihiro "Matz" Matsumoto 43881f6b97 Merge pull request #2718 from matsumoto-r/update-mruby-config
mruby-config supports MRUBY_LDFLAGS_BEFORE_LIBS in libmruby.flags.mak
2015-02-07 00:49:02 +09:00
Yukihiro "Matz" Matsumoto f5026f9b6c Merge pull request #2717 from sgnr/missing-lastpc-on-funcall-cfunc
Fix possible segfault when accessing backtrace with MRB_WORD_BOXING.
2015-02-07 00:48:08 +09:00
MATSUMOTO Ryosuke 7367bf6ffe mruby-config supports MRUBY_LDFLAGS_BEFORE_LIBS in libmruby.flags.mak 2015-02-06 07:15:54 -08:00
Yukihiro "Matz" Matsumoto 1346456c6c Merge pull request #2716 from kou/fix-ensure-context-on-break-and-return
Fix ensure with yield context on break and return
2015-02-07 00:13:14 +09:00
Simon Génier df382dea73 Fix possible segfault when accessing backtrace with MRB_WORD_BOXING. 2015-02-05 15:12:21 -05: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
Yukihiro "Matz" Matsumoto 4957c85269 Merge pull request #2715 from suzukaze/fix-dump.c
Replace int with mrb_bool in dump_bigendian_p func
2015-02-03 07:23:09 +09:00
Jun Hiroe b88c8b40d6 Replace int with mrb_bool in dump_bigendian_p func 2015-02-02 14:18:10 +09:00
Yukihiro "Matz" Matsumoto bc9c47d518 allow endian specification of mrb files by mrbc -e/-E
`mruby -b` now accepts both big/little endian mrb (compiled binary) files.

`mrbc` generates mrb files in big endian for .mrb files and in native endian
for C files (with -B option specified) by default.  If you are cross compiling,
you need to specify target endian by -e/-E options if it is different from
host endian.
2015-02-02 09:34:24 +09:00
Yukihiro "Matz" Matsumoto 089f1f6c75 block_given? should work with nested block; fix #2695 close #2712 2015-01-31 13:51:25 +09:00
Yukihiro "Matz" Matsumoto 02b54e5379 avoid block_given? in loop method for simplicity 2015-01-31 10:44:58 +09:00
Yukihiro "Matz" Matsumoto f01882a8e0 Merge pull request #2714 from xxuejie/use-setter-macro-when-necessary
Use setter macro instead of directly setting values
2015-01-26 16:11:58 +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 23e69edd2d Merge pull request #2713 from BenMorganIO/grammar-in-doc-updates
update grammar and preposition for debugger readme
2015-01-25 19:48:02 +09:00
Ben A Morgan cc11ee15b4 update grammar and preposition for debugger readme 2015-01-25 02:01:46 -08:00
Yukihiro "Matz" Matsumoto 8af688e2c9 Merge pull request #2710 from sdottaka/fix-window-build
tasks/ruby_ext.rake: Fix build error when file path includes \1 or \2.  ...
2015-01-23 01:15:44 +09:00
sdottaka a99fb39dc1 tasks/ruby_ext.rake: Fix build error when file path includes \1 or \2. #2709 2015-01-22 20:27:29 +09:00
Yukihiro "Matz" Matsumoto 8aba34301b String#[]= should support negative position; close #2707 2015-01-19 22:13:34 +09:00
Yukihiro "Matz" Matsumoto d764632f86 Merge pull request #2680 from sdottaka/add-fflush
mrdb, mirb: Add fflush() so that a external program can read output imme...
2015-01-19 08:30:52 +09:00
Yukihiro "Matz" Matsumoto 1c48be7822 Merge pull request #2706 from furunkel/master
Don't use Build.current if possible
2015-01-19 00:13:14 +09:00
Julian Aron Prenner 959a5cff60 Don't use Build.current if possible 2015-01-18 15:45:48 +01:00
Yukihiro "Matz" Matsumoto 7137ee88b5 Merge pull request #2705 from sdottaka/mrdb-step-into-proc-call
mrdb: fix crash when stepping into Proc.call
2015-01-18 20:24:46 +09:00
Yukihiro "Matz" Matsumoto f9e43724bf Merge pull request #2704 from takahashim/update-version-readme
update stable version number in README
2015-01-18 12:11:26 +09:00
sdottaka af51a4ac9d mrdb: fix crash when stepping into Proc.call
How to reproduce:

```
cat a.rb
Proc.new { 1 }.call

echo step | mrdb a.rb
```
2015-01-18 10:00:56 +09:00
takahashim c0f5be7858 update stable version number in README 2015-01-18 00:45:41 +09:00
Yukihiro "Matz" Matsumoto 16884b87af Merge pull request #2702 from takahashim/fix-string-match
fix infinite loop in String#match(arg) when arg is String
2015-01-14 09:33:41 +09:00
takahashim bcceeba09b fix infinite loop in String#match(arg) when arg is String 2015-01-14 02:18:56 +09:00
Yukihiro "Matz" Matsumoto d405eb5541 Merge pull request #2701 from suzukaze/string.upto
Add String#upto
2015-01-13 20:27:19 +09:00
Jun Hiroe e998094297 Add String#upto 2015-01-13 16:32:30 +09:00
Yukihiro "Matz" Matsumoto 4aef1ad209 Merge pull request #2700 from takahashim/string-ljust
add String#ljust into mruby-string-ext
2015-01-13 16:19:46 +09:00
Yukihiro "Matz" Matsumoto 1ab79ac414 Merge pull request #2699 from takahashim/fix-recursive-struct
fix Segmentation fault on Struct#inspect due to recursive Struct object
2015-01-13 16:18:50 +09:00