Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into dev/gc-mmtk
Browse files Browse the repository at this point in the history
  • Loading branch information
peterzhu2118 committed Oct 15, 2024
2 parents 42ed00c + f45eb3d commit f9afff4
Show file tree
Hide file tree
Showing 32 changed files with 266 additions and 271 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ jobs:
run: sudo rm /usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb

- name: Initialize CodeQL
uses: github/codeql-action/init@c36620d31ac7c881962c3d9dd939c40ec9434f2b # v3.26.12
uses: github/codeql-action/init@f779452ac5af1c261dce0346a8f964149f49322b # v3.26.13
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@c36620d31ac7c881962c3d9dd939c40ec9434f2b # v3.26.12
uses: github/codeql-action/autobuild@f779452ac5af1c261dce0346a8f964149f49322b # v3.26.13

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@c36620d31ac7c881962c3d9dd939c40ec9434f2b # v3.26.12
uses: github/codeql-action/analyze@f779452ac5af1c261dce0346a8f964149f49322b # v3.26.13
with:
category: '/language:${{ matrix.language }}'
upload: False
Expand Down Expand Up @@ -115,7 +115,7 @@ jobs:
continue-on-error: true

- name: Upload SARIF
uses: github/codeql-action/upload-sarif@c36620d31ac7c881962c3d9dd939c40ec9434f2b # v3.26.12
uses: github/codeql-action/upload-sarif@f779452ac5af1c261dce0346a8f964149f49322b # v3.26.13
with:
sarif_file: sarif-results/${{ matrix.language }}.sarif
continue-on-error: true
2 changes: 1 addition & 1 deletion .github/workflows/scorecards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: 'Upload to code-scanning'
uses: github/codeql-action/upload-sarif@c36620d31ac7c881962c3d9dd939c40ec9434f2b # v3.26.12
uses: github/codeql-action/upload-sarif@f779452ac5af1c261dce0346a8f964149f49322b # v3.26.13
with:
sarif_file: results.sarif
25 changes: 0 additions & 25 deletions LEGAL
Original file line number Diff line number Diff line change
Expand Up @@ -702,31 +702,6 @@ mentioned below.
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.

[ext/json/generator/generator.c]

The file contains the following copyright notice.

>>>
Copyright 2001-2004:: Unicode, Inc.

Disclaimer::

This source code is provided as is by Unicode, Inc. No claims are
made as to fitness for any particular purpose. No warranties of any
kind are expressed or implied. The recipient agrees to determine
applicability of information provided. If this file has been
purchased on magnetic or optical media from Unicode, Inc., the
sole remedy for any claim will be exchange of defective media
within 90 days of receipt.

Limitations on Rights to Redistribute This Code::

Unicode, Inc. hereby grants the right to freely use the information
supplied in this file in the creation of products supporting the
Unicode Standard, and to make copies of this file in any form
for internal or external distribution as long as this notice
remains attached.

[ext/psych]
[test/psych]

Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ The following bundled gems are updated.
* rexml 3.3.8
* rss 0.3.1
* net-ftp 0.3.8
* net-imap 0.4.16
* net-imap 0.4.17
* net-smtp 0.5.0
* rbs 3.6.1
* typeprof 0.21.11
Expand Down
45 changes: 25 additions & 20 deletions array.c
Original file line number Diff line number Diff line change
Expand Up @@ -1512,35 +1512,40 @@ rb_ary_shift(VALUE ary)

