/srv/irclogs.ubuntu.com/2008/10/24/#upstart.txt

sadmac2Keybuk: around?16:46
Keybukyup16:47
sadmac2Keybuk: could you commit your tweaks to the cursored foreach safe?16:47
ion_GStreamer is painful, partially thanks to GObject OO, which causes the equivalent of16:48
ion_end16:48
ion_class Foo16:48
ion_to be, like, 100 lines of code.16:48
sadmac2ion_: yes. GObject hurts16:48
sadmac2ion_: Gstreamer is alright in some other languages. Ruby has bindings that seem ok, but they aren't stable enough to use16:49
ion_I want to write a plugin; i guess i have do it in C.16:49
sadmac2ion_: what's the plugin do?16:49
ion_Really gapless playback of successive songs, taking possible silence in the beginning/end of audio stream into account. (Not crossfading.)16:51
sadmac2ion_: most music players I've seen don't even get normal gapless playback right16:51
ion_Indeed16:51
sadmac2ion_: though that's probably possible in current gstreamer. just not done right16:51
Keybuksadmac2: I'm not happy with it yet16:54
sadmac2Keybuk: me neither, but that's no reason to keep it out of source control :)16:55
sadmac2its less broken than head16:55
KeybukI'm not sure that's true16:56
Keybukthere's too much potential for bugs by having the cursor in the linked list16:56
Keybukyou can no longer assume that foo->next is of the same type as foo16:56
sadmac2Keybuk: which is why we need to get rid of foo->next16:57
sadmac2in code outside the libs16:57
sadmac2NIH_LIST_NEXT()16:57
KeybukI disagree16:57
Keybukit makes other code too inefficient16:57
sadmac2Keybuk: we're running out of options16:58
sadmac2Keybuk: I've already tried non linked list data structures, and we get similar issues16:59
sadmac2Keybuk: any other solutin is going to make list_head bigger. We need information to do this16:59
KeybukI suspect it's not a problem anyway17:00
Keybuksince the cursor is of the same size as the list head17:00
sadmac2Keybuk: which is not a problem?17:02
Keybukright17:03
KeybukI don't think the kinds of uses for which you would iterate a linked list are the same as those you'd expect the next element to be of a particular size17:04
sadmac2Keybuk: we use tne next pointer quite a bit in the test cases for init, but only in a couple places in the actual software17:06
Keybukright17:06
Keybukand in the test cases, we always check the size ;)17:06
Keybukin fact, checking the size is one of the fundamental tests17:06
sadmac2Keybuk: that's how we could find cursors.17:06
sadmac2Keybuk: we could ask nih_alloc how big the memory area is17:07
sadmac2oh, that's still a problem for stack.17:07
sadmac2nvm17:07
sadmac2wait, what does happen if you size-check a stack pointer?17:07
Keybuksize check only works if allocated with nih_alloc17:09
Keybukyou'd get a core dump probably17:09
Keybukor invalid data17:09
Keybukvalgrind would certainly notice17:09
sadmac2figured17:09
Keybukin almost every circumstance, you'd fail the nih_alloc assert() if you don't coredump17:10
sadmac2ok, looks like we never grab next inside the iterator in init17:10
sadmac2hoo!17:11
sadmac2we never do it in util17:11
KeybukI think I only ever do it on a list head to get the first entry17:15
sadmac2which will only fail for a few moments between when the loop puts the cursor there and when the loop realizes the cursor's there and terminates17:16
sadmac2so until we go multithread (if we do) all is well17:17
KeybukI'd kinda like to make libnih threadsafe one day17:17
sadmac2does it have to be today?17:18
sadmac2concurrent linked lists are a clusterfuck17:18
sadmac2and you're going to need a semaphore in list head, which means we add that extra word again17:19
sadmac2so what does that leave to figure out with the current list though?17:20
sadmac2we still need to make insert-before work17:21
KeybukI'm not too worried about that atm17:21
KeybukI never do it :)17:21
sadmac2ok17:21
sadmac2then we've fixed the issue :)17:21
KeybukTesting event_pending()17:44
KeybukBAD: wrong value for event->progress, expected 1 got 217:44
Keybukat tests/test_event.c:249 (test_pending).17:44
Keybukzsh: abort (core dumped)  ./test_event17:44
Keybuk...17:44
KeybukTesting event_pending()17:57
Keybuk==31387== Invalid write of size 817:57
Keybuk==31387==    at 0x42BC9C: nih_list_add (list.c:147)17:57
Keybuk==31387==    by 0x42C203: nih_hash_add (hash.c:179)17:57
Keybuk==31387==    by 0x405301: test_pending (test_event.c:244)17:57
Keybuk==31387==    by 0x414A61: main (test_event.c:1987)17:57
Keybuk==31387==  Address 0x7ff000558 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes17:57
Keybuk*giggle*17:57
Keybukthat implies a cursor is getting left in the list18:01
Keybukoh, I have something fun you can't do from an NIH_LIST_FOREACH_SAFE18:03
Keybukreturn18:03
Keybuk(the list will be invalid)18:04
sadmacwell shit18:08
Keybukthat wasn't that bug though18:08
sadmacyou could fix the return thing by defining a nested function18:09
sadmacmake your own stack frame18:10
sadmactrouble is getting the return type of the function you're in18:10
Keybukthis cursor thing causes *massive* problems18:40
Keybukall basically summed up as:18:54
Keybukcannot nestedly iterate the same linked list twice18:55
ion_Mmkay, the Finnish government has dedicated a team of ten police officers to “monitor the Internet” for “threatening content”, with a budget of a million € a year.19:07
=== laga is now known as rhpot1991_laptop
=== rhpot1991_laptop is now known as laga
* Keybuk wonders what the Finnish government would find threatening19:11
ion_I’m not entirely sure, but it’s a part of a knee-jerk reaction to a school shooting, where the shooter posted some videos of himself doing target practice and behaving all macho in advance.19:13
* Keybuk giggles19:25
KeybukNihList __attribute__(cleanup(nih_list_destroy)) _##iter##_cursor = { &_##iter##_cursor, &_##iter##_cursor }19:27
KeybukI think that solves the "return from the loop" issue :p19:27
ion_Ooh19:29
Keybukthat makes the definition just:19:40
Keybukdefine NIH_LIST_FOREACH_SAFE(list, iter)                               \19:40
Keybuk        for (NihList  _##iter __attribute__((cleanup(nih_list_destroy))) = \19:40
Keybuk                              { &_##iter, &_##iter }, \19:40
Keybuk                     *iter = nih_list_add_after ((list)->next, &_##iter)->prev; \19:40
Keybuk             iter != (list) && iter != &_##iter;                                \19:40
Keybuk             iter = nih_list_add_after (_##iter.next, &_##iter)->prev)19:40
* Keybuk wonders19:50
Keybukif I have an NihListCursor type19:50
Keybukcan I use19:50
Keybuk__builtin_object_size (iter, 0) == sizeof (NihListCursor)19:51
Keybuk:p19:51
=== mbiebl_ is now known as mbiebl
Keybukno, because it never evaluates iter :-/19:54
Keybuktho it should apprently19:54
sadmac2Keybuk: also as is iter is statically allocated20:08
sadmac2Keybuk: and the object could not be a cursor and be statically allocated20:08
sadmac2Keybuk: and The object could be a list head inside of another struct. Total size equaling NihListCursor20:09
=== soren_ is now known as soren

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!