58358 Commits

Author SHA1 Message Date
Kazuhiro NISHIYAMA
d6e68bb263
Use warn with uplevel: instead of caller 2019-10-12 13:25:52 +09:00
git
f6a666a1fc * 2019-10-12 [ci skip] 2019-10-12 12:07:36 +09:00
Sutou Kouhei
412cd56766
Import REXML 3.2.3 (#2548) 2019-10-12 12:07:15 +09:00
Yusuke Endoh
c866663784 io.c (NUM2IOCTLREQ): Accept a value more than INT_MAX
ioctl accepts int as request arguments on some platforms, but some
requests are more than INT_MAX, e.g., RNDGETENTCNT(0x80045200).
Passing (0x80045200 | (-1 << 32)) may work around the issue, but it may
not work on a platform where ioctl accepts unsigned long.  So this
change uses NUM2LONG and then casts it to int.
2019-10-11 21:43:18 +09:00
Yusuke Endoh
9e4a53fe13 test/ruby/test_rubyoptions.rb (test_encoding): skipped on Android
On Android, nl_langinfo() always returns UTF-8 even when LANG is C.
2019-10-11 21:39:21 +09:00
Yusuke Endoh
f3c4e620ac test/test_syslog.rb (test_log): skipped on Android
On Android 28, LOG_PERROR is defined, but not implemented yet.
This change skips Syslog#log explicitly.
2019-10-11 21:13:52 +09:00
Kazuhiro NISHIYAMA
d6c80876b7
Use bind_call instead of bind and call 2019-10-11 13:50:27 +09:00
Gabriel Nagy
ddfb306e8e win32.c: Remove unused calls to StartSockets (#2312)
NtSocketsInitialized behavior changed in e33b1690, requiring
a call to rb_w32_sysinit for starting Windows Sockets.

This commit removes NtSocketsInitialized entirely to avoid confusion.

Signed-off-by: Gabriel Nagy <gabriel.nagy@puppet.com>
2019-10-11 13:48:02 +09:00
ksss
7cc1cd3d1e Module#define_method: Add UnboundMethod to expected classes 2019-10-11 11:20:11 +09:00
Lourens Naudé
9c24ce551d Reduce the minimum string buffer size from 127 to 63 bytes 2019-10-11 11:16:16 +09:00
Lourens Naudé
0ca4f74967 Right size the numtable in insn_make_insn_table to VM_INSTRUCTION_SIZE 2019-10-11 11:15:43 +09:00
takkanm
87958520f3 set real path to __FILE__ and __dir__ in Binding#irb
When reading Binding#irb, the file of the calling source is reflected in __FILE__ and __dir__.
2019-10-11 09:33:25 +09:00
Jeremy Evans
29c1e9a0d4 Document the difference between expressions and statements [ci skip]
In the grammar, all expressions are statements, but not all
statements are expressions.  Some parts of the grammar accept
expressions and not other types of statements, which causes
similar looking code to parse differently due to operator
precedence.

Mostly from Dan0042 (Daniel DeLorme).

Fixes [Bug #16092]
2019-10-10 13:45:19 -07:00
git
ddb0267e76 * 2019-10-11 [ci skip] 2019-10-11 05:15:28 +09:00
Jeremy Evans
2322c94dd6 Support delegates for BasicObject
For BasicObject, bind the Kernel respond_to? instance method to the
object and call it instead of calling the method directly.

Also, use bind_call(recv, ...) for better performance.

Fixes [Bug #16127]
2019-10-10 13:15:00 -07:00
Yusuke Endoh
4171909695 mjit_worker.c: Add -lm to the C compiler in MJIT on Android
To avoid:

    cannot locate symbol "modf" referenced by .../_ruby_mjit_XXX.so"
2019-10-10 23:22:37 +09:00
Yusuke Endoh
f845e1bc99 ext/syslog/extconf.rb: add -llog for Android
Otherwise, requiring syslog results in:

    cannot locate symbol "__android_log_print" referenced by "syslog.so"
2019-10-10 23:21:24 +09:00
Yusuke Endoh
a886d5cb79 test/ruby/test_file_exhaustive.rb: check the owner of the root directory
The root directory may be owned by the current user, for example, in
chroot environment.
2019-10-10 23:18:44 +09:00
Nobuyoshi Nakada
c144d7215b
Skip very time consuming test [Bug #16196] 2019-10-10 21:02:45 +09:00
Nobuyoshi Nakada
9c0cd5c569
Prefer rb_gc_register_mark_object
* ext/openssl/ossl_asn1.c (Init_ossl_asn1): prefer
  `rb_gc_register_mark_object`, which is better for constant
  objects, over `rb_gc_register_address` for global/static
  variables which can be re-assigned at runtime.  [Bug #16196]
2019-10-10 19:59:21 +09:00
Nobuyoshi Nakada
0131fab749
Slimed down test runtime by stressing openssl.so only [Bug #16196] 2019-10-10 19:59:21 +09:00
卜部昌平
3f413896c3 forgot to delete unused #incude line 2019-10-10 18:15:33 +09:00
卜部昌平
2d393bf125 guard rb_fatal against non-GVL call
Suggested by ko1.  rb_fatal requires GVL so just in case one lacks,
print that information and let the process die.  As commented,
we cannot print the given messages on such situations.
2019-10-10 17:49:31 +09:00
卜部昌平
f1ce4897f2 make rb_raise a GVL-only function again
Requested by ko1 that ability of calling rb_raise from anywhere
outside of GVL is "too much".  Give up that part, move the GVL
aquisition routine into gc.c, and make our new gc_raise().
2019-10-10 17:10:21 +09:00
卜部昌平
d96f04d73a add "[FATAL]" marker on abort
Indicate that the situation is fatal.
2019-10-10 17:10:21 +09:00
Kazuhiro NISHIYAMA
0b26f56a77
Remove unreachable step level [ci skip] 2019-10-10 16:48:26 +09:00
Nobuyoshi Nakada
203b7fa1ae
Guard static variable first
* ext/openssl/ossl_asn1.c (Init_ossl_asn1): register the static
  variable to grab an internal object, before creating the object.
  otherwise the just-created object could get collected during the
  global variable list allocation.  [Bug #16196]
2019-10-10 16:25:28 +09:00
Nobuyoshi Nakada
6f522455bf [rubygems/rubygems] Do not compare with unreliable Gem::Specification::TODAY
https://gist.github.com/ko1/a88834d744a0682711dab53fd9015a04#file-brlog-trunk-nopara-20191005-235153-L393-L472

https://github.com/rubygems/rubygems/commit/707408d8e7
2019-10-10 14:51:48 +09:00
Nobuyoshi Nakada
dc2b301994 [rubygems/rubygems] Restrict possible date range
https://github.com/rubygems/rubygems/commit/1bd77f53df
2019-10-10 14:51:47 +09:00
Jean Boussier
717b72a8af [rubygems/rubygems] Optimize Gem::Package::TarReader#each
https://github.com/rubygems/rubygems/commit/1de8f39ac4
2019-10-10 14:51:45 +09:00
Nobuyoshi Nakada
495ebd6e95
Now error.o needs thread.h 2019-10-10 14:21:29 +09:00
Nobuyoshi Nakada
c2065c64cb
Fixed numbered parameter check
* parse.y (struct local_vars): moved numbered parameter NODEs for
  nesting check to separate per local variable scopes, as numbered
  parameters should belong to local variable scopes.  [Bug #16248]
2019-10-10 14:07:45 +09:00
Nobuyoshi Nakada
a23b639050
negative_size_allocation_error never returns 2019-10-10 14:07:45 +09:00
卜部昌平
9c3153e0da allow rb_raise from outside of GVL
Now that allocation routines like ALLOC_N() can raise exceptions
on integer overflows.  This is a problem when the calling thread
has no GVL.  Memory allocations has been allowed without it, but
can still fail.

Let's just relax rb_raise's restriction so that we can call it
with or without GVL.  With GVL the behaviour is unchanged.  With
no GVL, wait for it.

Also, integer overflows can theoretically occur during GC when
we expand the object space.  We cannot do so much then.  Call
rb_memerror and let that routine abort the process.
2019-10-10 12:07:38 +09:00
Nobuyoshi Nakada
25100c4697
lhs of pattern matching expression of should have a value 2019-10-10 08:53:46 +09:00
Nobuyoshi Nakada
42edb05626
extracted declare_under 2019-10-10 01:08:42 +09:00
Alan Wu
8dc5fe6e89 Simplify rb_define_module_id 2019-10-10 00:59:50 +09:00
git
ecf6c0402e * 2019-10-10 [ci skip] 2019-10-10 00:14:36 +09:00
卜部昌平
9b919885a0 fix memory corruption in old GCC
This typo introduced memory corruption when __builtin_add_overflow
is not available but uint128_t is.  GCC before 5 are one of such
situatins.

See also https://rubyci.org/logs/rubyci.s3.amazonaws.com/opensuseleap/ruby-master/log/20191009T120004Z.log.html.gz
2019-10-10 00:13:30 +09:00
Ben Woosley
bb71a128eb Prefer st_is_member over st_lookup with 0
The st_is_member DEFINE has simpler semantics, for more readable code.
2019-10-09 23:46:50 +09:00
Nobuyoshi Nakada
29e6782f5d
Share ruby_sighandler_t definition 2019-10-09 23:39:58 +09:00
Yusuke Endoh
891cbd66a4 signal.c: save the original sighandlers for fatal signals
On Android, a signal handler that is not SIG_DFL is set by default for
SIGSEGV.  Ruby's install_sighandler inserts Ruby's handler only when the
signal has no handler, so it does not insert Ruby's SEGV report handler,
which caused some test failures.

This changeset forces to install Ruby's handler for some fatal signals
(sigbus, sigsegv, and sigill).  They keep the original handlers, and
call them when the interpreter receives the signals.
2019-10-09 23:22:15 +09:00
Yusuke Endoh
dd477df411 error.c (rb_bug_for_fatal_signal): renamed from rb_bug_context
Just refactoring.

The name "rb_bug_context" is completely unclear for me.
(Can you see that "context" means "machine register context"?)
The context is available only when a fatal signal (sigbus, sigsegv, or
sigill) is received; in fact, the function is used only for fatal
signals.  So, I think the name should be changed.
2019-10-09 23:02:22 +09:00
Yusuke Endoh
b9cf58d2b2 signal.c (ruby_abort): move the definition for refactoring
The three functions for fatal signals, sigbus, sigsegv, and sigill, are
a family.  The definition of ruby_abort had interrupted them for no
reason.  This change just moves the definition after the family.
2019-10-09 22:57:19 +09:00
Kazuhiro NISHIYAMA
6f11c3b335
Check '[ci skip]' at job level 2019-10-09 17:46:05 +09:00
Yusuke Endoh
d0e30fc955 vm_eval.c (rb_adjust_argv_kw_splat): avoid memcpy with zero length
A method call is often with `argc = 1` and `argv = &v` where v is a
VALUE, and some functions shift the arguments by `argc-1` and `argv+1`
(for example, rb_sym_proc_call).  I'm unsure whether it is safe or not
to pass a pointer `argv+1` to memcpy with zero length, but Coverity Scan
complains it.  So this attempts to suppress the warning by explicit
check of the length.
2019-10-09 14:03:04 +09:00
Pavel Valena
b439ee1b8f Remove uselsess shebang
as the file is not executable anyway.
2019-10-09 12:41:41 +09:00
aycabta
12d05537d7 Update required_ruby_version to 2.4.0 2019-10-09 12:25:50 +09:00
Watson
2d001003e4 Improve performance of Array#sum with float elements (#1555)
The declaration of local variable in loop, it will initialize local variable for each run of the loop with clang generated code.
So, it shouldn't declare the local variable in heavy loop.

Array#sum with float elements will be faster around 30%.

* Before
       user     system      total        real
   3.320000   0.010000   3.330000 (  3.336088)

* After
       user     system      total        real
   2.590000   0.010000   2.600000 (  2.602399)

* Test code
require 'benchmark'

Benchmark.bmbm do |x|
  ary = []
  10000.times { ary << Random.rand }

  x.report do
    50000.times do
      ary.sum
    end
  end

end
2019-10-09 12:25:07 +09:00
卜部昌平
a14cc07f2f avoid returning NULL from xrealloc
This changeset is to kill future possibility of bugs similar to
CVE-2019-11932.   The vulnerability occurs when reallocarray(3)
(which is a variant of realloc(3) and roughly resembles our
ruby_xmalloc2()) returns NULL.  In our C API, ruby_xmalloc()
never returns NULL to raise NoMemoryError instead.  ruby_xfree()
does not return NULL by definition.  ruby_xrealloc() on the other
hand, _did_ return NULL, _and_ also raised sometimes.  It is very
confusing.  Let's not do that.  x-series APIs shall raise on
error and shall not return NULL.
2019-10-09 12:12:28 +09:00