Commit Graph

3983 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto 65a2c2082d Call mrb_str_to_str from mrb_string_value_ptr for compatibility. 2018-11-19 17:11:19 +09:00
Yukihiro "Matz" Matsumoto 53e2df3e93 Restore mrb_string_type function for compatibility. 2018-11-19 16:13:26 +09:00
Yukihiro "Matz" Matsumoto c308a149f0 Add Hash type check for OP_KARG and OP_KEY_P; ref #4166 2018-11-19 15:35:59 +09:00
Yukihiro "Matz" Matsumoto 87ffab5713 Adjust codedump output format; ref #4166 2018-11-19 15:25:42 +09:00
Yukihiro "Matz" Matsumoto 9516731329 Use type checking mrb_to_str instead of converting mrb_str_to_str. 2018-11-19 12:08:28 +09:00
Yukihiro "Matz" Matsumoto 610bcc88c2 Removed to_hash conversion method. 2018-11-19 12:08:28 +09:00
Yukihiro "Matz" Matsumoto 698f5f707c Removed to_ary conversion method. 2018-11-19 12:08:28 +09:00
Yukihiro "Matz" Matsumoto ff08856fe3 Remove implicit conversion using to_str method; fix #3854
We have added internal convenience method `__to_str` which
does string type check.

The issue #3854 was fixed but fundamental flaw of lack of stack
depth check along with fibers still remains. Use `MRB_GC_FIXED_ARENA`
for workaround.
2018-11-19 12:05:46 +09:00
Yukihiro "Matz" Matsumoto afca99a40b Remove implicit conversion using to_int method.
The ISO standard does not include implicit type conversion using
`to_int`. This implicit conversion often causes vulnerability.
There will be no more attacks like #4120.

In addition, we have added internal convenience method `__to_int` which
does type check and conversion (from floats).
2018-11-19 11:28:51 +09:00
Yukihiro "Matz" Matsumoto 31a961acf1 The current context may be changed in mrb_vm_exec; ref #3668 #4104 2018-11-19 09:50:31 +09:00
Yukihiro "Matz" Matsumoto cab6b0f39b Protect Fiber from GC in ecall(); fix #4104 2018-11-19 09:49:20 +09:00
Yukihiro "Matz" Matsumoto 25d390d6cc Improve Hash table using variable sized segments. 2018-11-19 09:30:15 +09:00
Yukihiro "Matz" Matsumoto 180b73fec4 The key or value object could be reclaimed by GC; fix #4164
The GC may occur between `sg_shift` and `mrb_assoc_new`, in which
case `key` and `value` could be freed even tough they are still alive.

