Commit Graph

11467 Commits

Author SHA1 Message Date
KOBAYASHI Shuji 112120969d Use type tag for hash code in ht_hash_func()
The function corresponding to `ht_hash_func()` was as follows in the days of
khash implementation (before d78acc7a).

  ```c
  mrb_hash_ht_hash_func(mrb_state *mrb, mrb_value key)
  {
    enum mrb_vtype t = mrb_type(key);
    ...
    switch (t) {
    ...
    default:
      hv = mrb_funcall(mrb, key, "hash", 0);
      h = (khint_t)t ^ (khint_t)mrb_fixnum(hv);
      break;
    }
    ...
  }
  ```

When switched to the segmented list implementation (d78acc7a), this function
was changed as follows.

  ```c
  sg_hash_func(mrb_state *mrb, seglist *t, mrb_value key)
  {
    enum mrb_vtype tt = mrb_type(key);
    ...
    switch (tt) {
    ...
    default:
      hv = mrb_funcall(mrb, key, "hash", 0);
      h = (size_t)t ^ (size_t)mrb_fixnum(hv);
      break;
    }
    ...
  }
  ```

Since the argument `t` was added, the variable for type tag was changed from
`t` to `tt`, but the variable used in the expression of `h` remained `t`.

Probably this is an omission of change, so fixed it.
2.1.2-rc2
2020-07-29 09:17:32 +09:00
Yukihiro "Matz" Matsumoto 63956036e1 Fix the VM stack handling bug in 'mrb_yield_with_class()`; fix #5042 2020-07-29 09:09:37 +09:00
dearblue cdf45438f0 Fixed shift width for MRB_ENV_SET_BIDX()
ref c07f24cd1 and close #5035
2020-07-29 09:05:29 +09:00
Hiroshi Mimaki b6b9c57f24 Update version to 2.1.2. (mruby 2.1.2 RC) 2.1.2-rc 2020-07-01 16:49:21 +09:00
Hiroshi Mimaki aa578c346d Revert "Free the original pointer if realloc failed."
This reverts commit 9cdf439db5.
2020-06-30 18:33:47 +09:00
Yukihiro "Matz" Matsumoto ac8360003e Fix the bug that mrbc generates a.rb.mrb instead of a.mrb.
The bug was introduced by 9dfe50f1d.
2020-06-29 07:25:03 +09:00
Yukihiro "Matz" Matsumoto 233cb49903 Remove unnecessary stack adjustment in OP_CALL. 2020-06-25 06:57:43 +09:00
Yukihiro "Matz" Matsumoto 9cdf439db5 Free the original pointer if realloc failed.
The POSIX `realloc` keep the original pointer untouched, so it can
easily leads to memory leakage. `mrb_realloc()` should handle those
bookkeeping, while `mrb_realloc_simple()` keeps the original `realloc`
behavior.
2020-06-25 06:57:43 +09:00
Yukihiro "Matz" Matsumoto 95360a17f2 Remove unnecessary break from numeric.c. 2020-06-25 06:57:42 +09:00
Yukihiro "Matz" Matsumoto 9dfe50f1d9 Use snprintf instead of memcpy in mrbc.c. 2020-06-25 06:57:42 +09:00
Yukihiro "Matz" Matsumoto c07f24cd18 Change flag names in preparation of REnv refactoring. 2020-06-25 06:57:41 +09:00
Yukihiro "Matz" Matsumoto 03c2b8656b Use mrb_get_argc() to improve performance. 2020-06-25 06:57:41 +09:00
Yukihiro "Matz" Matsumoto ea6e1b003c Create codeql-analysis.yml 2020-06-23 12:36:20 +09:00
Yukihiro "Matz" Matsumoto c2b37e76b3 Skip mrb_get_args() in mrb_ary_{aget,aset} unless necessary.
Use simpler `mrb_get_argc()` and `mrb_get_arg1()` instead.
2020-06-22 21:47:23 +09:00
Yukihiro "Matz" Matsumoto d40b922c98 Fix potential buffer overflow in sprintf.c. 2020-06-20 18:56:33 +09:00
Yukihiro "Matz" Matsumoto 28e793496a Support integer and float combination in mrb_equal(). 2020-06-20 18:56:05 +09:00
Yukihiro "Matz" Matsumoto 33c8d6af1e Move definition of BasicObject#!= to mrblib.
C implementation used `mrb_funcall()` that bypassed many optimization.
2020-06-20 14:09:23 +09:00
Yukihiro "Matz" Matsumoto 49ae2a69f2 Add mrb_get_arg1() that retrieves single (and only) argument.
`mrb_get_arg1()` raises `ArgumentError` if the method does not receive one
argument.

