HaikuArchives / StreamRadio

Haiku-native application to search for and listen to internet radio stations.
8 stars 11 forks source link

StreamRadio crashes on launch when built with GCC 8.3 #8

Closed Vidrep closed 5 years ago

Vidrep commented 5 years ago

hrev53233 x86_64 Built Haiku-Radio from source. The app crashes on launch. The version I already had installed does not. Debugger report below:

Debug information for team /boot/home/HaikuArchives/Haiku-Radio/dist/StreamRadio (3560):
CPU(s): 8x Intel Core™ i7-3770
Memory: 15.88 GiB total, 797.00 MiB used
Haiku revision: hrev53233 Jul  5 2019 17:08:51 (x86_64)

Active Threads:
    thread 3563: team 3560 debug task 
    thread 3560: StreamRadio (main)
        state: Exception (Segment violation)

        Frame       IP          Function Name
        -----------------------------------------------
        0x7fd6313927a0  0x1f99b7fc760   BEntry::GetStat(stat*) const@@LIBBE_1_ALPHA1 + 0 
            Disassembly:
                BEntry::GetStat(stat*) const@@LIBBE_1_ALPHA1:
                0x000001f99b7fc760:           8b4728  mov 0x28(%rdi), %eax <--

            Frame memory:
                [0x7fd631392798]  ........   b0 c7 7f 9b f9 01 00 00
        0x7fd631392850  0x1f99b7fc7ab   BEntry::_GetStat(stat_beos*) const + 0x1b 
        0x7fd631392a30  0xb392f68177    _Unwind_ForcedUnwind_Phase2(_Unwind_Exception*, _Unwind_Context*, long unsigned int*) + 0x57 (/sources/gcc-8.3.0/libgcc/unwind.inc:-1)
            Variables:
            exc: 0x1f99bae56b0 {
                exception_class: 2171567323184
                exception_cleanup: 0x1f99b7fb860
                private_1: 2171567327120
                private_2: 2171567327072
            }
            context: 0x7fd631392b30 {
                reg: Unavailable
                cfa: 0x7fd631392c70
                ra: 0x19704367146
                lsda: 0x197043788fa
                flags: 4611686018427387904
                version: 0
                args_size: 0
                by_value: 
            }
            frames_p: 0x7fd631392a38 {
                *frames_p: 140557925559088
            }
            stop: 0x1f99b7fc790
            stop_argument: 0x1f99b7fc760 {
                *stop_argument: Unavailable
            }
            code: _URC_NO_REASON
            frames: 1
            fs {
                pc: 0x1970436712e
                personality: 0xc625853910
                data_align: -8
                code_align: 1
                retaddr_column: 16
                fde_encoding: 27
                lsda_encoding: 27
                saw_z: 1
                signal_frame: 0
                eh_ptr: 0
            }
            action: 652

        0x7fd631392c60  0xb392f68990    _Unwind_Resume + 0x180 
        0x7fd631392d10  0x19704367146   _ZN12StationsList4SaveEv.cold.8 + 0 
        0x7fd631392e60  0x1970436b05a   RadioSettings::Load() + 0xca 
        0x7fd631392e90  0x1970436b0bf   RadioSettings::RadioSettings() + 0x3f 
        0x7fd631392eb0  0x1970436a78b   RadioApp::RadioApp() + 0x2b 
        0x7fd631392ed0  0x19704367e71   main + 0x21 
        0x7fd631392f00  0x197043681c9   _start + 0x39 
        0x7fd631392f30  0x208401fc573   runtime_loader + 0x103 
        00000000    0x7fce18ea6260  commpage_thread_exit + 0 
Vidrep commented 5 years ago

@jsteinaker

jsteinaker commented 5 years ago

It's not crashing here. I've uploaded a new HaikuPorts recipe a few hours ago, which doesn't use the patchset anymore, since the changes that were there are already merged on the tree. It's not merged yet but you should be able to get it anyway. Starting with that recipe only I can sucessfully build StreamRadio, downloading the sources from GitHub, and it doesn't crash. I was thinking that maybe the patch (if you're using it) is breaking something...

