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

segfault on start (in getLocalIps () at Hostdb.cpp:2844) #168

Open
onlyjob opened this issue May 5, 2021 · 4 comments
Open

segfault on start (in getLocalIps () at Hostdb.cpp:2844) #168

onlyjob opened this issue May 5, 2021 · 4 comments

Comments

@onlyjob
Copy link
Contributor

onlyjob commented May 5, 2021

Gigablast segfaults on start:

Program received signal SIGSEGV, Segmentation fault.
0x000055555575a724 in getLocalIps () at Hostdb.cpp:2844
2844                    int32_t ip = xx->sin_addr.s_addr;
(gdb) bt
#0  0x000055555575a724 in getLocalIps () at Hostdb.cpp:2844
#1  0x0000555555756d8b in Hostdb::init (this=0x555556722000 <g_hostdb>, hostIdArg=-1, netName=0x0, proxyHost=false, useTmpCluster=0 '\000', 
    cwd=0x555555f7b9e0 <getcwd2(char*)::s_cwdBuf> "/var/tmp/debian/TODO.gigablast/GITHUB.fork/") at Hostdb.cpp:1077
#2  0x00005555555e3e8a in main2 (argc=1, argv=0x7fffffffdc88) at main.cpp:1574
#3  0x00005555555e2e35 in main (argc=1, argv=0x7fffffffdc88) at main.cpp:399

(gdb) bt full
#0  0x000055555575a724 in getLocalIps () at Hostdb.cpp:2844
        xx = 0x56e63b38
        ip = 6215224
        s_valid = true
        ifap = 0x555556e63b00
        p = 0x555556e63b00
        ni = 1
        loopback = 16777343
#1  0x0000555555756d8b in Hostdb::init (this=0x555556722000 <g_hostdb>, hostIdArg=-1, netName=0x0, proxyHost=false, useTmpCluster=0 '\000', 
    cwd=0x555555f7b9e0 <getcwd2(char*)::s_cwdBuf> "/var/tmp/debian/TODO.gigablast/GITHUB.fork/") at Hostdb.cpp:1077
        dir = 0x555555f7b9e0 <getcwd2(char*)::s_cwdBuf> "/var/tmp/debian/TODO.gigablast/GITHUB.fork/"
        filename = 0x5555559f0890 "hosts.conf"
        f = {m_closedIt = false, 
          m_filename = "/var/tmp/debian/TODO.gigablast/GITHUB.fork/hosts.conf\000\003\000\000\000\200\340\377\367\377\177\000\000\002", '\000' <repeats 31 times>, m_this = 0x0, m_i = 0, m_closeCount = 1, m_fd = 3, m_flags = 0, m_calledOpen = 1 '\001', m_calledSet = 1 '\001', m_st_mtime = 0, m_st_size = 0}
        status = 1
        numRead = 2716
        p = 0x555556723ad8 <g_hostdb+6872> ""
        pend = 0x555556723ad8 <g_hostdb+6872> ""
        i = 1
        numGrunts = 1
        line = 67
        proxyNum = 0
        indexSplits = 1
        wdir2 = 0x0
        wdirlen2 = 0
        numMirrors = 0
        hostsPerShard = 1
        j = 0
        deadHostTimeout = 2147483647
        next = 1
        localIps = 0x0
        host = 0x0
        h = 0x0
        gcount = 0
#2  0x00005555555e3e8a in main2 (argc=1, argv=0x7fffffffdc88) at main.cpp:1574
        stackPointTestAnchor = 86 'V'
        cmdarg = 0
        cmd = 0x5555558d4c3e ""
        cmd2 = 0x5555558d4c3e ""
        arch = 64
        cc = 0x0
        testMandrill = false
        rl = {rlim_cur = 8388608, rlim_max = 18446744073709551615}
        lim = {rlim_cur = 1024, rlim_max = 1024}
        NOFILE = 1024
        rlim = {rlim_cur = 1024, rlim_max = 1024}
        isProxy = false
        useTmpCluster = 0 '\000'
        workingDir = 0x555555f7b9e0 <getcwd2(char*)::s_cwdBuf> "/var/tmp/debian/TODO.gigablast/GITHUB.fork/"
        h9 = 0x555556db23fc <g_scraper+264828>
        ips = 0x555556db25cc <g_scraper+265292>
        tmp = "\224\376\327VUU\000\000\264\376\327VUU\000\000\324\376\327VUU\000\000\364\376\327VUU\000\000,\000\330VUU\000\000p\032\330VUU\000\000T'\330VUU\000\000\360'\330VUU\000\000\244(\330VUU\000\000\354,\330VUU\000\000\344Y\330VUU\000\000\214\\\330VUU\000\000\064_\330VUU\000\000\334a\330VUU\000\000\204d\330VUU\000\000,g\330VUU\000"
        cleanFileName = {m_capacity = 1456969928, m_length = 21845, m_buf = 0x555556d7f218 <g_scraper+55448> "\001\001", m_label = 0x555556d7fc48 <g_scraper+58056> "",
          m_usingStack = 116, m_encoding = 22231, m_renderHtml = 85 'U'}
        pcount = 21845
        structureFile = "8\033\327VUU\000\000\024%\327VUU\000\000\310\067\327VUU\000\000\350\067\327VUU\000\000\b8\327VUU\000\000\340\071\327VUU\000\000@:\327VUU\000\000\330<\327VUU\000\000\b=\327VUU\000\000dB\327VUU\000\000 C\327VUU\000\000`C\327VUU\000\000\240C\327VUU\000\000\320C\327VUU\000\000\070|\327VUU\000\000X|\327VUU\000\000\254\210\327VUU\000\000\214\211\327VUU\000\000Ȋ\327VUU\000\000\374\213\327VUU\000\000H\215\327VUU\000\000\350\215\327VUU\000\000\f\216\327VUU\000\000,\216\327VUU\000\000L\216\327VUU\000\000l"...
        nce = 21845