And replaces all `mrb_get_args(mrb, "o", &arg)` by the new function.
2020-06-20 12:49:46 +09:00
Yukihiro "Matz" Matsumoto 2ffb77586a Symbolify saved alias name to improve performance. 2020-06-20 12:07:49 +09:00
Yukihiro "Matz" Matsumoto dad99afae8 Remove unnecessary comments from MRB_TT_* definitions. 2020-06-15 09:54:55 +09:00
Yukihiro "Matz" Matsumoto f93dffb5ee Remove unused MRB_TT_FILE. 2020-06-15 07:47:22 +09:00
Yukihiro "Matz" Matsumoto 742117e7a3 Reorganize gray mark functions in GC. 2020-06-11 16:18:52 +09:00
Yukihiro "Matz" Matsumoto 15ceb35e05 Remove GC test code from ancient. 2020-06-11 16:18:51 +09:00
Yukihiro "Matz" Matsumoto f0bad600e0 Remove endian configuration methods.
Since we made our opcode byte based, we need no endian option (`-e`
and `-E`) to `mrbc`.
2020-06-11 16:18:50 +09:00
Yukihiro "Matz" Matsumoto a8aeba89ef Merge pull request #5023 from dearblue/nesting
Remove `mrb_assert()` in `Module.nesting`
2020-06-11 12:21:26 +09:00
Yukihiro "Matz" Matsumoto 7f593893e8 Update OP_HASH generation to support big hash creation. 2020-06-09 22:42:38 +09:00
Yukihiro "Matz" Matsumoto 5d5b1d1f3c Merge pull request #5022 from dearblue/test-dir
Need `build/XXX/mrbgems/mruby-test` directory
2020-06-09 22:42:29 +09:00
Yukihiro "Matz" Matsumoto bb6846468a Merge pull request #5021 from dearblue/kernel-test
Update `test/t/kernel.rb`
2020-06-09 22:41:44 +09:00
dearblue 960c82e396 Remove mrb_assert() in Module.nesting
The following code was causing SIGSEGV:

```ruby
Module.method(:nesting).call
```
2020-06-09 21:54:13 +09:00
dearblue 5be33b82c7 Need build/XXX/mrbgems/mruby-test directory
An error may occur when performing `rake clean all` or `rake clean test`.

The directory is needed before writing to `mrbgems/mruby-test/assert.c`.
2020-06-09 21:24:53 +09:00
dearblue 4cd858f93d Update test/t/kernel.rb
- Remove unnecessoury assert
- Fix typo
2020-06-09 20:33:56 +09:00
Yukihiro "Matz" Matsumoto 2098acee7d Merge pull request #5020 from jethrodaniel/master
only use GEMNAME if defined in assert.rb
2020-06-08 15:51:03 +09:00
Mark Delk 3157efa57c only use GEMNAME if defined in assert.rb
Check if the constant GEMNAME is defined before use in `assert.rb`.

