sm00th / bitlbee-discord

Bitlbee plugin for Discord (http://discordapp.com)
GNU General Public License v2.0
290 stars 27 forks source link

Segfaults on arm/arm64. #83

Closed sm00th closed 7 years ago

sm00th commented 7 years ago

There were reports of bitlbee-discord segfaulting on arm boards. Got a backtrace of one of those and will need to further investigate this.

Program received signal SIGSEGV, Segmentation fault.
strlen () at ../ports/sysdeps/arm/armv6/strlen.S:26
26      ../ports/sysdeps/arm/armv6/strlen.S: No such file or directory.
---Type <return> to continue, or q <return> to quit---
#0  strlen () at ../ports/sysdeps/arm/armv6/strlen.S:26
#1  0x76ac8730 in _IO_vfprintf_internal (s=s@entry=0x7effe288,
    format=format@entry=0x7681ff44 "<<< (%s) %s %lu\n%s\n", ap=..., ap@entry=...) at vfprintf.c:1642
#2  0x76b68608 in __GI___vasprintf_chk (result_ptr=0x7effe360, flags=1,
    format=0x7681ff44 "<<< (%s) %s %lu\n%s\n", args=...) at vasprintf_chk.c:66
#3  0x76ea41f4 in g_vasprintf () from /lib/arm-linux-gnueabihf/libglib-2.0.so.0
#4  0x76e7b7ac in g_strdup_vprintf () from /lib/arm-linux-gnueabihf/libglib-2.0.so.0
#5  0x7681ecdc in discord_debug (format=0x7681ff44 "<<< (%s) %s %lu\n%s\n") at discord-util.c:25
#6  0x7681cac0 in discord_parse_message (ic=0x54b4cb78,
    buf=0x54b4fb50 "{\"t\":null,\"s\":null,\"op\":10,\"d\":{\"heartbeat_interval\":41250,\"_trace\":[\"discord-g---Type <return> to continue, or q <return> to quit---
ateway-prd-1-17\"]}}", size=<optimized out>) at discord-handlers.c:617
#7  0x7681f554 in discord_ws_in_cb (Cannot access memory at address 0x1
data=0x54b4cb78, source=<optimized out>, cond=<optimized out>)
    at discord-websockets.c:233
#8  0x54acd124 in ?? ()
Cannot access memory at address 0x1
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb)
ce-dot commented 7 years ago

Can confirm. Crashes on my Raspberry Pi Version B (armv6h) as soon as I activate the discord account with 'account discord on'. I'll try to look into it with my limited knowledge of these things...

sm00th commented 7 years ago

ad5b27b fixes that for me, if someone else is still experiences crashes on arm/arm64 please reopen and provide a backtrace.

dequis commented 7 years ago

Ohhh interesting one!

FWIW glib has a portability macro for PRIu64, G_GUINT64_FORMAT, but not sure what platforms need it.

sm00th commented 7 years ago

Might have used that instead, but I assume that'll be identical, just a little bit more readable. This segfault looks like glib's bug but I didn't look deeper into it, only found out this was the issue because standard vprintf started spewing out wrong values.

dequis commented 7 years ago

Yeah it's going to be PRIu64 where PRIu64 is available

Did you actually get any reports of this from arm64? Both reports in this thread are armv6 which is 32 bit and sizeof(long) is 4 there (as opposed to 8 in 64 bit linux platforms, see https://godbolt.org/g/iPfky8). So the way it broke makes sense

sm00th commented 7 years ago

Somebody reported it segfaulting on rpi3, which is arm64, but I didn't get any backtraces from that person. I don't have any arm64 boards handy but I should be able to find one. EDIT: a vm should be enough though

ce-dot commented 7 years ago

Can confirm this crash is fixed on my armv6h gen 1 RPi. Now I'm affected by https://github.com/sm00th/bitlbee-discord/issues/71 and am unable to log in.