|
I wanted to burn down the battery on a laptop so to help it along I tried writing a program that had an infinite loop:code:
|
# ? Jun 25, 2012 09:12 |
|
|
# ? Jun 6, 2024 07:33 |
|
Why go the roundabout way to introduce security vulnerabilities?PHP code:
|
# ? Jun 25, 2012 09:14 |
|
shrughes posted:I wanted to burn down the battery on a laptop so to help it along I tried writing a program that had an infinite loop: Wouldn't that get optimized out? Vanadium posted:Why go the roundabout way to introduce security vulnerabilities? I think $$ would be more easily missed than eval. And at least cargo-culting some random php.ini might disable eval for you, but probably not $$. Doctor w-rw-rw- fucked around with this message at 09:50 on Jun 25, 2012 |
# ? Jun 25, 2012 09:48 |
|
E: accidental double-post sorry
|
# ? Jun 25, 2012 09:49 |
|
Doctor w-rw-rw- posted:Wouldn't that get optimized out? I think so (not a C/++ programmer). I think shrughes is poking fun at his/her failing to spot that ahead of time.
|
# ? Jun 25, 2012 09:52 |
|
Doctor w-rw-rw- posted:Wouldn't that get optimized out? gcc wouldn't for a fairly long time under the assumption that such loops were there for timing purposes, but they reversed that position somewhat recently.
|
# ? Jun 25, 2012 10:03 |
|
Compiling C++ programs is probably as good a way to kill your battery as any, though.
|
# ? Jun 25, 2012 10:14 |
|
code:
|
# ? Jun 25, 2012 10:42 |
|
Just spent half an hour combing through routines that write to and read from FRAM and my SD card to figure out why data dumps had the byte order of integers swapped before realizing that ARM chips default to little endian. I am the coding horror
|
# ? Jun 25, 2012 13:43 |
|
Otto Skorzeny posted:Just spent half an hour combing through routines that write to and read from FRAM and my SD card to figure out why data dumps had the byte order of integers swapped before realizing that ARM chips default to little endian. I am the coding horror Well half an hour isn't that much, I know people who literally spent weeks trying to figure it out until somebody pointed it out to them that big endian exists.
|
# ? Jun 25, 2012 13:48 |
|
Otto Skorzeny posted:Just spent half an hour combing through routines that write to and read from FRAM and my SD card to figure out why data dumps had the byte order of integers swapped before realizing that ARM chips default to little endian. I am the coding horror Don't ARM processors let you change the endianness?
|
# ? Jun 25, 2012 13:50 |
|
StorrowS posted:Don't ARM processors let you change the endianness? Yes although some parts of the toolchain that my vendor provides make endianness assumptions so I can't just poke a register and change it without breaking other things. Besides that, now that I know that the CPU is little endian I can live with it, as I know my code wasn't hosed and I just have to squint a little at the hex dumps.
|
# ? Jun 25, 2012 14:35 |
|
Otto Skorzeny posted:Yes although some parts of the toolchain that my vendor provides make endianness assumptions so I can't just poke a register and change it without breaking other things. Besides that, now that I know that the CPU is little endian I can live with it, as I know my code wasn't hosed and I just have to squint a little at the hex dumps.
|
# ? Jun 25, 2012 16:37 |
|
Zhentar posted:Spoken like someone who hasn't had a co-worker try to sneak a for loop implemented with goto through a code review. How about the other direction; implementing gotos with a for loop? I've seen this a couple times before, actually seemed pretty reasonable at the time, though it also hinted that the code needed some restructuring: code:
code:
Progressive JPEG fucked around with this message at 17:57 on Jun 25, 2012 |
# ? Jun 25, 2012 17:09 |
|
Java is big endian and so is network byte order, so it definitely still comes up.
|
# ? Jun 25, 2012 17:10 |
|
This is powering Wikipedia, the Free Encyclopedia.
|
# ? Jun 25, 2012 17:56 |
|
Suspicious Dish posted:This is powering Wikipedia, the Free Encyclopedia. Looks like it's at least just a fallback for "MWTidy"? Though maybe that fallback should be inside MWTidy itself, given its apparent purpose of wrapping "Tidy". Progressive JPEG fucked around with this message at 18:03 on Jun 25, 2012 |
# ? Jun 25, 2012 18:00 |
|
KaneTW posted:How do these people even learn to code jeez. "Oh look let's just allow any variable to be controlled by the user! I have no idea how this can go wrong " I have to support some really ancient code that still uses register globals (granted it was written last decade -- it just hasn't been upgraded aside from security fixes because it, well, works, and isn't a pressing issue ever), but... why in the world wouldn't you use something like php:<? // smart people would order based on [url]http://www.php.net/manual/en/ini.core.php#ini.variables-order[/url] // smarter people wouldn't even touch this in the first place $a = array($_ENV, $_SERVER, $_GET, $_POST, $_COOKIE); foreach ($a as $v) { extract($v, EXTR_SKIP); }?>
|
# ? Jun 25, 2012 19:07 |
|
Zamujasa posted:... last decade ... Only ~2.5 years ago! Seems relatively young code to me.
|
# ? Jun 25, 2012 19:14 |
|
Suspicious Dish posted:This is powering Wikipedia, the Free Encyclopedia. http://en.wikipedia.org/wiki/Template:Convert This converts between units, like from kg to pounds. Control function: {{#ifeq:{{{sortable|}}}|on|{{ntsh|{{FORMATNUM:{{{1}}}|R}}}}}}{{convert/{{#if:1|{{{2}}}}}|{{FORMATNUM:{{{1}}}|R}}|{{#ifeq:{{#expr:{{{3|0}}}*0}}|0|0}}|{{{3|}}}|{{{4|}}}|{{{5|}}}|{{{6|}}}|{{{7|}}}|{{{8|}}}|r={{#ifeq:{{{sp}}}|us|er|re}}|d=L{{{lk|off}}}A{{#switch:{{{abbr}}}|off=none|def=off|{{{abbr|off}}}}}D{{{disp|b}}}S{{{adj|{{{sing|off}}}}}}|s={{{sigfig|}}}}} Implementation pages: http://en.wikipedia.org/w/index.php?title=Special%3APrefixIndex&prefix=Template%3AConvert&namespace=0
|
# ? Jun 25, 2012 19:22 |
|
StorrowS posted:Only ~2.5 years ago! Seems relatively young code to me. Okay, you got me -- it was actually over 10 years ago. Still ticking along today, with a few parts that haven't been touched in about as long. Oh god, Mediawiki templates. I never understood why they didn't just open up the whole extension interface; writing a simple <convert value="3.1" unit="kg" tounit="lb" abbr /> would've been easier. But then most of MediaWiki's internals are just
|
# ? Jun 25, 2012 19:53 |
|
Hammerite posted:I think so (not a C/++ programmer). I think shrughes is poking fun at his/her failing to spot that ahead of time. The horror was that the "infinite" loop only had 1000 billion cycles, which would only last, at 1 GHz, under 1000 seconds, or 17 minutes.
|
# ? Jun 26, 2012 00:07 |
|
PrBacterio posted:I thought endianness only ever caused trouble anymore when dealing with one of the remaining embedded platforms that still use big endian, because everything else that matters had settled on little endian by now. As I said before, I was inspecting hex dumps from said embedded platform
|
# ? Jun 26, 2012 00:23 |
|
shrughes posted:The horror was that the "infinite" loop only had 1000 billion cycles, which would only last, at 1 GHz, under 1000 seconds, or 17 minutes. But it's not a horror for that reason. What kind of assembly only takes one instruction to loop? increment comparison jump if done jump to increment Even assuming a relatively compact loop and one instruction per clock cycle, it would take at least an hour. Unless the loop looked like this: increment jump if not equal in which case it'd still take twice as long, and we're not even taking into account CPU scheduling, and the fact that compilers don't usually produce fully optimal code. Depending on the battery, it's not inconceivable that it might run down the battery significantly. EDIT: Ran into a coding horror of my own. Since Google's EasyTracker uses an activity subclass, guess what I get to write? This gem: TrackedRoboSherlockFragmentActivity. Adding EasyTracker, which inherits from RoboSherlockFragmentActivity, which adds RoboGuice, which inherits from SherlockFragmentActivity, which adds ActionBarSherlock, which inherits from FragmentActivity, which adds Fragment support, which inherits from the Activity base class. Doctor w-rw-rw- fucked around with this message at 00:56 on Jun 26, 2012 |
# ? Jun 26, 2012 00:41 |
|
I wouldn't put it past shrughes to have a VAX laptop. "Add, Compare and Branch": quote:The addend operand is added to the index operand and the index operand is replaced by the result. The index operand is compared with the limit operand. If the addend operand is positive (or zero) and the comparison is less than or equal to zero, or if the addend is negative and the comparison is greater than or equal to zero, the sign-extended branch displacement is added to the program counter (PC), and the PC is replaced by the result. edit: Although in that case you might use AOBLSS. (Add One, Branch Less Than) Internet Janitor fucked around with this message at 01:17 on Jun 26, 2012 |
# ? Jun 26, 2012 01:13 |
|
Doctor w-rw-rw- posted:Even assuming ... one instruction per clock cycle, I feel sorry for anyone using a CPU where 1 IPC is optimistic, particularly when it's a trivial loop. I think for a loop like that, a CPU that shrughes is likely to be using peaks out at 3 IPC, and would cut down the size of the loop a bit by fusing cmp + jne into a single instruction.
|
# ? Jun 26, 2012 01:17 |
|
The microop fusion is likely to be much more helpful than the multiple issue for this sort of thing. I think it's also a pretty safe assumption that the 1GHz figure thrown out in the example did not reflect the actual clock rate of his hardware.
|
# ? Jun 26, 2012 01:23 |
|
And even if all of that were the case and it did actually take an hour, that doesn't change the underlying horror, which is that the "infinite" loop is anything but and on a modern laptop won't last long enough to wear down the battery even if you run it once on each core.
|
# ? Jun 26, 2012 01:35 |
|
One cycle per loop iteration is reasonable for any modern CPU. On my machine, with a 1.6 GHz E-350 CPU, setting the loop limit to 2 billion makes the program last 11.3 seconds. With -O1 it lasts 3.772s. 2.0 / 3.772 = 0.530. So it's doing 530 million rounds of the loop per second. So that's three CPU cycles per iteration. The main itself in -O1 gets compiled to these instructions: code:
Edit: By the way, if we add another sub $0x1, %rax into the loop, we still get 0.747s. So that's 2 cycles per loop (that does two decrements). Add a third, fourth, fifth, we get the same running time. Add four decrements to %rdx interspersed among those to %rax and you get the same running time. Add a fifth and you get 0.808s. Add a sixth and you get 0.9s. shrughes fucked around with this message at 04:49 on Jun 26, 2012 |
# ? Jun 26, 2012 04:38 |
|
Why not just spawn n instances of 'yes > /dev/null'?
|
# ? Jun 26, 2012 05:39 |
|
I stand corrected. I thought multiple microcode operations could happen per cycle, but not multiple instructions. Eep.
|
# ? Jun 26, 2012 05:39 |
|
man yes posted:yes -- be repetitively affirmative Easily the best man page.
|
# ? Jun 26, 2012 05:59 |
|
http://pedromadias.wordpress.com/2012/06/25/all-your-asus-servers-ikvmipmi-may-belong-to-other/code:
quote:Holy crap ASUS store user passwords in plain text!
|
# ? Jun 28, 2012 04:00 |
|
It's too hot today.
|
# ? Jun 28, 2012 04:26 |
|
It's so hotta here.
|
# ? Jun 28, 2012 04:41 |
|
|
# ? Jun 28, 2012 05:01 |
|
Janin posted:http://pedromadias.wordpress.com/2012/06/25/all-your-asus-servers-ikvmipmi-may-belong-to-other/ I refuse to loving believe this.
|
# ? Jun 28, 2012 05:13 |
|
Oh my.
|
# ? Jun 28, 2012 08:22 |
|
|
# ? Jun 28, 2012 16:23 |
|
|
# ? Jun 6, 2024 07:33 |
|
I can't wrap my head around ASUS servers in the first place
|
# ? Jun 28, 2012 17:34 |