Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimization flags other than -O0 causing segfault on clang #270

Closed
bket opened this issue Jul 12, 2020 · 0 comments · Fixed by #271
Closed

Optimization flags other than -O0 causing segfault on clang #270

bket opened this issue Jul 12, 2020 · 0 comments · Fixed by #271

Comments

@bket
Copy link
Contributor

bket commented Jul 12, 2020

I'm currently testing sslh-1.21 on OpenBSD current (amd64), which has clang-8.0.1 as base compiler. When the optimization level is other than -O0, sslh segfaults:

$ egdb --args ./sslh-fork -v 4                         
GNU gdb (GDB) 7.12.1
Copyright (C) 2017 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 "x86_64-unknown-openbsd6.7".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://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 ./sslh-fork...done.
(gdb) r
Starting program: /home/code/sslh/sslh-fork -v 4

Program received signal SIGSEGV, Segmentation fault.
0x0000089a3c9b55b0 in config_setting_lookup () from /usr/local/lib/libconfig.so.11.0
(gdb) bt full
#0  0x0000089a3c9b55b0 in config_setting_lookup () from /usr/local/lib/libconfig.so.11.0
No symbol table info available.
#1  0x000008977e077b29 in config_setting_lookup_ud (cfg=0x4, desc=<optimized out>) at sslh-conf.c:1030
        name = "v"
        setting = <optimized out>
#2  0x000008977e078e77 in read_block_setval (target=0x8977e0880b0 <cfg>, cfg=0x4, desc=0x8977e0852c0 <table_sslhcfg>, errmsg=0x7f7ffffd01d8) at sslh-conf.c:1148
        setting = <optimized out>
        in_cfg = <error reading variable in_cfg (Cannot access memory at address 0x0)>
        i = <optimized out>
        block = <optimized out>
#3  0x000008977e0782f4 in read_block (cfg=0x4, target=0x8977e0880b0 <cfg>, desc=0x8977e0852c0 <table_sslhcfg>, errmsg=0x7f7ffffd01d8) at sslh-conf.c:1206
        set = <optimized out>
#4  0x000008977e07814f in sslhcfg_cl_parse (argc=<optimized out>, argv=<optimized out>, cfg=0x8977e0880b0 <cfg>) at sslh-conf.c:1501
        argtable = {0x89a3ad81b00, 0x899a75e1e00, 0x899c46e7000, 0x89a791fd680, 0x89a46e45100, 0x899a75e1180, 0x89a791fdc80, 0x899a75e1d80, 0x899c46e7d80, 
          0x899a75e1500, 0x89a46e45180, 0x899c46e7280, 0x899985c1700, 0x89a61d6da00, 0x89a61d6de00, 0x89a45087500, 0x89a3ad81f00, 0x89a61d6d000, 0x89a45087600, 
          0x89a3ad81a00, 0x89a45087900, 0x89a2960b400}
        nerrors = <optimized out>
        c = {root = 0x4, destructor = 0xb, options = 0, tab_width = 0, float_precision = 0, default_format = 5884, include_dir = 0x7f7ffffd0178 "", 
          include_fn = 0x89a1f8fc8c9 <_dl_find_symbol+457>, error_text = 0x7f7ffffd0188 "", error_file = 0x8977e06f338 "Y", error_line = 2114388485, 
          error_type = (CONFIG_ERR_FILE_IO | CONFIG_ERR_PARSE | unknown: 2196), filenames = 0x899cea50358, hook = 0x89a1da92400}
        errmsg = 0x7f7ffffd02a0 ""
        s = 0x40000000000000
        res = <optimized out>
#5  0x000008977e07b26a in main (argc=4, argv=0x7f7ffffd02b8, envp=<optimized out>) at sslh-main.c:268
        res = <optimized out>
        listen_sockets = <optimized out>
        num_addr_listen = <optimized out>
  • Switching to GCC fixes this issue for all optimization levels
  • Using -O0 with Clang fixes this issue

Any idea how to address this issue?

bket added a commit to bket/sslh that referenced this issue Jul 14, 2020
Without this change the config_t structure is ONLY initialized when it
meets a specific criterion. If this criterion is not met the config_t
structure is still used, which can cause a segmentation fault.

Fixes yrutschle#270.
yrutschle added a commit that referenced this issue Jul 15, 2020
Always initialize config_t structure, fixes #270
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant