zedeus / nitter

Alternative Twitter front-end
https://nitter.net
GNU Affero General Public License v3.0
10.13k stars 535 forks source link

Alignment trap: not handling instruction ed837b00 at [<006cf43c>] #316

Open Marcool04 opened 3 years ago

Marcool04 commented 3 years ago

Hi, I have been experimenting with using nitter on a Raspberrypi 4B+ (8Gb RAM) running Archlinuxarm, and the program keeps crashing after a short while of otherwise normal use.

Some basic information on the system:

[root@HOSTNAME ~]# uname -a
Linux HOSTNAME 5.4.83-5-ARCH #1 SMP PREEMPT Sun Jan 3 16:11:27 UTC 2021 armv7l GNU/Linux
[root@HOSTNAME ~]# nim --version
Nim Compiler Version 1.4.2 [Linux: arm]
Compiled at 2020-12-15
Copyright (c) 2006-2020 by Andreas Rumpf

active boot switches: -d:release -d:nativeStackTrace
[root@HOSTNAME ~]# nimble --version
nimble v0.12.0 compiled at 2020-10-17 11:33:44
git hash: couldn't determine git hash

Here is my nitter.conf:

[Server]
address = "localhost"  # Change this?
port = 13500  # Change this?
https = false  # disable to enable cookies when not using https
staticDir = "/usr/share/webapps/nitter/public"
title = "nitter"  # Change this?
hostname = "nitter.HOSTNAME"  # Change this

[Cache]
listMinutes = 240  # how long to cache list info (not the tweets, so keep it high)
rssMinutes = 10  # how long to cache rss queries
redisHost = "localhost"
redisPort = 6379
redisConnections = 20 # connection pool size
redisMaxConnections = 30
# max, new connections are opened when none are available, but if the pool size
# goes above this, they're closed when released. don't worry about this unless
# you receive tons of requests per second

[Config]
hmacKey = "RANDOM_KEY" # Regenerate e.g. `head -c 25 </dev/urandom | sha256sum`
base64Media = true # use base64 encoding for proxied media urls
tokenCount = 10
# minimum amount of usable tokens. tokens are used to authorize API requests,
# but they expire after ~1 hour, and have a limit of 187 requests.
# the limit gets reset every 15 minutes, and the pool is filled up so there's
# always at least $tokenCount usable tokens. again, only increase this if
# you receive major bursts all the time

# Change default preferences here, see src/prefs_impl.nim for a complete list
[Preferences]
theme = "twitter_dark"  # Change this?
replaceTwitter = "nitter.HOSTNAME"  # Use the same "hostname" as above
replaceYouTube = ""
replaceInstagram = ""
proxyVideos = false
hlsPlayback = false
infiniteScroll = false

After the crashes started I tried to get a backtrace from the core dump with gdb and discovered the installation process had stripped the debug symbols, so I modified it to include them again. I adapted the ArchUserRepository script nitter-git, and here is the PKGBUILD I used to build and install nitter:

# Maintainer: somini <dev@somini.xyz>
_pkgname=nitter
pkgname=nitter-git
pkgver=r693.67e15bb
pkgrel=1
pkgdesc="Alternative Twitter front-end"
url="https://github.com/zedeus/nitter"
depends=('redis')
provides=("$_pkgname")
conflicts=("$_pkgname")
makedepends=('git' 'nim' 'nimble' 'libsass')
backup=('etc/webapps/nitter/nitter.conf')
license=('AGPL3')
arch=('x86_64' 'armv7h')
options=(debug !strip)
install=nitter.install
source=("$pkgname::git+$url.git#branch=master"
            "config.patch"
            "tmpfilesd.conf"
            "nitter.sh"
            "nitter.service"
            "nitter.install")
sha256sums=('SKIP'
            'eaa75a67d28d3fbcbd24f3f13a53bb21eded0412a38e67b61330cbab308154bd'
            '620e38c7bb978a64d276b499d097ec4967fe8bda16852fe0c416ed61744b6526'
            '79469c5cfeacf38c7469a2240ba5c19670ddaf757e6d1b5286206a18a0718487'
            '560d98833c56979cb6b5d187a827788dbbdff95871f957225604b58b15c1c219'
            '57eb0d0aa47416006f107df078221e64023881123e8ec961266029db9228af9d')

pkgver() {
  cd "$pkgname"
  ( set -o pipefail
    git describe --long 2>/dev/null | sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
  )
}

prepare() {
  cd "$pkgname"

  # Tweak the configuration file
  patch -p1 <"$srcdir/config.patch"
}

build() {
    cd "${srcdir}/$pkgname"

    # Based on the Dockerfile
#    nimble build -y -d:release
    nimble build -y --debugger:native --debuginfo
    nimble scss
}

