Commit Graph

5699 Commits

Author SHA1 Message Date
dearblue 2c66d34a7e Corrected strange conditional in mrb_vm_run()
This was introduced in commit 365c151df0.
I should have checked env first.
2024-02-18 18:18:21 +09:00
Yukihiro "Matz" Matsumoto 7d199b7256 src/error.h: remove unused header 2024-02-16 08:10:53 +09:00
Yukihiro "Matz" Matsumoto a1be05e79f src/opcode.h: remove unused header 2024-02-16 08:09:58 +09:00
Yukihiro "Matz" Matsumoto 3eeeb8fabf string.c (memsearch_swar): skip a local variable 2024-02-15 14:01:49 +09:00
Yukihiro "Matz" Matsumoto 55ca34c31b backtrace.c (mrb_print_backtrace): skip a local variable 2024-02-15 14:01:48 +09:00
Yukihiro "Matz" Matsumoto 9c840a68e2 string.c (memsearch_swar): boundary check by the latest position 2024-02-13 22:36:03 +09:00
Yukihiro "Matz" Matsumoto 6810423da1 backtrace.c (mrb_print_backtrace): avoid backtrace to array conversion
Made print_backtrace() to support both array form and packed backtrace
form, so that we can avoid allocating an array.
2024-02-13 16:18:14 +09:00
Yukihiro "Matz" Matsumoto 441de05376 error.h: use RBasic instead of RObject for generic objects
RObject is type for objects with instance variables. For generic
objects, use RBasic.
2024-02-13 11:05:27 +09:00
Yukihiro "Matz" Matsumoto f285420653 backtrace.c (decode_location): decode packed backtrace location on demand. 2024-02-13 00:07:54 +09:00
Yukihiro "Matz" Matsumoto abcad36bae string.c (memsearch_swar): fixed a buffer overflow 2024-02-09 19:09:01 +09:00
Yukihiro "Matz" Matsumoto 868aeaf48c string.c (memsearch_swar): fixed a buffer overflow 2024-02-09 18:52:44 +09:00
Yukihiro "Matz" Matsumoto 874f1e0138 backtrace.c (copy_location): rename some function and arguments 2024-02-08 23:41:22 +09:00
Yukihiro "Matz" Matsumoto 432caf0670 backtrace.c (pack_backtrace): refactor the function that called once 2024-02-08 23:22:48 +09:00
Yukihiro "Matz" Matsumoto 60919807e5 backtrace.c (each_backtrace): make return type to size_t 2024-02-07 17:34:33 +09:00
Yukihiro "Matz" Matsumoto 0a11215452 backtrace.c (packed_backtrace): avoid calling each_backtrace() twice
Since the length of the backtrace is at most `ciidx + 1` we can avoid
the first call of each_backtrace().
2024-02-07 17:32:58 +09:00
Yukihiro "Matz" Matsumoto b67cea4442 backtrace.c (pack_backtrace_i): avoid infinite loop; ref #6161
When irep->refcnt reaches UINT16_MAX, mrb_irep_incref() raises
exception but the function pack_backtrace_i() is called from
mrb_exc_raise() thus causes the infinite loop problem. So this is a
hack-ish workaround by making irep reference to NULL if refcnt reaches
the maximum count. Probably we will address this issue again to make it
better.
2024-02-07 17:30:11 +09:00
Yukihiro "Matz" Matsumoto b8e4c4b6ba Merge pull request #6166 from dearblue/mrb_heap_page
Stop pseudo flexible array in `mrb_heap_page`
2024-02-05 21:45:04 +09:00
Yukihiro "Matz" Matsumoto 32fb0c04ee Merge pull request #6165 from dearblue/RVALUE
Reduce `RVALUE` related pointer casts.
2024-02-05 21:42:51 +09:00
dearblue 8f14785f10 Stop pseudo flexible array in mrb_heap_page
For reference, the flexible array was introduced by commit 3ab2f9371e (#2997).
Subsequently changed for compatibility with C++ by commit 24939723d7 (#5596).
2024-02-04 21:55:54 +09:00
dearblue 84fbe63457 Change the end parameter of obj_free() to a boolean type
The caller is a boolean value from the first.
2024-02-04 21:55:54 +09:00
dearblue dde5fe3a60 Reduce RVALUE related pointer casts. 2024-02-04 21:55:53 +09:00
Yukihiro "Matz" Matsumoto f04a729dc9 gc.c (obj_free): check if irep is NULL before mrb_irep_decref(); #6161 2024-02-04 17:06:05 +09:00
Yukihiro "Matz" Matsumoto 2f63b49542 backtrace.c: use mrb_irep references instead of struct RProc
To reduce GC burden (no mark needed). We use `mrb_irep_incref()` and
`mrb_irep_decref()` instead to track irep memory usage; ref #6161
2024-02-04 16:48:42 +09:00
Yukihiro "Matz" Matsumoto 4dfadb4f9f Merge pull request #6159 from dearblue/debug/irep-free
Allow to detect use-after-free after `mrb_irep_free()` for debugging
2024-02-04 16:26:03 +09:00
Yukihiro "Matz" Matsumoto 0abc36f761 Merge pull request #6161 from dearblue/backtrace
Fixed use-after-free by backtrace object
2024-02-03 23:39:58 +09:00
Yukihiro "Matz" Matsumoto 08c422c7ee numeric.c (cmpnum): support fixnum cmp bignum; fix #6163 2024-02-02 14:18:57 +09:00
Yukihiro "Matz" Matsumoto 6e09555749 Merge pull request #6150 from dearblue/itself
Introduce `mrb_obj_itself()`
2024-02-01 16:15:42 +09:00
dearblue 9543cfa7ee Fixed use-after-free by backtrace object
The `MRB_TT_BACKTRACE` object has been added for the purpose.

Previously, "use-after-free" could occur because the reference count in `backtrace_location::irep` was not incremented.

fixed #6160
2024-01-31 22:17:16 +09:00
Yukihiro "Matz" Matsumoto cac698fe88 string.c (memsearch_swar): changed the function name
For your information, SWAR stands for SIMD within a register.
2024-01-31 21:37:39 +09:00
Yukihiro "Matz" Matsumoto f8527f0670 string.c (mrb_memsearch_ss): update a comment regarding alignment issue 2024-01-31 21:36:05 +09:00
Yukihiro "Matz" Matsumoto d8144aef78 string.c: remove a comment regarding unsigned char* 2024-01-31 21:34:54 +09:00
Yukihiro "Matz" Matsumoto 363f795432 string.c: remove unnecessary type casts
We don't need `unsigned` for string pointers.
2024-01-31 15:06:04 +09:00
Yukihiro "Matz" Matsumoto e61a2881a7 string.c (mrb_memsearch_ss): fix potential buffer overflow; fix #6158
- stop using `bigint*`
- stop integer pointer dereferences
- use `memcpy` to integer variables
- add reminder search for shorter patterns
2024-01-31 07:48:24 +09:00
Yukihiro "Matz" Matsumoto 219cfd63e1 string.c (mrb_memsearch_ss): update integer prefixes (LLU -> ULL) 2024-01-31 07:42:52 +09:00
Yukihiro "Matz" Matsumoto 6ba65ea0f0 string.c (mrb_memsearch_ss): update comment 2024-01-31 01:54:37 +09:00
Yukihiro "Matz" Matsumoto 44a5882bc2 string.c (mrb_memsearch_ss): remove useless alignment adjustment
Ref #6158
2024-01-31 01:27:10 +09:00
Yukihiro "Matz" Matsumoto be5448fd16 string.c (mrb_memsearch): refactor m==1 (use memchr) case 2024-01-31 01:17:12 +09:00
Yukihiro "Matz" Matsumoto d8e1aed646 string.c (search_nonascii): need not to check n>3 on 32bit platforms 2024-01-30 12:35:56 +09:00
dearblue 60dd6b5586 Allow to detect use-after-free after mrb_irep_free() for debugging
Write invalid value to `irep` if `MRB_DEBUG` is defined by `MRuby::Build#enable_debug`.
2024-01-29 21:32:04 +09:00
Yukihiro "Matz" Matsumoto e859b430cc fixup! string.c (search_nonascii): add faster search using SSE2 2024-01-27 11:59:29 +09:00
Yukihiro "Matz" Matsumoto dee1ded7b5 string.c (mrb_memsearch_ss): support bigendians 2024-01-27 06:23:16 +09:00
Yukihiro "Matz" Matsumoto 06d9a54760 string.c (mrb_memsearch): remove simple search and quick search
Since mrb_memsearch_ss() is fast enough for most of the cases, we try to
simplify the code.
2024-01-27 06:22:55 +09:00
Yukihiro "Matz" Matsumoto 2943ca2685 string.c (mrb_memsearch_ss): faster integer-wise substring search
The function is based on @WojciechMula's code from the repository
https://github.com/WojciechMula/sse4-strstr.git Since it's licensed
under 2 clause BSD, we updated LEGAL file too.
2024-01-27 06:16:33 +09:00
Yukihiro "Matz" Matsumoto 08cd281200 string.c (search_nonascii): skip alignment adjustment for some CPUs
Some CPUs (e.g. x86) allow unaligned access to the memory.
2024-01-26 08:22:33 +09:00
Yukihiro "Matz" Matsumoto 68ab95ea57 string.c (mrb_memsearch): take char* instead of void*
Avoid useless `void*`.
2024-01-25 22:32:31 +09:00
Yukihiro "Matz" Matsumoto cf0cd6785c string.c: rename MRB_QS_SHORT_STRING_LENGTH
The new name is MRB_SEARCH_SHORT_STRING_LENGTH since it's no longer used
in the mrb_memsearch_qs(). FYI, 'qs' stands for 'quick search'.
2024-01-23 23:28:45 +09:00
Yukihiro "Matz" Matsumoto fb2ebcde7c string.c (search_nonascii): add faster search using SSE2 2024-01-23 23:28:45 +09:00
Yukihiro "Matz" Matsumoto 4108b85c62 string.c (search_nonascii): faster search using integer match
If you define `SIMPLE_SEARCH_NONASCII`, you can use old, naive
implementation of search_nonascii(). You may want to use the old one for
code size constraint for example.
2024-01-23 23:28:45 +09:00
dearblue bf2db1ed2b Check mrb_bigint_p() before mrb_integer() 2024-01-21 10:59:06 +09:00
dearblue 3111990089 Introduce mrb_obj_itself()
Some method definitions were changed to use this function.
2024-01-20 22:07:29 +09:00