Commit Graph

12052 Commits

Author SHA1 Message Date
KOBAYASHI Shuji aaa12911e2 Refactor src/mruby_core.rake 2020-11-20 17:55:26 +09:00
Yukihiro "Matz" Matsumoto 5dc9a8249f Merge pull request #5150 from shuujii/allow-bintest-even-if-build-name-is-not-host
Allow `bintest` even if build name is not `host`
2020-11-19 12:41:53 +09:00
KOBAYASHI Shuji fd113da3aa Allow bintest even if build name is not host 2020-11-19 11:37:00 +09:00
Yukihiro "Matz" Matsumoto 15d6e172e9 Merge pull request #5146 from shuujii/fix-integer-overflow-error-in-mrdb-test
Fix integer overflow error in mrdb test
2020-11-18 19:19:48 +09:00
KOBAYASHI Shuji f50cde9924 Fix integer overflow error in mrdb test 2020-11-18 18:54:00 +09:00
Yukihiro "Matz" Matsumoto 25e76ee5ce Merge pull request #5149 from mruby/revert-5147-patch1
Revert "Check if irep->reps is NULL in lv_defined_p"
2020-11-18 18:48:17 +09:00
Yukihiro "Matz" Matsumoto a211a326de Revert "Check if irep->reps is NULL in lv_defined_p" 2020-11-18 18:47:46 +09:00
Yukihiro "Matz" Matsumoto e7d0baaf3b Use mrb_int_value() instead of mrb_fixnum_value(); fix #5142 2020-11-18 18:38:53 +09:00
Yukihiro "Matz" Matsumoto b9c80a5357 Merge pull request #5147 from hifoolno/patch1
Check if irep->reps is NULL in lv_defined_p
2020-11-18 18:13:31 +09:00
Zhang Xiaohui d3e17eedee Check if irep->reps is NULL in lv_defined_p 2020-11-18 17:07:20 +08:00
Yukihiro "Matz" Matsumoto e0df303547 Merge pull request #5143 from shuujii/use-mrb_int_value-instead-of-mrb_fixnum_value-in-src-hash.c
Use `mrb_int_value` instead of `mrb_fixnum_value` in `src/hash.c`
2020-11-18 17:29:34 +09:00
Yukihiro "Matz" Matsumoto 557e0645bf Merge pull request #5145 from shuujii/remove-unused-MRubyBuild-enable_bintest=
Remove unused `MRuby::Build#enable_{bin,}test=`
2020-11-18 17:28:47 +09:00
Yukihiro "Matz" Matsumoto 26dd35be59 Merge pull request #5144 from hifoolno/master
Check if irep->reps is NULL
2020-11-18 17:27:49 +09:00
KOBAYASHI Shuji dbb6010d8e Remove unused MRuby::Build#enable_{bin,}test=
The writers seem to be unnecessary because `MRuby::Build#enable_{bin,}test`
are used from the beginning.
2020-11-18 15:41:56 +09:00
Zhang Xiaohui eca6266524 Check if irep->reps is NULL 2020-11-18 14:41:27 +08:00
KOBAYASHI Shuji 4cea788970 Use mrb_int_value instead of mrb_fixnum_value in src/hash.c 2020-11-18 15:13:42 +09:00
Yukihiro "Matz" Matsumoto 3d8350f920 Retrieve irep from proc after MRB_PROC_CFUNC_P check; ref #5140 2020-11-18 10:07:26 +09:00
Yukihiro "Matz" Matsumoto 7c80edb577 Revert half of 9fbf0ef8.
I misunderstand the meaning of #4483. Sorry.
2020-11-17 22:47:25 +09:00
Yukihiro "Matz" Matsumoto 5abb283dd7 Check division overflow (MRB_INT_MIN and -1). 2020-11-17 22:41:43 +09:00
Yukihiro "Matz" Matsumoto 1f12525154 Merge pull request #5141 from shuujii/fix-deprecated-set-env-command-error-on-GitHub-Actions
Fix deprecated `set-env` command error on GitHub Actions [ci skip]
2020-11-17 22:07:33 +09:00
KOBAYASHI Shuji bed04414d7 Fix deprecated set-env command error on GitHub Actions [ci skip]
I tried `$GITHUB_PATH` and `$GITHUB_ENV` instead of `set-env`, but
for some reason path was not recognized, so I changed to using
`ACTIONS_ALLOW_UNSECURE_COMMANDS`.
2020-11-17 18:40:59 +09:00
Yukihiro "Matz" Matsumoto 68cebb6331 Overflown integers should not be fall back to float values. 2020-11-17 16:20:54 +09:00
Yukihiro "Matz" Matsumoto a8cd364ece Detect overflow in flo_shift(). 2020-11-17 16:20:53 +09:00
Yukihiro "Matz" Matsumoto 9fbf0ef886 Refactoring integer ranges.
- Remove `mrb_ssize`
- Fix `MRB_FIXNUM_{MIN,MAX}` to 32 bits on `MRB_NAN_BOXING`
2020-11-17 12:41:10 +09:00
Yukihiro "Matz" Matsumoto aae8237335 Scan all active C source files; ref 600e333
In addition, `include/mruby.h` will be scanned for error class symbols.
2020-11-17 09:00:06 +09:00
Yukihiro "Matz" Matsumoto 354934d398 Refactor integer division. 2020-11-17 07:10:31 +09:00
Yukihiro "Matz" Matsumoto 37a1884749 Simplify mrb_num_div_int(). 2020-11-17 00:24:43 +09:00
Yukihiro "Matz" Matsumoto 3107d1caae Allow int size combinations for MRB_WORD_BOXING.
- `MRB_64BIT` and `MRB_INT32`
- `MRB_32BIT` and `MRB_INT64`
2020-11-16 22:49:55 +09:00
Yukihiro "Matz" Matsumoto 3bb419aeab Merge pull request #5137 from shuujii/use-uintptr_t-instead-of-unsigned-long-in-include-mruby-boxing_word.h
Use `uintptr_t` instead of `unsigned long` in `include/mruby/boxing_word.h`
2020-11-16 22:49:42 +09:00
Yukihiro "Matz" Matsumoto 2609f0a2b3 Merge pull request #5139 from shuujii/avoid-undefined-behavior
Avoid undefined behavior
2020-11-16 22:49:03 +09:00
Yukihiro "Matz" Matsumoto 5156ea997f Merge pull request #5138 from shuujii/simplify-obj_free
Simplify `obj_free`
2020-11-16 22:48:05 +09:00
KOBAYASHI Shuji 7c470e25b8 Avoid undefined behavior
### ASAN report (`MRB_INT32`)

  ```console
  $ bin/mruby -ve '-0x40000000'
  mruby 3.0.0preview (2020-10-16)
  00001 NODE_SCOPE:
  00001   NODE_BEGIN:
  00001     NODE_NEGATE:
  00001       NODE_INT 40000000 base 16
  irep 0x6070000001e0 nregs=2 nlocals=1 pools=0 syms=0 reps=0 iseq=9
  file: -e
  /mruby/src/codedump.c:173:49: runtime error: left shift of 49152 by 16 places cannot be represented in type 'int'
  SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /mruby/src/codedump.c:173:49 in
      1 000 OP_LOADI32	R1	-1073741824
      1 006 OP_RETURN	R1
      1 008 OP_STOP

  /mruby/src/vm.c:1138:7: runtime error: left shift of 49152 by 16 places cannot be represented in type 'mrb_int' (aka 'int')
  SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /mruby/src/vm.c:1138:7 in
  ```
