Menu

#1317 segfault on Ubuntu 24 used by GitHub Actions Runner

3.0 Series
open
nobody
None
5
2025-07-22
2025-01-04
No

Building the installer for pumpCompanion fails, with a segfault just after adding a lot of files. This consistently happens in the same place, so it is deterministic, but could be just due to the total size the installer is growing to. Due to the presence of a portable Cygwin layer, such installers are ~1GB .

File: "catman.8.gz" [compress] 1854 bytes
File: "mandb.8.gz" [compress] 3053 bytes
File: Descending to: "../../../pumpCompanion-accessories/parts/ubcp/package_ubcp-core/ubcp/cygwin/usr/share/man/man1/"
./ubiquitous_bash.sh: line 46037: 61114 Segmentation fault (core dumped) makensis -V4 "$scriptLib"/nsis/pumpCompanion.nsi

The git repository and commit for which this error occurs is:

https://github.com/mirage335-gizmos/pumpCompanion/tree/bcb8d94c90e35317e23e576c8598a8f1e081db88

This is the nsi file:

https://github.com/mirage335-gizmos/pumpCompanion/blob/bcb8d94c90e35317e23e576c8598a8f1e081db88/_lib/nsis/pumpCompanion.nsi#L66

This is the GitHub Actions workflow:

https://github.com/mirage335-gizmos/pumpCompanion/blob/bcb8d94c90e35317e23e576c8598a8f1e081db88/.github/workflows/build.yml

For now, I am attempting to workaround this bug by such means as pinning to Ubuntu version 22 for runners building these installers.

