hugoam / kiui

Auto-layout Ui library, lightweight, skinnable and system agnostic, with an OpenGL backend
zlib License
749 stars 70 forks source link

Example app hangs on startup #9

Closed alexeyknyshev closed 9 years ago

alexeyknyshev commented 9 years ago

Gdb backtrace of hanged thread. Looks like hang at libkiui.so dynamic lib start:

(gdb) bt

0 syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38

1 0x00007ffff63e3023 in __cxa_guard_acquire () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6

2 0x00007ffff79c6132 in mk::Type::cls() () from /usr/local/lib/libkiui.so

3 0x00007ffff79c5ebc in mk::Type::Type() () from /usr/local/lib/libkiui.so

4 0x00007ffff79c6150 in mk::Type::cls() () from /usr/local/lib/libkiui.so

5 0x00007ffff79c5ebc in mk::Type::Type() () from /usr/local/lib/libkiui.so

6 0x00007ffff79cf05d in mk::Type& mk::typecls() () from /usr/local/lib/libkiui.so

7 0x00007ffff79d21b8 in mk::Dispatch<mk::ValueWidget, bool&, &(mk::WValue& mk::valueWidget<bool&, mk::Input >(mk::Sheet*, mk::Lref&, bool&))>::Dispatch() () from /usr/local/lib/libkiui.so

8 0x00007ffff79cee44 in __static_initialization_and_destruction_0 () from /usr/local/lib/libkiui.so

9 0x00007ffff79cefb1 in _GLOBAL__sub_I_mkInput.cpp () from /usr/local/lib/libkiui.so

10 0x00007ffff7dea9fa in call_init (l=, argc=argc@entry=1, argv=argv@entry=0x7fffffffe0c8,

env=env@entry=0x7fffffffe0d8) at dl-init.c:78

11 0x00007ffff7deaae3 in call_init (env=0x7fffffffe0d8, argv=0x7fffffffe0c8, argc=1, l=) at dl-init.c:36

12 _dl_init (main_map=0x7ffff7ffe1a8, argc=1, argv=0x7fffffffe0c8, env=0x7fffffffe0d8) at dl-init.c:126

13 0x00007ffff7ddd1ca in _dl_start_user () from /lib64/ld-linux-x86-64.so.2

14 0x0000000000000001 in ?? ()

15 0x00007fffffffe3dc in ?? ()

16 0x0000000000000000 in ?? ()

alexeyknyshev commented 9 years ago

I try to figure out root of problem 426db21 hangs

hugoam commented 9 years ago

Does that fix it ? f7d10df (It's the path set by CMake that might have been wrong, if you don't want to rerun cmake you can modify KIUI_EXAMPLE_RESSOURCE_PATH manually and tell me if that fixes it)

The backtrace is really weird though. I don't see what could go wrong so early...

hugoam commented 9 years ago

Oooh wait I think I'm starting to seeing the problem in Type(), calling Type::cls() from Type::cls()

alexeyknyshev commented 9 years ago

I'll be able to check at the morning. Now I'm lying in bed :р

hugoam commented 9 years ago

No problem. I think I fixed it in 16b7c4d, keep me posted.

alexeyknyshev commented 9 years ago

Looks like it's not connected with Type() bug. Problem has not gone. I'm trying to figure out...

hugoam commented 9 years ago

If the application hangs, it should be possible to pause the debugger and see where exactly the hang happens. Could you try to give me this information so that I try to understand what is going on ?

hugoam commented 9 years ago

Nevermind. The data path was not set properly between win32 and linux 4ef1ec4 and af54385. Tell me if that solves the problem.

alexeyknyshev commented 9 years ago

Hang callstack, hangs in static initialization of Type ty(0); static Type& cls() { static Type ty(0); return ty; }

0 syscall /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.19.so 38 0x7ffff5b91fd9
1 cxa_guard_acquire 0x7ffff63cf023
2 mk::Type::cls mkType.h 54 0x7ffff79bd748
3 mk::Indexed<mk::Type, void>::indexer mkIndexer.h 78 0x7ffff79be37f
4 mk::Type::Type mkType.cpp 17 0x7ffff79bd3d4
5 mk::Type::cls mkType.h 54 0x7ffff79bd76b
6 mk::Type::Type mkType.cpp 21 0x7ffff79bd43c
7 mk::typecls mkTyped.h 42 0x7ffff79c66b6
8 mk::Dispatch<mk::ValueWidget, bool&, &mk::valueWidget<bool&, mk::Input>>::Dispatch mkDispatch.h 89 0x7ffff79c9b0a
9
static_initialization_and_destruction_0 mkDispatch.h 102 0x7ffff79c645e
10 _GLOBAL__sub_I_mkInput.cpp(void) mkInput.cpp 110 0x7ffff79c65cb
11 call_init /usr/lib/debug/lib/x86_64-linux-gnu/ld-2.19.so 78 0x7ffff7dea9fa
12 call_init /usr/lib/debug/lib/x86_64-linux-gnu/ld-2.19.so 36 0x7ffff7deaae3
13 _dl_init /usr/lib/debug/lib/x86_64-linux-gnu/ld-2.19.so 126 0x7ffff7deaae3
14 _dl_start_user 0x7ffff7ddd1ca
15 ?? 0x1 16 ?? 0x7fffffffea31
17 ??

Looks like dead look due to double static initailization. First time it acquires look and goes deeper, calls Type::cls() again and again makes static initialization, which already locked ==> deadlock as the result.

hugoam commented 9 years ago

Yes now I see it. I already removed one such recursion in Type() and now I see there's another one when it calls indexer(). Gonna fix it right away.

hugoam commented 9 years ago

Here dd5d3c8

alexeyknyshev commented 9 years ago

Ought to be fixed! Great! Thx a lot!