Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 847286

Summary: =dev-ruby/ffi-1.15.5 on sparc with >=dev-lang/ruby-3: ArgumentError: wrong number of arguments (given 2, expected 1)
Product: Gentoo Linux Reporter: matoro <matoro_bugzilla_gentoo>
Component: Current packagesAssignee: Gentoo Ruby Team <ruby>
Status: RESOLVED FIXED    
Severity: normal CC: matoro_bugzilla_gentoo, sparc, xtkoba
Priority: Normal Keywords: PATCH
Version: unspecified   
Hardware: Sparc   
OS: Linux   
URL: https://github.com/ffi/ffi/pull/957
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: build.log
dev-ruby/ffi-1.15.5: Reproduce #847286 on major platforms

Description matoro archtester 2022-05-24 17:53:17 UTC
=dev-ruby/ffi-1.15.5 fails to compile for me on sparc with any ruby3x release.  It does build fine on ruby2x.  ~dev-ruby/ffi-1.14.2 does not support ruby3x so it can't be tested.

Manually modified the ebuild to add --trace to rake command in order to get a more detailed traceback:

** Invoke default (first_time)
** Invoke /var/tmp/portage/dev-ruby/ffi-1.15.5/work/ruby31/ffi-1.15.5/lib/ffi/platform/sparcv9-linux/types.conf (first_time)
** Execute /var/tmp/portage/dev-ruby/ffi-1.15.5/work/ruby31/ffi-1.15.5/lib/ffi/platform/sparcv9-linux/types.conf
rake aborted!
ArgumentError: wrong number of arguments (given 2, expected 1)
/usr/lib64/ruby/3.1.0/fileutils.rb:206:in `mkdir_p'
/var/tmp/portage/dev-ruby/ffi-1.15.5/work/ruby31/ffi-1.15.5/gen/Rakefile:12:in `block in <top (required)>'
/usr/lib64/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/usr/lib64/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/usr/lib64/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/usr/lib64/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/usr/lib64/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/usr/lib64/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/usr/lib64/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:243:in `block in invoke_prerequisites'
/usr/lib64/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:241:in `each'
/usr/lib64/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:241:in `invoke_prerequisites'
/usr/lib64/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
/usr/lib64/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/usr/lib64/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/usr/lib64/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/usr/lib64/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/usr/lib64/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/usr/lib64/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/usr/lib64/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/usr/lib64/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/usr/lib64/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/usr/lib64/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:83:in `block in run'
/usr/lib64/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/usr/lib64/ruby/gems/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:80:in `run'
/usr/lib64/ruby/gems/3.1.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/usr/bin/rake:9:in `load'
/usr/bin/rake:9:in `<main>'
Tasks: TOP => default => /var/tmp/portage/dev-ruby/ffi-1.15.5/work/ruby31/ffi-1.15.5/lib/ffi/platform/sparcv9-linux/types.conf

This seems to be somehow related to https://github.com/ruby/fileutils/commit/482de6d397742526d1111576e2791f9b7051e3c0 which changed the fileutils module to take keyword arguments.  From my perspective, it looks like this traceback is correct, and this should not be valid Ruby 3.x.  However this issue does not reproduce on any other (little-endian) architecture that I have.

Reproducible: Always




Portage 3.0.30 (python 3.10.4-final-0, default/linux/sparc/17.0/64ul, gcc-12.1.0, glibc-2.35-r5, 5.18.0-gentoo-sparc64 sparc64)
=================================================================
System uname: Linux-5.18.0-gentoo-sparc64-sparc64-sun4v-with-glibc2.35
KiB Mem:    32683776 total,  28261720 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Mon, 23 May 2022 16:33:07 +0000
Head commit of repository gentoo: a0f58cba71636bd0532c4c80449079bf13fd6613

sh bash 5.1_p16
ld GNU ld (Gentoo 2.38 p4) 2.38
app-misc/pax-utils:        1.3.4::gentoo
app-shells/bash:           5.1_p16::gentoo
dev-lang/perl:             5.34.1-r3::gentoo
dev-lang/python:           3.10.4_p1::gentoo
dev-util/cmake:            3.23.1::gentoo
dev-util/meson:            0.62.1::gentoo
sys-apps/baselayout:       2.8::gentoo
sys-apps/openrc:           0.44.10::gentoo
sys-apps/sandbox:          2.29::gentoo
sys-devel/autoconf:        2.71-r1::gentoo
sys-devel/automake:        1.16.5::gentoo
sys-devel/binutils:        2.38-r2::gentoo
sys-devel/binutils-config: 5.4.1::gentoo
sys-devel/gcc:             12.1.0::gentoo
sys-devel/gcc-config:      2.5-r1::gentoo
sys-devel/libtool:         2.4.7::gentoo
sys-devel/make:            4.3::gentoo
sys-kernel/linux-headers:  5.17-r1::gentoo (virtual/os-headers)
sys-libs/glibc:            2.35-r5::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/gentoo
    sync-user: portage:portage
    priority: -1000
    sync-git-verify-commit-signature: yes

guru
    location: /var/lib/layman/guru
    sync-type: laymansync
    sync-uri: https://anongit.gentoo.org/git/repo/proj/guru.git
    masters: gentoo
    priority: 50

ACCEPT_KEYWORDS="sparc ~sparc"
ACCEPT_LICENSE="@FREE"
CBUILD="sparc64-unknown-linux-gnu"
CFLAGS="-O3 -mcpu=native -mtune=native -pipe"
CHOST="sparc64-unknown-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-O3 -mcpu=native -mtune=native -pipe"
DISTDIR="/var/cache/distfiles"
EMERGE_DEFAULT_OPTS="--usepkg --autounmask=n --complete-graph --keep-going --with-bdeps=y"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS=""
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs buildpkg buildpkg-live compress-build-logs compressdebug config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync network-sandbox news parallel-install pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O3 -mcpu=native -mtune=native -pipe"
GENTOO_MIRRORS="https://gentoo.osuosl.org/ https://mirror.leaseweb.com/gentoo/ https://mirror.rackspace.com/gentoo/"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j56"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
SHELL="/bin/bash"
USE="acl bash-completion big-endian bzip2 caps cli crypt dri elogind fortran gdbm gentoo-vm graphite headless-awt iconv ipv6 libbsd libglvnd libtirpc llvm-libunwind lto ncurses nls nptl openmp pam pcre pgo readline sparc split-usr ssl symlink threads udev unicode verify-sig vhosts vim-syntax xattr zlib" ADA_TARGET="gnat_2020" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-4 php8-0" POSTGRES_TARGETS="postgres12 postgres13" PYTHON_SINGLE_TARGET="python3_10" PYTHON_TARGETS="python3_10" RUBY_TARGETS="ruby31" USERLAND="GNU" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LEX, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS
Comment 1 matoro archtester 2022-05-24 17:53:54 UTC
Created attachment 780572 [details]
build.log
Comment 2 Tee KOBAYASHI 2022-05-25 03:17:25 UTC
Created attachment 780578 [details, diff]
dev-ruby/ffi-1.15.5: Reproduce #847286 on major platforms

This does not happen on "major" platforms for which the pre-generated types.conf exists under lib/ffi/platform/. With the attached patch applied to the ebuild file, this reproduces on my x86_64-linux-gnu environment.

Fix should be fairly straightforward.
Comment 3 matoro archtester 2022-05-25 13:48:13 UTC
(In reply to Tee KOBAYASHI from comment #2)
> Created attachment 780578 [details, diff] [details, diff]
> dev-ruby/ffi-1.15.5: Reproduce #847286 on major platforms
> 
> This does not happen on "major" platforms for which the pre-generated
> types.conf exists under lib/ffi/platform/. With the attached patch applied
> to the ebuild file, this reproduces on my x86_64-linux-gnu environment.
> 
> Fix should be fairly straightforward.

Thanks, this is interesting because there is actually a pregenerated types.conf at lib/ffi/platform/sparc64-linux, unless I'm missing something?
Comment 4 Tee KOBAYASHI 2022-05-25 17:38:23 UTC
(In reply to matoro from comment #3)
> Thanks, this is interesting because there is actually a pregenerated
> types.conf at lib/ffi/platform/sparc64-linux, unless I'm missing something?

See the build log. The build system is trying to generate lib/ffi/platform/sparcv9-linux/types.conf which does not exist. I do not know whether it is an expected or unexpected behavior to use "sparcv9-linux" as the target name instead of "sparc64-linux".
Comment 5 matoro archtester 2022-05-25 18:21:58 UTC
(In reply to Tee KOBAYASHI from comment #4)
> (In reply to matoro from comment #3)
> > Thanks, this is interesting because there is actually a pregenerated
> > types.conf at lib/ffi/platform/sparc64-linux, unless I'm missing something?
> 
> See the build log. The build system is trying to generate
> lib/ffi/platform/sparcv9-linux/types.conf which does not exist. I do not
> know whether it is an expected or unexpected behavior to use "sparcv9-linux"
> as the target name instead of "sparc64-linux".

Thanks, that was the clue I needed!  In https://github.com/ffi/ffi/pull/575 , sparc64 was changed to sparcv9, but the directory in lib/ffi/platform was never renamed.  Sending a patch upstream shortly.
Comment 6 matoro archtester 2022-06-14 14:25:50 UTC
(In reply to Tee KOBAYASHI from comment #4)
> (In reply to matoro from comment #3)
> > Thanks, this is interesting because there is actually a pregenerated
> > types.conf at lib/ffi/platform/sparc64-linux, unless I'm missing something?
> 
> See the build log. The build system is trying to generate
> lib/ffi/platform/sparcv9-linux/types.conf which does not exist. I do not
> know whether it is an expected or unexpected behavior to use "sparcv9-linux"
> as the target name instead of "sparc64-linux".

There is one more issue, even after fixing this, two of the tests are failing and I'm not quite sure why.

Failures:

  1) Callback interop from ffi to ffi
     Failure/Error: LibTestFFI.testCallbackVrV(FFI::Pointer.new(func.to_i))
     
     RangeError:
       bignum too big to convert into `long long'
     # ./spec/ffi/callback_spec.rb:883:in `initialize'
     # ./spec/ffi/callback_spec.rb:883:in `new'
     # ./spec/ffi/callback_spec.rb:883:in `block (3 levels) in <module:CallbackInteropSpecs>'
     # ./spec/ffi/callback_spec.rb:872:in `assert_callback_in_same_thread_called_once'
     # ./spec/ffi/callback_spec.rb:881:in `block (2 levels) in <module:CallbackInteropSpecs>'

  2) Callback interop from ffi to ffi with blocking:true
     Failure/Error: LibTestFFI.testCallbackVrV_blocking(FFI::Pointer.new(func.to_i))
     
     RangeError:
       bignum too big to convert into `long long'
     # ./spec/ffi/callback_spec.rb:890:in `initialize'
     # ./spec/ffi/callback_spec.rb:890:in `new'
     # ./spec/ffi/callback_spec.rb:890:in `block (3 levels) in <module:CallbackInteropSpecs>'
     # ./spec/ffi/callback_spec.rb:872:in `assert_callback_in_same_thread_called_once'
     # ./spec/ffi/callback_spec.rb:888:in `block (2 levels) in <module:CallbackInteropSpecs>'