Discussion

  • Michael Lane

    Michael Lane - 2025-05-13

    We also experienced this issue. I managed to retrieve a core dump from the GitHub runner, which showed that the stack backtrace at the point of the segfault was:

    #0  0x00007fca43e9bd1d in __wcslen_avx2 () from /lib64/libc.so.6
    No symbol table info available.
    #1  0x00007fca4419c1f9 in std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::operator=(wchar_t const*) () from /lib64/libstdc++.so.6
    No symbol table info available.
    #2  0x000000000042279e in posix_dir_reader::read (this=0x21f0fac0, dir=L"Release/bin/TestData")
        at Source/dirreader.cpp:217
            name = L""
            st = {st_dev = 2049, st_ino = 792794, st_nlink = 1, st_mode = 33188, st_uid = 1001, st_gid = 118,
              __pad0 = 0, st_rdev = 0, st_size = 24492, st_blksize = 4096, st_blocks = 48, st_atim = {
                tv_sec = 1746760063, tv_nsec = 403011398}, st_mtim = {tv_sec = 1746757267, tv_nsec = 413842357},
              st_ctim = {tv_sec = 1746757267, tv_nsec = 413842357}, __glibc_reserved = {0, 0, 0}}
            file = "Release/bin/TestData/An_Lão_District.shp"
            dit = 0x2206cea0
            platformpathsep = "/"
            nativedir = 0x21fb4ba0 "Release/bin/TestData"
            dip = 0x2206a170
    #3  0x000000000046531b in CEXEBuild::do_add_file (this=0x7ffd6a926c30,
        lgss=0x21eea740 L"Release/bin/TestData/share", attrib=0, recurse=1, total_files=0x7ffd6a925b54,
        name_override=0x0, generatecode=1, data_handle=0x0, excluded=std::set with 2 elements = {...},
        basedir=L"bin\\TestData", dir_created=false) at Source/script.cpp:5244
            __PRETTY_FUNCTION__ = "int CEXEBuild::do_add_file(const TCHAR*, int, int, int*, const TCHAR*, int, int*, const std::set<std::__cxx11::basic_string<wchar_t> >&, const tstring&, bool)"
            dir = L"Release/bin/TestData"
            spec = L"share"
            dr = {ptr = 0x21f0fac0}
    #4  0x0000000000465810 in CEXEBuild::do_add_file (this=0x7ffd6a926c30, lgss=0x220a0ae0 L"Release/bin/share",
        attrib=0, recurse=1, total_files=0x7ffd6a925b54, name_override=0x0, generatecode=1, data_handle=0x0,
        excluded=std::set with 2 elements = {...}, basedir=L"bin", dir_created=false) at Source/script.cpp:5302
            new_spec = L"Release/bin/TestData/share"
            new_spec_c = 0x21eea740 L"Release/bin/TestData/share"
            new_dir = L"bin\\TestData"
            created = false
            res = 1461362687
            dirs_itr = L"TestData"
            __PRETTY_FUNCTION__ = "int CEXEBuild::do_add_file(const TCHAR*, int, int, int*, const TCHAR*, int, int*, const std::set<std::__cxx11::basic_string<wchar_t> >&, const tstring&, bool)"
            dir = L"Release/bin"
            spec = L"share"
            dr = {ptr = 0x21ee6fd0}
    #5  0x0000000000465810 in CEXEBuild::do_add_file (this=0x7ffd6a926c30, lgss=0x21f27370 L"Release/share", attrib=0,
        recurse=1, total_files=0x7ffd6a925b54, name_override=0x0, generatecode=1, data_handle=0x0,
        excluded=std::set with 2 elements = {...}, basedir=L"", dir_created=true) at Source/script.cpp:5302
            new_spec = L"Release/bin/share"
            new_spec_c = 0x220a0ae0 L"Release/bin/share"
            new_dir = L"bin"
            created = false
            res = 32765
            dirs_itr = L"bin"
            __PRETTY_FUNCTION__ = "int CEXEBuild::do_add_file(const TCHAR*, int, int, int*, const TCHAR*, int, int*, const std::set<std::__cxx11::basic_string<wchar_t> >&, const tstring&, bool)"
            dir = L"Release"
            spec = L"share"
            dr = {ptr = 0x21ebbfa0}
    #6  0x000000000045b65f in CEXEBuild::doCommand (this=0x7ffd6a926c30, which_token=166, line=...)
        at Source/script.cpp:3742
            buf = L"$PLUGINSDIR\\AccessControl.dll\000ca"
            tf = 0
            fn = 0x21f27370 L"Release/share"
            t = 0x21fb67b0 L"Release\\share"
            pluginfullpath = L""
            v = 1461362687
            excluded = std::set with 2 elements = {[0] = L".sconsign", [1] = L"<redacted>.pdf"}
            a = 7
            attrib = 0
            reserveplugin = false
    --Type <RET> for more, q to quit, c to continue without paging--c
            fatal = true
            rec = true
            newfont = {lfHeight = 36, lfWidth = 80, lfEscapement = 76, lfOrientation = 85, lfWeight = 71,
              lfItalic = 73 'I', lfUnderline = 0 '\000', lfStrikeOut = 0 '\000', lfCharSet = 0 '\000',
              lfOutPrecision = 78 'N', lfClipPrecision = 0 '\000', lfQuality = 0 '\000', lfPitchAndFamily = 0 '\000',
              lfFaceName = L"SDIR\\AccessControl.dll\000capeXT\\-1"}
            ent = {which = 0, offsets = {0, 0, 0, 0, 0, 0}}
            __PRETTY_FUNCTION__ = "int CEXEBuild::doCommand(int, LineParser&)"
    #7  0x000000000044a953 in CEXEBuild::doParse (this=0x7ffd6a926c30,
        str=0x21f40070 L"File /r /x \".sconsign\" /x \"<redacted>.pdf\" \"Release\\share\"") at Source/script.cpp:468
            line = {_vptr.LineParser = 0x49aa60 <vtable for LineParser+16>, m_eat = 0, m_nt = 7,
              m_incommentblock = false, m_incomment = false, m_tokens = 0x21e875a0}
            res = 0
            cchstr = 62
            ignore_escaping = false
            enc = {m_cp = 65535}
            ppoline = {<IGrowBuf> = {_vptr.IGrowBuf = 0x4945c8 <vtable for GrowBuf+16>}, m_s = 0x0, m_alloc = 0,
              m_used = 0, m_zero = false, m_bs = 32768}
            tokstr0 = 0x21f48ca0 L"File"
            np = 1
            op = -1
            pos = 50
            tkid = 166
            v = 5
            if_from_else = 0
    #8  0x000000000044b49d in CEXEBuild::parseScript (this=0x7ffd6a926c30) at Source/script.cpp:683
            hist = {m_gr = {<IGrowBuf> = {_vptr.IGrowBuf = 0x4945c8 <vtable for GrowBuf+16>}, m_s = 0x0, m_alloc = 0,
                m_used = 0, m_zero = false, m_bs = 32768}}
            linedata = {<IGrowBuf> = {_vptr.IGrowBuf = 0x4945c8 <vtable for GrowBuf+16>}, m_s = 0x21f40050,
              m_alloc = 32776, m_used = 284, m_zero = false, m_bs = 32768}
            oldline = 0x0
            ret = 0
            lrres = 0
            p = 0x7ffd6a926da0 L""
            __PRETTY_FUNCTION__ = "int CEXEBuild::parseScript()"
            str = 0x7ffd6a926c88 L"        File /r /x \".sconsign\" /x \"<redacted>.pdf\" \"Release\\share\""
            linereader = @0x7ffd6a926b60: {m_Strm = @0x7ffd6a926c20, m_PrevNL = 13 L'\r'}
    #9  0x00000000004493d1 in CEXEBuild::process_script (this=0x7ffd6a926c30, Strm=...,
        filename=0x21edde00 L"/github/workspace/<redacted>.nsi")
        at Source/script.cpp:136
            linereader = {m_Strm = @0x7ffd6a926c20, m_PrevNL = 13 L'\r'}
            oldfilename = 0x0
            oldtimestamp = 0x0
            ret = 0
    #10 0x0000000000433669 in makensismain (argc=12, argv=0x21e6deb0) at Source/makenssi.cpp:637
            nsifile = L"/github/workspace/<redacted>.nsi"
            strm = {<NBaseStream> = {m_hFile = 0x21eb3b90, m_Enc = {m_cp = 65001}}, <No data fields>}
            bufcpdisp = L"UTF8", '\000' <repeats 15 times>
            ret = 52
            __PRETTY_FUNCTION__ = <optimized out>
            hostnotifyhandle = 0x0
            stdoutredirname = 0x0
            inputenc = {m_cp = 65001}
            outputenc = @0x4e5072: {m_cp = 65001}
            argpos = 11
            do_cd = 0 '\000'
            noconfig = 1 '\001'
            do_exec = 0 '\000'
            no_logo = false
            warnaserror = false
            initialparsefail = false
            in_files = false
            oneoutputstream = false
            pponly = 0 '\000'
            stdoutredir = 0x7fca43f35780 <_IO_2_1_stdout_>
            nousage = 0
            performed = 0
            files_processed = 1
            cmds_processed = 0
            build = <error reading variable build (value of type `CEXEBuild' requires 87288 bytes, which is more than max-value-size)>
            badnonwinswitchfmt = 0x49dd50 L"-%ls is disabled for non Win32 platforms."
            parsed_all_params = false
            processed_any = false
    #11 0x0000000000433b14 in wmain (argc=12, argv=0x21e6deb0) at Source/makenssi.cpp:709
            retval = 0
    #12 0x0000000000433bfb in main (argc=12, argv=0x7ffd6a93c458) at Source/makenssi.cpp:732
            wargc = 12
            term = L""
            p = 0x21e6e610 L"/github/workspace/<redacted>.nsi"
            wargv = 0x21e6deb0
    

    The crash is at line Source/dirreader.cpp:217:

    name = PosixBug_CtoTString(dit->d_name);
    

    And appears to be in the assignment operator for std::wstring
    I think is being called with dit->d_name equal to "An_Lão_District.shp".

    This might be something to do with the multi-byte to wchar_t conversion which takes place in the class constructed by PosixBug_CtoTString().

    void CtoTString::Init(const char* str, UINT cp)
    {
    #if defined(_UNICODE) && !defined(_WIN32)
      if (CP_ACP == cp)
      {
        assert(NSISRT_free_is_STDC_free());
        m_wStr = NSISRT_mbtowc(str); // Should be faster than iconv
        return ;
      }
    #endif
    ...
    

    We have managed to work around this by tightening up the file specification for the File /r command so that it doesn't search the TestData directory where that file is located and this has avoided the problem for us.

     

    Last edit: Michael Lane 2025-05-13
    • Anders

      Anders - 2025-07-22

      What if you remove the entire #if defined(_UNICODE) && !defined(_WIN32) block and just leave the MultiByteToWideChar part?

       

Log in to post a comment.

MongoDB Logo MongoDB