--Type <RET> for more, q to quit, c to continue without paging--
        maxMem = 1457201372
        json = {m_sb = {m_capacity = 0, m_length = 0, m_buf = 0x0, m_label = 0x7ffff7ffe180 "", m_usingStack = 96, m_encoding = -1, m_renderHtml = -1 '\377'}, m_stack = {
            0x7fffffffd240, 0x0, 0x7ffff7891130, 0x2, 0x0, 0x0, 0x0, 0x0, 0x7ffff7890a90, 0x7ffff7fdbf9c <check_match+300>, 0xd82b830, 0x1, 0x7ffff76b6dc8,
            0x7ffff7fdbf9c <check_match+300>, 0xb01bca00, 0x0, 0x7ffff7fd0190, 0x7fffffffd6d0, 0x0, 0x7ffff7fdc3a4 <do_lookup_x+932>, 0x2, 0x7ffff7fd02d8, 0x7ffff7ffe730,
            0x7fffffffd568, 0x7fffffffd564, 0x7ffff7fdbf9c <check_match+300>, 0xe6854b87, 0x0, 0x7ffff7fd02d8, 0x7ffff7fd01b8, 0x7ffff783c478, 0xb01bca00, 0x2c06f28,
            0x7fffffffd564, 0x7ffff7ffe758, 0x555556cc6288 <g_repair+218984>, 0x7fffffffd560, 0x555556da1c24 <g_scraper+197284>, 0x7fffffffd570, 0x55555572e05c
     <Msg0::constructor()+164>, 0x7fffffffd590, 0x555556da1b98 <g_scraper+197144>, 0x7fffffffd5a0, 0x55555572df79 <Msg0::Msg0()+61>, 0x555556d719d4 <g_scraper+84>,
            0x55555570deb7 <Query::reset()+275>, 0x7fffffffd5b0, 0x555556dbba0c <g_scraper+303244>, 0xffffffffffffffff, 0x555556e13274 <g_scraper+661748>,
            0x555556d719d4 <g_scraper+84>, 0x5555558351e2 <TagRec::reset()+74>, 0x555556e0fa34 <g_scraper+647348>, 0x555556d8b860 <g_scraper+106208>,
            0x555556d719d4 <g_scraper+84>, 0x555556da20b4 <g_scraper+198452>, 0x555556d719d4 <g_scraper+84>, 0x555555661829 <XmlDoc::reset()+4137>, 0x7fffffffd620,
            0x555556d719d4 <g_scraper+84>, 0x555556e1c354 <g_scraper+698836>, 0x555556e1c2dc <g_scraper+698716>, 0x555556e1c2fc <g_scraper+698748>,
            0x555556e1c374 <g_scraper+698868>}, m_stackPtr = 1457636280, m_prev = 0x55662b1800005555}
#3  0x00005555555e2e35 in main (argc=1, argv=0x7fffffffdc88) at main.cpp:399
        ret = 0


(gdb) thread apply all bt

Thread 1 (Thread 0x7ffff76a6740 (LWP 188821) "gb"):
#0  0x000055555575a724 in getLocalIps () at Hostdb.cpp:2844
#1  0x0000555555756d8b in Hostdb::init (this=0x555556722000 <g_hostdb>, hostIdArg=-1, netName=0x0, proxyHost=false, useTmpCluster=0 '\000', cwd=0x555555f7b9e0 <getcwd2(char*)::s_cwdBuf> "/var/tmp/debian/TODO.gigablast/GITHUB.fork/") at Hostdb.cpp:1077
#2  0x00005555555e3e8a in main2 (argc=1, argv=0x7fffffffdc88) at main.cpp:1574
#3  0x00005555555e2e35 in main (argc=1, argv=0x7fffffffdc88) at main.cpp:399

https://github.com/gigablast/open-source-search-engine/blob/master/Hostdb.cpp#L2844

@onlyjob
Copy link
Contributor Author

onlyjob commented May 5, 2021

I've been trying to get around this problem and I've managed to start Gigablast with the following patch (not a fix!):

--- a/Hostdb.cpp
+++ b/Hostdb.cpp
@@ -2833,10 +2833,12 @@
 	int32_t ni = 0;
 	// store loopback just in case
 	int32_t loopback = atoip("127.0.0.1");
 	s_localIps[ni++] = loopback;
+	s_localIps[ni++] = loopback;
 	for ( ; p && ni < 18 ; p = p->ifa_next ) {
 		// avoid possible core dump
+		continue;
 		if ( ! p->ifa_addr ) continue;
 		//break; // mdw hack...
 		struct sockaddr_in *xx = (sockaddr_in *)p->ifa_addr;
 		// fix the bug when compiling for 64-bit arch

Unfortunately I'm not qualified to fix the problem properly but I hope that the patch might get us just a little bit closer to understanding...

@onlyjob
Copy link
Contributor Author

onlyjob commented May 5, 2021

@CompunixAustralia
Copy link
Contributor

This appears to be related to #86

Even after ifaddr.h is placed above gb-include.h, the swapInts function causes segfault with *xx and needs further debuging.
segfault also occurs with swapInts call removed and ifaddr.h below gb-include.h

Will issue a pull request

@CompunixAustralia
Copy link
Contributor

See CompunixAustralia@014ed8d

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

No branches or pull requests

2 participants