/*
* call-seq:
* array.shift -> object or nil
* array.shift(n) -> new_array
* shift -> object or nil
* shift(count) -> new_array or nil
*
* Removes and returns leading elements.
* Removes and returns leading elements from +self+.
*
* When no argument is given, removes and returns the first element:
* With no argument, removes and returns one element, if available,
* or +nil+ otherwise:
*
* a = [:foo, 'bar', 2]
* a.shift # => :foo
* a # => ['bar', 2]
*
* Returns +nil+ if +self+ is empty.
* a = [0, 1, 2, 3]
* a.shift # => 0
* a # => [1, 2, 3]
* [].shift # => nil
*
* When positive Integer argument +n+ is given, removes the first +n+ elements;
* returns those elements in a new +Array+:
* With non-negative numeric argument +count+ given,
* removes and returns the first +count+ elements:
*
* a = [:foo, 'bar', 2]
* a.shift(2) # => [:foo, 'bar']
* a # => [2]
* a = [0, 1, 2, 3]
* a.shift(2) # => [0, 1]
* a # => [2, 3]
* a.shift(1.1) # => [2]
* a # => [3]
* a.shift(0) # => []
* a # => [3]
*
* If +n+ is as large as or larger than <tt>self.length</tt>,
* removes all elements; returns those elements in a new +Array+:
* If +count+ is large,
* removes and returns all elements:
*
* a = [:foo, 'bar', 2]
* a.shift(3) # => [:foo, 'bar', 2]
* a = [0, 1, 2, 3]
* a.shift(50) # => [0, 1, 2, 3]
* a # => []
*
* If +n+ is zero, returns a new empty +Array+; +self+ is unmodified.
* If +self+ is empty, returns a new empty array.
*
* Related: #push, #pop, #unshift.
* Related: see {Methods for Deleting}[rdoc-ref:Array@Methods+for+Deleting].
*/

static VALUE
Expand Down
24 changes: 17 additions & 7 deletions array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,25 @@ def each
end

# call-seq:
# array.shuffle!(random: Random) -> array
# shuffle!(random: Random) -> self
#
# Shuffles the elements of +self+ in place.
# a = [1, 2, 3] #=> [1, 2, 3]
# a.shuffle! #=> [2, 3, 1]
# a #=> [2, 3, 1]
# Shuffles all elements in +self+ into a random order,
# as selected by the object given by keyword argument +random+;
# returns +self+:
#
# The optional +random+ argument will be used as the random number generator:
# a.shuffle!(random: Random.new(1)) #=> [1, 3, 2]
# a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
# a.shuffle! # => [5, 3, 8, 7, 6, 1, 9, 4, 2, 0]
# a.shuffle! # => [9, 4, 0, 6, 2, 8, 1, 5, 3, 7]
#
# Duplicate elements are included:
#
# a = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]
# a.shuffle! # => [1, 0, 0, 1, 1, 0, 1, 0, 0, 1]
# a.shuffle! # => [0, 1, 0, 1, 1, 0, 1, 0, 1, 0]
#
# The object given with keyword argument +random+ is used as the random number generator.
#
# Related: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
def shuffle!(random: Random)
Primitive.rb_ary_shuffle_bang(random)
end
Expand Down
8 changes: 4 additions & 4 deletions bootstraptest/test_yjit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def test(name, args)