package() {
    # Create the cache directory
    install -D -m644 tmpfilesd.conf "$pkgdir/usr/lib/tmpfiles.d/nitter.conf"
    # SystemD service
    install -D -m644 nitter.service -t "$pkgdir/usr/lib/systemd/system"
    # Use a wrapper script as entrypoint
    install -D -m755 nitter.sh "$pkgdir/usr/bin/nitter"

    main_dir="${pkgdir}/usr/share/webapps/${_pkgname}"
    config_dir="${pkgdir}/etc/webapps/${_pkgname}"
    install -dD "$main_dir"
    install -dD "$config_dir"

    cd "${srcdir}/$pkgname"
    # Main EXE
    install -D -m755 nitter -t "$main_dir"
    # Patched Configuration File
    install -D -m600 nitter.conf -t "$config_dir"
    # Link it on the "working" directory
    ln -sv "${config_dir}/nitter.conf" "$main_dir/nitter.conf"
    # Public Folder
    cp -r --no-preserve=all public -t "$main_dir"
    # System User
    printf 'u nitter - "Nitter" \"%s\"' "$main_dir" | install -Dm644 /dev/stdin "$pkgdir/usr/lib/sysusers.d/$pkgname.conf"
}

Here is the debugging information I was able to collect :


[root@HOSTNAME nitter]# journalctl --with-filters
Jan 19 17:53:41 HOSTNAME nitter[22824]: DEBUG GET /ploum/status/1258858160053420032
Jan 19 17:53:41 HOSTNAME nitter[22824]: DEBUG   200 OK {"content-type": @["text/html;charset=utf-8"]}
Jan 19 17:54:42 HOSTNAME kernel: Alignment trap: not handling instruction ed837b00 at [<006cf43c>]
Jan 19 17:54:42 HOSTNAME kernel: 8<--- cut here ---
Jan 19 17:54:42 HOSTNAME kernel: Unhandled fault: alignment exception (0xa21) at 0xb657517b
Jan 19 17:54:42 HOSTNAME kernel: pgd = 4ee18fcd
Jan 19 17:54:42 HOSTNAME kernel: [b657517b] *pgd=1892f003, *pmd=1fcc1b003
Jan 19 17:54:43 HOSTNAME systemd[1]: Started Process Core Dump (PID 23109/UID 0).
Jan 19 17:54:43 HOSTNAME systemd-coredump[23110]: Process 22824 (nitter) of user 973 dumped core.

                                                            Stack trace of thread 22824:
                                                            #0  0x00000000006cf440 uncompress__vyRMsETNmHQ8drxECadMOg (nitter + 0x1ef440)
                                                            #1  0x000000000083e254 uncompress__DxRaQ2KO1dhb0jxK7jUbBQsupersnappy (nitter + 0x35e254)
                                                            #2  0x00000000007f2ab0 matchNimAsyncContinue__lIfHPramjJ4GshQGJBBm6Q (nitter + 0x312ab0)
                                                            #3  0x00000000005cc300 processPendingCallbacks__xdICRvJ1ns9byYHPjM07uJQ (nitter + 0xec300)
                                                            #4  0x00000000005ccd18 runOnce__nEnn7ilZ6aSkcXTtLEKnJA (nitter + 0xecd18)
                                                            #5  0x00000000005cd260 poll__wcvh7vf5dGU1VYto9aiAnpA (nitter + 0xed260)
                                                            #6  0x00000000005d2700 runForever__4E2MjiuuW9bb2xAhvUqWsoQ_2 (nitter + 0xf2700)
                                                            #7  0x0000000000637598 serve__uyVGO9b8GZDPA7YPHmJyO1w (nitter + 0x157598)
                                                            #8  0x000000000086f9b0 NimMainModule (nitter + 0x38f9b0)
                                                            #9  0x000000000086fa78 NimMainInner (nitter + 0x38fa78)
                                                            #10 0x000000000087a5d8 NimMain (nitter + 0x39a5d8)
                                                            #11 0x000000000087a638 main (nitter + 0x39a638)
                                                            #12 0x00000000b6ce2154 __libc_start_main (libc.so.6 + 0x1b154)
Jan 19 17:54:43 HOSTNAME systemd[1]: systemd-coredump@28-23109-0.service: Succeeded.
Jan 19 17:54:43 HOSTNAME systemd[1]: nitter.service: Main process exited, code=dumped, status=7/BUS
Jan 19 17:54:43 HOSTNAME nitter[22824]: DEB
Jan 19 17:54:43 HOSTNAME httpd[27729]: ERRLOG FROM:[SOURCE_IP]:57912 (SOURCE_IP:57912) TO:nitter.HOSTNAME id:277-15 YAcO0kfqbd3i4vbOORU98QABFRA code:(20014)Internal error (specific information not available) level:error module: proxy_http AH01102: error reading status line from remote server 127.0.0.1:13500
Jan 19 17:54:43 HOSTNAME systemd[1]: nitter.service: Failed with result 'core-dump'.
Jan 19 17:54:43 HOSTNAME systemd[1]: nitter.service: Consumed 2.445s CPU time, received 4.7M IP traffic, sent 4.0M IP traffic.