Also, it seems the crash is coming from the Load method in Radio Settings class. I haven't changed anything there. Save() method now calls Rewind(), so it actually deletes a Station when asked, but that method shouldn't be called on startup anyway. Did you try deleting your "Stations" folder?

Thanks for reporting!

EDIT: same exact hrev and arch here. Waaaaaay less memory, inside VirtualBox.

Vidrep commented 5 years ago

Did you test on 64 bit? I also built from the new recipe, and it also crashes (same as above). I tried deleting the "stations" folder too. Same. Previously installed version works OK.

jsteinaker commented 5 years ago

Yes, I'm on x64. It would be great if more people could try building the new version to see what happens.

humdingerb commented 5 years ago

c983b6e3ed5c5ef9b3f53ef8a6204d1cd5e0cdd8 works on 32bit (hrev53209).

diversys commented 5 years ago

c983b6e crashes on 64bit (hrev53233)

jsteinaker commented 5 years ago

Just downloaded last 64bit nightly (hrev53237) to start the build absolutely from scratch. Works fine here.

Maybe a stupid idea but... how much memory do you guys have? Real hardware or VM? The main difference between your setup and mine that I can think of it's this one, I'm on a VM with only 2-3gb of RAM...

waddlesplash commented 5 years ago

Try using the guarded heap, it's possible some slight difference is triggering memory corruption which the guarded heap should catch.

jsteinaker commented 5 years ago

Do you mean this? https://www.haiku-os.org/blog/mmlr/2010-02-08_using_malloc_debug_find_memory_related_bugs/

Also, what about the while condition check line in the Load() method in RadioSettings.cpp? I'm taking about operator precedence, I guess that might be wrong but I can't check now

Vidrep commented 5 years ago

Built on real hardware. x86_64 Core i7-3770, 16GB memory

waddlesplash commented 5 years ago

Yes, you'll want the guarded heap though, so in addition to the LD_PRELOAD, add MALLOC_DEBUG=g also.

Vidrep commented 5 years ago

Running the following: LD_PRELOAD=libroot_debug.so MALLOC_DEBUG=g StreamRadio

`` Debug information for team /boot/system/apps/StreamRadio (920): CPU(s): 8x Intel Core™ i7-3770 Memory: 15.88 GiB total, 624.45 MiB used Haiku revision: hrev53233 Jul 5 2019 17:08:51 (x86_64)

Active Threads: thread 923: team 920 debug task thread 920: StreamRadio (main) state: Call (abort() called)

    Frame       IP          Function Name
    -----------------------------------------------
    00000000    0x2095f3a9e7f   _kern_debugger + 0x7 
        Disassembly:
            _kern_debugger:
            0x000002095f3a9e78:   48c7c0e1000000  mov $0xe1, %rax
            0x000002095f3a9e7f:             0f05  syscall  <--

    0x7feee7ffa770  0x2095f3a1cc3   abort + 0x4a 
    0x7feee7ffa9b0  0x1326f918773   __absvdi2(DItype) + 0x73 (/sources/gcc-8.3.0/libgcc/libgcc2.c:-1)
    0x7feee7ffaa50  0x1d8ba1f4146   _ZN12StationsList4SaveEv.cold.8 + 0 
    0x7feee7ffaba0  0x1d8ba1f805a   RadioSettings::Load() + 0xca 
    0x7feee7ffabd0  0x1d8ba1f80bf   RadioSettings::RadioSettings() + 0x3f 
    0x7feee7ffabf0  0x1d8ba1f778b   RadioApp::RadioApp() + 0x2b 
    0x7feee7ffac10  0x1d8ba1f4e71   main + 0x21 
    0x7feee7ffac40  0x1d8ba1f51c9   _start + 0x39 
    0x7feee7ffac70  0x99501c3573    runtime_loader + 0x103 
    00000000    0x7fff3d81d260  commpage_thread_exit + 0 