Finished in 6.9 seconds (files took 18.85 seconds to load)
4944 examples, 2 failures

Failed examples:

rspec ./spec/ffi/callback_spec.rb:880 # Callback interop from ffi to ffi
rspec ./spec/ffi/callback_spec.rb:887 # Callback interop from ffi to ffi with blocking:true


I added a debug print line to print the value of the function pointer that FFI generates and it gives:

#<FFI::Function address=0xfff80001000d4000 size=48>

which definitely seems wrong, that address is indeed outside the 64-bit range - I don't know how it's possible to even generate that.  Would you happen to have any idea?
Comment 7 matoro archtester 2022-06-17 20:58:19 UTC
Fixed upstream with https://github.com/ffi/ffi/pull/962.  When combined with my changes in https://github.com/ffi/ffi/pull/957, everything checks out.  Will include this in my Ruby work in https://github.com/gentoo/gentoo/pull/25906.
Comment 8 Larry the Git Cow gentoo-dev 2022-10-22 21:33:53 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4cf664faf645b70935eaee5124eb2a13e35edc44

commit 4cf664faf645b70935eaee5124eb2a13e35edc44
Author:     matoro <matoro@users.noreply.github.com>
AuthorDate: 2022-06-15 04:29:18 +0000
Commit:     Matt Turner <mattst88@gentoo.org>
CommitDate: 2022-10-22 21:33:10 +0000

    dev-ruby/ffi: revbump 1.15.5-r1, fix sparc
    
    See: https://github.com/ffi/ffi/pull/957
    Closes: https://bugs.gentoo.org/847286
    Signed-off-by: matoro <matoro@users.noreply.github.com>
    Signed-off-by: Matt Turner <mattst88@gentoo.org>

 dev-ruby/ffi/ffi-1.15.5-r1.ebuild        | 71 ++++++++++++++++++++++++++++++++
 dev-ruby/ffi/files/backport-pr-962.patch | 48 +++++++++++++++++++++
 dev-ruby/ffi/files/pr-957-sparc.patch    | 42 +++++++++++++++++++
 3 files changed, 161 insertions(+)