2020-11-16 20:20:30 +09:00
KOBAYASHI Shuji cbc3dbedb4 Simplify obj_free 2020-11-16 16:40:37 +09:00
KOBAYASHI Shuji 8a019106c0 Use uintptr_t instead of unsigned long in include/mruby/boxing_word.h
`mrb_bool`  on LLP64 environment seems to become false if, for example,
`mrb_value` is a pointer whose lower 32 bits are 0.
2020-11-16 16:04:05 +09:00
Yukihiro "Matz" Matsumoto 8a6614d30e Merge pull request #5135 from shuujii/fix-paths-of-gem-files-to-be-scanned-for-presym
Fix paths of gem files to be scanned for presym
2020-11-15 23:15:34 +09:00
Yukihiro "Matz" Matsumoto 144cf6cd58 Merge pull request #5134 from shuujii/fix-that-large-integer-is-not-GCed-with-Word-boxing
Fix that large integer is not GCed with Word-boxing
2020-11-15 23:14:59 +09:00
KOBAYASHI Shuji e334c02a50 Fix paths of gem files to be scanned for presym
When building from outside `MRUBY_ROOT` (e.g. `rake -f`), gem files were not
scanned.
2020-11-15 20:16:12 +09:00
KOBAYASHI Shuji acc114003b Fix that large integer is not GCed with Word-boxing
### Example (32-bit Word-boxing)

  ```ruby
  # example.rb
  int_count = ObjectSpace.count_objects[:T_INTEGER]||0
  int = 1<<30
  p (ObjectSpace.count_objects[:T_INTEGER]||0) - int_count
  int = nil
  GC.start
  p (ObjectSpace.count_objects[:T_INTEGER]||0) - int_count
  ```

