#qi-hardware IRC log for Thursday, 2013-01-24

--- Thu Jan 24 201300:00
LunaVoraxHi06:47
wpwrakhmm. seems that i've found a code generation bug in gcc :-( (cross-compiling for the ben)06:57
wpwrakgiven a code fragment  tricky = foo; if (blah) tricky = bar;  is adds the equivalent of  else tricky = tricky;06:58
wpwrakunfortunately, "tricky" is a register (with volatile and all that) ...06:59
wpwrak... PDFUNS, to be precise. and it very much resents this sort of treatment.07:05
whitequarkwpwrak: sounds like an optimizer gone wrong07:59
whitequarkI'm fairly sure that volatile semantics (apart from being inapplicable for I/O memory) forbids that08:00
larscwpwrak: can you paste the code?09:31
wpwrakwhitequark: yes, looks like the optimizer got confused. i think my code indicates things correctly. need to see if i may have been a bit overzealous with the volatile, though. (not that this would be an excuse, but it may have made life unnecessarily hard for the poor compiler.)11:50
wpwrakbut first the morning mails and some caffeine ...11:50
wpwraki need a senility check. given this code fragment: http://pastebin.pl/7276813:28
wpwrakif you compile it with gcc 4.6.3 or gcc 4.7.2, e.g., for amd64 or mipsel, gcc reads from *ptr. my understanding is that it's not supposed to do that. anyone disagrees ?13:30
wpwrakbtw, with llvm 3.0, i get the code i expect. in fact, llvm is a bit too zealous and treats "ptr" as volatile as well13:31
wpwrak(compiling with -O9)13:32
Fallenouhum it seems gcc should only write to ptr13:44
wpwrak2:1 against gcc's interpretation :) or 3:1 if we count llvm.13:53
larscthere is probably a clause somewhere in the standard that permits this13:57
larscand gcc sticks to the standard and not to what is practical13:57
wpwrakthe standard is pretty fuzzy about "volatile"13:58
wpwrakand gcc's documentation is more confusing than helpful there. http://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Volatiles.html13:59
wpwrakparticularly the memory barrier example is puzzling. it would seem that just making that pointer volatile ought to do the trick. yet ...14:00
larscI even get the problem without the first *ptr = 1;14:07
larscah, no misread the generated cod14:08
larsce14:08
larscIt's a bit strange anyway on ARM it generates "movne r2, #2; ldreq r2, [r3]; str r2, [r3]" while the shorter "movne r2, #2; strne r2, [r3]" would be correct14:10
wpwrakyeah, it really really wants to do that read :)14:12
wpwrakan obsessive-compulsive anti-optimization14:13
larscwhitequark: ruby got almost 50% https://github.com/search?p=&q=path:.ssh/id_rsa&type=Repositories14:14
wpwrakgrmbl. in 2010, this was a theoretical issue. seems that we've progressed beyond that. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4494314:21
whitequarklarsc: compare with total count of repositories by language14:26
whitequarkidiots are distributed roughly evenly ;)14:26
whitequarklarsc: what actually worries me is Puppet. because sysadmins gotta know it better.14:27
larscwhitequark: turns out I copy pasted the link to fast, the path: filter doesn't seem to work14:27
larscit's just text somewhere in a readme file14:27
whitequarklarsc: the actual link has the majority in ruby too14:28
whitequarklarsc: btw I'm not even sure why does it has the same distribution or shows ruby at all. That stuff should be in dotfiles theoretically...14:35
qi-bot[commit] Werner Almesberger: ubb-la/Makefile (CFLAGS): -O9 is currently unsafe; use -O1 (master) http://qi-hw.com/p/ben-blinkenlights/e1eea4f18:37
qi-bot[commit] Werner Almesberger: ubb-patgen/Makefile (CFLAGS):  -O9 is currently unsafe; use -O1 (master) http://qi-hw.com/p/ben-blinkenlights/00ef01a18:37
wpwrakof course, now my delay measurements are probably off ...18:37
larsccan't you just work around the bug?19:08
wpwraki could change the API. e.g., instead of PDFUNS = foo; it would become write_reg(PDFUNS, foo), etc.19:12
wpwrakbut i kinda like to keep those register accesses nice and simple. besides, a lot of other people are probably using quite similar things.19:12
wpwrakso the work-around for now is to drop the optimization level19:13
wpwrak(API change) or do things like #define PDFUNS(x) write_reg(__PDFUNS, x). a little less ugly, but still. also, there may be other registers outside the GPIO group that don't have nice  *ptr = *ptr  semantics either19:18
wpwrakonly that those might be even harder to spot19:18
wpwrakhmm. still getting trouble despite the -O1 :-(20:20
qi-bot[commit] Werner Almesberger: ubb-la/Makefile (CFLAGS): even -O1 isn't safe; use -O0 instead (master) http://qi-hw.com/p/ben-blinkenlights/bac21bf20:38
Action: wpwrak hates compiler bugs20:38
larschates bugs20:39
larscsome can be amusing though20:39
wpwrakespecially those you find in other people's code :) (and even more so if what you do doesn't depend on their code)20:41
wpwrakwell, this one has quite interesting effects. what happens is that the bad accesses to PDFUNS mess up the keyboard. in ubb-la, this means that the "press key to abort" functionality i'm adding mis-fires. (and of course, the keyboard in general doesn't behave very well after that involuntary reconfiguration)20:43
wpwraki also saw this earlier in ubb-patgen, but didn't realize what it was. there, it caused Enter to repeat endlessly. that's why the invocation of ubb-patgen at the end of http://downloads.qi-hardware.com/people/werner/ubb/patgen/ubb-patgen-demo.jpg20:45
wpwrakwasn't actually run (the waveform is from an earlier run)20:46
wpwrakwell, at least that's the theory. haven't verified yet whether this is really what happened there.20:46
qi-bot[commit] Werner Almesberger: ubb-la/ubb-la.c: add command-line options, keyboard abort (master) http://qi-hw.com/p/ben-blinkenlights/62284fb21:27
qi-bot[commit] Maarten ter Huurne: Changed text color of warnings from yellow to magenta (packages) http://qi-hw.com/p/gmenu2x/a18730e22:29
qi-bot[commit] Maarten ter Huurne: Made GMenu2X::menu private (packages) http://qi-hw.com/p/gmenu2x/e4d78be22:29
qi-bot[commit] Maarten ter Huurne: Ignore OPK files of which the name starts with a dot (packages) http://qi-hw.com/p/gmenu2x/90ec4b922:29
qi-bot[commit] Werner Almesberger: ubb-patgen/Makefile (CFLAGS): even -O1 isn't safe; use -O0 instead (master) http://qi-hw.com/p/ben-blinkenlights/fc4b8e723:09
qi-bot[commit] Werner Almesberger: ubb-la/ubb-la.c (do_buf): skip over the first 122 samples (master) http://qi-hw.com/p/ben-blinkenlights/4ce686623:09
qi-bot[commit] Werner Almesberger: ubb-la/README: brief description of ubb-la (master) http://qi-hw.com/p/ben-blinkenlights/070267523:09
--- Fri Jan 25 201300:00

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