# regression test for GC marking stubs in invalidated code
assert_normal_exit %q{
skip true unless defined?(GC.compact)
skip true unless GC.respond_to?(:compact)
garbage = Array.new(10_000) { [] } # create garbage to cause iseq movement
eval(<<~RUBY)
def foo(n, garbage)
Expand Down Expand Up @@ -158,7 +158,7 @@ def call_foo = foo(0, 1, 2, 3, &->{})

# regression test for invokeblock iseq guard
assert_equal 'ok', %q{
skip :ok unless defined?(GC.compact)
skip :ok unless GC.respond_to?(:compact)
def foo = yield
10.times do |i|
ret = eval("foo { #{i} }")
Expand Down Expand Up @@ -1230,7 +1230,7 @@ def special.[](idx)

# Test that object references in generated code get marked and moved
assert_equal "good", %q{
skip :good unless defined?(GC.compact)
skip :good unless GC.respond_to?(:compact)
def bar
"good"
end
Expand Down Expand Up @@ -2351,7 +2351,7 @@ def foo(obj)

# Test EP == BP invalidation with moving ISEQs
assert_equal 'ok', %q{
skip :ok unless defined?(GC.compact)
skip :ok unless GC.respond_to?(:compact)
def entry
ok = proc { :ok } # set #entry as an EP-escaping ISEQ
[nil].reverse_each do # avoid exiting the JIT frame on the constant
Expand Down
4 changes: 3 additions & 1 deletion ext/json/json.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ Gem::Specification.new do |s|
s.rdoc_options = ["--title", "JSON implementation for Ruby", "--main", "README.md"]
s.files = [
"CHANGES.md",
"LICENSE",
"COPYING",
"BSDL",
"LEGAL",
"README.md",
"ext/json/ext/fbuffer/fbuffer.h",
"ext/json/ext/generator/depend",
Expand Down
23 changes: 12 additions & 11 deletions ext/socket/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,11 @@ rsock_socket(int domain, int type, int proto)

/* emulate blocking connect behavior on EINTR or non-blocking socket */
static int
wait_connectable(int fd, struct timeval *timeout)
wait_connectable(VALUE self, VALUE timeout)
{
int sockerr, revents;
int sockerr;
socklen_t sockerrlen;
int fd = rb_io_descriptor(self);

sockerrlen = (socklen_t)sizeof(sockerr);
if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&sockerr, &sockerrlen) < 0)
Expand Down Expand Up @@ -510,7 +511,13 @@ wait_connectable(int fd, struct timeval *timeout)
*
* Note: rb_wait_for_single_fd already retries on EINTR/ERESTART
*/
revents = rb_wait_for_single_fd(fd, RB_WAITFD_IN|RB_WAITFD_OUT, timeout);
VALUE result = rb_io_wait(self, RB_INT2NUM(RUBY_IO_READABLE|RUBY_IO_WRITABLE), timeout);

if (result == Qfalse) {
rb_raise(rb_eIOTimeoutError, "Connect timed out!");
}

int revents = RB_NUM2INT(result);

if (revents < 0)
return -1;
Expand All @@ -525,12 +532,6 @@ wait_connectable(int fd, struct timeval *timeout)
* be defensive in case some platforms set SO_ERROR on the original,
* interrupted connect()
*/

/* when the connection timed out, no errno is set and revents is 0. */
if (timeout && revents == 0) {
errno = ETIMEDOUT;
return -1;
}
case EINTR:
#ifdef ERESTART
case ERESTART:
Expand Down Expand Up @@ -578,7 +579,7 @@ socks_connect_blocking(void *data)
#endif

int
rsock_connect(VALUE self, const struct sockaddr *sockaddr, int len, int socks, struct timeval *timeout)
rsock_connect(VALUE self, const struct sockaddr *sockaddr, int len, int socks, VALUE timeout)
{
int descriptor = rb_io_descriptor(self);
rb_blocking_function_t *func = connect_blocking;
Expand All @@ -602,7 +603,7 @@ rsock_connect(VALUE self, const struct sockaddr *sockaddr, int len, int socks, s
#ifdef EINPROGRESS
case EINPROGRESS:
#endif
return wait_connectable(descriptor, timeout);
return wait_connectable(self, timeout);
}
}
return status;
Expand Down
9 changes: 1 addition & 8 deletions ext/socket/ipsocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@ init_inetsock_internal(VALUE v)
int family = AF_UNSPEC;
const char *syscall = 0;
VALUE connect_timeout = arg->connect_timeout;
struct timeval tv_storage;
struct timeval *tv = NULL;

if (!NIL_P(connect_timeout)) {
tv_storage = rb_time_interval(connect_timeout);
tv = &tv_storage;
}

arg->remote.res = rsock_addrinfo(arg->remote.host, arg->remote.serv,
family, SOCK_STREAM,
Expand Down Expand Up @@ -130,7 +123,7 @@ init_inetsock_internal(VALUE v)
}

if (status >= 0) {
status = rsock_connect(io, res->ai_addr, res->ai_addrlen, (type == INET_SOCKS), tv);
status = rsock_connect(io, res->ai_addr, res->ai_addrlen, (type == INET_SOCKS), connect_timeout);
syscall = "connect(2)";
}
}
Expand Down
2 changes: 1 addition & 1 deletion ext/socket/rubysocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ VALUE rsock_s_recvfrom_nonblock(VALUE sock, VALUE len, VALUE flg, VALUE str,
VALUE ex, enum sock_recv_type from);
VALUE rsock_s_recvfrom(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from);

int rsock_connect(VALUE self, const struct sockaddr *sockaddr, int len, int socks, struct timeval *timeout);
int rsock_connect(VALUE self, const struct sockaddr *sockaddr, int len, int socks, VALUE timeout);

VALUE rsock_s_accept(VALUE klass, VALUE io, struct sockaddr *sockaddr, socklen_t *len);
VALUE rsock_s_accept_nonblock(VALUE klass, VALUE ex, rb_io_t *fptr,
Expand Down
7 changes: 3 additions & 4 deletions ext/socket/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,16 +387,15 @@ rsock_sock_s_socketpair(int argc, VALUE *argv, VALUE klass)
* * connect function in Microsoft's Winsock functions reference
*/
static VALUE
sock_connect(VALUE sock, VALUE addr)
sock_connect(VALUE self, VALUE addr)
{
VALUE rai;
rb_io_t *fptr;

SockAddrStringValueWithAddrinfo(addr, rai);
addr = rb_str_new4(addr);
GetOpenFile(sock, fptr);

int result = rsock_connect(sock, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_SOCKLEN(addr), 0, NULL);
int result = rsock_connect(self, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_SOCKLEN(addr), 0, RUBY_IO_TIMEOUT_DEFAULT);

if (result < 0) {
rsock_sys_fail_raddrinfo_or_sockaddr("connect(2)", addr, rai);
}
Expand Down
2 changes: 1 addition & 1 deletion ext/socket/udpsocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ udp_connect_internal(VALUE v)
struct addrinfo *res;

for (res = arg->res->ai; res; res = res->ai_next) {
if (rsock_connect(arg->io, res->ai_addr, res->ai_addrlen, 0, NULL) >= 0) {
if (rsock_connect(arg->io, res->ai_addr, res->ai_addrlen, 0, RUBY_IO_TIMEOUT_DEFAULT) >= 0) {
return Qtrue;
}
}
Expand Down
2 changes: 1 addition & 1 deletion ext/socket/unixsocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static VALUE
unixsock_connect_internal(VALUE a)
{
struct unixsock_arg *arg = (struct unixsock_arg *)a;
return (VALUE)rsock_connect(arg->io, (struct sockaddr*)arg->sockaddr, arg->sockaddrlen, 0, NULL);
return (VALUE)rsock_connect(arg->io, (struct sockaddr*)arg->sockaddr, arg->sockaddrlen, 0, RUBY_IO_TIMEOUT_DEFAULT);
}

static VALUE
Expand Down
4 changes: 2 additions & 2 deletions ext/zlib/zlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1521,7 +1521,7 @@ rb_zstream_total_out(VALUE obj)
}

/*
* Guesses the type of the data which have been inputed into the stream. The
* Guesses the type of the data which have been inputted into the stream. The
* returned value is either <tt>BINARY</tt>, <tt>ASCII</tt>, or
* <tt>UNKNOWN</tt>.
*/
Expand Down Expand Up @@ -4054,7 +4054,7 @@ rb_gzreader_read(int argc, VALUE *argv, VALUE obj)
* call-seq:
* gzipreader.readpartial(maxlen [, outbuf]) => string, outbuf
*
* Reads at most <i>maxlen</i> bytes from the gziped stream but
* Reads at most <i>maxlen</i> bytes from the gzipped stream but
* it blocks only if <em>gzipreader</em> has no data immediately available.
* If the optional <i>outbuf</i> argument is present,
* it must reference a String, which will receive the data.
Expand Down
2 changes: 1 addition & 1 deletion gems/bundled_gems
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test-unit 3.6.2 https://github.com/test-unit/test-unit
rexml 3.3.8 https://github.com/ruby/rexml
rss 0.3.1 https://github.com/ruby/rss
net-ftp 0.3.8 https://github.com/ruby/net-ftp
net-imap 0.4.16 https://github.com/ruby/net-imap
net-imap 0.4.17 https://github.com/ruby/net-imap
net-pop 0.1.2 https://github.com/ruby/net-pop
net-smtp 0.5.0 https://github.com/ruby/net-smtp
matrix 0.4.2 https://github.com/ruby/matrix
Expand Down
12 changes: 6 additions & 6 deletions lib/bundler/rubygems_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -384,13 +384,13 @@ def extensions_dir
end
end

remove_method :ignored? if new.respond_to?(:ignored?)
# Can be removed once RubyGems 3.5.22 support is dropped
unless new.respond_to?(:ignored?)
def ignored?
return @ignored unless @ignored.nil?

# Same as RubyGems, but without warnings, because Bundler prints its own warnings
def ignored?
return @ignored unless @ignored.nil?

@ignored = missing_extensions?
@ignored = missing_extensions?
end
end
end

Expand Down
Loading

0 comments on commit f9afff4

Please sign in to comment.