Bug 263779 - editors/imhex: Fails to build with -Werrror (error: no member named 'has_single_bit' in namespace 'std')
Summary: editors/imhex: Fails to build with -Werrror (error: no member named 'has_sing...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: MANTANI Nobutaka
URL:
Keywords: needs-qa
Depends on:
Blocks:
 
Reported: 2022-05-05 01:52 UTC by alt2600
Modified: 2022-07-06 16:52 UTC (History)
0 users

See Also:
nobutaka: maintainer-feedback+


Attachments
partial build log when errors started (20.61 KB, text/plain)
2022-05-05 01:52 UTC, alt2600
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description alt2600 2022-05-05 01:52:18 UTC
Created attachment 233730 [details]
partial build log when errors started

won't build only think I can find is maybe this
https://tagmerge.com/issue/rui314/mold/308

#include<bit> required for clang as it doesn't seem to have this I believe C++20 feature? not sure but either way its not building when old imhex is or isn't installed.
Comment 1 Kubilay Kocak freebsd_committer freebsd_triage 2022-05-05 01:57:41 UTC
-Werror should be disabled or overridden for official ports. Issues can of course be reported upstream.  Is -Werror being added by the build system, or locally?
Comment 2 alt2600 2022-05-05 03:05:09 UTC
(In reply to Kubilay Kocak from comment #1)

I certainly didn't add it in my cflags or any other building options in make.conf, its not included when i check make -v CFLAGS nor CXXFLAGS either

but wasn't it recently added as default in ports somewhere I seem to recall reading about that somewhere else? Maybe another commit saying they had to do something to work around it? I might be totally wrong, but it sticks in my head I saw something about it when you mentioned it. maybe I'm confusing or merging things in my head. 

I also checked imhex's CMake logs during configure and its not being added in there or shown to be part of the compiler flags, so I don't know why it is being set. But would that trigger this error when it seems the port cannot locate a feature in the std library? wouldn't that fail either way?
Comment 3 MANTANI Nobutaka freebsd_committer freebsd_triage 2022-05-05 17:15:01 UTC
Thank you for the report. Because ImHex heavily uses C++20 functions, FreeBSD 13-stable after 6 December 2021 (LLVM13 import to the base system) is necessary to successfully build current editors/imhex port. libc++ of older version of FreeBSD including 13.0-RELEASE lacks support of C++20 functions. 

Commit log of the LLVM13 import
https://cgit.freebsd.org/src/commit/contrib/llvm-project/libcxx?h=stable/13&id=5f7ddb1456d5b926e85710da690bf548ef0c9fc8

The error of "private field 'm_key' is not used" occurs with clang++ of Clang12. So I suppose that you use older version of FreeBSD. Could you try upgrading FreeBSD to 13-stable or upcoming 13.1-RELEASE (scheduled on 16 May 2022)? I confirmed successful build on 13.1-RC5. I am sorry for your inconvenience.

Note that -Werror flag is added in CMakeLists.txt at various directories of ImHex original source.
Comment 4 alt2600 2022-05-07 00:07:39 UTC
(In reply to MANTANI Nobutaka from comment #3)

not going to go through upgrading 2000 ports going to stable or a RC to test this port out. Its broken on 13.0 that's all I need to know. I'll just wait until 13.1 releases and I will try again then. This should be marked broken on ABI's less then the one that imported LLVM 13 or should just use LLVM 13 from ports for those release ABIs, but given the new release is slated for another week or so possibly overkill at this point.
Comment 5 commit-hook freebsd_committer freebsd_triage 2022-05-07 19:44:52 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=7fafedd73f0b64a16c85cc221244360b520ca3f9

commit 7fafedd73f0b64a16c85cc221244360b520ca3f9
Author:     MANTANI Nobutaka <nobutaka@FreeBSD.org>
AuthorDate: 2022-05-07 19:22:26 +0000
Commit:     MANTANI Nobutaka <nobutaka@FreeBSD.org>
CommitDate: 2022-05-07 19:44:12 +0000

    editors/imhex: Mark IGNORE for FreeBSD versions that uses old libc++

    ImHex heavily uses C++20 API functions and some of them are unavailable
    in old libc++ before LLVM13 import to the base system.
    Therefore, build always fails on the systems that use old libc++.

    PR:     263779

 editors/imhex/Makefile | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
Comment 6 MANTANI Nobutaka freebsd_committer freebsd_triage 2022-05-07 19:59:53 UTC
I have marked IGNORE for FreeBSD versions before LLVM13 import.
Unfortunately using devel/llvm13 port does not solve the problem because the port does not install libc++. 
Could you please let me know whether it is possible to build after upgrading to  13.1-RELEASE? I will close this PR after your confirmation.
Comment 7 alt2600 2022-05-26 21:26:55 UTC
(In reply to MANTANI Nobutaka from comment #6)

so under 13.1 amd64 it builds fine, and runs, but when the application closes it seg faults for me.
Comment 8 alt2600 2022-05-27 18:52:17 UTC
(In reply to alt2600 from comment #7)

sorry, perhaps this would help with what i mean, this is after closing the application.

Process 8480 stopped
* thread #1, name = 'imhex', stop reason = signal SIGSEGV: invalid address (fault address: 0x80a28cbe8)
    frame #0: 0x0000000800e41b21 libimhex.so`std::__1::__tree<std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::function<bool (pl::PatternLanguage&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)> >, std::__1::__map_value_compare<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::function<bool (pl::PatternLanguage&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, true>, std::__1::allocator<std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::function<bool (pl::PatternLanguage&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)> > > >::destroy(std::__1::__tree_node<std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::function<bool (pl::PatternLanguage&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)> >, void*>*) + 97
libimhex.so`std::__1::__tree<std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::function<bool (pl::PatternLanguage&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)> >, std::__1::__map_value_compare<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::function<bool (pl::PatternLanguage&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, true>, std::__1::allocator<std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::function<bool (pl::PatternLanguage&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)> > > >::destroy:
->  0x800e41b21 <+97>:  callq  *(%rcx,%rax,8)
    0x800e41b24 <+100>: testb  $0x1, 0x20(%rbx)
    0x800e41b28 <+104>: jne    0x800e41b03               ; <+67>
    0x800e41b2a <+106>: jmp    0x800e41b0c               ; <+76>
(lldb)
Comment 9 alt2600 2022-05-27 18:56:20 UTC
(In reply to alt2600 from comment #8)

and for completeness

(lldb) c
Process 8502 resuming
This version of LLDB has no plugin for the language "assembler". Inspection of frame variables will be limited.
Process 8502 stopped
* thread #1, name = 'imhex', stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
    frame #0: 0x0000000802efe91a libc.so.7`memcpy at memmove.S:314
   311  END(memmove)
   312  #else
   313  ENTRY(memcpy)
-> 314          MEMMOVE erms=0 overlap=1 begin=MEMMOVE_BEGIN end=MEMMOVE_END
   315  END(memcpy)
   316  #endif
(lldb) c
Comment 10 MANTANI Nobutaka freebsd_committer freebsd_triage 2022-05-29 16:11:36 UTC
Thank you for checking the build on 13.1. I also see segmentation fault on exit but I am not able to find the cause of it so far. I am working on updating editors/imhex port to 1.18.1. Though ImHex 1.18.1 fixed crash on exit according to the changelog, the segmentation fault still occurs on my environment. It may be a FreeBSD-specific issue.

Changelog of ImHex 1.18.1
https://github.com/WerWolv/ImHex/releases/tag/v1.18.1
Comment 11 alt2600 2022-05-31 00:54:01 UTC
(In reply to MANTANI Nobutaka from comment #10)

as you indicated it would it is faulting on a different function now, so perhaps the other issue was indeed resolved in 1.18.1 . it also appears to be faulting in the programs own library instead of libc, but outside of a guess a destructor or finalizer has issues I'm not sure what this really all means, but it does at least point to a specific function in the project for saving gui settings.

Process 86372 stopped
* thread #1, name = 'imhex', stop reason = signal SIGSEGV: invalid address (fault address: 0x80a2b53f8)
    frame #0: 0x0000000800e45fc1 libimhex.so`std::__1::__tree<std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::function<bool (pl::PatternLanguage&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)> >, std::__1::__map_value_compare<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::function<bool (pl::PatternLanguage&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, true>, std::__1::allocator<std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::function<bool (pl::PatternLanguage&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)> > > >::destroy(std::__1::__tree_node<std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::function<bool (pl::PatternLanguage&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)> >, void*>*) + 97
libimhex.so`std::__1::__tree<std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::function<bool (pl::PatternLanguage&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)> >, std::__1::__map_value_compare<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::function<bool (pl::PatternLanguage&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, true>, std::__1::allocator<std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::function<bool (pl::PatternLanguage&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)> > > >::destroy:
->  0x800e45fc1 <+97>:  callq  *(%rcx,%rax,8)
    0x800e45fc4 <+100>: testb  $0x1, 0x20(%rbx)
    0x800e45fc8 <+104>: jne    0x800e45fa3               ; <+67>
    0x800e45fca <+106>: jmp    0x800e45fac               ; <+76>
(lldb) c
Process 86372 resuming
Process 86372 stopped
* thread #1, name = 'imhex', stop reason = signal SIGSEGV: invalid address (fault address: 0x329c)
    frame #0: 0x0000000800b73f65 libimhex.so`ImGui::SaveIniSettingsToDisk(char const*) + 37
libimhex.so`ImGui::SaveIniSettingsToDisk:
->  0x800b73f65 <+37>: movl   $0x0, 0x329c(%rax)
    0x800b73f6f <+47>: testq  %rdi, %rdi
    0x800b73f72 <+50>: je     0x800b73fbe               ; <+126>
    0x800b73f74 <+52>: movq   %rdi, %rbx
(lldb)
Comment 12 MANTANI Nobutaka freebsd_committer freebsd_triage 2022-06-05 13:30:38 UTC
I have updated editors/imhex port to 1.18.2 and I am still investigating the segmentation fault. It seems that ImGui::SaveIniSettingsToDisk is called from a signal handler with the following code.

-------------------------------------------------------------------------
[ImHex-1.18.2/main/source/window/window.cpp]

        EventManager::subscribe<EventAbnormalTermination>(this, [this, CrashBackupFileName](int) {
            ImGui::SaveIniSettingsToDisk(this->m_imguiSettingsPath.string().c_str());

            if (!ProjectFile::hasUnsavedChanges())
                return;

            for (const auto &path : fs::getDefaultPaths(fs::ImHexPath::Config)) {
                if (ProjectFile::store((std::fs::path(path) / CrashBackupFileName).string()))
                    break;
            }
        });

        EventManager::subscribe<RequestOpenPopup>(this, [this](auto name) {
            this->m_popupsToOpen.push_back(name);
        });

        auto signalHandler = [](int signalNumber) {
            EventManager::post<EventAbnormalTermination>(signalNumber);

            if (std::uncaught_exceptions() > 0) {
                log::fatal("Uncaught exception thrown!");
            }

            // Let's not loop on this...
            std::signal(signalNumber, nullptr);

#if defined(DEBUG)
            assert(false);
#else
            std::raise(signalNumber);
#endif
        };

-------------------------------------------------------------------------
Comment 13 MANTANI Nobutaka freebsd_committer freebsd_triage 2022-07-06 16:52:54 UTC
I have updated editors/imhex port to 1.19.0 and the segfault issue is fixed in this version!