The issue is found and fixed by https://hackerone.com/hexodus
2018-11-16 01:04:57 +09:00
Yukihiro "Matz" Matsumoto 0a022f7b8d The saved pc from ERR_PC_SET was wrong; fix #4138
The saving `pc` position should be beginning of the instruction.
But after `mruby 2.0` byte code modification, the `pc` variable
points the beginning of the next instruction. We save the previous
position in a local variable `pc0`.
2018-11-15 23:34:32 +09:00
Yukihiro "Matz" Matsumoto faf51f82c7 Rename local variables in mrb_debug_info_append_file 2018-11-15 23:34:32 +09:00
Yukihiro "Matz" Matsumoto 56db3cf3eb Simplify argument parsing; ref #4161 2018-11-15 21:01:56 +09:00
Yukihiro "Matz" Matsumoto f39f428ed4 Silence -fsanitize=undefined warning in src/enum.c; fix #4161 2018-11-15 21:01:56 +09:00
Yukihiro "Matz" Matsumoto 61f49690e4 Remove filename&lines from mrb_irep struct.
This patch slightly reduce memory consumption (2% for my test).
2018-11-15 21:01:56 +09:00
Yukihiro "Matz" Matsumoto 1bea1e2050 Small renaming refactor in dump.c 2018-11-15 19:24:45 +09:00
Hiroshi Mimaki 7d7f9feee7 Wrong pool data length for negative floating value in a mrb file. 2018-11-07 17:20:18 +09:00
Yukihiro "Matz" Matsumoto d25ebec988 Fixed wrong ArgumentError with keyword arguments; fix #4159 2018-11-05 21:52:17 +09:00
Yukihiro "Matz" Matsumoto d47003aea4 Fixed a bug in argument number check with kwargs; fix #4159 2018-11-05 07:44:25 +09:00
Yukihiro "Matz" Matsumoto d9e2532552 Remove reserved symbols for now.
It should be done by planned embedded symbols.
2018-11-02 22:58:12 +09:00
Yukihiro "Matz" Matsumoto 9c5e28646b Merge pull request #4151 from take-cheeze/remove_op_symidx
Reduce instruction size
2018-11-02 22:37:47 +09:00
take-cheeze 57a435aa1d Suppress warning 2018-11-02 15:49:34 +09:00
take-cheeze 659c680a5b Fix dump and load with endianess 2018-11-02 15:47:28 +09:00
Yukihiro "Matz" Matsumoto 0419f07915 Add NULL checks for mrb->ci and proc->upeer; #4024 2018-11-02 14:57:03 +09:00
Yukihiro "Matz" Matsumoto 7ad53273a2 Silence Appveyor's VC compilation warnings. 2018-11-01 22:52:12 +09:00
Yukihiro "Matz" Matsumoto d68da042b3 The env object referenced from fibers may be freed; fix #4154
By dffa203 that reclaim `env` objects from heaps, there's more chance
for `env` objects referenced from fibers may be freed from heap pages.
2018-11-01 22:36:06 +09:00
Hiroshi Mimaki 73727aeb50 Fixed a bug in INIT_DISPATCH for non direct threading; fix #4153 2018-11-01 11:10:47 +09:00
take-cheeze 486c9d902d Fix codedumper 2018-10-29 19:35:31 +09:00
take-cheeze 557805da07 Fix operator 2018-10-29 19:29:43 +09:00
take-cheeze 68714ab648 Fix SEGV 2018-10-29 19:26:00 +09:00
take-cheeze e022080390 Define null symbol 2018-10-29 19:22:53 +09:00
take-cheeze 3248de83b6 Reduce instruction size 2018-10-29 19:17:05 +09:00
take-cheeze b37b312081 Rename libmruby stuff to avoid confusion 2018-10-29 14:07:16 +09:00
Yukihiro "Matz" Matsumoto fa33a4d75a We need no write barrier here; ref #4143 2018-10-29 12:01:27 +09:00
Yukihiro "Matz" Matsumoto 3dc3643e34 Marking from terminated fibers are not needed; ref #4143
The old condition marks the top-level callinfo even after the
fiber is terminated.
2018-10-29 11:58:10 +09:00
Yukihiro "Matz" Matsumoto dffa203d07 Need to mark shared env objects as MRB_TT_FREE; fix #4143
The following code mistakenly exits from the function without marking
the env object as `MRB_TT_FREE`.

``` ruby
      if (MRB_ENV_STACK_SHARED_P(e)) {
        /* cannot be freed */
        return; // <- should be `break`
      }
```
2018-10-29 11:51:04 +09:00
Yukihiro "Matz" Matsumoto 7ff84789c3 Add argument check to Array#clear; fix #4144 2018-10-29 10:12:10 +09:00
Yukihiro "Matz" Matsumoto 80b5a56f51 Need to freeze string keys. 2018-10-20 19:02:12 +09:00
Yukihiro "Matz" Matsumoto e5f160dc7e Should not compare undef (deleted) key in hashes; fix #4136 2018-10-12 19:00:45 +09:00
Yukihiro "Matz" Matsumoto 249fef7dc4 Add NULL check in sg_compact(); fix #4139 2018-10-12 08:30:57 +09:00
Yukihiro "Matz" Matsumoto 82e00ce60f Hash#delete should return the deleted value; fix #4133 2018-10-12 08:25:54 +09:00
Yukihiro "Matz" Matsumoto 54ec08c7f1 Implement Hash#rehash in C using sg_compact(). 2018-09-26 23:09:48 +09:00
Yukihiro "Matz" Matsumoto d78acc7afe Add index to larger segment lists for performance 2018-09-26 23:09:48 +09:00
Yukihiro "Matz" Matsumoto 8ffd4e47fb Use mrb_undef_value for delete mark instead of shifting Hash entry table.
That means entry table should be compacted periodically by `sg_compact()`.
2018-09-26 23:09:48 +09:00
Yukihiro "Matz" Matsumoto e8dcfe1745 Use segmented list to implement Hash [Experimental]
I know it's not hash at all, but reduce memory consumption.
2018-09-26 12:55:22 +09:00
Yukihiro "Matz" Matsumoto 78195eb2ae Small refactoring in vm.c 2018-09-26 12:17:38 +09:00
sbsoftware 8fc56f062e Add compiler flag to disable direct threading (#4075)
* Add option to disable direct threading

* Prepend MRB_ to option name
2018-09-21 11:22:53 +09:00