View previous topic :: View next topic |
Author |
Message |
Deathcrow n00b
Joined: 24 Jul 2006 Posts: 32
|
Posted: Sun Apr 12, 2015 11:37 am Post subject: Random segfaults when building libX11 on armv7a |
|
|
Hello!
libX11-1.6.3 (also 1.6.2) fails on a "armv7a-hardfloat-linux-musleabi" CHOST (musl libc) with a segfault during emerge:
Code: |
/usr/bin/cpp -undef -traditional -DWCHAR32=1 < /var/tmp/portage/x11-libs/libX11-1.6.3/work/libX11-1.6.3/nls/ko_KR.UTF-8/Compose.pre | LC_CTYPE=C sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' -e '/^[ ]*XCOMM$/s/XCOMM/#/' -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/#/' -e '/^[ ]*XHASH/s/XHASH/#/' -e 's,X11_LOCALEDATADIR,/usr/share/X11/locale,g' -e '/\@\@$/s/\@\@$/\\/' > ko_KR.UTF-8/Compose
/bin/sh: line 1: 20515 Done(2) /usr/bin/cpp -undef -traditional -DWCHAR32=1 < /var/tmp/portage/x11-libs/libX11-1.6.3/work/libX11-1.6.3/nls/koi8-c/Compose.pre
20516 Segmentation fault | LC_CTYPE=C sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' -e '/^[ ]*XCOMM$/s/XCOMM/#/' -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/#/' -e '/^[ ]*XHASH/s/XHASH/#/' -e 's,X11_LOCALEDATADIR,/usr/share/X11/locale,g' -e '/\@\@$/s/\@\@$/\\/' > koi8-c/Compose
Makefile:980: recipe for target 'koi8-c/Compose' failed
make[1]: *** [koi8-c/Compose] Error 139
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/var/tmp/portage/x11-libs/libX11-1.6.3/work/libX11-1.6.3-.default/nls'
Makefile:509: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1
|
When running the failing line in the working directory manually it sometimes goes through without error and sometimes segfaults:
Code: |
odroid nls # /usr/bin/cpp -undef -traditional -DWCHAR32=1 < /var/tmp/portage/x11-libs/libX11-1.6.3/work/libX11-1.6.3/nls/koi8-c/Compose.pre | sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' -e '/^[ ]*XCOMM$/s/XCOMM/#/' -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/#/' -e '/^[ ]*XHASH/s/XHASH/#/' -e 's,X11_LOCALEDATADIR,/usr/share/X11/locale,g' -e '/\@\@$/s/\@\@$/\\/' > koi8-c/Compose
odroid nls # /usr/bin/cpp -undef -traditional -DWCHAR32=1 < /var/tmp/portage/x11-libs/libX11-1.6.3/work/libX11-1.6.3/nls/koi8-c/Compose.pre | sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' -e '/^[ ]*XCOMM$/s/XCOMM/#/' -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/#/' -e '/^[ ]*XHASH/s/XHASH/#/' -e 's,X11_LOCALEDATADIR,/usr/share/X11/locale,g' -e '/\@\@$/s/\@\@$/\\/' > koi8-c/Compose
Segmentation fault
odroid nls # /usr/bin/cpp -undef -traditional -DWCHAR32=1 < /var/tmp/portage/x11-libs/libX11-1.6.3/work/libX11-1.6.3/nls/koi8-c/Compose.pre | sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' -e '/^[ ]*XCOMM$/s/XCOMM/#/' -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/#/' -e '/^[ ]*XHASH/s/XHASH/#/' -e 's,X11_LOCALEDATADIR,/usr/share/X11/locale,g' -e '/\@\@$/s/\@\@$/\\/' > koi8-c/Compose
Segmentation fault
odroid nls # /usr/bin/cpp -undef -traditional -DWCHAR32=1 < /var/tmp/portage/x11-libs/libX11-1.6.3/work/libX11-1.6.3/nls/koi8-c/Compose.pre | sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' -e '/^[ ]*XCOMM$/s/XCOMM/#/' -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/#/' -e '/^[ ]*XHASH/s/XHASH/#/' -e 's,X11_LOCALEDATADIR,/usr/share/X11/locale,g' -e '/\@\@$/s/\@\@$/\\/' > koi8-c/Compose
Segmentation fault
odroid nls # /usr/bin/cpp -undef -traditional -DWCHAR32=1 < /var/tmp/portage/x11-libs/libX11-1.6.3/work/libX11-1.6.3/nls/koi8-c/Compose.pre | sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' -e '/^[ ]*XCOMM$/s/XCOMM/#/' -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/#/' -e '/^[ ]*XHASH/s/XHASH/#/' -e 's,X11_LOCALEDATADIR,/usr/share/X11/locale,g' -e '/\@\@$/s/\@\@$/\\/' > koi8-c/Compose
odroid nls # /usr/bin/cpp -undef -traditional -DWCHAR32=1 < /var/tmp/portage/x11-libs/libX11-1.6.3/work/libX11-1.6.3/nls/koi8-c/Compose.pre | sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' -e '/^[ ]*XCOMM$/s/XCOMM/#/' -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/#/' -e '/^[ ]*XHASH/s/XHASH/#/' -e 's,X11_LOCALEDATADIR,/usr/share/X11/locale,g' -e '/\@\@$/s/\@\@$/\\/' > koi8-c/Compose
Segmentation fault
COMM/#/' -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/#/' -e '/^[ ]*XHASH/s/XHASH/#/' -e 's,X11_LOCALEDATADIR,/usr/share/X11/locale,g' -e '/\@\@$/s/\@\@$/\\/' > koi8-c/Compose
odroid nls # /usr/bin/cpp -undef -traditional -DWCHAR32=1 < /var/tmp/portage/x11-libs/libX11-1.6.3/work/libX11-1.6.3/nls/koi8-c/Compose.pre | sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' -e '/^[ ]*XCOMM$/s/XCOMM/#/' -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/#/' -e '/^[ ]*XHASH/s/XHASH/#/' -e 's,X11_LOCALEDATADIR,/usr/share/X11/locale,g' -e '/\@\@$/s/\@\@$/\\/' > koi8-c/Compose
odroid nls # /usr/bin/cpp -undef -traditional -DWCHAR32=1 < /var/tmp/portage/x11-libs/libX11-1.6.3/work/libX11-1.6.3/nls/koi8-c/Compose.pre | sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' -e '/^[ ]*XCOMM$/s/XCOMM/#/' -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/#/' -e '/^[ ]*XHASH/s/XHASH/#/' -e 's,X11_LOCALEDATADIR,/usr/share/X11/locale,g' -e '/\@\@$/s/\@\@$/\\/' > koi8-c/Compose
odroid nls # /usr/bin/cpp -undef -traditional -DWCHAR32=1 < /var/tmp/portage/x11-libs/libX11-1.6.3/work/libX11-1.6.3/nls/koi8-c/Compose.pre | sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' -e '/^[ ]*XCOMM$/s/XCOMM/#/' -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/#/' -e '/^[ ]*XHASH/s/XHASH/#/' -e 's,X11_LOCALEDATADIR,/usr/share/X11/locale,g' -e '/\@\@$/s/\@\@$/\\/' > koi8-c/Compose
Segmentation fault
odroid nls # /usr/bin/cpp -undef -traditional -DWCHAR32=1 < /var/tmp/portage/x11-libs/libX11-1.6.3/work/libX11-1.6.3/nls/koi8-c/Compose.pre | sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' -e '/^[ ]*XCOMM$/s/XCOMM/#/' -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/#/' -e '/^[ ]*XHASH/s/XHASH/#/' -e 's,X11_LOCALEDATADIR,/usr/share/X11/locale,g' -e '/\@\@$/s/\@\@$/\\/' > koi8-c/Compose
odroid nls # /usr/bin/cpp -undef -traditional -DWCHAR32=1 < /var/tmp/portage/x11-libs/libX11-1.6.3/work/libX11-1.6.3/nls/koi8-c/Compose.pre | sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' -e '/^[ ]*XCOMM$/s/XCOMM/#/' -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/#/' -e '/^[ ]*XHASH/s/XHASH/#/' -e 's,X11_LOCALEDATADIR,/usr/share/X11/locale,g' -e '/\@\@$/s/\@\@$/\\/' > koi8-c/Compose
odroid nls # /usr/bin/cpp -undef -traditional -DWCHAR32=1 < /var/tmp/portage/x11-libs/libX11-1.6.3/work/libX11-1.6.3/nls/koi8-c/Compose.pre | sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' -e '/^[ ]*XCOMM$/s/XCOMM/#/' -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/#/' -e '/^[ ]*XHASH/s/XHASH/#/' -e 's,X11_LOCALEDATADIR,/usr/share/X11/locale,g' -e '/\@\@$/s/\@\@$/\\/' > koi8-c/Compose
odroid nls # /usr/bin/cpp -undef -traditional -DWCHAR32=1 < /var/tmp/portage/x11-libs/libX11-1.6.3/work/libX11-1.6.3/nls/koi8-c/Compose.pre | sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' -e '/^[ ]*XCOMM$/s/XCOMM/#/' -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/#/' -e '/^[ ]*XHASH/s/XHASH/#/' -e 's,X11_LOCALEDATADIR,/usr/share/X11/locale,g' -e '/\@\@$/s/\@\@$/\\/' > koi8-c/Compose
odroid nls # /usr/bin/cpp -undef -traditional -DWCHAR32=1 < /var/tmp/portage/x11-libs/libX11-1.6.3/work/libX11-1.6.3/nls/koi8-c/Compose.pre | sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' -e '/^[ ]*XCOMM$/s/XCOMM/#/' -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/#/' -e '/^[ ]*XHASH/s/XHASH/#/' -e 's,X11_LOCALEDATADIR,/usr/share/X11/locale,g' -e '/\@\@$/s/\@\@$/\\/' > koi8-c/Compose
Segmentation fault
|
So then I try to figure out which part of that line actually segfaults
Code: |
/usr/bin/cpp -undef -traditional -DWCHAR32=1 < /var/tmp/portage/x11-libs/libX11-1.6.3/work/libX11-1.6.3/nls/koi8-c/Compose.pre > ~/problemtext.txt
|
Works 100% of the time without segfault.
Code: |
cat ~/problemtext.txt | LC_CTYPE=C sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' -e '/^[ ]*XCOMM$/s/XCOMM/#/' -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/#/' -e '/^[ ]*XHASH/s/XHASH/#/' -e 's,X11_LOCALEDATADIR,/usr/share/X11/locale,g' -e '/\@\@$/s/\@\@$/\\/' > koi8-c/Compose
|
Also works 100% of the time without segfault.
What is happening? I'm stumped.
My 'emerge --info'
Code: |
Portage 2.2.14 (python 2.7.9-final-0, hardened/linux/musl/arm/armv7a, gcc-4.7.4, musl-1.1.8, 3.10.73 armv7l)
=================================================================
System uname: Linux-3.10.73-armv7l-ARMv7_Processor_rev_1_-v7l-with-gentoo-2.2
KiB Mem: 866548 total, 79884 free
KiB Swap: 2097148 total, 2059528 free
Timestamp of tree: Sat, 11 Apr 2015 13:30:01 +0000
ld GNU ld (Gentoo 2.24 p1.4) 2.24
distcc 3.1 armv7a-hardfloat-linux-musleabi [disabled]
app-shells/bash: 4.2_p53
dev-lang/perl: 5.20.2
dev-lang/python: 2.7.9-r1, 3.3.5-r1
dev-util/pkgconfig: 0.28-r1
sys-apps/baselayout: 2.2
sys-apps/openrc: 0.13.11
sys-apps/sandbox: 2.6-r999::hardened-development
sys-devel/autoconf: 2.69
sys-devel/automake: 1.13.4
sys-devel/binutils: 2.24-r3
sys-devel/gcc: 4.7.4-r99::hardened-development
sys-devel/gcc-config: 1.7.3
sys-devel/libtool: 2.4.6
sys-devel/make: 4.1-r1
sys-kernel/linux-headers: 3.16 (virtual/os-headers)
Repositories: gentoo hardened-development
ACCEPT_KEYWORDS="arm"
ACCEPT_LICENSE="*"
CBUILD="armv7a-hardfloat-linux-musleabi"
CFLAGS="-O2 -pipe -fomit-frame-pointer -march=armv7-a -mtune=cortex-a5 -mfpu=neon-vfpv4 -mfloat-abi=hard"
CHOST="armv7a-hardfloat-linux-musleabi"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe -fomit-frame-pointer -march=armv7-a -mtune=cortex-a5 -mfpu=neon-vfpv4 -mfloat-abi=hard"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -pipe -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
INSTALL_MASK="charset.alias"
LANG="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j7"
PKGDIR="/usr/portage/packages"
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"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/hardened-development"
USE="X arm cli cracklib crypt cxx dri ffmpeg flac fortran gold hardened iconv ipv6 jpeg modules mp3 ncurses nls nptl ogg openmp opus pax_kernel pcre pic png python readline session ssl tcpd truetype udev unicode xattr zlib" 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="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="musl" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev mouse keyboard" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_3" RUBY_TARGETS="ruby19 ruby20" USERLAND="GNU" VIDEO_CARDS="vesa mali" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset: CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, SYNC, USE_PYTHON
|
Edit: By retrying emerge until I got lucky I managed to finish the package. Still worried about the random segfaults though.
Last edited by Deathcrow on Tue Apr 14, 2015 9:26 pm; edited 1 time in total |
|
Back to top |
|
|
heiwa n00b
Joined: 24 Oct 2012 Posts: 70
|
Posted: Sun Apr 12, 2015 8:18 pm Post subject: |
|
|
I also don't really have an idea but it should be useful to get a more
minimal example.
* What happens if you use the sed from busybox?
* Try removing some argument for sed
* Try simplifying the input file. (It contains only one line
include "X11_LOCALEDATADIR/en_US.UTF-8/Compose"
?) |
|
Back to top |
|
|
Deathcrow n00b
Joined: 24 Jul 2006 Posts: 32
|
Posted: Mon Apr 13, 2015 1:04 am Post subject: |
|
|
Thanks for trying to help.
Just to avoid any confusion or potential misunderstandings: I was not able to reproduce the segfault when using cpp or sed alone. Your advise seems to be under the assumption that the segfault happens with sed, but my experiments didn't show that. I only get the segfault (~50% of the time) when using the full command with cpp piped into sed.
Since I made that post I tried to do an 'emerge -e world' in case some library was badly compiled, but still having the same issue. Everything else builds completely fine. |
|
Back to top |
|
|
heiwa n00b
Joined: 24 Oct 2012 Posts: 70
|
Posted: Mon Apr 13, 2015 6:38 am Post subject: |
|
|
I've meant that you test exactly the same command line (including cpp)
but with the sed part slightly modified. Sorry for being unclear. |
|
Back to top |
|
|
heiwa n00b
Joined: 24 Oct 2012 Posts: 70
|
Posted: Mon Apr 13, 2015 7:16 am Post subject: |
|
|
Actually could you try reproducing from a fresh stage3? It already has cpp
and sed, you just need to add the offending Compose.pre and run your tests. |
|
Back to top |
|
|
Deathcrow n00b
Joined: 24 Jul 2006 Posts: 32
|
Posted: Mon Apr 13, 2015 1:00 pm Post subject: |
|
|
heiwa wrote: | Actually could you try reproducing from a fresh stage3? It already has cpp
and sed, you just need to add the offending Compose.pre and run your tests. |
That's not a bad idea, maybe I try that later (EDIT: Tried it now, extracted stage3 tarball (stage3-armv7a_hardfp-musl-hardened-20150401.tar.bz2) and chrooted. Still segfaulting randomly. So it's not my own CFLAGS or toolchains that are cause)
Before I read your post I did some further testing, your input would be appreciated.
I decided to use a named pipe:
Code: |
mkfifo /tmp/blablub
|
Now I run in Bash #1:
Code: | /usr/bin/cpp -undef -traditional -DWCHAR32=1 < /var/tmp/portage/x11-libs/libX11-1.6.2/work/libX11-1.6.2/nls/koi8-c/Compose.pre > /tmp/blablub |
and in Bash #2:
Code: | sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' -e '/^[ ]*XCOMM$/s/XCOMM/#/' -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/#/' -e '/^[ ]*XHASH/s/XHASH/#/' -e 's,X11_LOCALEDATADIR,/usr/share/X11/locale,g' -e '/\@\@$/s/\@\@$/\\/' < /tmp/blablub > koi8-c/Compose |
Bash #2 shows segfault 70% of attempts:
Code: | odroid nls # sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' -e '/^[ ]*XCOMM$/s/XCOMM/#/' -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/#/' -e '/^[ ]*XHASH/s/XHASH/#/' -e 's,X11_LOCALEDATADIR,/usr/share/X11/locale,g' -e '/\@\@$/s/\@\@$/\\/' < /tmp/blablub > koi8-c/Compose
Segmentation fault |
Maybe it's really sed? Compiling sed with minimal cflags for debugging:
Code: | CFLAGS="-O0 -pipe -march=native" |
(Newly compiled sed still leads to segfaults btw)
Running 'gdb sed':
Code: |
odroid nls # gdb sed
GNU gdb (Gentoo 7.7.1 p1) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "armv7a-hardfloat-linux-musleabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://bugs.gentoo.org/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from sed...(no debugging symbols found)...done.
(gdb) set args -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' -e '/^[ ]*XCOMM$/s/XCOMM/#/' -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/#/' -e '/^[ ]*XHASH/s/XHASH/#/' -e 's,X11_LOCALEDATADIR,/usr/share/X11/locale,g' -e '/\@\@$/s/\@\@$/\\/' < /tmp/blablub
(gdb) run
Starting program: /bin/sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' -e '/^[ ]*XCOMM$/s/XCOMM/#/' -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/#/' -e '/^[ ]*XHASH/s/XHASH/#/' -e 's,X11_LOCALEDATADIR,/usr/share/X11/locale,g' -e '/\@\@$/s/\@\@$/\\/' < /tmp/blablub
#
# koi8-c Compose Sequence
#
# Sequence Definition
#
#
# <Multi_key> Means <Compose>
# Special Character
<Multi_key> <plus> <plus> : "#" numbersign
<Multi_key> <apostrophe> <space> : "'" apostrophe
<Multi_key> <space> <apostrophe> : "'" apostrophe
<Multi_key> <A> <T> : "@" at
<Multi_key> <parenleft> <parenleft> : "[" bracketleft
<Multi_key> <slash> <slash> : "\\" backslash
<Multi_key> <slash> <less> : "\\" backslash
<Multi_key> <less> <slash> : "\\" backslash
<Multi_key> <parenright> <parenright> : "]" bracketright
<Multi_key> <asciicircum> <space> : "^" asciicircum
<Multi_key> <space> <asciicircum> : "^" asciicircum
<Multi_key> <greater> <space> : "^" asciicircum
<Multi_key> <space> <greater> : "^" asciicircum
<Multi_key> <grave> <space> : "`" grave
<Multi_key> <space> <grave> : "`" grave
<Multi_key> <parenleft> <minus> : "{" braceleft
<Multi_key> <minus> <parenleft> : "{" braceleft
<Multi_key> <slash> <asciicircum> : "|" bar
<Multi_key> <asciicircum> <slash> : "|" bar
<Multi_key> <V> <L> : "|" bar
<Multi_key> <L> <V> : "|" bar
<Multi_key> <v> <l> : "|" bar
<Multi_key> <l> <v> : "|" bar
<Multi_key> <parenright> <minus> : "}" braceright
<Multi_key> <minus> <parenright> : "}" braceright
<Multi_key> <asciitilde> <space> : "~" asciitilde
<Multi_key> <space> <asciitilde> : "~" asciitilde
<Multi_key> <minus> <space> : "~" asciitilde
<Multi_key> <space> <minus> : "~" asciitilde
<Multi_key> <space> <space> : "\240" nobreakspace
<Multi_key> <Cyrillic_ghe> <minus> : "\200" Cyrillic_ghe_bar
<Multi_key> <Cyrillic_GHE> <minus> : "\220" Cyrillic_GHE_bar
<Multi_key> <Cyrillic_zhe> <comma> : "\201" Cyrillic_zhe_descender
<Multi_key> <Cyrillic_ZHE> <comma> : "\221" Cyrillic_ZHE_descender
<Multi_key> <Cyrillic_ka> <comma> : "\202" Cyrillic_ka_descender
<Multi_key> <Cyrillic_KA> <comma> : "\222" Cyrillic_KA_descender
<Multi_key> <Cyrillic_ka> <slash> : "\203" Cyrillic_ka_vertstroke
<Multi_key> <Cyrillic_KA> <slash> : "\223" Cyrillic_KA_vertstroke
<Multi_key> <Cyrillic_ka> <bar> : "\203" Cyrillic_ka_vertstroke
<Multi_key> <Cyrillic_KA> <bar> : "\223" Cyrillic_KA_vertstroke
<Multi_key> <Cyrillic_en> <comma> : "\204" Cyrillic_en_descender
<Multi_key> <Cyrillic_EN> <comma> : "\224" Cyrillic_EN_descender
<Multi_key> <Cyrillic_u> <apostrophe> : "\205" Cyrillic_u_straight
<Multi_key> <Cyrillic_U> <apostrophe> : "\225" Cyrillic_U_straight
<Multi_key> <Cyrillic_u> <bar> : "\205" Cyrillic_u_straight
<Multi_key> <Cyrillic_U> <bar> : "\225" Cyrillic_U_straight
<Multi_key> <Cyrillic_u> <comma> : "\206" Cyrillic_u_straight_bar
<Multi_key> <Cyrillic_U> <comma> : "\226" Cyrillic_U_straight_bat
<Multi_key> <Cyrillic_u> <slash> : "\206" Cyrillic_u_straight_bar
<Multi_key> <Cyrillic_U> <slash> : "\226" Cyrillic_U_straight_bat
<Multi_key> <Cyrillic_ha> <comma> : "\207" Cyrillic_ha_descender
<Multi_key> <Cyrillic_HA> <comma> : "\227" Cyrillic_HA_descender
<Multi_key> <Cyrillic_che> <comma> : "\210" Cyrillic_che_descender
<Multi_key> <Cyrillic_CHE> <comma> : "\230" Cyrillic_CHE_descender
<Multi_key> <Cyrillic_che> <slash> : "\211" Cyrillic_che_vertstroke
<Multi_key> <Cyrillic_CHE> <slash> : "\231" Cyrillic_CHE_vertstroke
<Multi_key> <Cyrillic_che> <bar> : "\211" Cyrillic_che_vertstroke
<Multi_key> <Cyrillic_CHE> <bar> : "\231" Cyrillic_CHE_vertstroke
<Multi_key> <Cyrillic_ha> <apostrophe> : "\212" Cyrillic_shha
<Multi_key> <Cyrillic_HA> <apostrophe> : "\232" Cyrillic_SHHA
<Multi_key> <h> <apostrophe> : "\212" Cyrillic_shha
<Multi_key> <H> <apostrophe> : "\232" Cyrillic_SHHA
<Multi_key> <h> <h> : "\212" Cyrillic_shha
<Multi_key> <H> <H> : "\232" Cyrillic_SHHA
<Multi_key> <Cyrillic_ie> <Cyrillic_ie> : "\213" Cyrillic_schwa
<Multi_key> <Cyrillic_IE> <Cyrillic_IE> : "\233" Cyrillic_SCHWA
<Multi_key> <e> <e> : "\213" Cyrillic_schwa
<Multi_key> <E> <E> : "\233" Cyrillic_SCHWA
<Multi_key> <Cyrillic_i> <minus> : "\214" Cyrillic_i_macron
<Multi_key> <Cyrillic_I> <minus> : "\234" Cyrillic_I_macron
<Multi_key> <Cyrillic_o> <minus> : "\215" Cyrillic_o_bar
<Multi_key> <Cyrillic_O> <minus> : "\235" Cyrillic_O_bar
<Multi_key> <Cyrillic_u> <minus> : "\216" Cyrillic_u_macron
<Multi_key> <Cyrillic_U> <minus> : "\236" Cyrillic_U_macron
<Multi_key> <Cyrillic_de> <Cyrillic_je> : "\241" Serbian_dje
<Multi_key> <Cyrillic_DE> <Cyrillic_JE> : "\261" Serbian_DJE
<Multi_key> <Cyrillic_ghe> <Cyrillic_je> : "\242" Macedonia_gje
<Multi_key> <Cyrillic_GHE> <Cyrillic_JE> : "\262" Macedonia_GJE
<Multi_key> <Cyrillic_shorti> <Cyrillic_o> : "\243" Cyrillic_io
<Multi_key> <Cyrillic_SHORTI> <Cyrillic_O> : "\263" Cyrillic_IO
<Multi_key> <Cyrillic_je> <Cyrillic_o> : "\243" Cyrillic_io
<Multi_key> <Cyrillic_JE> <Cyrillic_O> : "\263" Cyrillic_IO
<Multi_key> <Cyrillic_ie> <colon> : "\243" Cyrillic_io
<Multi_key> <Cyrillic_IE> <colon> : "\263" Cyrillic_IO
<Multi_key> <Cyrillic_el> <Cyrillic_je> : "\251" Cyrillic_lje
<Multi_key> <Cyrillic_EL> <Cyrillic_JE> : "\271" Cyrillic_LJE
<Multi_key> <Cyrillic_en> <Cyrillic_je> : "\252" Cyrillic_nje
<Multi_key> <Cyrillic_EN> <Cyrillic_JE> : "\272" Cyrillic_NJE
<Multi_key> <Cyrillic_shorti> <Cyrillic_u> : "\300" Cyrillic_yu
<Multi_key> <Cyrillic_SHORTI> <Cyrillic_U> : "\340" Cyrillic_YU
<Multi_key> <Cyrillic_je> <Cyrillic_u> : "\300" Cyrillic_yu
<Multi_key> <Cyrillic_JE> <Cyrillic_U> : "\340" Cyrillic_YU
<Multi_key> <Cyrillic_te> <Cyrillic_es> : "\303" Cyrillic_tse
<Multi_key> <Cyrillic_TE> <Cyrillic_ES> : "\343" Cyrillic_TSE
<Multi_key> <Cyrillic_shorti> <Cyrillic_a> : "\321" Cyrillic_ya
<Multi_key> <Cyrillic_SHORTI> <Cyrillic_A> : "\361" Cyrillic_YA
<Multi_key> <Cyrillic_je> <Cyrillic_a> : "\321" Cyrillic_ya
<Multi_key> <Cyrillic_JE> <Cyrillic_A> : "\361" Cyrillic_YA
<Multi_key> <Cyrillic_sha> <comma> : "\335" Cyrillic_shcha
<Multi_key> <Cyrillic_SHA> <comma> : "\375" Cyrillic_SHCHA
# End of Sequence Definition
[Inferior 1 (process 10842) exited normally]
|
Works perfectly always.
I keep thinking something goes wrong during pipe. Maybe gdb pipe works differently?
Attempting to debug bash with a testscript.sh:
Code: |
#!/bin/bash
cd /var/tmp/portage/x11-libs/libX11-1.6.2/work/libX11-1.6.2-.default/nls
sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' -e '/^[ ]*XCOMM$/s/XCOMM/#/' -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/#/' -e '/^[ ]*XHASH/s/XHASH/#/' -e 's,X11_LOCALEDATADIR,/usr/share/X11/locale,g' -e '/\@\@$/s/\@\@$/\\/' < /tmp/blablub > koi8-c/Compose
|
in gdb:
Code: |
odroid nls # gdb --args bash ~/testscript.sh
GNU gdb (Gentoo 7.7.1 p1) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "armv7a-hardfloat-linux-musleabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://bugs.gentoo.org/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from bash...(no debugging symbols found)...done.
(gdb) run
Starting program: /bin/bash /root/testscript.sh
/root/testscript.sh: line 3: 24562 Segmentation fault sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' -e '/^[ ]*XCOMM$/s/XCOMM/#/' -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/#/' -e '/^[ ]*XHASH/s/XHASH/#/' -e 's,X11_LOCALEDATADIR,/usr/share/X11/locale,g' -e '/\@\@$/s/\@\@$/\\/' < /tmp/blablub > koi8-c/Compose
[Inferior 1 (process 24559) exited with code 0213]
(gdb)
|
Thanks gdb, but this doesn't help me at all :/
Maybe 'set follow-fork-mode child' will tell me more?
Code: |
odroid nls # gdb --args bash ~/testscript.sh
GNU gdb (Gentoo 7.7.1 p1) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "armv7a-hardfloat-linux-musleabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://bugs.gentoo.org/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from bash...(no debugging symbols found)...done.
(gdb) set follow-fork-mode child
(gdb) run
Starting program: /bin/bash /root/testscript.sh
[New process 24697]
process 24697 is executing new program: /bin/sed
[Inferior 2 (process 24697) exited normally]
(gdb)
|
No problems?! So is it really bash that is segfaulting? I'm not very experienced with gdb usage...
Trying sed line from within busybox:
Code: |
odroid nls # busybox sh
/var/tmp/portage/x11-libs/libX11-1.6.2/work/libX11-1.6.2-.default/nls # sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' < /tmp/blablub > koi8-c/Compose
/var/tmp/portage/x11-libs/libX11-1.6.2/work/libX11-1.6.2-.default/nls # sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' < /tmp/blablub > koi8-c/Compose
/var/tmp/portage/x11-libs/libX11-1.6.2/work/libX11-1.6.2-.default/nls # sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' < /tmp/blablub > koi8-c/Compose
/var/tmp/portage/x11-libs/libX11-1.6.2/work/libX11-1.6.2-.default/nls # sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' < /tmp/blablub > koi8-c/Compose
/var/tmp/portage/x11-libs/libX11-1.6.2/work/libX11-1.6.2-.default/nls # sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' < /tmp/blablub > koi8-c/Compose
/var/tmp/portage/x11-libs/libX11-1.6.2/work/libX11-1.6.2-.default/nls # sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' < /tmp/blablub > koi8-c/Compose
/var/tmp/portage/x11-libs/libX11-1.6.2/work/libX11-1.6.2-.default/nls # sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' < /tmp/blablub > koi8-c/Compose
/var/tmp/portage/x11-libs/libX11-1.6.2/work/libX11-1.6.2-.default/nls # sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' < /tmp/blablub > koi8-c/Compose
/var/tmp/portage/x11-libs/libX11-1.6.2/work/libX11-1.6.2-.default/nls #
|
Seems to work. How do I properly debug bash?
Interesting output of 'sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' < /tmp/blablub'
Code: |
odroid nls # sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' < /tmp/blablub
XCOMM
XCOMM koi8-c Compose Sequence
XCOMM
XCOMM Sequence Definition
XCOMM
XCOMM
XCOMM <Multi_key> Means <Compose>
XCOMM Special Character
<Multi_key> <plus> <plus> : "#" numbersign
<Multi_key> <apostrophe> <space> : "'" apostrophe
<Multi_key> <space> <apostrophe> : "'" apostrophe
<Multi_key> <A> <T> : "@" at
<Multi_key> <parenleft> <parenleft> : "[" bracketleft
<Multi_key> <slash> <slash> : "\\" backslash
<Multi_key> <slash> <less> : "\\" backslash
<Multi_key> <less> <slash> : "\\" backslash
<Multi_key> <parenright> <parenright> : "]" bracketright
<Multi_key> <asciicircum> <space> : "^" asciicircum
<Multi_key> <space> <asciicircum> : "^" asciicircum
<Multi_key> <greater> <space> : "^" asciicircum
<Multi_key> <space> <greater> : "^" asciicircum
<Multi_key> <grave> <space> : "`" grave
<Multi_key> <space> <grave> : "`" grave
<Multi_key> <parenleft> <minus> : "{" braceleftodroid nls #
|
Another mildly interesting experiment:
Bash #1:
Code: |
cat ~/problemtext.txt > /tmp/blablub
|
Bash #2 as always:
Code: | sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' < /tmp/blablub |
Works always! What is the difference between 'cat ~/problemtext.txt > /tmp/blablub' and '/usr/bin/cpp -undef -traditional -DWCHAR32=1 < /var/tmp/portage/x11-libs/libX11-1.6.2/work/libX11-1.6.2/nls/koi8-c/Compose.pre > /tmp/blablub'. I do not understand. Should be the same. And diff...
Code: |
odroid nls # /usr/bin/cpp -undef -traditional -DWCHAR32=1 < /var/tmp/portage/x11-libs/libX11-1.6.2/work/libX11-1.6.2/nls/koi8-c/Compose.pre | diff ~/problemtext.txt -
odroid nls #
|
... agrees that there is no difference.
This segfault is some kind of sherlock holmes mystery.
PS: Thanks for your advice with a simpler sed line (incorporated in tests). Still segfaults with...
Code: |
odroid nls # sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d' < /tmp/blablub > koi8-c/Compose
Segmentation fault
|
(also works perfectly fine when run in gdb) |
|
Back to top |
|
|
heiwa n00b
Joined: 24 Oct 2012 Posts: 70
|
Posted: Mon Apr 13, 2015 6:38 pm Post subject: |
|
|
bash is not segfaulting. It is just telling you that when executing
your script a child exited on signal SIGSEGV. Since it is the last
command in the script, bash exits with status 128+SIGSEGV=139=O213.
The difference between cat and cpp is that cpp writes its output line
by line whereas cat writes everything at once.
I could not reproduce the segfault with a clean stage3 and qemu
user emulation. (Read your update now. Might try to reproduce on
real hardware later.)
The remaining two regular expressions on the command line don't
seem to match the input file at all. So I would expect that only the
line lengths matter. Does the segfault still occur when you first
let the file run through sed 's/./a/g'?
What happens if you compile sed with USE=static or
CFLAGS="-fno-stack-protector"?
Sorry for not yet being able to pinpoint what's wrong. |
|
Back to top |
|
|
Deathcrow n00b
Joined: 24 Jul 2006 Posts: 32
|
Posted: Mon Apr 13, 2015 6:49 pm Post subject: |
|
|
First off: Thanks for sticking with this and trying to help out. My posts have been kinda verbose, sorry for that. But I've been trying to include all relevant information.
Quote: |
The difference between cat and cpp is that cpp writes its output line
by line whereas cat writes everything at once.
|
How do you explain that I don't get the segfault in busybox (might have missed that info in the verboseness of my posts) or in gdb?
Quote: |
I could not reproduce the segfault with a clean stage3 and qemu
user emulation. (Read your update now. Might try to reproduce on
real hardware later.)
|
Okay. Cool that you tried. I don't even know what it means when a segfault happens kinda randomly, but it could be a hardware bug eh?
Quote: |
The remaining two regular expressions on the command line don't
seem to match the input file at all. So I would expect that only the
line lengths matter. Does the segfault still occur when you first
let the file run through sed 's/./a/g'?
What happens if you compile sed with USE=static or
CFLAGS="-fno-stack-protector"?
|
I'll try that later.
Quote: | Sorry for not yet being able to pinpoint what's wrong. |
Oh no please don't apologize. I really appreciate your input. |
|
Back to top |
|
|
heiwa n00b
Joined: 24 Oct 2012 Posts: 70
|
Posted: Mon Apr 13, 2015 7:16 pm Post subject: |
|
|
When using busybox you most likely will also use busybox sed and I
interpreted your tests as evidence that the culprit is coreutils sed.
For explanations why you can't reproduce in gdb, check out
http://stackoverflow.com/questions/4628521/segfault-only-when-not-using-debugger
I've now also tried on real hardware (Cubieboard 2) but also could not
reproduce there. So I'm now also leaning towards a hardware problem.
However the segfault is more regular than I would expect for faulty
hardware.
A non-hardware explanation for random segfaults would be a race
condition. |
|
Back to top |
|
|
Deathcrow n00b
Joined: 24 Jul 2006 Posts: 32
|
Posted: Mon Apr 13, 2015 8:14 pm Post subject: |
|
|
heiwa wrote: | When using busybox you most likely will also use busybox sed and I
interpreted your tests as evidence that the culprit is coreutils sed.
|
D'oh. You're right of course... and I'm a dumbdumb.
Thanks.
Quote: |
I've now also tried on real hardware (Cubieboard 2) but also could not
reproduce there. So I'm now also leaning towards a hardware problem.
However the segfault is more regular than I would expect for faulty
hardware.
A non-hardware explanation for random segfaults would be a race
condition.
|
Hrm.
Back to your earlier ideas:
Quote: |
The remaining two regular expressions on the command line don't
seem to match the input file at all. |
You mean "sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d". I'm really bad at regular expressions, but comparing the outputs this removes the top 3 lines:
Code: |
odroid nls # diff ~/problemtext.txt ~/sed-problemfile.txt -u
--- /root/problemtext.txt 2015-04-13 00:47:28.623542993 +0000
+++ /root/sed-problemfile.txt 2015-04-13 20:00:00.809764000 +0000
@@ -1,6 +1,3 @@
-# 1 "<stdin>"
-# 1 "<command-line>"
-# 1 "<stdin>"
XCOMM
XCOMM koi8-c Compose Sequence
XCOMM
|
Quote: | So I would expect that only the
line lengths matter. Does the segfault still occur when you first
let the file run through sed 's/./a/g'? |
I tried that:
Code: |
odroid nls # sed -e 's/./a/g' < /tmp/blablub
aaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaa
aaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaa
aaaaaaaaaaaaaaaaaaaaaaaaa
aaaaa
aaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Segmentation fault
|
Yep, you're totally right. Curious why it only segfaults parsing that particular file. There are many cpp/sed in that fasion during the libX11 build and "libX11-1.6.2/work/libX11-1.6.2/nls/koi8-c/Compose.pre" is the only one that results in this problem. I'll try to investigate what's the big different there.
EDIT: Did a quick test to make sure that it is a problem with parsing certain words. Repeated this command until it didn't segfault:
Code: | /usr/bin/cpp -undef -traditional -DWCHAR32=1 < /var/tmp/portage/x11-libs/libX11-1.6.2/work/libX11-1.6.2/nls/koi8-c/Compose.pre | sed -e 's/./a/g'> ~/sed-as.txt |
then replacing a's with b's:
Code: | /usr/bin/cpp -undef -traditional -DWCHAR32=1 < sed-as.txt | sed -e 's/./b/g' |
Works always (tried about 50 times to be sure).
Quote: |
What happens if you compile sed with USE=static or
CFLAGS="-fno-stack-protector"?
|
Just tried it... still borked. That's removing one of the hardened options right? |
|
Back to top |
|
|
heiwa n00b
Joined: 24 Oct 2012 Posts: 70
|
Posted: Mon Apr 13, 2015 10:17 pm Post subject: |
|
|
Deathcrow wrote: |
Back to your earlier ideas:
Quote: |
The remaining two regular expressions on the command line don't
seem to match the input file at all. |
You mean "sed -e '/^# *[0-9][0-9]* *.*$/d' -e '/^#line *[0-9][0-9]* *.*$/d". I'm really bad at regular expressions, but comparing the outputs this removes the top 3 lines:
Code: |
odroid nls # diff ~/problemtext.txt ~/sed-problemfile.txt -u
--- /root/problemtext.txt 2015-04-13 00:47:28.623542993 +0000
+++ /root/sed-problemfile.txt 2015-04-13 20:00:00.809764000 +0000
@@ -1,6 +1,3 @@
-# 1 "<stdin>"
-# 1 "<command-line>"
-# 1 "<stdin>"
XCOMM
XCOMM koi8-c Compose Sequence
XCOMM
|
|
Ah, I didn't realize that cpp inserts this on top.
Code: |
cpp Compose.pre | sed -e 's/./a/g'
|
is not exactly what I've meant but interesting that this segfaults too.
Code: |
cpp Compose.pre | sed -e 's/./a/g' | cpp | sed -e 's/./b/g'
|
does not segfault because the line lengths have changed. (There are
additional lines.)
The test I had been thinking of would have been.
Code: |
sed -e 's/./a/g' Compose.pre | cpp | sedcommandfrombefore
|
Quote: |
Quote: |
What happens if you compile sed with USE=static or
CFLAGS="-fno-stack-protector"?
|
Just tried it... still borked. That's removing one of the hardened options right? |
Yes, or possibly it is now enabled by default everywhere on gentoo. |
|
Back to top |
|
|
Deathcrow n00b
Joined: 24 Jul 2006 Posts: 32
|
Posted: Tue Apr 14, 2015 12:02 am Post subject: |
|
|
Quote: | The test I had been thinking of would have been.
Code: |
sed -e 's/./a/g' Compose.pre | cpp | sedcommandfrombefore
|
|
Hmm this doesn't seem to segfault... ever. I'm still no closer to figuring out *why* the segfault is occuring so I have no idea what result you expected from the test.
Code: |
odroid nls # sed -e 's/./a/g' /var/tmp/portage/x11-libs/libX11-1.6.2/work/libX11-1.6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aaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
|
|
Back to top |
|
|
heiwa n00b
Joined: 24 Oct 2012 Posts: 70
|
Posted: Tue Apr 14, 2015 7:30 pm Post subject: |
|
|
Ok...
You've tried out running the sed in strace?
You've also tried the '(gdb) set disable-randomization off' from stackoverflow?
I'd also be curious about whether the sed testsuite ('make check') causes segfaults. |
|
Back to top |
|
|
Deathcrow n00b
Joined: 24 Jul 2006 Posts: 32
|
Posted: Tue Apr 14, 2015 8:26 pm Post subject: |
|
|
heiwa wrote: | Ok...
You've tried out running the sed in strace?
|
I wasn't able to successfully compile strace yet.
Code: | signal.c: In function ‘sys_sigreturn’:
signal.c:729:3: error: invalid use of undefined type ‘struct pt_regs’ |
I assume some kind of musl incompatibility. Haven't had time to look into it yet.
Quote: |
You've also tried the '(gdb) set disable-randomization off' from stackoverflow?
|
Yep I did. I wasn't able to reproduce the segfault in gdb, even with that setting.
Quote: |
I'd also be curious about whether the sed testsuite ('make check') causes segfaults. |
Hmmm:
Code: | ======================================
2 of 65 tests failed
Please report to bug-gnu-utils@gnu.org
======================================
|
Full log here: http://sprunge.us/NjFa
Not sure what to make of it yet. |
|
Back to top |
|
|
heiwa n00b
Joined: 24 Oct 2012 Posts: 70
|
|
Back to top |
|
|
Deathcrow n00b
Joined: 24 Jul 2006 Posts: 32
|
Posted: Tue Apr 14, 2015 10:47 pm Post subject: |
|
|
I already tried something like that but I think I did it wrong the last time. Now it worked. strace here we come... I made simple bash script to execute a bunch of times hoping for segfault:
http://sprunge.us/GVKM?bash
Output: http://sprunge.us/XdYM?bash
Sadly no segfaults during strace. They only happen when not using strace (see bottom).
This was a great idea! I didn't think of creating a core dump...
Code: |
odroid ~ # gdb sed core
GNU gdb (Gentoo 7.7.1 p1) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "armv7a-hardfloat-linux-musleabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://bugs.gentoo.org/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from sed...done.
[New LWP 2420]
Core was generated by `sed -e s/./a/g'.
Program terminated with signal SIGSEGV, Segmentation fault.
Cannot access memory at address 0x3f
#0 0xb6ef42e4 in ?? () from /lib/ld-musl-armhf.so.1
(gdb) bt
Cannot access memory at address 0x3f
#0 0xb6ef42e4 in ?? () from /lib/ld-musl-armhf.so.1
#1 0xb6ef4730 in ?? () from /lib/ld-musl-armhf.so.1
Cannot access memory at address 0x3f
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb)
|
Am I reading this correct that it is musl library that is segfaulting? I recompile musl with debugging flags.
Code: |
odroid musl-1.1.8 # gdb sed core
GNU gdb (Gentoo 7.7.1 p1) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "armv7a-hardfloat-linux-musleabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://bugs.gentoo.org/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from sed...done.
[New LWP 19788]
Core was generated by `sed -e s/./a/g'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 unbin (c=0x2ffd8, c@entry=0x47, i=i@entry=63) at src/malloc/malloc.c:240
240 c->prev->next = c->next;
(gdb) bt
#0 unbin (c=0x2ffd8, c@entry=0x47, i=i@entry=63) at src/malloc/malloc.c:240
#1 0xb6e9e97c in alloc_rev (c=0x47, c@entry=0x2ffd8) at src/malloc/malloc.c:271
#2 0xb6e9ea9c in free (p=p@entry=0x2ffe0) at src/malloc/malloc.c:502
#3 0x0001eb88 in re_search_stub (bufp=bufp@entry=0xb6f106c0, string=string@entry=0xb6f10f50 "<Multi_key> <Cyrillic_zhe> <comma> : \"\\201\"\tCyrillic_zhe_descender", length=<optimized out>, start=<optimized out>, range=71,
range@entry=-1225727464, stop=71, regs=0x2a2bc <regs>, regs@entry=0xf86c <match_regex+132>, ret_len=ret_len@entry=false) at regexec.c:505
#4 0x0001f090 in rpl_re_search (bufp=bufp@entry=0xb6f106c0, string=string@entry=0xb6f10f50 "<Multi_key> <Cyrillic_zhe> <comma> : \"\\201\"\tCyrillic_zhe_descender", length=<optimized out>, start=<optimized out>, range=71,
regs=regs@entry=0x2a2bc <regs>) at regexec.c:334
#5 0x0000f86c in match_regex (regex=0xb6f106c0, buf=0xb6f10f50 "<Multi_key> <Cyrillic_zhe> <comma> : \"\\201\"\tCyrillic_zhe_descender", buflen=<optimized out>, buf_start_offset=buf_start_offset@entry=0,
regarray=regarray@entry=0x2a2bc <regs>, regsize=1) at regexp.c:252
#6 0x0000ec94 in do_subst (sub=0x0) at execute.c:1187
#7 execute_program (vec=0x30018, input=<optimized out>) at execute.c:1624
#8 0x0000f564 in process_files (the_program=0xb6f10270, argv=<optimized out>) at execute.c:1855
#9 0x0000a480 in main (argc=<optimized out>, argv=0xbed0a024) at sed.c:349
(gdb)
|
malloc.c:236ff
Code: |
static void unbin(struct chunk *c, int i)
{
if (c->prev == c->next)
a_and_64(&mal.binmap, ~(1ULL<<i));
c->prev->next = c->next;
c->next->prev = c->prev;
c->csize |= C_INUSE;
NEXT_CHUNK(c)->psize |= C_INUSE;
}
|
Code: |
(gdb) print c
$10 = (struct chunk *) 0x2f2e8
(gdb) print c->prev
$11 = (struct chunk *) 0xb6ffdd20 <mal+688>
(gdb) print c->prev->prev
$12 = (struct chunk *) 0xb6fff268
(gdb) print c->prev->prev->prev
$13 = (struct chunk *) 0x2f2e8
(gdb) print c->next
$14 = (struct chunk *) 0xb6fff268
(gdb) print c->next->next
$15 = (struct chunk *) 0xb6ffdd20 <mal+688>
(gdb) print c->next->next->next
$16 = (struct chunk *) 0x2f2e8
(gdb)
|
What's <mal+688>?
EDIT: FYI, the segfault becomes _much_ harder to reproduce when sed and musl compiled with O0 and various debugging stuff (first I thought it didn't occur at all anymore). |
|
Back to top |
|
|
heiwa n00b
Joined: 24 Oct 2012 Posts: 70
|
Posted: Wed Apr 15, 2015 7:08 pm Post subject: |
|
|
Thanks for the strace output. I don't think it would be very different
in the segfaulting cases.
The segfault looks like a memory corruption issue which might have
occured much earlier. <mal+688> is if I did not miscompute pointing
to mal.bins[42]. This is a struct bin and not a struct chunk. For
32bit archs the pointers in these structs match up. But it seems
very likely that this condition should never happen.
I don't have many ideas how to go further. Try asking for help on
#musl...
It's nice that the sed line is very minimal. I'm assuming that
the arguments to cpp are also unecessary. Is that right? Also are
the segfaults sensitive to random changes in the input file?
For debugging the memory corruption further, it might be useful
to log malloc, calloc, free and realloc with an LD_PRELOAD library.
Adapted from http://stackoverflow.com/a/6083624, compile with
gcc -shared -fPIC -o replace.so replace.c :
Code: |
#define _GNU_SOURCE
#include <stdio.h>
#include <dlfcn.h>
static void *(*real_malloc)(size_t) = NULL;
static void *(*real_calloc)(size_t, size_t) = NULL;
static void *(*real_realloc)(void *, size_t) = NULL;
static void (*real_free)(void *) = NULL;
static void mtrace_init(void)
{
real_malloc = dlsym(RTLD_NEXT, "malloc");
real_calloc = dlsym(RTLD_NEXT, "calloc");
real_realloc = dlsym(RTLD_NEXT, "realloc");
real_free = dlsym(RTLD_NEXT, "free");
if (NULL == real_malloc) fprintf(stderr, "Error in `dlsym`: %s\n", dlerror());
if (NULL == real_calloc) fprintf(stderr, "Error in `dlsym`: %s\n", dlerror());
if (NULL == real_realloc) fprintf(stderr, "Error in `dlsym`: %s\n", dlerror());
if (NULL == real_free) fprintf(stderr, "Error in `dlsym`: %s\n", dlerror());
}
void *malloc(size_t size)
{
if(real_malloc==NULL) mtrace_init();
void *p = NULL;
fprintf(stderr, "malloc(%ld) = ", size);
p = real_malloc(size);
fprintf(stderr, "%p\n", p);
return p;
}
void *calloc(size_t nelem, size_t elsize)
{
if(real_calloc==NULL) mtrace_init();
void *p = NULL;
fprintf(stderr, "calloc(%ld, %ld) = ", nelem, elsize);
p = real_calloc(nelem, elsize);
fprintf(stderr, "%p\n", p);
return p;
}
void *realloc(void *p, size_t size)
{
if(real_realloc==NULL) mtrace_init();
void *q = NULL;
fprintf(stderr, "realloc(%p, %ld) = ", p, size);
q = real_realloc(p, size);
fprintf(stderr, "%p\n", q);
return q;
}
void free(void *p)
{
if(real_free==NULL) mtrace_init();
fprintf(stderr, "free(%p)\n", p);
real_free(p);
}
|
|
|
Back to top |
|
|
Deathcrow n00b
Joined: 24 Jul 2006 Posts: 32
|
Posted: Wed Apr 15, 2015 9:08 pm Post subject: |
|
|
heiwa wrote: | Thanks for the strace output. I don't think it would be very different
in the segfaulting cases.
The segfault looks like a memory corruption issue which might have
occured much earlier. <mal+688> is if I did not miscompute pointing
to mal.bins[42]. This is a struct bin and not a struct chunk. For
32bit archs the pointers in these structs match up. But it seems
very likely that this condition should never happen.
|
I agree that it must happen somewhere earlier. The c->next... stuff looks pretty harmless by itself.
Quote: |
I don't have many ideas how to go further. Try asking for help on
#musl...
|
Maybe... usually IRC is just a bunch of people idling with no one responding.
Quote: |
It's nice that the sed line is very minimal. I'm assuming that
the arguments to cpp are also unecessary. Is that right? Also are
the segfaults sensitive to random changes in the input file?
|
About changing parts of the input file: In my earlier tests I screwed around with this and was able to delete some lines and still get the segfault. I didn't find a consistent pattern thought.
About cpp: Actually no, the segfaults disappear when "-traditional" is removed. From my look at things -traditional changes some stuff with the formatting? Tabs, spaces,etc...
Quote: |
For debugging the memory corruption further, it might be useful
to log malloc, calloc, free and realloc with an LD_PRELOAD library.
Adapted from http://stackoverflow.com/a/6083624, compile with
gcc -shared -fPIC -o replace.so replace.c :
|
This is the output of the LD_PRELOAD trick:
http://sprunge.us/cZQH?bash
I don't think free(0) is a good move, but I'm not sure. Maybe this is normal in segfaults? |
|
Back to top |
|
|
heiwa n00b
Joined: 24 Oct 2012 Posts: 70
|
Posted: Thu Apr 16, 2015 5:58 pm Post subject: |
|
|
Deathcrow wrote: |
I agree that it must happen somewhere earlier. The c->next... stuff looks pretty harmless by itself.
Quote: |
I don't have many ideas how to go further. Try asking for help on
#musl...
|
Maybe... usually IRC is just a bunch of people idling with no one responding.
|
#musl is quite active and there are clever people there.
Quote: |
Quote: |
It's nice that the sed line is very minimal. I'm assuming that
the arguments to cpp are also unecessary. Is that right? Also are
the segfaults sensitive to random changes in the input file?
|
About changing parts of the input file: In my earlier tests I screwed around with this and was able to delete some lines and still get the segfault. I didn't find a consistent pattern thought.
About cpp: Actually no, the segfaults disappear when "-traditional" is removed. From my look at things -traditional changes some stuff with the formatting? Tabs, spaces,etc...
|
I see.
Quote: |
Quote: |
For debugging the memory corruption further, it might be useful
to log malloc, calloc, free and realloc with an LD_PRELOAD library.
Adapted from http://stackoverflow.com/a/6083624, compile with
gcc -shared -fPIC -o replace.so replace.c :
|
This is the output of the LD_PRELOAD trick:
http://sprunge.us/cZQH?bash
|
Thanks. I would be interesting to compare to the output in the case
when no segfault happens and to see how the output varies between
different runs.
Quote: |
I don't think free(0) is a good move, but I'm not sure. Maybe this is normal in segfaults? |
The C standard says that free(0) is a nop. |
|
Back to top |
|
|
Deathcrow n00b
Joined: 24 Jul 2006 Posts: 32
|
Posted: Mon Apr 20, 2015 12:04 pm Post subject: |
|
|
Some users from #musl helped me to get some more information.
First off: When I did an strace earlier in this thread I did it against cpp and not sed. Simple fuckup.
Furthermore: Even though there's no segfault when strace'ing sed there's still the possibility of comparing different strace runs. Here's 2 interesting diffs:
http://sprunge.us/DISN
http://sprunge.us/cDSQ
I was also advised to set /proc/sys/kernel/randomize_va_space (address space randomization) to 0 in order to remove the randomness I'm experiencing. This didn't change anything in the behavior of sed though. |
|
Back to top |
|
|
heiwa n00b
Joined: 24 Oct 2012 Posts: 70
|
Posted: Tue Apr 21, 2015 5:54 pm Post subject: |
|
|
Deathcrow wrote: |
Some users from #musl helped me to get some more information.
|
I thought that they would have some better ideas about what is wrong
Quote: |
First off: When I did an strace earlier in this thread I did it against
cpp and not sed. Simple fuckup.
Furthermore: Even though there's no segfault when strace'ing sed there's
still the possibility of comparing different strace runs. Here's 2 interesting diffs:
http://sprunge.us/DISN
http://sprunge.us/cDSQ
|
I guess that the second diff is mostly due to the fact that in one case
stdout was a terminal but not in the other. Actually, in my strace's of
sed there is no TIOCGWSIZE at all.
The differences between the readv's is what I would expect when the
speed in which cpp writes to the pipe and sed tries to read from it
varies slightly from time to time.
Quote: |
I was also advised to set /proc/sys/kernel/randomize_va_space (address
space randomization) to 0 in order to remove the randomness I'm
experiencing. This didn't change anything in the behavior of sed though.
|
It is very sensible to try to reduce the randomness.
It would be cool to have even less randomness, like a reproducible test
case... Let's add some logging to sed:
Code: |
--- a/sed-4.2.2/sed/utils.c
+++ b/sed-4.2.2/sed/utils.c
@@ -263,6 +263,7 @@
error = ferror (stream);
}
+ fprintf(stderr, "getdelim(%p, %lu, %d, %p) = %ld\n", text, buflen, (int)buffer_delimiter, stream, result);
if (error)
panic (_("read error on %s: %s"), utils_fp_name(stream), strerror(errno));
|
Maybe you can then see some pattern distinguishing between the good and
bad runs. |
|
Back to top |
|
|
chainsawbike Tux's lil' helper
Joined: 27 Dec 2007 Posts: 78 Location: the great new zealand
|
Posted: Sat Oct 24, 2015 5:44 am Post subject: |
|
|
i hit the same issue
for me it works if i set "MAKEOPTS" to j3 or below
setting it to j4 consistently causes the segfault above |
|
Back to top |
|
|
heiwa n00b
Joined: 24 Oct 2012 Posts: 70
|
Posted: Sat Oct 24, 2015 5:47 pm Post subject: |
|
|
I can now reproduce the issue (in sed) consistently. Test program:
Code: |
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <fcntl.h>
int main(void)
{
char buf[2048];
struct timespec ts = {0, 20000*1000};
int i;
char *p = buf, nl = '\n';
for (i = 0; i < 33; i++) *(p++) = 'a';
*(p++) = '\n';
for (i = 0; i < 919; i++) *(p++) = '\n';
for (i = 0; i < 71; i++) *(p++) = 'b';
*(p++) = '\n';
*(p++) = '\n';
for (i = 0; i < 72; i++) *(p++) = 'c';
write(1, &nl, 1);
nanosleep(&ts, 0);
write(1, buf, 1098);
return 0;
}
|
Compile and pipe output to "sed 's/./a/g'". Now strace and gdb work:
Code: |
Program received signal SIGSEGV, Segmentation fault.
0xb6f870c4 in realloc () from /lib/ld-musl-armhf.so.1
(gdb) bt
#0 0xb6f870c4 in realloc () from /lib/ld-musl-armhf.so.1
#1 0xb6fad5a8 in getdelim () from /lib/ld-musl-armhf.so.1
#2 0x7f564110 in ck_getline (text=0x7f5982a0 <b>, buflen=0x7f5982a4 <blen>, stream=0x7f59d2e0) at utils.c:273
#3 0x7f55d5dc in read_file_line (input=0xbefff7b0) at execute.c:528
#4 0x7f55e730 in read_pattern_space (input=0xbefff7b0, the_program=0xb6fff260, append=0) at execute.c:868
#5 0x7f561a40 in process_files (the_program=0xb6fff260, argv=0xbefff8cc) at execute.c:1853
#6 0x7f557814 in main (argc=3, argv=0xbefff8c4) at sed.c:349
|
|
|
Back to top |
|
|
heiwa n00b
Joined: 24 Oct 2012 Posts: 70
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|