summaryrefslogtreecommitdiffhomepage
path: root/mrbgems
AgeCommit message (Collapse)Author
2021-04-21test/math.rb: `10**30` could cause integer overflow; ref #5420Yukihiro "Matz" Matsumoto
2021-04-20Remove unused `#include` in `complex.c` and `rational.c`KOBAYASHI Shuji
2021-04-19Merge pull request #5415 from dearblue/unwind-mrb_protectYukihiro "Matz" Matsumoto
Introducing the `mrb_protect_raw()` API function
2021-04-19Introducing the `mrb_protect_raw()` API functiondearblue
The purpose is two-fold: 1. to be able to specify a pointer directly when user data is used When using `mrb_protect()`, it is necessary to allocate objects by `mrb_obj_cptr()` function when using user data. Adding `mrb_protect_raw()` will make it simpler to reimplement `mrbgems/mruby-error`. 2. to correctly unwind callinfo when an exception is raised from a C function defined as a method (the main topic) If a method call is made directly under `mrb_protect()` and a C function is called, control is returned from `mrb_protect()` if an exception occurs there. In this case, callinfo is not restored, so it is out of sync. Moreover, returning to mruby VM (`mrb_vm_exec()` function) in this state will indicate `ci->pc` of C function which is equal to `NULL`, and subsequent `JUMP` will cause `SIGSEGV`. Following is an example that actually causes `SIGSEGV`: - `crash.c` ```c #include <mruby.h> #include <mruby/compile.h> #include <mruby/error.h> static mrb_value level1_body(mrb_state *mrb, mrb_value self) { return mrb_funcall(mrb, self, "level2", 0); } static mrb_value level1(mrb_state *mrb, mrb_value self) { return mrb_protect(mrb, level1_body, self, NULL); } static mrb_value level2(mrb_state *mrb, mrb_value self) { mrb_raise(mrb, E_RUNTIME_ERROR, "error!"); return mrb_nil_value(); } int main(int argc, char *argv[]) { mrb_state *mrb = mrb_open(); mrb_define_method(mrb, mrb->object_class, "level1", level1, MRB_ARGS_NONE()); mrb_define_method(mrb, mrb->object_class, "level2", level2, MRB_ARGS_NONE()); mrb_p(mrb, mrb_load_string(mrb, "p level1")); mrb_close(mrb); return 0; } ``` - compile & run ```console % `bin/mruby-config --cc --cflags --ldflags` crash.c `bin/mruby-config --libs` % ./a.out zsh: segmentation fault (core dumped) ./a.out ``` After applying this patch, it will print exception object and exit normally. The `mrb_protect()`, `mrb_ensure()` and `mrb_rescue_exceptions()` in `mrbgems/mruby-error` have been rewritten using `mrb_protect_raw()`.
2021-04-19time.c: add integer boundary check for year.Yukihiro "Matz" Matsumoto
On configurations where `sizeof(mrb_int) > sizeof(int)`.
2021-04-17array.rb: add `Array#intersect?` from Ruby3.0.1.Yukihiro "Matz" Matsumoto
2021-04-16feat(CI): add the GitHub Super LinterJohn Bampton
The GitHub Super Linter is a more robust and better supported tool than the current GitHub Actions we are using. Running these checks: ERROR_ON_MISSING_EXEC_BIT: true VALIDATE_BASH: true VALIDATE_BASH_EXEC: true VALIDATE_EDITORCONFIG: true VALIDATE_MARKDOWN: true VALIDATE_SHELL_SHFMT: true VALIDATE_YAML: true https://github.com/marketplace/actions/super-linter https://github.com/github/super-linter Added the GitHub Super Linter badge to the README. Also updated the pre-commit framework and added more documentation on pre-commit. Added one more pre-commit check: check-executables-have-shebangs Added one extra check for merge conflicts to our GitHub Actions. EditorConfig and Markdown linting. Minor grammar and spelling fixes. Update linter.yml
2021-04-15Fix `enable_debug_info?` in `mrbgems/mruby-proc-ext/test/proc.rb`KOBAYASHI Shuji
2021-04-13mrbgem.rake: avoid implicit receivers in `mrbgem.rake`.Yukihiro "Matz" Matsumoto
2021-04-13mruby-io: fix `IO#ungetbyte`; ref #5389Yukihiro "Matz" Matsumoto
- remove `Integer#chr` (thus `mruby-sting-ext`) dependency - fix the behavior when `c.is_a? String` - fix the behavior when `c > 255`
2021-04-10io.rb: fix `IO#getbyte` to work with UTF-8 characters; ref #5389Yukihiro "Matz" Matsumoto
2021-04-10io.rb: add `IO#readbyte`; ref #5389Yukihiro "Matz" Matsumoto
2021-04-10io.c: add assertions to `mrb_io_bufread()`; ref #5389Yukihiro "Matz" Matsumoto
2021-04-10io.rb: `@buf` should be empty on `EOF`; #4983, #5389Yukihiro "Matz" Matsumoto
2021-04-10Add IO#getbytetake-cheeze
2021-04-09Merge pull request #5400 from jbampton/fix-spellingYukihiro "Matz" Matsumoto
chore: fix spelling
2021-04-09Merge pull request #5401 from dearblue/mcallYukihiro "Matz" Matsumoto
Reorganize `mcall()` in `mruby-method`
2021-04-08mruby-config.bat: update as the shell version. [ci skip]Yukihiro "Matz" Matsumoto
2021-04-06mruby-config: add `--cc` and `--ld` options.Yukihiro "Matz" Matsumoto
* `--cc` print compiler name * `--ld` print linker name
2021-04-04Making a proc object static for a method with static irepdearblue
The following methods will be made static. - `Class#new` - `Proc#call` - `Kernel#catch` Previously, static const RProc could not be registered as a method, but this has been changed to allow it.
2021-04-03Reorganize `mcall()` in `mruby-method`.dearblue
Use `mrb_exec_irep()`. If possible, re-entry into the VM will be suppressed. Note that due to the effect of being a tail-call, the backtrace of `Method#call` will be lost, and it will look as if the target method was called directly. This change fixes the problem of infinite loops when redefining methods that make block calls using `mruby-method`. ```console % bin/mruby -e 'mm = method(:proc); define_method(:proc, ->(*a, &b) { mm.call(*a, &b) }); p proc { 1 }' trace (most recent call last): [257] -e:1 [256] -e:1:in proc [255] -e:1:in proc ...SNIP... [1] -e:1:in proc -e:1:in proc: stack level too deep (SystemStackError) ```
2021-04-03Make `mrb_exec_irep()` allow non-VM to enter.dearblue
Change the old `mrb_exec_irep()` as-is to static `mrb_exec_irep_vm()`. Extract the VM entry part from the old `exec_irep()` in `mruby-eval/src/eval.c` and make it the core of the new `mrb_exec_irep()`.
2021-04-03chore: fix spellingJohn Bampton
2021-04-02Merge pull request #5396 from shuujii/fix-build-with-MRB_USE_ALL_SYMBOLSYukihiro "Matz" Matsumoto
Fix build with `MRB_USE_ALL_SYMBOLS`
2021-03-31Fix build with `MRB_USE_ALL_SYMBOLS`KOBAYASHI Shuji
2021-03-31codegen.c: `s->ainfo` should be zero along with `OP_ENTER(0)`.Yukihiro "Matz" Matsumoto
2021-03-31codegen.c: `yield` outside of method is now `SyntaxError`.Yukihiro "Matz" Matsumoto
2021-03-31Merge pull request #5394 from fundamental/partial-backtraceYukihiro "Matz" Matsumoto
Add support for partial backtraces
2021-03-31rational.c: add explicit cast from `mrb_int` to `mrb_float`.Yukihiro "Matz" Matsumoto
2021-03-31should have removed `codegen error:` prefix from the test.Yukihiro "Matz" Matsumoto
2021-03-31codegen.c: remove `codegen error:` prefix from error messages.Yukihiro "Matz" Matsumoto
2021-03-31codegen.c: `ainfo` may be negative.Yukihiro "Matz" Matsumoto
When argument information is not available. So it should not happen for `yield` (error). In contrast, the error from `super` should be handled in run time (ignored).
2021-03-30Disable tests on backtraces w/ unknown line numbersfundamental
2021-03-28numeric.c: function renaming.Yukihiro "Matz" Matsumoto
- `mrb_num_div_int(mrb,x,y)` -> `mrb_div_int(mrb,x,y)` - `mrb_num_div_flo(mrb,x,y)` -> `mrb_div_flo(x,y)` They are internal function not supposed to be used outside of the core.
2021-03-27Move default `Integer#/` from `rational.c` to `complex.c`.Yukihiro "Matz" Matsumoto
2021-03-26complex.rb: add test for arithmetic operators. [ci skip]Yukihiro "Matz" Matsumoto
Tests for (`Float` or `Integer`) `op` `Complex`. Also added test dependency to `mruby-rational` since `int_div` definition relies on `Rational` when `MRB_USE_RATIONAL` is defined.
2021-03-26rational.rb: add test for arithmetic operators.Yukihiro "Matz" Matsumoto
Tests for (`Float` or `Integer`) `op` `Rational`.
2021-03-25rational.c: fix wrong `funcall` method in `rational_mul`.Yukihiro "Matz" Matsumoto
2021-03-25rational.c: inline `mrb_rational_eq()`.Yukihiro "Matz" Matsumoto
It removes non-static function, so that strictly saying, it's an incompatible change. But the function was added recently and I am sure no one uses it yet.
2021-03-24rational.c: implement `Rational#<=>` in C.Yukihiro "Matz" Matsumoto
2021-03-24rational.c: implement `Rational#/` and `#quo` in C.Yukihiro "Matz" Matsumoto
2021-03-24rational.c: implement `Rational#*` in C.Yukihiro "Matz" Matsumoto
2021-03-24rational.c: implement `Rational#-` in C.Yukihiro "Matz" Matsumoto
2021-03-24fixup! rational.c: prepare utility function `rat_to_flo()`.Yukihiro "Matz" Matsumoto
2021-03-24rational.c: prepare utility function `rat_to_flo()`.Yukihiro "Matz" Matsumoto
This function takes `struct mrb_rational*` and returns converted `mrb_float` value.
2021-03-24rational.c: implement `Rational#+` in C.Yukihiro "Matz" Matsumoto
2021-03-24complex.c: use `mrb_num_div_flo` to avoid copying function.Yukihiro "Matz" Matsumoto
This change relies that `mrb_num_div_flo` does not use `mrb` inside.
2021-03-24rational.c: check integer overflow in `rational_minus`.Yukihiro "Matz" Matsumoto
2021-03-24complex.rb: unary plus (`+@`) to return self avoiding copying.Yukihiro "Matz" Matsumoto
2021-03-24complex.c: implement `Complex` addition and subtraction in C.Yukihiro "Matz" Matsumoto