[root@HOSTNAME nitter]# coredumpctl info 22824
           PID: 22824 (nitter)
           UID: 973 (nitter)
           GID: 973 (nitter)
        Signal: 7 (BUS)
     Timestamp: Tue 2021-01-19 17:54:42 CET (40s ago)
  Command Line: ./nitter
    Executable: /usr/share/nitter/nitter
 Control Group: /system.slice/nitter.service
          Unit: nitter.service
         Slice: system.slice
       Boot ID: 0f6da8f6ede94a34aab058ee3fde7e08
    Machine ID: 636821c06d704bb1a53de6839b7fe2c3
      Hostname: HOSTNAME
       Storage: /var/lib/systemd/coredump/core.nitter.973.0f6da8f6ede94a34aab058ee3fde7e08.22824.16110752820>
       Message: Process 22824 (nitter) of user 973 dumped core.

                Stack trace of thread 22824:
                #0  0x00000000006cf440 uncompress__vyRMsETNmHQ8drxECadMOg (nitter + 0x1ef440)
                #1  0x000000000083e254 uncompress__DxRaQ2KO1dhb0jxK7jUbBQsupersnappy (nitter + 0x35e254)
                #2  0x00000000007f2ab0 matchNimAsyncContinue__lIfHPramjJ4GshQGJBBm6Q (nitter + 0x312ab0)
                #3  0x00000000005cc300 processPendingCallbacks__xdICRvJ1ns9byYHPjM07uJQ (nitter + 0xec300)
                #4  0x00000000005ccd18 runOnce__nEnn7ilZ6aSkcXTtLEKnJA (nitter + 0xecd18)
                #5  0x00000000005cd260 poll__wcvh7vf5dGU1VYto9aiAnpA (nitter + 0xed260)
                #6  0x00000000005d2700 runForever__4E2MjiuuW9bb2xAhvUqWsoQ_2 (nitter + 0xf2700)
                #7  0x0000000000637598 serve__uyVGO9b8GZDPA7YPHmJyO1w (nitter + 0x157598)
[root@HOSTNAME ~]# coredumpctl gdb 22824
           PID: 22824 (nitter)
           UID: 973 (nitter)
           GID: 973 (nitter)
        Signal: 7 (BUS)
     Timestamp: Tue 2021-01-19 17:54:42 CET (1min 25s ago)
  Command Line: ./nitter
    Executable: /usr/share/nitter/nitter
 Control Group: /system.slice/nitter.service
          Unit: nitter.service
         Slice: system.slice
       Boot ID: 0f6da8f6ede94a34aab058ee3fde7e08
    Machine ID: 636821c06d704bb1a53de6839b7fe2c3
      Hostname: HOSTNAME
       Storage: /var/lib/systemd/coredump/core.nitter.973.0f6da8f6ede94a34aab058ee3fde7e08.22824.161107528200
0000.zst
       Message: Process 22824 (nitter) of user 973 dumped core.

                Stack trace of thread 22824:
                #0  0x00000000006cf440 uncompress__vyRMsETNmHQ8drxECadMOg (nitter + 0x1ef440)
                #1  0x000000000083e254 uncompress__DxRaQ2KO1dhb0jxK7jUbBQsupersnappy (nitter + 0x35e254)
                #2  0x00000000007f2ab0 matchNimAsyncContinue__lIfHPramjJ4GshQGJBBm6Q (nitter + 0x312ab0)
                #3  0x00000000005cc300 processPendingCallbacks__xdICRvJ1ns9byYHPjM07uJQ (nitter + 0xec300)
                #4  0x00000000005ccd18 runOnce__nEnn7ilZ6aSkcXTtLEKnJA (nitter + 0xecd18)
                #5  0x00000000005cd260 poll__wcvh7vf5dGU1VYto9aiAnpA (nitter + 0xed260)
                #6  0x00000000005d2700 runForever__4E2MjiuuW9bb2xAhvUqWsoQ_2 (nitter + 0xf2700)
                #7  0x0000000000637598 serve__uyVGO9b8GZDPA7YPHmJyO1w (nitter + 0x157598)
                #8  0x000000000086f9b0 NimMainModule (nitter + 0x38f9b0)
                #9  0x000000000086fa78 NimMainInner (nitter + 0x38fa78)
                #10 0x000000000087a5d8 NimMain (nitter + 0x39a5d8)
                #11 0x000000000087a638 main (nitter + 0x39a638)
                #12 0x00000000b6ce2154 __libc_start_main (libc.so.6 + 0x1b154)

