Coder Social home page Coder Social logo

Comments (8)

rui314 avatar rui314 commented on July 18, 2024 2

Thank you very much @nehaljwani for finding the flag to reproduce the issue. I submitted fc4aafa so that at least on my machine, mold is now clean with these extra assertions

from mold.

Logarithmus avatar Logarithmus commented on July 18, 2024

from mold.

wezm avatar wezm commented on July 18, 2024

I'm not sure, but to me it looks like mold isn't being linked properly. You probably just have an empty ELF. Please run strip for mold executable and tell what's the resulting size? If it's very small, then likely I'm right.

makepkg automatically strips binaries as part of the build process:

==> Entering fakeroot environment...
==> Starting package()...
install -Dm 755 mold /home/wmoore/Projects/aur.me/mold/pkg/mold/usr/bin/mold
install -m 755 -d /home/wmoore/Projects/aur.me/mold/pkg/mold/usr/lib/mold
install -m 644 mold-wrapper.so /home/wmoore/Projects/aur.me/mold/pkg/mold/usr/lib/mold
install -Dm 644 docs/mold.1 /home/wmoore/Projects/aur.me/mold/pkg/mold/usr/share/man/man1/mold.1
==> Tidying install...
  -> Removing libtool files...
  -> Purging unwanted files...
  -> Removing static library files...
  -> Stripping unneeded symbols from binaries and libraries...
  -> Compressing man and info pages...
==> Checking for packaging issues...
==> Creating package "mold"...
  -> Generating .PKGINFO file...
  -> Generating .BUILDINFO file...
  -> Generating .MTREE file...
  -> Compressing package...
==> Leaving fakeroot environment.
==> Finished making: mold 0.9.1-1 (Sat 03 Jul 2021 10:30:17)

Confirming binary is non-empty and stripping does not alter the binary (as it's already stripped):

$ strip /usr/bin/mold -o /tmp/mold-stripped
$ ls -l /usr/bin/mold /tmp/mold-stripped
.rwxr-xr-x 1.8M root    3 Jul 10:30 /usr/bin/mold
.rwxr-xr-x 1.8M wmoore  3 Jul 11:28 /tmp/mold-stripped
$ sha256sum /usr/bin/mold /tmp/mold-stripped
a57f51bfe05952d0f8953b1714b3cdf47a650944ea372ce395d3a83b1a25fccc  /usr/bin/mold
a57f51bfe05952d0f8953b1714b3cdf47a650944ea372ce395d3a83b1a25fccc  /tmp/mold-stripped

ldd output in case it's useful:

$ ldd /usr/bin/mold
	linux-vdso.so.1 (0x00007ffe75ff1000)
	libcrypto.so.1.1 => /usr/lib/libcrypto.so.1.1 (0x00007fd8adb7d000)
	libtbb.so.2 => /usr/lib/libtbb.so.2 (0x00007fd8adb37000)
	libz.so.1 => /usr/lib/libz.so.1 (0x00007fd8adb1d000)
	libmimalloc.so.2.0 => /usr/lib/libmimalloc.so.2.0 (0x00007fd8ada99000)
	libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007fd8ad883000)
	libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007fd8ad868000)
	libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007fd8ad845000)
	libc.so.6 => /usr/lib/libc.so.6 (0x00007fd8ad679000)
	/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007fd8ae048000)
	libdl.so.2 => /usr/lib/libdl.so.2 (0x00007fd8ad672000)
	librt.so.1 => /usr/lib/librt.so.1 (0x00007fd8ad667000)
	libm.so.6 => /usr/lib/libm.so.6 (0x00007fd8ad523000)

from mold.

rui314 avatar rui314 commented on July 18, 2024

Let me run makepkg in a Docker environment to see if I can reproduce the issue locally. I don't know what that command is exactly doing, but I guess I'd have to investigate the issue by bisecting -- find out differences of plain make and makepkg and identify which step causes a break.

from mold.

rui314 avatar rui314 commented on July 18, 2024

It looks like it's working for me. Here is the config files I made to build mold with makepkg. https://github.com/rui314/aur/tree/master/mold

from mold.

nehaljwani avatar nehaljwani commented on July 18, 2024

One can replicate this problem with: make EXTRA_CPPFLAGS="-Wp,-D_GLIBCXX_ASSERTIONS"

Many modern distributions like Fedora and Arch use this as one of the default flags while building packages.

I found two places where problems were caught. Fix for one is available at #78

The second one is:

/usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/span:276: std::span::reference std::span<ElfSym<X86_64>, 18446744073709551615>::operator[](std::span::size_type) const [_Type = ElfSym<X86_64>, _Extent = 18446744073709551615]: Assertion '__idx < size()' failed.

Thread 2.1 "mold" received signal SIGABRT, Aborted.
[Switching to LWP 3204173]
0x00007ffff78aa2a2 in raise () from /lib64/libc.so.6
(gdb) bt
#0  0x00007ffff78aa2a2 in raise () from /lib64/libc.so.6
#1  0x00007ffff78938a4 in abort () from /lib64/libc.so.6
#2  0x000000000041b13d in std::__replacement_assert (__file=<optimized out>, __line=<optimized out>, __line@entry=276, __function=<optimized out>, __condition=<optimized out>)
    at /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/x86_64-redhat-linux/bits/c++config.h:2654
#3  0x000000000044e94e in std::span<ElfSym<X86_64>, 18446744073709551615ul>::operator[] (this=<optimized out>, __idx=0) at /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/span:276
#4  Symbol<X86_64>::esym (this=this@entry=0x53cf84f0140) at ./mold.h:1960
#5  0x000000000044dd7c in get_rank<X86_64> (sym=...) at object_file.cc:778

For some reason, at:

mold/mold.h

Lines 1957 to 1961 in 426a689

const ElfSym<E> &esym() const {
if (file->is_dso)
return *((SharedFile<E> *)file)->elf_syms[sym_idx];
return ((ObjectFile<E> *)file)->elf_syms[sym_idx];
}

sym_idx is uninitialized for elf-init.oS which comes from libc_nonshared.a

from mold.

wezm avatar wezm commented on July 18, 2024

Fantastic detective work @nehaljwani and thanks for fixing one of the issues.

from mold.

rui314 avatar rui314 commented on July 18, 2024

Feel free to reopen if it still persists.

from mold.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.