* Chew segmentation fault while building on Ubuntu/Debian
@ 2021-12-27 12:30 Tiberiu Chibici
2021-12-29 7:50 ` Alan Modra
2022-01-08 2:38 ` Tiberiu Chibici
0 siblings, 2 replies; 6+ messages in thread
From: Tiberiu Chibici @ 2021-12-27 12:30 UTC (permalink / raw)
To: binutils
Hello,
I've been trying to build a cross compiler the last few days, and I keep
getting this build error:
/bin/bash: line 1: 31514 Segmentation fault (core dumped) ./chew -f
../../../binutils-2.37/bfd/doc/doc.str <
../../../binutils-2.37/bfd/doc/../corefile.c > core.tmp
/bin/bash: line 1: 31508 Segmentation fault (core dumped) ./chew -f
../../../binutils-2.37/bfd/doc/doc.str <
../../../binutils-2.37/bfd/doc/../archures.c > archures.tmp
/bin/bash: line 1: 31510 Segmentation fault (core dumped) ./chew -f
../../../binutils-2.37/bfd/doc/doc.str <
../../../binutils-2.37/bfd/doc/../bfd.c > bfd.tmp
/bin/bash: line 1: 31507 Segmentation fault (core dumped) ./chew -f
../../../binutils-2.37/bfd/doc/doc.str <
../../../binutils-2.37/bfd/doc/../archive.c > archive.tmp
make[4]: *** [Makefile:998: core.stamp] Error 139
/bin/bash: line 1: 31504 Segmentation fault (core dumped) ./chew -f
../../../binutils-2.37/bfd/doc/doc.str <
../../../binutils-2.37/bfd/doc/../aoutx.h > aoutx.tmp
/bin/bash: line 1: 31513 Segmentation fault (core dumped) ./chew -f
../../../binutils-2.37/bfd/doc/doc.str <
../../../binutils-2.37/bfd/doc/../coffcode.h > coffcode.tmp
make[4]: *** Waiting for unfinished jobs....
/bin/bash: line 1: 31512 Segmentation fault (core dumped) ./chew -f
../../../binutils-2.37/bfd/doc/doc.str <
../../../binutils-2.37/bfd/doc/../cache.c > cache.tmp
I started with a clean Ubuntu 20.04 machine using WSL2. I tried all the
binutils versions from 2.34 to 2.37. I also tried this on Debian, and a
clean Ubuntu 20.04 LTS VM (after updating all the packages).
Using latest Fedora Workstation, I was able to build successfully, so the
issue seems to be related to Debian and Ubuntu.
These are the packages I installed right after setting up the machines
(trying to follow this guide from the OSDEV wiki:
https://wiki.osdev.org/GCC_Cross-Compiler#Installing_Dependencies ):
sudo apt install build-essential bison flex libgmp3-dev libmpc-dev
libmpfr-dev texinfo \
nasm mtools
And here is the build script I'm using:
https://github.com/chibicitiberiu/nanobyte_os/blob/master/build_scripts/toolchain.mk
Is this something you've encountered before? Could anyone help me figure
out what the problem is?
Thank you very much, I hope this is the right channel for asking this type
of stuff.
--
Best regards,
Chibici Tiberiu
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Chew segmentation fault while building on Ubuntu/Debian
2021-12-27 12:30 Chew segmentation fault while building on Ubuntu/Debian Tiberiu Chibici
@ 2021-12-29 7:50 ` Alan Modra
2021-12-29 11:07 ` Tiberiu Chibici
2022-01-08 2:38 ` Tiberiu Chibici
1 sibling, 1 reply; 6+ messages in thread
From: Alan Modra @ 2021-12-29 7:50 UTC (permalink / raw)
To: Tiberiu Chibici; +Cc: binutils
On Mon, Dec 27, 2021 at 02:30:39PM +0200, Tiberiu Chibici via Binutils wrote:
> Hello,
> I've been trying to build a cross compiler the last few days, and I keep
> getting this build error:
>
> /bin/bash: line 1: 31514 Segmentation fault (core dumped) ./chew -f
Was chew compiled with a compiler for the build machine?
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Chew segmentation fault while building on Ubuntu/Debian
2021-12-29 7:50 ` Alan Modra
@ 2021-12-29 11:07 ` Tiberiu Chibici
0 siblings, 0 replies; 6+ messages in thread
From: Tiberiu Chibici @ 2021-12-29 11:07 UTC (permalink / raw)
To: Alan Modra; +Cc: binutils
Hello Alan,
Yes, you can see the complete build script in the github link I sent in my
original message. In the build script, I download binutils.tar.gz, unpack
it, run configure and then build.
These are the exact steps I took when setting up the VMs:
1. Install latest Ubuntu 20.04 LTS in a fresh VM
2. Install all updates (sudo apt update && sudo apt upgrade)
3. Install these dependencies:
$ sudo apt install build-essential bison flex libgmp3-dev libmpc-dev
libmpfr-dev texinfo \
nasm mtools git
4. Clone repo (https://github.com/chibicitiberiu/nanobyte_os.git)
5. Run
$ make toolchain
which runs the script linked in my previous message.
On Wed, Dec 29, 2021 at 9:50 AM Alan Modra <amodra@gmail.com> wrote:
> On Mon, Dec 27, 2021 at 02:30:39PM +0200, Tiberiu Chibici via Binutils
> wrote:
> > Hello,
> > I've been trying to build a cross compiler the last few days, and I keep
> > getting this build error:
> >
> > /bin/bash: line 1: 31514 Segmentation fault (core dumped) ./chew -f
>
> Was chew compiled with a compiler for the build machine?
>
> --
> Alan Modra
> Australia Development Lab, IBM
>
--
Chibici Tiberiu
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Chew segmentation fault while building on Ubuntu/Debian
2021-12-27 12:30 Chew segmentation fault while building on Ubuntu/Debian Tiberiu Chibici
2021-12-29 7:50 ` Alan Modra
@ 2022-01-08 2:38 ` Tiberiu Chibici
2022-01-08 2:57 ` Mike Frysinger
1 sibling, 1 reply; 6+ messages in thread
From: Tiberiu Chibici @ 2022-01-08 2:38 UTC (permalink / raw)
To: binutils
Hello,
I have some more information about this issue, another person running
Ubuntu 20.04.3 LTS was able to reproduce the same issue (using WSL). Also,
I tried to debug the issue in GDB, and this seems to be the origin of the
segmentation fault. Is there anything else I can help with to get closer to
the source of the problem?
(gdb) run -f ../../../binutils-2.37/bfd/doc/doc.str <
../../../binutils-2.37/bfd/doc/../archures.c
Starting program:
/home/tibi/Nanobyte/nanobyte_os_with_interrupts/toolchain/binutils-build-2.37/bfd/doc/chew
-f ../../../binutils-2.37/bfd/doc/doc.str <
../../../binutils-2.37/bfd/doc/../archures.c
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Program received signal SIGSEGV, Segmentation fault.
__strcmp_avx2 () at ../sysdeps/x86_64/multiarch/strcmp-avx2.S:105
105 ../sysdeps/x86_64/multiarch/strcmp-avx2.S: No such file or
directory.
(gdb) bt
#0 __strcmp_avx2 () at ../sysdeps/x86_64/multiarch/strcmp-avx2.S:105
#1 0x00005555555575a1 in lookup_word (word=0x55555555f890
"skip_past_newline") at ../../../binutils-2.37/bfd/doc/chew.c:1242
#2 0x0000555555557bce in compile (
string=0x55555555d2bb "\tget_stuff_in_command kill_bogus_lines
catstr\n\t;\n\n: ENDDD\n\tskip_past_newline\n\t;\n\n:
EXAMPLE\n\tskip_past_newline\t\n\tget_stuff_in_command kill_bogus_lines
do_fancy_stuff tr
anslatecomments \n\tcourierize cats"...) at
../../../binutils-2.37/bfd/doc/chew.c:1429
#3 0x0000555555558447 in main (ac=3, av=0x7fffffffdc58) at
../../../binutils-2.37/bfd/doc/chew.c:1612
(gdb) info reg
rax 0x990 2448
rbx 0x0 0
rcx 0xffffffff 4294967295
rdx 0x0 0
rsi 0x55555555f890 93824992278672
rdi 0x55561990 1431706000
rbp 0x7fffffffda60 0x7fffffffda60
rsp 0x7fffffffda38 0x7fffffffda38
r8 0x55555555f890 93824992278672
r9 0x55555555f9b0 93824992278960
r10 0x55555555f880 93824992278656
r11 0x7ffff7f8ecc0 140737353673920
r12 0x7fffffffdc58 140737488346200
r13 0x555555557fdf 93824992247775
r14 0x0 0
r15 0x7ffff7ffbc40 140737354120256
rip 0x7ffff7f1131e 0x7ffff7f1131e <__strcmp_avx2+30>
eflags 0x10283 [ CF SF IF RF ]
cs 0x33 51
ss 0x2b 43
ds 0x0 0
es 0x0 0
fs 0x0 0
gs 0x0 0
Thank you and best regards,
Tiberiu Chibici
On Mon, Dec 27, 2021 at 2:30 PM Tiberiu Chibici <chibicitiberiu@gmail.com>
wrote:
> Hello,
> I've been trying to build a cross compiler the last few days, and I keep
> getting this build error:
>
> /bin/bash: line 1: 31514 Segmentation fault (core dumped) ./chew -f
> ../../../binutils-2.37/bfd/doc/doc.str <
> ../../../binutils-2.37/bfd/doc/../corefile.c > core.tmp
> /bin/bash: line 1: 31508 Segmentation fault (core dumped) ./chew -f
> ../../../binutils-2.37/bfd/doc/doc.str <
> ../../../binutils-2.37/bfd/doc/../archures.c > archures.tmp
> /bin/bash: line 1: 31510 Segmentation fault (core dumped) ./chew -f
> ../../../binutils-2.37/bfd/doc/doc.str <
> ../../../binutils-2.37/bfd/doc/../bfd.c > bfd.tmp
> /bin/bash: line 1: 31507 Segmentation fault (core dumped) ./chew -f
> ../../../binutils-2.37/bfd/doc/doc.str <
> ../../../binutils-2.37/bfd/doc/../archive.c > archive.tmp
> make[4]: *** [Makefile:998: core.stamp] Error 139
> /bin/bash: line 1: 31504 Segmentation fault (core dumped) ./chew -f
> ../../../binutils-2.37/bfd/doc/doc.str <
> ../../../binutils-2.37/bfd/doc/../aoutx.h > aoutx.tmp
> /bin/bash: line 1: 31513 Segmentation fault (core dumped) ./chew -f
> ../../../binutils-2.37/bfd/doc/doc.str <
> ../../../binutils-2.37/bfd/doc/../coffcode.h > coffcode.tmp
> make[4]: *** Waiting for unfinished jobs....
> /bin/bash: line 1: 31512 Segmentation fault (core dumped) ./chew -f
> ../../../binutils-2.37/bfd/doc/doc.str <
> ../../../binutils-2.37/bfd/doc/../cache.c > cache.tmp
>
> I started with a clean Ubuntu 20.04 machine using WSL2. I tried all the
> binutils versions from 2.34 to 2.37. I also tried this on Debian, and a
> clean Ubuntu 20.04 LTS VM (after updating all the packages).
>
> Using latest Fedora Workstation, I was able to build successfully, so the
> issue seems to be related to Debian and Ubuntu.
>
> These are the packages I installed right after setting up the machines
> (trying to follow this guide from the OSDEV wiki:
> https://wiki.osdev.org/GCC_Cross-Compiler#Installing_Dependencies ):
>
> sudo apt install build-essential bison flex libgmp3-dev libmpc-dev libmpfr-dev texinfo \
> nasm mtools
>
>
> And here is the build script I'm using:
> https://github.com/chibicitiberiu/nanobyte_os/blob/master/build_scripts/toolchain.mk
>
> Is this something you've encountered before? Could anyone help me figure
> out what the problem is?
>
> Thank you very much, I hope this is the right channel for asking this type
> of stuff.
>
> --
> Best regards,
> Chibici Tiberiu
>
--
Chibici Tiberiu
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Chew segmentation fault while building on Ubuntu/Debian
2022-01-08 2:38 ` Tiberiu Chibici
@ 2022-01-08 2:57 ` Mike Frysinger
2022-01-08 13:18 ` Tiberiu Chibici
0 siblings, 1 reply; 6+ messages in thread
From: Mike Frysinger @ 2022-01-08 2:57 UTC (permalink / raw)
To: Tiberiu Chibici; +Cc: binutils
[-- Attachment #1: Type: text/plain, Size: 1674 bytes --]
On 08 Jan 2022 04:38, Tiberiu Chibici via Binutils wrote:
> I have some more information about this issue, another person running
> Ubuntu 20.04.3 LTS was able to reproduce the same issue (using WSL). Also,
> I tried to debug the issue in GDB, and this seems to be the origin of the
> segmentation fault. Is there anything else I can help with to get closer to
> the source of the problem?
>
> (gdb) run -f ../../../binutils-2.37/bfd/doc/doc.str <
> ../../../binutils-2.37/bfd/doc/../archures.c
the chew program is extremely simple. you can enable more debugging info:
$ cd bfd/doc
$ make clean
$ make CC_FOR_BUILD='gcc -O0 -ggdb3 -fsanitize=address'
$ ./chew -f ../../../binutils-2.37/bfd/doc/doc.str < ../../../binutils-2.37/bfd/doc/../archures.c
see if that triggers a failure with more logging.
> Starting program:
> /home/tibi/Nanobyte/nanobyte_os_with_interrupts/toolchain/binutils-build-2.37/bfd/doc/chew
> -f ../../../binutils-2.37/bfd/doc/doc.str <
> ../../../binutils-2.37/bfd/doc/../archures.c
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
>
> Program received signal SIGSEGV, Segmentation fault.
> __strcmp_avx2 () at ../sysdeps/x86_64/multiarch/strcmp-avx2.S:105
> 105 ../sysdeps/x86_64/multiarch/strcmp-avx2.S: No such file or
> directory.
> (gdb) bt
> #0 __strcmp_avx2 () at ../sysdeps/x86_64/multiarch/strcmp-avx2.S:105
> #1 0x00005555555575a1 in lookup_word (word=0x55555555f890
> "skip_past_newline") at ../../../binutils-2.37/bfd/doc/chew.c:1242
you can set a break on lookup_word and see what the *root tree looks like.
-mike
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Chew segmentation fault while building on Ubuntu/Debian
2022-01-08 2:57 ` Mike Frysinger
@ 2022-01-08 13:18 ` Tiberiu Chibici
0 siblings, 0 replies; 6+ messages in thread
From: Tiberiu Chibici @ 2022-01-08 13:18 UTC (permalink / raw)
To: Tiberiu Chibici, binutils
Hello Alan,
I finally figured it out! The problem was that some of the variables in my
makefile (CC, CFLAGS, LD etc) were being applied to the binutils build.
After clearing these (by running CC= CFLAGS= LD= ./configure ...), the
problem was gone.
Thank you very much for your help, and best regards.
Tiberiu Chibici
On Sat, Jan 8, 2022 at 4:57 AM Mike Frysinger <vapier@gentoo.org> wrote:
> On 08 Jan 2022 04:38, Tiberiu Chibici via Binutils wrote:
> > I have some more information about this issue, another person running
> > Ubuntu 20.04.3 LTS was able to reproduce the same issue (using WSL).
> Also,
> > I tried to debug the issue in GDB, and this seems to be the origin of the
> > segmentation fault. Is there anything else I can help with to get closer
> to
> > the source of the problem?
> >
> > (gdb) run -f ../../../binutils-2.37/bfd/doc/doc.str <
> > ../../../binutils-2.37/bfd/doc/../archures.c
>
> the chew program is extremely simple. you can enable more debugging info:
> $ cd bfd/doc
> $ make clean
> $ make CC_FOR_BUILD='gcc -O0 -ggdb3 -fsanitize=address'
> $ ./chew -f ../../../binutils-2.37/bfd/doc/doc.str <
> ../../../binutils-2.37/bfd/doc/../archures.c
>
> see if that triggers a failure with more logging.
>
> > Starting program:
> >
> /home/tibi/Nanobyte/nanobyte_os_with_interrupts/toolchain/binutils-build-2.37/bfd/doc/chew
> > -f ../../../binutils-2.37/bfd/doc/doc.str <
> > ../../../binutils-2.37/bfd/doc/../archures.c
> > [Thread debugging using libthread_db enabled]
> > Using host libthread_db library
> "/lib/x86_64-linux-gnu/libthread_db.so.1".
> >
> > Program received signal SIGSEGV, Segmentation fault.
> > __strcmp_avx2 () at ../sysdeps/x86_64/multiarch/strcmp-avx2.S:105
> > 105 ../sysdeps/x86_64/multiarch/strcmp-avx2.S: No such file or
> > directory.
> > (gdb) bt
> > #0 __strcmp_avx2 () at ../sysdeps/x86_64/multiarch/strcmp-avx2.S:105
> > #1 0x00005555555575a1 in lookup_word (word=0x55555555f890
> > "skip_past_newline") at ../../../binutils-2.37/bfd/doc/chew.c:1242
>
> you can set a break on lookup_word and see what the *root tree looks like.
> -mike
>
--
Chibici Tiberiu
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-01-08 13:18 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-27 12:30 Chew segmentation fault while building on Ubuntu/Debian Tiberiu Chibici
2021-12-29 7:50 ` Alan Modra
2021-12-29 11:07 ` Tiberiu Chibici
2022-01-08 2:38 ` Tiberiu Chibici
2022-01-08 2:57 ` Mike Frysinger
2022-01-08 13:18 ` Tiberiu Chibici
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).