This is added to prevent an undefined constant error when using
`assert.rb` in other environments - for example, testing CRuby.
2020-06-08 00:30:46 -05:00
Yukihiro "Matz" Matsumoto 613e0bee5e Merge pull request #5013 from shuujii/print-exception-backtrace-if-possible-without--v-in-test
Print exception backtrace if possible without `-v` in test
2020-06-08 09:59:43 +09:00
Yukihiro "Matz" Matsumoto 78c9c71bdf Add proper cast. 2020-06-05 17:52:22 +09:00
Yukihiro "Matz" Matsumoto aa30b13b36 Change arena index from mrb_int to int. 2020-06-05 17:26:40 +09:00
Yukihiro "Matz" Matsumoto 6ba542cd53 Revert part of #5019 (mruby_io_test.c) to honor #4987
The issue was reported by @shuujii.
2020-06-05 17:20:41 +09:00
Yukihiro "Matz" Matsumoto 106f4c4e9d Add proper casts to silence VC warnings. 2020-06-05 16:04:30 +09:00
Yukihiro "Matz" Matsumoto f1523d2404 Squashed commit of the following:
commit 2d7d545c4c4bfce7fdcbcbe9baaeb437915742f0
Merge: 625a1249 b178914b
Author: Yukihiro "Matz" Matsumoto <matz@ruby.or.jp>
Date:   Fri Jun 5 14:35:13 2020 +0900

    Merge branch 'fix-mrb_open-with-nomem' of https://github.com/dearblue/mruby into dearblue-fix-mrb_open-with-nomem

commit b178914b11
Author: dearblue <dearblue@users.noreply.github.com>
Date:   Sat Jan 19 22:22:44 2019 +0900

    Fix invalid pointer free inside other heap's block

     1. `e = mrb_obj_alloc(...)`
     2. `e->stack = mrb->c->stack` (`mrb->c->stack` is anywhere in the range `stbase...stend`)
     3. And raised exception by `mrb_malloc()`!
     4. `mrb_free(e->stack)` by GC part (wrong free)

commit 52e3d5d858
Author: dearblue <dearblue@users.noreply.github.com>
Date:   Sat Jan 19 21:55:36 2019 +0900

    Fix memory leak for temporary symbols when out of memory

commit 4c5499b88e
Author: dearblue <dearblue@users.noreply.github.com>
Date:   Sun Jan 20 11:42:07 2019 +0900

    Fix uninitialized pointer dereference for debug section

commit 8e993167de
Author: dearblue <dearblue@users.noreply.github.com>
Date:   Sun Jan 20 11:41:09 2019 +0900

    Fix memory leak for temporary filenames when out of memory

commit 8b422577e6
Author: dearblue <dearblue@users.noreply.github.com>
Date:   Sun Jan 20 10:57:51 2019 +0900

    Fix memory leak for irep when out of memory

commit 6b35ebf49a
Author: dearblue <dearblue@users.noreply.github.com>
Date:   Sun Jan 20 10:55:50 2019 +0900

    Fix uninitialized pointer dereference when do not finished initializing irep

commit 2531f2631e
Author: dearblue <dearblue@users.noreply.github.com>
Date:   Sun Jan 20 10:48:15 2019 +0900

    Fix NULL pointer dereference when do not finished initializing irep

commit e2d6896eba
Author: dearblue <dearblue@users.noreply.github.com>
Date:   Sat Jan 19 12:54:19 2019 +0900

    Fix memory leak for irep when out of memory by `mrb_proc_new()`

commit b6214ff8a0
Author: dearblue <dearblue@users.noreply.github.com>
Date:   Sat Jan 19 12:53:07 2019 +0900

    Fix memory leak for `khash_t` in `kh_init_size()` when out of memory by `kh_alloc()`

commit 19162dd6c1
Author: dearblue <dearblue@users.noreply.github.com>
Date:   Sun Jan 20 02:15:07 2019 +0900

    Fix memory leak for symbol string when out of memory in `kh_put()`

commit 15e67297ff
Author: dearblue <dearblue@users.noreply.github.com>
Date:   Sun Jan 20 02:12:24 2019 +0900

    Fix keep wrong symbol index when out of memory

commit 3f8e2b3752
Author: dearblue <dearblue@users.noreply.github.com>
Date:   Sun Jan 20 02:08:13 2019 +0900

    Fix keep wrong symbol capacity when out of memory

