/srv/irclogs.ubuntu.com/2009/01/29/#upstart.txt

Keybukwhoah00:05
Keybuknow I've hit a segfault that looks like mr pointer went west00:05
ion_Thought flow: West. Go west. Someone should feed Go West to Songsmith and post it to Youtube.00:08
Keybukhuh?00:08
ion_You haven’t seen the numerous Songsmith versions of songs on Youtube?00:09
Keybuknope00:09
Keybukexampel?00:09
ion_http://www.youtube.com/watch?v=YSWmh9ZTLOY http://www.youtube.com/watch?v=_V1DuHUs22Q http://www.youtube.com/watch?v=itsT9zgWRoM http://www.youtube.com/watch?v=ypycpKQxXR0 http://www.youtube.com/watch?v=e1e_h1OJfS4 http://www.youtube.com/watch?v=6iCJHTzH5DY http://www.youtube.com/watch?v=WmC28cXWqLc http://www.youtube.com/watch?v=Um6WeRFC93400:14
Keybukwonderfully bad00:19
ion_Yeah00:20
ion_So, what was the segfault problem?00:21
Keybuknot sure yet00:23
Keybukit's uninitialised data00:24
Keybukwhich is surprising00:24
KeybukI was expecting write to freed memory00:24
Keybukit _is_ happening inside a destructor though00:31
Keybuk(gdb) p source->files->bins[4]00:34
Keybuk$52 = {prev = 0x7fff2454a6f0, next = 0x7fff2454a6f0}00:34
Keybukhah00:34
Keybuknow, how the hell does that happen?00:36
Keybukohhhhhhhhhhhhhhhhhhhhh00:36
KeybukI know what that is00:36
Keybukthat's a list iterator!00:36
Keybukthis is the bug I knew there was with cursors in NIH_LIST_FOREACH_SAFE00:37
Keybukthat makes me happy00:37
ion_How is the bug triggered?00:37
Keybukiterating a linked list while iterating a linked list with NIH_LIST_FOREACH_SAFE00:38
Keybukhonestly, the real problem here is that the ConfFile destructor is bogus00:38
Keybukit does all sorts of heavy work, which really isn't appropriate00:38
Keybukdestructors are for cleaning up a structure, not for going around and restarting other jobs ;)00:39
ion_Yeah...00:39
ion_2009-01-26 22:38:22 < ion_> Note to self: ask Keybuk why: * nih_config_parse() now reads the file into memory, instead of using mmap().00:42
Keybuktruncate a file while it's mmapped and try reading from it ;)00:42
ion_Ok00:43
sadmacKeybuk: take file lock?00:43
Keybuksadmac: how does that help?00:43
Keybukfile locks only work if everyone co-operates00:43
sadmacKeybuk: never mind00:43
Keybukyou can core the process with just :> filename00:44
ion_At least the command is happy.00:44
Keybuk                /* Mark the job to be deleted when it stops, in case            00:47
Keybuk                 * it cannot be deleted here.                                   00:47
Keybuk                 */00:47
Keybuk                file->job->deleted = TRUE;00:47
Keybuk...00:47
Keybukwhat does _that_ do?00:47
Keybukthis whole job deletion stuff always scares me00:48
Keybukit's just a bag or corner cases00:48
ion_Heh00:49
Keybukaha01:04
Keybukthis makes sense01:04
Keybukconf_file_new () doesn't do anything with a job01:04
Keybukso the destructor bloody well shouldn't either01:05
Keybukcode gets easier to understand by being less clever01:05
sadmacKeybuk: can you make the alloc system error when someone tries to code this way?01:06
KeybukI don't see how01:09
Keybuksweet02:02
Keybuknih and upstart are now valgrind-clean02:02
sadmacnice02:07
Keybukfixed the issue where test_job_process sometimes locks up too02:15
sadmacah. don't remember that one02:23
Keybukdamn02:31
Keybukgrepping for usage of nih_free() and many of these are quite valid02:31
Keybuk1) clean-up in case of function error02:31
Keybukbut most importantly02:32
sadmacKeybuk: shouldn't that be an nih_local thing now?02:32
Keybuk2) hanging workers02:32
Keybuksadmac: not really, since the parent is passed in02:32
Keybukhere's an example of #202:33
Keybuknih_io_reopen (job, ...)02:34
Keybukie. create an nih_io structure that's a child of job, but never actually make job know about it02:34
Keybukit's just doing something on job's behalf02:34
Keybuknih_timer_new (job, ...)02:34
Keybukin fact, I do this for just about everything02:34
Keybukif you free job, the io or timer are automatically cancelled and cleaned up02:34
Keybukbut they're only doing work on its behalf02:34
Keybukmany of them are handled from the main loop and self-free02:35
Keybuktimer's a good example, the main loop frees timers02:35
sadmachm02:35
Keybukalso NihError relies on its quite heavily ;)02:40
Keybukbut then NihError is an aberration since it's the only part of libnih you can't reference <g>02:40
Keybuk(except you can now - but don't <g>)02:40
sadmacKeybuk: ...I have complete working code in another project for try{}catch{}02:43
Keybukusing setjmp?02:44
sadmacyeah02:44
sadmacits amazing what it does to clean up code. especially with the wrapper macros.02:45
Keybukusually try looks something like02:45
Keybuksetjmp, if (! error)02:45
Keybukand catch something like02:45
Keybukif (error)02:46
sadmacnot quite02:46
sadmacits if (! error)02:46
sadmacand else if (error == foo)02:46
sadmacand a bunch of for loops which don't loop but throw code after the block.02:46
sadmacbut once all the bits are in place02:47
sadmacif (! bytes = read(...)) { /* handle error in 2 or 3 lines */ }02:47
sadmacbecomes bytes = e_(read(...))02:47
Keybukwhy read?02:51
sadmacKeybuk: just an example.02:51
sadmacKeybuk: I have 2 or 3 character wrappers to turn all the varying POSIX errno-based semantics into exception throws02:51
Keybukah02:57
Keybukwhy e_?02:57
Keybukoh, I see02:57
Keybukdpkg has something a bit different02:57
Keybukyou push cleanup handler functions with push_cleanup()02:57
Keybukand you set checkpoints02:57
Keybukif an error occurs, you call ohshit() or ohshite()02:57
Keybukthat rolls back to the last checkpoint, calling up cleanup handlers on the way02:58
sadmacKeybuk: I do memory management that way :)02:58
sadmacKeybuk: Memory is allocated on obstacks, and then simply forgotten about, like it had been malloc'd and there was a garbage collector02:58
sadmacKeybuk: and then at a few points in the program, particular obstacks are simply dumped out completely02:59
Keybukit was one of my original ideas for nih_alloc02:59
Keybukthat the contexts would match the error handling contexts02:59
sadmacthere's a few cases it doesn't work for. but I'm ok with it varying02:59
sadmacKeybuk: have you looked at the way lisp does exceptions?03:29
Keybukno?03:40
sadmacKeybuk: its something like this:03:41
sadmacon_error("fooerror") do { /*closure*/ }03:42
sadmac /* stuff that might trigger error */03:42
sadmacrestore_handler("fooerror")03:42
sadmacwe could do it in C, but to do it right we'd need nested functions and pointers thereto (read: trampolines (read: executable stack (read: in pid 1 (read: cancer))))03:44
Keybukerr03:44
Keybuk??03:44
sadmacKeybuk: they call it signals, and it works a bit like unix signals.03:44
sadmacKeybuk: you install a function to handle a particular type of error.03:45
sadmacKeybuk: but its lisp, so this can be done for very granular short-term cases03:45
sadmac(because defining a function in lisp is simple)03:45
Keybukand the function lasts for the inner scope?03:46
sadmacKeybuk: in most cases. If it makes sense to install a global function as an error handler you do it03:48
sadmacKeybuk: but the big technical difference is you don't rewind the stack when you get an error. You execute the handler in place. meaning its more likely that you can get at state info and see what happened03:48
sadmacYou then have the /option/ to rewind the stack.03:49
Keybukyeah, I often wish you could do that with exceptions in Python03:49
Keybukexcept KeyboardInterrupt:03:49
Keybuk  bank03:49
sadmacbank?03:50
Keybukany language that has a "pass" keyboard should have a "bank" keyword ;)03:50
sadmac...I get the sense there's a language barrier here.03:51
sadmacis this a British pun?03:51
Keybukyou have "Weakest Link" in the US, right?03:51
sadmacwe did for a bit03:52
sadmacdon't think we do anymore03:52
sadmacwhich is sad03:52
Keybukahh03:52
sadmacbecause it was awesome03:52
sadmacKeybuk: in this system it would look like (in python03:52
sadmacon_error("KeyboardInterrupt", lambda: pass)03:52
sadmac# go about your business03:53
sadmacKeybuk: http://www.gigamonkeys.com/book/beyond-exception-handling-conditions-and-restarts.html04:08
KeybukI love my test suite04:11
sadmacI like it too04:13
KeybukI feel nice and safe about making far sweeping changes04:14
sadmacwhat far sweeping changes are you making now?04:24
KeybukI was just thinking in terms of rewriting the fundamental function call that manages memory04:26
sadmacwhat will you change?04:32
sadmacright now isn't it just a realloc?04:32
Keybukno, I mean what I've changed04:32
Keybukie. the switch to multi-reference nih_alloc04:32
sadmacah.04:33
Keybukgnargh05:18
KeybukI wish gcc could understand the TEST_ALLOC_FAIL loop05:18
sadmacwhat's it doing wrong?05:19
Keybukit thinks variables can be unused05:20
Keybukerr, used unused I mean05:20
Keybukused uninitialized05:20
Keybuk:)05:20
sadmacwe got there eventually05:21
sadmacdamn. every time I commit a 2-line change to a Fedora Infrastructure project, they give me commit access, and it comes with a mailing list that emails me every time someone changes something05:24
Keybukheh05:24
Keybukwe have similar problems05:24
Keybukcustomer bugs as generally private at first, since they often involve NDA hardware05:24
Keybukso if you want to read the bug (or have to), they join you to the team working on that hardware05:25
Keybukwhich usually means you get flooded with all the bug traffic, commits,e tc.05:25
sadmacheh05:25
sadmacOur IT system at work has public and private comments.05:25
sadmacPublic are... public. Private can be seen by me (the engineer), and either an L2 or a TAM05:26
sadmacIf its an L2, you give your usual nerdy harshing-shit-up spiel about the problem, and the L2 tells the customer in much more polite terms05:27
sadmacTAMs get you in trouble.05:27
sadmacrh.com email, but they live, work, and eat with the people having the issue.05:27
sadmacYou try to whisper through them and then realize they're on the other side.05:27
KeybukYeah I've heard about that05:33
sadmacIts all good, I mean, we're all "on the same side"05:33
sadmacits just a tone selection.05:33
sadmacKeybuk: what error should I raise if the reply hasn't been received somehow within the callback?06:04
sadmacKeybuk: I almost think it should be an nih_assert, since why would dbus have called us if there was no reply?06:04
Keybukhmm06:05
Keybukif the reply is corrupt you mean?06:05
Keybukor missing entirely?06:06
sadmacKeybuk: dbus_pending_call_steal_reply returns the reply or NULL if none received.06:06
Keybukah, yeah, I'd assert on that one()06:06
sadmacok06:06
Keybuka more interesting question is what do you do when the arguments in the reply don't match what you're expecting <g>06:06
Keybuk(call the error handling with the NIH_DBUS_INVALID_ARGS error)06:06
sadmacthe current type error raises ENOMEM. I don't know how that works out...06:08
* sadmac was pretty sure that part of the code was copypasta...06:08
sadmacalso neither of the error conditions for the marshaller unref anything before returning06:09
Keybukthey all get attached to the message object, I think06:10
Keybukwhich gets unref'd06:10
sadmacmem_error unrefs reply but type_error doesn't06:10
sadmacI'm in ur black box, bein white?06:11
Keybukdunno, I'd have to read the code again ;)06:11
sadmacKeybuk: nih_free is type void and takes one type void* right?06:32
Keybukreturns an int06:36
Keybukand takes void *06:36
sadmacah, that explains that06:36
Keybukoh?06:36
sadmacKeybuk: why it wasn't a valid DBusFreeFunction06:37
Keybukheh06:39
Keybukyeah06:39
Keybukof course, shouldn't that be nih_discard? :)06:40
sadmacKeybuk: I hate you >:(06:41
Keybukwhy?06:43
sadmacstupid discard is for poopy-heads06:43
Keybukheh06:44
sadmacKeybuk: go look at that async branch again06:51
sadmacbzr+ssh://bazaar.launchpad.net/~cjdahlin/libnih/async/06:51
=== sadmac_ is now known as sadmac
sadmacKeybuk: did you get that?06:58
=== Keybuk changed the topic of #upstart to: Upstart 0.5.1 "Unexpected item in bagging area"
Keybuksadmac: I got your branch URL07:00
=== Keybuk changed the topic of #upstart to: Upstart 0.5.1 "Unexpected item in bagging area" | http://upstart.ubuntu.com/
sadmacKeybuk: ok, there was nothing after that07:01
sadmacNice release name07:01
* sadmac hits McDonalds07:02
sadmacbbs07:02
sadmacI return07:15
* Keybuk shall just brain dump review again07:19
Keybukyou still have the extra names() functions, what are those about?07:20
sadmacKeybuk: for bulk-passing a group of variables to a function07:20
sadmacKeybuk: where using vars would yield foofunc(int foo, int bar)'07:21
Keybukdo you use it anyway?07:21
sadmacusing names would yield foofunc(foo, bar)07:21
Keybukoh, I see07:21
sadmacI use it07:21
Keybukmem_error/type_error07:23
Keybukyou raise the errors then return07:23
Keybukwhich means the errors will get eaten somewhere inside libnih-dbus07:23
KeybukI expect you meant to call the error handler there?07:23
Keybukstyle, errno = ENOMEM, nih_error_raise_system () - instead of doing it by hand07:23
sadmacKeybuk: line number?07:23
Keybuk1363..07:23
Keybukalso missing _() around NIH_DBUS_INVALID_ARGS_STR on 136907:24
sadmacKeybuk: copypasta. That should be your code07:24
sadmacKeybuk: I don't think it gets it. its defined with N_ already07:24
KeybukN_ just marks for translation07:25
KeybukN_ stuff needs _() called on it later07:25
Keybukuserdata -> data07:25
KeybukNihAsyncNotifyData -> NihDBusPendingCall ?07:26
sadmacKeybuk: I dunno about that one07:26
sadmacI don't think those are the same thing07:26
KeybukNihDBusCallback_%s -> YourFunctionNameInCapsCallback07:26
KeybukNihDBusErrback_%s -> YourFunctionNameInCapsErrorHandler07:26
sadmacis there a underscore-to-camel converter in this already?07:27
Keybukprobably not07:27
sadmacone liner07:27
Keybukwouldn't bother with the async_notify_data_free function07:29
Keybukjust cast it07:29
Keybukcf. nih-dbus/dbus_connection.c07:29
sadmacKeybuk: cf. ?07:29
Keybukcompare to07:30
sadmacok07:30
Keybukcan you stick a changelog entry on that, and I'll merge it07:31
sadmacKeybuk: I had just casted nih_free before, and then I moved to the function. If you pop off the top commit you get that one fixed.07:32
sadmacI'll do a revert commit and then add the changelog and push07:32
Keybukif you can be reasonable detailed (at least describe each new function, etc.) that would be muchly appreciated07:33
sadmacKeybuk: pull07:53
sadmacand now sleep08:06
keesjmorning08:38
suihkulokkiKeybuk: http://repository.maemo.org/pool/fremantle/free/u/upstart/11:54
keesjsuihkulokki: doing maemo stuff?12:01
suihkulokkikeesj: yes12:34
keesjas maemo platform developer?12:40
ion_Nokia is both cool and extremely evil.12:41
keesjsuihkulokki: I also work on upstart for an embedded platform. 12:43
keesjion_: it greatly depends at what side of Nokia you look.12:46
keesjsuihkulokki: are you also going to fosdem?12:57
suihkulokkikeesj: unfortunately not this year13:20
keesjalright13:46
keesjI am looking into the problems faced while creating as state machine inside upstart13:49
keesjI currently implmented as upstart job but that gives a few problems13:52
keesjfirst of all I can't recieve all events becasue the events don't get send while my state machine is running. for example I did start on event_a or event_b and if emit event_a and event_b one after the oder I can miss the second event13:57
hiciuI have problem with upstart on armv4 machine (Neo Freerunner)14:03
keesjwhat kind?14:03
hiciuas far as I can see the code works up to line 308 here: http://pastebin.com/d6558c13214:03
hiciuthen it jumps here: http://pastebin.com/d7dbb199014:03
hiciuon screen I can see everything up to last "return!"14:04
hiciuand it stops14:04
hiciuany idea how to debug it?14:05
hiciu(the code if from: http://upstart.ubuntu.com/download/0.5/upstart-0.5.0.tar.bz2, compiled with "--exec-prefix=/ --enable-compat=sysv")14:06
Keybukhiciu: does "make check" pass?14:09
hiciuI will check that now14:10
keesjdoes that mean that event is NULL?14:13
keesjhiciu: given the arguments I guess you must be using sbox or compiling on the target?14:14
hiciuyes14:14
keesjthe only configure magic I have going is adding export ac_cv_func_malloc_0_nonnull="yes"14:16
keesjbut I can't remember why..14:17
keesjbut the configure doesn't use it14:18
keesjsuihkulokki: acting dead mode is battry charging?14:29
hiciuI mean, under 'sbox2' :)14:31
hiciuin event_new, on return event != null14:31
hiciubut it does not pass tests: http://pastebin.com/d2154bba014:32
Keybukyou might need to do some porting14:33
keesj./.libs/libnih.a: could not read symbols: File in wrong format??14:33
Keybukkeesj has Upstart working on ARM, I believe?14:33
keesjyes, I have it running without modifs on qemu-arm and arm1114:34
hiciuhttp://pastebin.com/d5b909a8114:34
suihkulokkikeesj: da14:35
suihkulokkimaemo also has upstart workin on arm (obviously)14:35
suihkulokkibut that still 0.3.x14:35
keesjhiciu: how do you run upstart anyway under qemu?14:55
keesj(I run a full system including a kernel)14:56
hiciui'm running it on freerunner14:56
hiciuok, I will try to build it on freerunner (on device, not crosscompiling) later (when I manage to boot freerunner ;]).15:30
hiciuin meantime, simple bash script should work15:31
hiciuthanks for help! :)15:31
keesj:P15:35
keesjKeybuk: would it be possible to listen to /(and consume) to all the events perfomed by upstart?15:36
keesjmuch like 0.3.9 had "initctl events" but with the addition that the event only get probatated once the "jobs" consumed the event15:37
keesjwhy can't I gdb --pid 1 ?16:10
sadmac2keesj: kernel too old?16:11
sadmac2keesj: (its veeery recent that they made that actually work)16:11
sadmac2like, during the end of the 0.5.0 dev cycle that started working for me16:11
keesjthanks for the tip . so .28 or something?16:12
sadmac2keesj: not quite that recent16:12
sadmac227, maybe late 2616:13
keesjalright 16:13
=== sadmac2_ is now known as sadmac2
KDeskhi21:56
KDeskWill upstart 0.5 be in Jaunty?21:56
sadmacKDesk: I don't think so22:35
KDeskhi sadmac, isn't it ready, is the version 0.3 better?22:36
sadmacKDesk: its proven a bit shaky so far (0.5.1 should fix a /lot/ of that). Keybuk could tell you more if he were around22:38
KDesksadmac oh, hopefully the new upstart will be in ubuntu some time in the future. Thanks for your explanation.22:40
=== sadmac_ is now known as sadmac
mbieblKeybuk: hi23:39

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