GNU gdb (GDB) 10.1
Copyright (C) 2020 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 "armv7l-unknown-linux-gnueabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
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 /usr/share/nitter/nitter...
[New LWP 22824]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
Core was generated by `./nitter'.
Program terminated with signal SIGBUS, Bus error.
(gdb) bt
#0  uncompress__vyRMsETNmHQ8drxECadMOg (src=0x47c22100 <error: Cannot access memory at address 0x47c22100>,
    src@entry=0xb658f030 "\344\032\360i<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rss xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns:dc=\"http://purl\005%@dc/elements/1.1/\"\031{<2.0\">\n  <channel\001\f@  <atom:link href\025Rlnitter.HOSTNAME/se"..., srcLen_0=srcLen_0@entry=1342, dst=0xbe9623ac,
    dst@entry=0xbe9623a4) at NIMBLE_DIR/pkgs/supersnappy-#1.1.5/supersnappy.nim:123
#1  0x0083e254 in uncompress__DxRaQ2KO1dhb0jxK7jUbBQsupersnappy (srcLen_0=1342,
    src=0xb658f030 "\344\032\360i<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rss xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns:dc=\"http://purl\005%@dc/elements/1.1/\"\031{<2.0\">\n  <channel\001\f@  <atom:link href\025Rlnitter.HOSTNAME/se"...) at NIMBLE_DIR/pkgs/supersnappy-#1.1.5/supersnappy.nim:137
#2  matchIter__I2hm28G1FxblnQt5YDc6DQ (ClE_0=0xb5ff4018)
    at NIMBLE_DIR/pkgs/supersnappy-#1.1.5/supersnappy.nim:362
#3  0x007f2ab0 in matchNimAsyncContinue__lIfHPramjJ4GshQGJBBm6Q (ClE_0=0x0)
    at /usr/lib/nim/pure/asyncmacro.nim:29
#4  0x005cc300 in processPendingCallbacks__xdICRvJ1ns9byYHPjM07uJQ (p=p@entry=0xb68a4b08,
    didSomeWork=0xbe9627b3, didSomeWork@entry=0xbe9627ab) at /usr/lib/nim/pure/asyncdispatch.nim:208
#5  0x005ccd18 in runOnce__nEnn7ilZ6aSkcXTtLEKnJA (timeout=timeout@entry=500)
    at /usr/lib/nim/pure/asyncdispatch.nim:1368
#6  0x005cd260 in poll__wcvh7vf5dGU1VYto9aiAnpA (timeout=timeout@entry=500)
    at /usr/lib/nim/pure/asyncdispatch.nim:1627
#7  0x005d2700 in runForever__4E2MjiuuW9bb2xAhvUqWsoQ_2 () at /usr/lib/nim/pure/asyncdispatch.nim:1930
#8  0x00637598 in serve__uyVGO9b8GZDPA7YPHmJyO1w (self=0x88301c,
    self@entry=0x92884c <jes__41VljY6DvAvV5k7Vh0ajiw>)
    at NIMBLE_DIR/pkgs/jester-0.5.0/jester.nim:511
#9  0x0086f9b0 in NimMainModule ()
    at NITTER_BUILD_DIR/src/nitter.nim:55
#10 0x0086fa78 in NimMainInner () at NIMBLE_DIR/pkgs/markdown-#abdbe5e/markdown.nim:1659
#11 0x0087a5d8 in NimMain () at NIMBLE_DIR/pkgs/markdown-#abdbe5e/markdown.nim:1667
#12 0x0087a638 in main (argc=<optimized out>, args=<optimized out>, env=<optimized out>)
    at NIMBLE_DIR/pkgs/markdown-#abdbe5e/markdown.nim:1674
(gdb) q

Let me know if there is anything I can do to help, and sorry if this enters into a "niche" category (arm? archlinux?…) that you don't support. Thanks for the great software anyhow! Best regards, Mark.

zedeus commented 2 years ago

Sorry about the very long delay. Can you confirm this is still an issue with the latest commit compiled with Nim 1.6.2?

Missingmew commented 2 years ago

I ran into a similar issue (nitter crashing with SIGBUS) after pulling an update recently (going to commit 51c6605d3). I unfortunately have no idea which commit I was on previously, but it was buildable with nim 1.4.4.

From the limited testing I had time to do so far, the crash happens whenever the profile of a user (e.g. host/Username) is accessed. Using the commit mentioned above: Building with nim versions 1.4.4 (by editing nitter.nimble), 1.4.8 and 1.6.2 produces reliable crashes, so it doesnt appear to be a nim specific issue.

Platform is a Raspi 4B, 4GB model.

Ill try to set up a debug build as per the OP when I get the chance to do so (and if its still needed).