commit a3cfe755ab
Author: dearblue <dearblue@users.noreply.github.com>
Date:   Sat Jan 19 10:11:37 2019 +0900

    Fix NULL pointer dereference `mrb->c` by `mark_context()`

commit d9c7b6be6e
Author: dearblue <dearblue@users.noreply.github.com>
Date:   Sun Jan 20 15:25:09 2019 +0900

    Fix protect exception for print error message

commit 100642750e
Author: dearblue <dearblue@users.noreply.github.com>
Date:   Sun Jan 20 11:59:02 2019 +0900

    Protect exception for mruby core initialization

commit 7a0418304e
Author: dearblue <dearblue@users.noreply.github.com>
Date:   Fri Jan 18 20:38:27 2019 +0900

    Fix memory leak for string object when out of memory

    The `mrb_str_pool()` function has a path to call `malloc()` twice.

    If occurs `NoMemoryError` exception in second `malloc()`,
    first `malloc()` pointer is not freed.

commit fef1c152ce
Author: dearblue <dearblue@users.noreply.github.com>
Date:   Sat Jan 19 13:05:09 2019 +0900

    Fix stack overflow when out of memory

    As a result of this change, no backtrace information is set
    for NoMemoryError (`mrb->nomem_err`).

    Detailes:

    When generating a backtrace, called `mrb_intern_lit()`,
    `mrb_str_new_cstr()` and `mrb_obj_iv_set()` function with
    `exc_debug_info()` function in `src/error.c`.

    If a `NoMemoryError` exception occurs at this time,
    the `exc_debug_info()` function will be called again,
    and in the same way `NoMemoryError` exception raised will result
    in an infinite loop to occurs stack overflow (and SIGSEGV).

commit da7d7f881b
Author: dearblue <dearblue@users.noreply.github.com>
Date:   Sun Jan 20 12:00:38 2019 +0900

    Fix NULL pointer dereference `mrb->nomem_err` when not initialized

    Add internal functions (not `static`):

      * `mrb_raise_nomemory()`
      * `mrb_core_init_abort()`
2020-06-05 14:40:07 +09:00
Yukihiro "Matz" Matsumoto 00f6271e3b Change arena index from mrb_int to int. 2020-06-05 14:40:07 +09:00
Yukihiro "Matz" Matsumoto b0e49ef79e Merge pull request #5019 from mruby/stable
Merge mruby 2.1.1
2020-06-05 13:04:36 +09:00
Hiroshi Mimaki 81d340e042 Merge master. 2020-06-05 12:42:56 +09:00
Yukihiro "Matz" Matsumoto 4e40169ed6 Remove rake -v option from GitHub Actions. 2020-06-04 18:24:58 +09:00
Yukihiro "Matz" Matsumoto 49f1c0e94d Ignore files for clangd.
- `compile_flags.txt'
- `compile_commands.json`
2020-06-04 18:09:03 +09:00
Yukihiro "Matz" Matsumoto dcfebc6eed Remove bison installation from GitHub Actions. 2020-06-04 18:08:08 +09:00
Hiroshi Mimaki f9d113f764 Update release date. 2.1.1 2020-06-04 17:20:46 +09:00
Yukihiro "Matz" Matsumoto 3d2d9f8a9b Add explicit cast to DROP_PRECISION macro in rtional.c. 2020-06-04 11:01:31 +09:00
Yukihiro "Matz" Matsumoto 07129c76d9 Add mruby-complex and mruby-rational to default.gembox. 2020-06-04 11:01:30 +09:00
Yukihiro "Matz" Matsumoto 6fe03f3b39 Add explicit cast to silence warnings on AppVeyor. 2020-06-04 11:01:30 +09:00
Yukihiro "Matz" Matsumoto 41f3456a28 Merge pull request #4865 from take-cheeze/istruct_align
Align RIStruct data for rational/complex
2020-06-04 11:01:04 +09:00