summaryrefslogtreecommitdiff
path: root/test/-ext-
AgeCommit message (Collapse)Author
2019-11-18test/-ext-/string/test_fstring.rb: suppress a warning for taintYusuke Endoh
2019-11-18Deprecate taint/trust and related methods, and make the methods no-opsJeremy Evans
This removes the related tests, and puts the related specs behind version guards. This affects all code in lib, including some libraries that may want to support older versions of Ruby. Notes: Merged: https://github.com/ruby/ruby/pull/2476
2019-11-09Fix typosKazuki Tsujimoto
2019-11-05Revert "[EXPERIMENTAL] Make Symbol#to_s return a frozen String [Feature #16150]"NARUSE, Yui
This reverts commit 6ffc045a817fbdf04a6945d3c260b55b0fa1fd1e.
2019-10-08more use of RbConfig::LIMITS卜部昌平
`8 * RbConfig::SIZEOF` ... is not straight.
2019-09-30Add rb_enumeratorize_with_size_kw and related macrosJeremy Evans
Currently, there is not a way to create a sized enumerator in C with a different set of arguments than provided by Ruby, and correctly handle keyword arguments. This function allows that. The need for this is fairly uncommon, but it occurs at least in Enumerator.produce, which takes arugments from Ruby but calls rb_enumeratorize_with_size with a different set of arguments. Notes: Merged: https://github.com/ruby/ruby/pull/2509
2019-09-30test/-ext-/string/test_fstring.rb: suppress "possibly useless use of -@"Yusuke Endoh
"in void context" by assigning the result to a dummy variable.
2019-09-29Add three more C-API functions for handling keywordsJeremy Evans
This adds rb_funcall_passing_block_kw, rb_funcallv_public_kw, and rb_yield_splat_kw. This functions are necessary to easily handle cases where rb_funcall_passing_block, rb_funcallv_public, and rb_yield_splat are currently used and a keyword argument separation warning is raised. Notes: Merged: https://github.com/ruby/ruby/pull/2507
2019-09-26[EXPERIMENTAL] Make Symbol#to_s return a frozen StringBenoit Daloze
* Always the same frozen String for a given Symbol. * Avoids extra allocations whenever calling Symbol#to_s. * See [Feature #16150] Notes: Merged: https://github.com/ruby/ruby/pull/2437
2019-09-26Tag string shared roots to fix use-after-freeAlan Wu
The buffer deduplication codepath in rb_fstring can be used to free the buffer of shared string roots, which leads to use-after-free. Introudce a new flag to tag strings that at one point have been a shared root. Check for it in rb_fstring to avoid freeing buffers that are shared by multiple strings. This change is based on nobu's idea in [ruby-core:94838]. The included test case test for the sequence of calls to internal functions that lead to this bug. See attached ticket for Ruby level repros. [Bug #16151] Notes: Merged: https://github.com/ruby/ruby/pull/2480
2019-09-25Make rb_scan_args handle keywords more similar to Ruby methods (#2460)Jeremy Evans
Cfuncs that use rb_scan_args with the : entry suffer similar keyword argument separation issues that Ruby methods suffer if the cfuncs accept optional or variable arguments. This makes the following changes to : handling. * Treats as **kw, prompting keyword argument separation warnings if called with a positional hash. * Do not look for an option hash if empty keywords are provided. For backwards compatibility, treat an empty keyword splat as a empty mandatory positional hash argument, but emit a a warning, as this behavior will be removed in Ruby 3. The argument number check needs to be moved lower so it can correctly handle an empty positional argument being added. * If the last argument is nil and it is necessary to treat it as an option hash in order to make sure all arguments are processed, continue to treat the last argument as the option hash. Emit a warning in this case, as this behavior will be removed in Ruby 3. * If splitting the keyword hash into two hashes, issue a warning, as we will not be splitting hashes in Ruby 3. * If the keyword argument is required to fill a mandatory positional argument, continue to do so, but emit a warning as this behavior will be going away in Ruby 3. * If keyword arguments are provided and the last argument is not a hash, that indicates something wrong. This can happen if a cfunc is calling rb_scan_args multiple times, and providing arguments that were not passed to it from Ruby. Callers need to switch to the new rb_scan_args_kw function, which allows passing of whether keywords were provided. This commit fixes all warnings caused by the changes above. It switches some function calls to *_kw versions with appropriate kw_splat flags. If delegating arguments, RB_PASS_CALLED_KEYWORDS is used. If creating new arguments, RB_PASS_KEYWORDS is used if the last argument is a hash to be treated as keywords. In open_key_args in io.c, use rb_scan_args_kw. In this case, the arguments provided come from another C function, not Ruby. The last argument may or may not be a hash, so we can't set keyword argument mode. However, if it is a hash, we don't want to warn when treating it as keywords. In Ruby files, make sure to appropriately use keyword splats or literal keywords when calling Cfuncs that now issue keyword argument separation warnings through rb_scan_args. Also, make sure not to pass nil in place of an option hash. Work around Kernel#warn warnings due to problems in the Rubygems override of the method. There is an open pull request to fix these issues in Rubygems, but part of the Rubygems tests for their override fail on ruby-head due to rb_scan_args not recognizing empty keyword splats, which this commit fixes. Implementation wise, adding rb_scan_args_kw is kind of a pain, because rb_scan_args takes a variable number of arguments. In order to not duplicate all the code, the function internals need to be split into two functions taking a va_list, and to avoid passing in a ton of arguments, a single struct argument is used to handle the variables previously local to the function. Notes: Merged-By: jeremyevans <code@jeremyevans.net>
2019-08-10Warn instance variable `E`Nobuyoshi Nakada
It is not dumped, as it is a short alias for `:encoding`.
2019-08-01fix tracepoint + backtrace SEGV卜部昌平
PC modification in gc_event_hook_body was careless. There are (so to say) abnormal iseqs stored in the cfp. We have to check sanity before we touch the PC. This has not been fixed because there was no way to (ab)use the setup from pure-Ruby. However by using our official C APIs it is possible to touch such frame(s), resulting in SEGV. Fixes [Bug #14834].
2019-07-01Fixed inadvertent ID creation in rb_iv_getNobuyoshi Nakada
2019-06-30Suppress "statement not reached" warningNobuyoshi Nakada
2019-06-30Suppress unused literal warnings in verbose modeNobuyoshi Nakada
2019-06-28Removed unused variablesNobuyoshi Nakada
2019-06-26Resize capacity for fstringJohn Hawthorn
When a string is #frozen, it's capacity is resized to fit (if it is much larger), since we know it will no longer be mutated. > puts ObjectSpace.dump(String.new("a"*30, capacity: 1000)) {"type":"STRING", "class":"0x7feaf00b7bf0", "bytesize":30, "capacity":1000, "value":"... > puts ObjectSpace.dump(String.new("a"*30, capacity: 1000).freeze) {"type":"STRING", "class":"0x7feaf00b7bf0", "frozen":true, "bytesize":30, "value":"... (ObjectSpace.dump doesn't show capacity if capacity is equal to bytesize) Previously, if we dedup into an fstring, using String#-@, capacity would not be reduced. > puts ObjectSpace.dump(-String.new("a"*30, capacity: 1000)) {"type":"STRING", "class":"0x7feaf00b7bf0", "frozen":true, "fstring":true, "bytesize":30, "capacity":1000, "value":"... This commit makes rb_fstring call rb_str_resize, the same as rb_str_freeze does. Closes: https://github.com/ruby/ruby/pull/2256
2019-06-23Get rid of error with frozen string literalNobuyoshi Nakada
[Bug #14194]
2019-06-01Ignore warnings about argument prefix with operator symbol.Hiroshi SHIBATA
2019-05-10Adjust indentNobuyoshi Nakada
2019-05-09str_duplicate: Don't share with a frozen shared stringAlan Wu
This is a follow up for 3f9562015e651735bfc2fdd14e8f6963b673e22a. Before this commit, it was possible to create a shared string which shares with another shared string by passing a frozen shared string to `str_duplicate`. Such string looks like: ``` -------- ----------------- | root | ------ owns -----> | root's buffer | -------- ----------------- ^ ^ ^ ----------- | | | shared1 | ------ references ----- | ----------- | ^ | ----------- | | shared2 | ------ references --------- ----------- ``` This is bad news because `rb_fstring(shared2)` can make `shared1` independent, which severs the reference from `shared1` to `root`: ```c /* from fstr_update_callback() */ str = str_new_frozen(rb_cString, shared2); /* can return shared1 */ if (STR_SHARED_P(str)) { /* shared1 is also a shared string */ str_make_independent(str); /* no frozen check */ } ``` If `shared1` was the only reference to `root`, then `root` can be reclaimed by the GC, leaving `shared2` in a corrupted state: ``` ----------- -------------------- | shared1 | -------- owns --------> | shared1's buffer | ----------- -------------------- ^ | ----------- ------------------------- | shared2 | ------ references ----> | root's buffer (freed) | ----------- ------------------------- ``` Here is a reproduction script for the situation this commit fixes. ```ruby a = ('a' * 24).strip.freeze.strip -a p a 4.times { GC.start } p a ``` - string.c (str_duplicate): always share with the root string when the original is a shared string. - test_rb_str_dup.rb: specifically test `rb_str_dup` to make sure it does not try to share with a shared string. [Bug #15792] Closes: https://github.com/ruby/ruby/pull/2159
2019-03-11The combination of non-Symbol keys and Symbol keys is now allowed againmame
Revert r64358. [Bug #15658] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-11numeric.c: fix infinite loopnobu
* numeric.c (int_pow): fix infinite loop in the case of y equal 1 and power of x does not overflow. [ruby-core:91734] [Bug #15651] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-06Symbol creation is not a problem now unless pinned downnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-04introduce rb_nogvl C-API to mark ubf as async-signal-safenormal
zlib and bignum both contain unblocking functions which are async-signal-safe and do not require spawning additional threads. We can execute those functions directly in signal handlers without incurring overhead of extra threads, so provide C-API users the ability to deal with that. Other C-API users may have similar need. This flexible API can supercede existing uses of rb_thread_call_without_gvl and rb_thread_call_without_gvl2 by introducing a flags argument to control behavior. Note: this API is NOT finalized. It needs approval from other committers. I prefer shorter name than previous rb_thread_call_without_gvl* functions because my eyes requires big fonts. [Bug #15499] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-29test_iseq_load.rb: increase timeout for stressful roundtripk0kubun
Even 60s is short for our CI environments: https://rubyci.org/logs/rubyci.s3.amazonaws.com/amazon/ruby-trunk/log/20181228T153002Z.fail.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66626 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-28test_iseq_load.rb: increase timeout for RubyCIk0kubun
https://rubyci.org/logs/rubyci.s3.amazonaws.com/arch/ruby-trunk/log/20181228T090001Z.fail.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-12Add test cases of rb_arithmetic_sequence_extractmrkn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-06Show diff in failure messagesnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-22revisit more MJIT test skipsk0kubun
r65308 passed both trunk-mjit and trunk-mjit-wait CIs. MJIT copy job looks working fine. Then this commit skips 5 more tests. Some of them were skipped in a very early stage and may still need to be skipped, but I want to confirm them since they haven't been changed for a long time. And this prefers having inline information on `RubyVM::MJIT.enabled?`. This commit makes it easier to confirm whether there's suspicious test skip by RubyVM::MJIT.enabled? or not. After this commit, tentatively we're not skipping tests for MJIT other than `assert_no_memory_leak` ones. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-21revert revert of r65285k0kubun
because CI was actually hitting another one. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65291 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-21revert r65285k0kubun
because it didn't work. Partially leaving "sometimes fail" tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65290 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-21try to remove some test skips for MJITk0kubun
Eric Wong made some effort to keep compatibility around fd with MJIT. Also I'm hoping r65279 (and r65280) eliminates major MJIT bugs, so I want to start solely testing MJIT. Other test skips branched by MJIT enablement seemed reasonable to me. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-21* remove trailing spaces.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-21escape all env properly.ko1
* vm_backtrace.c (rb_debug_inspector_open): escape all env using `rb_vm_stack_to_heap()` before making bindings. [Bug #15105] There is a complicated story of this issue: Without this patch, IFUNC frame does not escaped. A IFUNC frame points to CFUNC ep as previous ep. However, CFUNC ep can be escaped because of making bindings of Ruby level frames. IFUNC's ep can points to invalidated ep and `rb_iter_break()` will fail. This is why `any?` fails. * test/-ext-/debug/test_debug.rb: add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-21Add more assertions for NotImplementedError of instance methodkazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64495 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-14non-symbol keys in kwargsnobu
* class.c (separate_symbol): [EXPERIMENTAL] non-symbol key in keyword arguments hash causes an exception now. c.f. https://twitter.com/yukihiro_matz/status/1022287578995646464 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-13Add some tests for *method_defined?usa
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-13Fix test bugkazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64344 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-13Add test for method_defined?(notimplement)kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-11test_iseq_load.rb: reduce timeout of test_stressful_roundtripk0kubun
We should increase RUBY_TEST_SUBPROCESS_TIMEOUT_SCALE for slow environments, and we configured some CI machines. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-10test_iseq_load.rb: increase timeoutk0kubun
It's timed out on CI like this https://gist.github.com/ko1/33df53d78fbec9e4156c017eeae023bb. I'm not sure how long it would take (it finishes immediately on my machine), so I chose 600s because r64271 says it took 635s on mswinci. (probably it's improved by the commit, though.) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-10Use assert_separately in TestIseqLoad#test_stressful_roundtripnaruse
It takes 635 seconds on mswinci http://mswinci.japaneast.cloudapp.azure.com/vc12-x64/ruby-trunk/log/20180810T061315Z.log.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-20test/-ext-/gvl/test_last_thread.rb: skip under MJITnormal
Spurious wakeup is unavoidable with MJIT; and any real code must be able to deal with spurious wakeup anyways. [ruby-core:87882] https://bugs.ruby-lang.org/issues/14901 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-09Fix crash when loading iseq from an arraytenderlove
Objects loaded during iseq deserialization using arrays need to be added to the compile time mark array so that they stay alive until iseqs finish loading. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-05Move a test fileyui-knk
* test/-ext-/ast/test_ast.rb: This test file has not depended C extension since r63534, so move to 'test/ruby/'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-31Define AST module under RubyVM [experimental]yui-knk
* ext/-test-/ast/ast.c: Rename to ast.c and define AST module under RubyVM. * common.mk: compile ast.c. * ext/-test-/ast/extconf.rb: Don't need this file anymore. * inits.c (rb_call_inits): Call Init_ast to setup AST module. * test/-ext-/ast/test_ast.rb: Follow up the namespace change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-14test_wait_for_single_fd.rb: remove with_pipe helpernormal
IO.pipe natively accepts a block, nowadays. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63422 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-14test_wait_for_single_fd: ensure this works with kqueuenormal
Regardless of future features, this needs to work with kqueue descriptors across platforms. Today this will be useful for 3rd-party libraries using kqueue. In the future, Ruby may use kqueue natively and we shall ensure we can wait on it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e