Git Product home page Git Product logo

Comments (12)

hugoam avatar hugoam commented on July 1, 2024

Cannot reproduce. My best guess is that one of the data files hasn't been updated in your data install folder (from the last commits)

from kiui.

mrzv avatar mrzv commented on July 1, 2024

I have the same problem with the latest master. I'm getting a segfault with the following backtrace:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7a082cb in mk::Dockbar::vappend (this=0x91c740, widget=std::unique_ptr<mk::Widget> containing 0x0) at /home/users/morozov/Projects/U
pstream/kiui/src/Ui/Scheme/mkDockbar.cpp:57
(gdb) back
#0  0x00007ffff7a082cb in mk::Dockbar::vappend (this=0x91c740, widget=std::unique_ptr<mk::Widget> containing 0x0) at /home/users/morozov/Projec
ts/Upstream/kiui/src/Ui/Scheme/mkDockbar.cpp:57
#1  0x00007ffff7ab8f6e in mk::Sheet::emplace<mk::StyleEdit, mk::Styler&> (this=0x91c740) at /home/users/morozov/Projects/Upstream/kiui/src/Ui/W
idget/mkSheet.h:54
#2  0x00007ffff7aac6f0 in mk::createUiStyleEdit (parent=...) at /home/users/morozov/Projects/Upstream/kiui/src/Ui/mkUiExample.cpp:520
#3  0x00007ffff7aace8e in mk::createUiTest (root=...) at /home/users/morozov/Projects/Upstream/kiui/src/Ui/mkUiExample.cpp:593
#4  0x000000000041e5d2 in main (argc=1, argv=0x7fffffffe488) at /home/users/morozov/Projects/Upstream/kiui/example/example.cpp:36
(gdb) up
#1  0x00007ffff7ab8f6e in mk::Sheet::emplace<mk::StyleEdit, mk::Styler&> (this=0x91c740) at /home/users/morozov/Projects/Upstream/kiui/src/Ui/W
idget/mkSheet.h:54
(gdb) down
#0  0x00007ffff7a082cb in mk::Dockbar::vappend (this=0x91c740, widget=std::unique_ptr<mk::Widget> containing 0x0) at /home/users/morozov/Projec
ts/Upstream/kiui/src/Ui/Scheme/mkDockbar.cpp:57

from kiui.

alexeyknyshev avatar alexeyknyshev commented on July 1, 2024

Exactly same bt on very fresh installation of debian 9
Vote up. It's a blocker on Linux.

from kiui.

hugoam avatar hugoam commented on July 1, 2024

I'll investigate, but if someone on the system where it fails, can step the debugger to find a plausible origin, it's welcome.

from kiui.

mrzv avatar mrzv commented on July 1, 2024

The problem turns out to be very simple. std::move() in that last line (mkDockbar.cpp:57) destroys the contents of the widget unique_ptr. When it tries to call widget->name(), things break. The fix, of course, is trivial:

        auto name = widget->name();
        return this->addDock(name, icon, std::move(widget));

from kiui.

alexeyknyshev avatar alexeyknyshev commented on July 1, 2024

auto name = widget->name();

Not resolves problem. Because signature of this function:

const string &Widget::name()

which in this case returns reference to temporary and leads to segfault

See fix in a pull request #28
Please, merge
Regards, Alexey Knyshev

from kiui.

mrzv avatar mrzv commented on July 1, 2024

That's strange. Not only do I not see the second segfault, but the way I understand auto type deduction, in

auto name = widget->name();

auto gets resolved to string and one simply gets a local copy.

from kiui.

alexeyknyshev avatar alexeyknyshev commented on July 1, 2024

auto is resolved into direct return type which in this case in

const string &

And it is reference to string object in widget, so then it is going to be destroyed when widget is destroyed.

from kiui.

mrzv avatar mrzv commented on July 1, 2024

I really don't think that's how auto type deduction works. Here's a simple test for you, compile and try for yourself.

#include <type_traits>

struct A
{
    struct B {};
    const B& f () { return b; }
    B b;
};

int main()
{
    A a;
    auto x = a.f();
    static_assert(std::is_same<decltype(x), A::B>::value,        "A::B");
    static_assert(std::is_same<decltype(x), const A::B&>::value, "const A::B&");
}

Also worth noting, widget doesn't get destroyed anywhere in this function; a unique_ptr to it simply gets moved. So even if name was a const-reference, nothing would break — the addresses don't change.

from kiui.

alexeyknyshev avatar alexeyknyshev commented on July 1, 2024

Sorry, was asleep while writting comment about auto. Everything is ok with:

auto name = widget->name()

Regrads, Alexey Knyshev

from kiui.

alexeyknyshev avatar alexeyknyshev commented on July 1, 2024

BTW, my pull request is ok and may be merged 😄

from kiui.

hugoam avatar hugoam commented on July 1, 2024

Aaah yeah, the order isn't guaranteed to be ->name before std::move. Makes a lot of sense. Thanks for finding it while I'm away from computer.

from kiui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.