``

diversys commented 5 years ago

I'just built 26f3bbda29da165c849d246038af98e17270249c and it crashes with the same back trace.

diversys commented 5 years ago

Also built current version from haikuports (after commenting out PATCHES) and it has the same problem.

jsteinaker commented 5 years ago

Thank you all for the feedback.

I ran StreamRadio using malloc_debug=g. It did not crash on startup. BUT, it crashed when doing a search, so I've just fixed that on my repo.

However, if you double-click on an empty space on the stations list on the main window, it crashes (with or without malloc_debug=g). It might be related to https://github.com/fishpond-haiku/Haiku-Radio/issues/4 and I guess it might be related to the crash you're experiencing as well.

I'll keep further investigating this.

diversys commented 5 years ago

Still crashes with your fix applied.

diversys commented 5 years ago

MALLOC_DEBUG=g StreamRadio

image

jsteinaker commented 5 years ago

Well, that was... ¿expected? The crash I fixed was apparently a different one.

I've just fixed the one happening when double-clicking the main window. Not that should fix the crash you're experiencing on startup, since I can't reproduce that one, even with MALLOC_DEBUG=g (and MALLOC_DEBUG it's working, cause I wasn't seeing the first crash I've fixed before enabling the flag). I'll keep looking around the code in your screenshot.

Again, thanks for the feedback, it's much appreciated.

jsteinaker commented 5 years ago

A couple of lines before the line marked in your screenshot, when casting to (BGroupLayout), there's a space that shouldn't be there between BGroupLayout and the character... could be this? I've tried it and it compiles and works OK, but I wasn't experiencing the crash in first place so I can't tell...

diversys commented 5 years ago

With your new fix and with space removed it still crashes as before. In release mode as in description and in debug mode in MainWindow.cpp. Have you tried make clean and rebuilding again?

Vidrep commented 5 years ago

How about a real time discussion on IRC at #haiku-3rdparty

jsteinaker commented 5 years ago

Just did it, same result, works fine here (I even started with a fresh virtual machine and different hrev at some point)

@Vidrep I'm leaving now, but I'm up for that at a different moment.

diversys commented 5 years ago

What gcc version do you use? Note, that by default it is still gcc7 now.

waddlesplash commented 5 years ago

Huh? No, we are using GCC8?

diversys commented 5 years ago

anyboot images still have gcc7 by default I believe.

jsteinaker commented 5 years ago

Will check later, but definitely whatever is on latest x64 nightly anyboot by default

jsteinaker commented 5 years ago

gcc 7.3.0 here

diversys commented 5 years ago

So, can you try with gcc8?

jsteinaker commented 5 years ago

Updated to gcc-8.3.0, make clean, recompiled. Aaaaaand we have a crash on startup, finally. Also, A LOT more warnings during compilation (it was only throwing a small one with gcc7).

I guess I should start reading them, but that's a different story. Any pointers in the right direction are very welcome. If anyone wants to try the changes in StreamRadio in the meantime, gcc7 is the answer.

jsteinaker commented 5 years ago

Ok, the warnings and runtime errors were related and fortunately the fixes were easy. Can you please try them? I've already made a pull request, I'll make another for the haikuports tree as soon as this one is approved.

diversys commented 5 years ago

Thanks! It release version doesn't crash anymore in 9d387c7de01c1e0a33d09b3848fdcf290e7878c9. However, it still crashes when compiled with DEBUGGER := TRUE.

jsteinaker commented 5 years ago

Great. I'll keep investigating the matter. Should we close this? (Or maybe change the subject to reflect the crash was about the transition to gcc8, and not about the changes made). Thanks!

Vidrep commented 5 years ago

StreamRadio now launching without a crash when built with gcc8.3. Closing as fixed. Thank you for looking into this issue!