Project

General

Profile

Actions

Bug #14425

closed

rb_funcall too strict on extra args

Added by normalperson (Eric Wong) about 6 years ago. Updated about 6 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:85266]

Description

Ruby 2.5 instroduces extra checking for rb_funcall checking,
but apparently it is too strict for some compilers and extra
args should not cause fatal problems (only warnings).

Jeremy first reported this to me in:
https://bogomips.org/kgio-public/20171215053434.GT7579@jeremyevans.local/
but there's apparently hundreds of instances on RubyGems.org alone.

Attached are over 500 gem-codesearch results of latest gems.

/me goes to setup a sid chroot again...


Files

Actions #1

Updated by normalperson (Eric Wong) about 6 years ago

  • Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN to 2.3: DONTNEED, 2.4: DONTNEED, 2.5: REQUIRED
Actions #3

Updated by Anonymous about 6 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r62116.


ruby.h: relax rb_funcall check on extra args for clang

clang 5.+ (tested clang 7.0.0) seems to be attempting division-by-zero
and giving a very large number for static args to rb_funcall.

  • include/ruby/ruby.h (rb_varargs_bad_length): relax check for clang
  • ext/-test-/funcall/funcall.c: renamed from passing_block.c
    define extra_args_name function
  • test/-ext-/funcall/test_funcall.rb: new test
    [ruby-core:85266] [Bug #14425]

From: Eric Wong

Updated by mame (Yusuke Endoh) about 6 years ago

normalperson (Eric Wong) wrote:

Attached are over 500 gem-codesearch results of latest gems.

nitpick: Your query includes rb_funcall2, rb_funcall3, and rb_funcallv which are safe to pass "0, 0".

Updated by normalperson (Eric Wong) about 6 years ago

wrote:

normalperson (Eric Wong) wrote:

Attached are over 500 gem-codesearch results of latest gems.

nitpick: Your query includes rb_funcall2, rb_funcall3, and rb_funcallv which are safe to pass "0, 0".

Oops :x

Btw, I guess this is undefined behavior?
In a standalone case, gcc prints "0", clang prints a randomly high
number. I expected compilation to fail with both compilers.

/* $CC -O2 -Wextra -Wall -o divzero /path/to/this/file.c */
#include <stdio.h>
int main(void)
{
	int a = 0;
	int b = 1;
	int c = a / (a == b);

	printf("%d\n", c);
	return 0;
}

Updated by naruse (Yui NARUSE) about 6 years ago

  • Backport changed from 2.3: DONTNEED, 2.4: DONTNEED, 2.5: REQUIRED to 2.3: DONTNEED, 2.4: DONTNEED, 2.5: DONE

ruby_2_5 r62501 merged revision(s) 62116,62151.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0