#### Before this patch:

  ```console
  $ bin/mruby example.rb
  1
  1
  ```

#### After this patch:

  ```console
  $ bin/mruby example.rb
  1
  0
  ```
2020-11-15 16:45:03 +09:00
Yukihiro "Matz" Matsumoto a6119b0077 Fixed further wrong condition in overflow detection. 2020-11-15 08:08:55 +09:00
Yukihiro "Matz" Matsumoto bb1fb2f43d Fixed wrong condition in mrb_int_mul_overflow(). 2020-11-14 23:34:43 +09:00
Yukihiro "Matz" Matsumoto 2c6a5d3a77 Change the fallback mrb_int_mul_overflow(). 2020-11-14 23:28:05 +09:00
Yukihiro "Matz" Matsumoto 10c1c9d6f8 Change the type of rlen to uint8_t in mrb_irep. 2020-11-14 23:27:28 +09:00
Yukihiro "Matz" Matsumoto 8a5dfa92ab Integer overflow in operations should cause RangeError. 2020-11-14 20:44:07 +09:00
Yukihiro "Matz" Matsumoto dd3ed8d99c Allow full mrb_int operations in overflow detection.
Fix overflow detection in integer operations with `MRB_WORD_BOXING`.
This bug made `1073741824 == 1073741824+0` to be `false` on 32bit
platforms.
2020-11-14 20:40:06 +09:00
Yukihiro "Matz" Matsumoto 19450df41e Integer operation should result in Integer.
Should raise `RangeError` if the operation overflows.
2020-11-14 19:38:27 +09:00
Yukihiro "Matz" Matsumoto 600e3330b3 Scan source files only from cdump enabled gems. 2020-11-14 18:52:57 +09:00
Yukihiro "Matz" Matsumoto 4dcd8dd7ce Merge pull request #5132 from shuujii/remove-redundant-command-execution-in-header_search_paths
Remove redundant command execution in `header_search_paths`
2020-11-14 18:52:48 +09:00
KOBAYASHI Shuji e941fb7866 Remove redundant command execution in header_search_paths
There is no need to execute command in duplicate for the same
reason as #5128.
2020-11-14 17:19:38 +09:00
Yukihiro "Matz" Matsumoto 8398020d0a Merge pull request #5131 from shuujii/remove-unused-constant-in-lib-mruby-build-command.rb
Remove unused constant in `lib/mruby/build/command.rb`
2020-11-14 17:01:37 +09:00
Yukihiro "Matz" Matsumoto 69dbe8cfa5 Merge pull request #5130 from shuujii/workaround-to-build-mirb-with-Homebrews-readline-on-Mac
Workaround to build `mirb` with Homebrew's readline on Mac; fix #4537
2020-11-14 16:53:23 +09:00