Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

Immediately crashes under -fsanitize=address #259

Open
FauxFaux opened this issue Feb 22, 2018 · 0 comments
Open

Immediately crashes under -fsanitize=address #259

FauxFaux opened this issue Feb 22, 2018 · 0 comments

Comments

@FauxFaux
Copy link
Contributor

gcc's -fsanitize=address finds memory safety bugs, normally caused by running older C code on modern compilers. The first bug it finds in charybdis is:

$ make -j 8 CC='gcc -Og -g -fsanitize=address'
...
$ ircd/charybdis -foreground
=================================================================
==19319==ERROR: AddressSanitizer: global-buffer-overflow on address 0x7f53f7ae05a0 at pc 0x7f53f781802a bp 0x7ffe71fbae60 sp 0x7ffe71fbae50
WRITE of size 4 at 0x7f53f7ae05a0 thread T0
    #0 0x7f53f7818029 in parseargs /home/faux/code/charybdis/ircd/getopt.c:67
    #1 0x7f53f781ec24 in charybdis_main /home/faux/code/charybdis/ircd/ircd.c:659
    #2 0x55e8779bc982 in main /home/faux/code/charybdis/ircd/main.c:8
    #3 0x7f53f73f01c0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x211c0)
    #4 0x55e8779bc899 in _start (/home/faux/code/charybdis/ircd/.libs/charybdis+0x899)

0x7f53f7ae05a1 is located 0 bytes to the right of global variable 'server_state_foreground' defined in 'ircd.c:104:6' (0x7f53f7ae05a0) of size 1

..which is the getopt code type-punning a bool into an int:

*((int *) opts[i].argloc) = 1;

Please fix it, and have a play with charybdis built in this mode, to try and improve the developer experience.

You need a reasonably recent gcc, I'm testing 7.3, but I'm pretty sure 6 will catch it.

(I was looking at this as charybdis just segfaults on start for me, which I'm still investigating, and pretty angry about.)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant