Denise 1.1.3.1 crashes on NetBSD

Issue #27 on hold
Rhialto created an issue

I just tried to update the pkgsrc entry for Denise to 1.1.3.1 but when testing it, Denise crashed immediately.

.../pkgsrc/wip/denise$ denise
terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string::_M_construct null not valid
Abort trap (core dumped)

I have these patches, adjusted from 1.1.2:

$NetBSD$

Fix installation directories.
Don't be interactive during install.
Don't run update-mime-database or update-desktop-database.

--- Makefile.orig       2022-06-27 19:02:54.000000000 +0000
+++ Makefile
@@ -14,7 +14,8 @@ shaderFolder := shader
 imgFolder := img
 soundFolder := sounds

-prefix ?= /usr
+prefix := ${DESTDIR}${PREFIX}
+#prefix ?= /usr
 #prefix ?= $(HOME)/.local

 include data/Makefile
@@ -256,7 +257,7 @@ ifeq ($(platform),macosx)
 else ifeq ($(platform),windows)
        $(strip $(compiler) -o out/$(name) $(objects) $(link))
 else ifeq ($(platform),BSD)
-       @sed -i '' '1 s/$$(wildcard //g;1 s/.o:/.o: $$\(wildcard/g;$$ s/)//g;$$ s/$$/\)/g' obj/*.d
+       #@sed -i '' '1 s/$$(wildcard //g;1 s/.o:/.o: $$\(wildcard/g;$$ s/)//g;$$ s/$$/\)/g' obj/*.d

        $(strip $(compiler) -o out/$(loname) $(objects) $(link))
 else
@@ -319,12 +320,7 @@ install: ## Install
        fi
        install -m 644 data/img/$(loname).png $(prefix)/share/icons/$(loname).png
        install -m 644 data/$(loname).desktop $(prefix)/share/applications/$(loname).desktop
-       @echo "Install file associations? [y/n]"; \
-       read line; if [ $$line = "y" ]; then \
-           install -m 644 data/application-x-$(loname).xml $(prefix)/share/mime/packages/application-x-$(loname).xml; \
-           if [ $(shell which update-mime-database) ]; then update-mime-database $(prefix)/share/mime; fi; \
-           if [ $(shell which update-desktop-database) ]; then update-desktop-database $(prefix)/share/applications; fi; \
-       fi
+           install -m 644 data/application-x-$(loname).xml $(prefix)/share/mime/packages/application-x-$(loname).xml;
        install -m 644 data/$(translationFolder)/* $(prefix)/share/$(loname)/$(translationFolder)
        install -m 644 data/$(dataFolder)/* $(prefix)/share/$(loname)/$(dataFolder)
        install -m 644 data/$(fontFolder)/*.ttf $(prefix)/share/$(loname)/$(fontFolder)
$NetBSD$

Use plain g++ instead of g++10.

--- data/Makefile.bak   2022-09-11 17:48:38.629412808 +0000
+++ data/Makefile
@@ -33,7 +33,8 @@ ifeq ($(compiler),)
        compiler := clang++
     endif
     ifeq ($(platform),BSD)
-       compiler := g++10
+       # compiler := g++10
+       compiler := g++
     endif
 endif
$NetBSD$

We don't have udev, and need a RPATH for -lX11.

--- driver/Makefile.orig        2022-06-27 19:02:54.000000000 +0000
+++ driver/Makefile
@@ -12,7 +12,8 @@ else ifeq ($(platform),macosx)
     drv += cgl openal coreaudio iokit

 else
-    drv += glx openal pulseaudio xlib udev sdlinput
+    # drv += glx openal pulseaudio xlib udev sdlinput
+    drv += glx openal pulseaudio xlib sdlinput

 endif
 # show in screen status text for opengl
@@ -35,7 +36,7 @@ else ifeq ($(platform),macosx)
 else
     drvflags = $(cppflags) 
     drvflags += $(shell pkg-config --cflags gtk+-3.0)
-    drvlink = -lX11 -lXext -ldl -lXfixes
+    drvlink = -Wl,-R,/usr/X11R7/lib -lX11 -lXext -lXfixes
     drvlink += $(if $(findstring openal,$(drv)),-lopenal)
     ifneq ($(findstring xlib,$(drv)),)
        drvlink += $(if $(findstring sdl,$(drv)), $(shell $(env)sdl2-config --libs))
@@ -67,5 +68,5 @@ drvlink += $(if $(findstring cgl,$(drv))
 drvlink += $(if $(findstring coreaudio,$(drv)),-framework CoreAudio -framework AudioToolbox -framework AudioUnit)

 drvlink += $(if $(findstring glx,$(drv)),-lGL)
-drvlink += $(if $(findstring udev,$(drv)),-ludev)
+# drvlink += $(if $(findstring udev,$(drv)),-ludev)
 drvlink += $(if $(findstring pulseaudio,$(drv)),-lpulse)
$NetBSD$

Include required header file.

--- emulation/tools/socket.cpp.orig     2021-05-12 15:32:16.000000000 +0000
+++ emulation/tools/socket.cpp
@@ -6,6 +6,7 @@
     #define closesocket close
     #include <sys/socket.h>
     #include <netdb.h>
+    #include <netinet/in.h>
     #include <netinet/tcp.h>
     #include <unistd.h>
     #include <cerrno>

Comments (11)

  1. PiCiJi repo owner

    Thanks for info, I will adjust the makfile according to your changes.

    After I had to admit to myself that a NetBSD installation is not so easy to accomplish, I came across Ghost BSD. All customizations in the makefile are based on it.

    We don't have udev

    It is built in GhostBSD, but no joystick is recognized. (same with SDL)

    Use plain g++ instead of g++10

    oh, i forgot to symlink g++10

    "terminate called after throwing an instance of 'std::logic_error'"
    Which g++ version are you using?

    Is there somewhere a VirtualBox or VMWare image with a full NetBSD installation?

  2. Rhialto reporter

    g++ is g++ (GCC) 8.4.0 in this case. I suppose I could try with 7.5 (which comes natively with NetBSD 9.x) but probably that won’t help.

    I thought there would be easy to find live images of NetBSD available (since they are easy (though a bit time-consuming) to make if you have the full source installed), but it seems not,

    Here is the official amd64 installer image: https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.3/images/NetBSD-9.3-amd64-install.img.gz

    It installs a basic system with optionally X. Make sure that after the installation itself, you go into the “Config menu” and then “Enable installation of binary packages“, for easy installation of SDL etc etc.

    I did find a site which is not officially affiliated with NetBSD but seems to have some images: http://www.ceres.dti.ne.jp/tsutsui/netbsd/liveimage/ . I don’t know what it has pre-installed; if needed, start “sysinst” and follow the same menus as I mentioned above to install pkgin, the binary package manager. Which packages you need to install, you can see from the pkgsrc entry’s Makefile.

    I suspect that the error is a fairly trivial in itself, but finding where it occurs might be a bit tricky, since it provides no context at all.

    So I tried building with -ggdb and without -s and that got me a bit more info. I hope it means something to you:

    Reading symbols from out/denise...
    (gdb) r
    Starting program: /tmpfs/wip/denise/work.x86_64/piciji-denise-c592258703c8/out/denise
    terminate called after throwing an instance of 'std::logic_error'
      what():  basic_string::_M_construct null not valid
    
    Program received signal SIGABRT, Aborted.
    0x00007900d5767dea in _lwp_kill () from /usr/lib/libc.so.12
    (gdb) bt
    #0  0x00007900d5767dea in _lwp_kill () from /usr/lib/libc.so.12
    #1  0x00007900d576769a in abort () at /usr/src/lib/libc/stdlib/abort.c:74
    #2  0x000000015a492d12 in __gnu_cxx::__verbose_terminate_handler ()
        at ../../../../gcc-8.4.0/libstdc++-v3/libsupc++/vterminate.cc:95
    #3  0x000000015a502db6 in __cxxabiv1::__terminate (handler=<optimized out>)
        at ../../../../gcc-8.4.0/libstdc++-v3/libsupc++/eh_terminate.cc:47
    #4  0x000000015a502dea in std::terminate ()
        at ../../../../gcc-8.4.0/libstdc++-v3/libsupc++/eh_terminate.cc:57
    #5  0x000000015a502ed9 in __cxxabiv1::__cxa_throw (
        obj=obj@entry=0x7900dd04dee0,
        tinfo=0x15a863af8 <typeinfo for std::logic_error>,
        dest=0x15a5726f2 <std::logic_error::~logic_error()>)
        at ../../../../gcc-8.4.0/libstdc++-v3/libsupc++/eh_throw.cc:95
    #6  0x000000015a49223c in std::__throw_logic_error (
        __s=__s@entry=0x15a577720 "basic_string::_M_construct null not valid")
    #7  0x000000015a371311 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*> (
        this=this@entry=0x7f7fff36fd90, __beg=__beg@entry=0x0,
        __end=<optimized out>) at /usr/pkg/gcc8/include/c++/bits/char_traits.h:350
    #8  0x000000015a37140a in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct_aux<char const*> (
        __end=<optimized out>, __beg=0x0, this=0x7f7fff36fd90)
        at /usr/pkg/gcc8/include/c++/bits/basic_string.h:252
    #9  std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*> (__end=<optimized out>, __beg=0x0,
        this=0x7f7fff36fd90) at /usr/pkg/gcc8/include/c++/bits/basic_string.h:255
    #10 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string<std::allocator<char> > (this=this@entry=0x7f7fff36fd90,
        __s=__s@entry=0x0, __a=...)
        at /usr/pkg/gcc8/include/c++/bits/basic_string.h:516
    #11 0x000000015a379862 in GUIKIT::pApplication::fetchDesktopSession ()
        at /usr/pkg/gcc8/include/c++/ext/new_allocator.h:79
    #12 0x000000015a379b29 in GUIKIT::pApplication::initialize ()
        at guikit/gtk/main.cpp:73
    #13 0x000000015a37b73c in GUIKIT::Application::initialize ()
        at guikit/api.cpp:112
    #14 0x000000015a391e6f in GUIKIT::Base::Base (this=this@entry=0x7900dc3fa1d0)
        at guikit/api.cpp:51
    #15 0x000000015a394d52 in GUIKIT::Timer::Timer (this=0x7900dc3fa1d0)
        at guikit/api.cpp:1263
    #16 0x000000015a3c3b7b in Fileloader::Fileloader (this=0x7900dc3fa140)
        at /usr/pkg/gcc8/include/c++/bits/std_mutex.h:94
    #17 0x000000015a29d3dd in Program::Program (this=0x7f7fff370000)
        at program/program.cpp:60
    #18 0x000000015a4935e9 in main (argc=1, argv=0x7f7fff370098)
        at program/program.cpp:49
    (gdb) 
    

    Thanks for looking into this!

  3. Rhialto reporter

    Maybe I found the error already.

    76      auto pApplication::fetchDesktopSession() -> void {
    77          desktopSession = DesktopSession::Unknown;
    (gdb) list
    78      
    79          const char* currentDesktop = getenv("XDG_CURRENT_DESKTOP");
    80      
    81          if (String::findString(currentDesktop, "Cinnamon"))
    82              desktopSession = DesktopSession::Cinnamon;
    83          else if (String::findString(currentDesktop, "GNOME"))
    84              desktopSession = DesktopSession::Gnome;
    85          else if (String::findString(currentDesktop, "KDE"))
    86              desktopSession = DesktopSession::KDE;
    87          else if (String::findString(currentDesktop, "MATE"))
    

    XDG_CURRENT_DESKTOP is not set because I don’t use desktops.

    If I set that environment variable, the error goes away.

    I do see some issues with the menus in the window though; they don’t go away if you move to another menu. But that’s a different issue.

  4. PiCiJi repo owner

    Thank you for your hints. Now I was able to install NetBSD. While building Denise, I stumbled across the problems you indicated.
    I've added some changes. The patches "patch-guikit_gtk_main.cpp", "patch-emulation_tools_socket.cpp", "patch-driver_Makefile", "patch-data_Makefile" can be removed.
    GhostBSD(FreeBSD) uses the macOS variant of "sed", but NetBSD uses the Linux variant. FreeBSD also includes udev. That's why I now differentiate between "NetBSD" and the other BSD's in the platform detection, whereby I have never tried openBSD.

    In “patch-Makefile”, you can reuse "sed" due to the changed platform detection.

    I added "-Wl,-R,/usr/X11R7/lib", but I could build it without it.

    XDG_CURRENT_DESKTOP is not set because I don’t use desktops.

    good find, I forgot to check if the pointer exists.

    I do see some issues with the menus in the window though

    I also get the error with the menu in NetBSD. It only happens if emulation is still disabled. Ok I'll try to fix this soon.

  5. Rhialto reporter

    Thanks for looking at my patches and incorporating them. For the next release, I will be able to remove them from pkgsrc-wip, nice!

  6. Rhialto reporter

    I already packaged version 2.x, so no 1.x versions are needed as far as I am concerned. Thanks!

  7. Log in to comment