Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde

Zamujasa posted:

A new day, a new horror... If I'm becoming grating with Tales from The Boss, then let me know and I'll cut back on sharing them.
I don't have any problem with the series but just keep in mind that you never know who's reading and what they might do if they're able to somehow identify the site you're talking about.

Gazpacho fucked around with this message at 17:57 on Aug 1, 2012

Adbot
ADBOT LOVES YOU

bucketmouse
Aug 16, 2004

we con-trol the ho-ri-zon-tal
we con-trol the verrr-ti-cal
E: Probably the wrong thread for this. Visual Studio is terrible anyways.

VVV : tl;dr There's some weird quirk that will make the runtime crash violently (complete with call-stack corruption!) if it calls a method declared virtual within a C++ template. I've got no idea what causes it but I spent a good 4 hours today debugging what I thought was a memory corruption issue. I thought it was the original coder's fault (and was going to complain about it) but the code compiles and runs fine via g++ so I've got no idea.

bucketmouse fucked around with this message at 01:47 on Aug 2, 2012

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug
^^^ Ah, I can't speak to Visual Studio's C++ support. It's great if you're developing in a purely Microsoft world, like I am. And VS2012 is out on August 15th! :neckbeard:

Microsoft is pretty good about responding to bug reports if you can come up with a minimal repro.

bucketmouse posted:

Visual Studio is terrible anyways.

How so?

New Yorp New Yorp fucked around with this message at 03:59 on Aug 2, 2012

Zamujasa
Oct 27, 2010



Bread Liar

Gazpacho posted:

I don't have any problem with the series but just keep in mind that you never know who's reading and what they might do if they're able to somehow identify the site you're talking about.

Yeah, I know. I try to fudge enough that the point is never lost; usually just recreating the disasters from memory is enough. I showed a close friend a real example of something instead of the fudged version and apparently the real thing is far worse than my summary.


On that note, I found something better than the last exploit. A file uploader with no auth check, complete with painted-on "File types" list. (No actual type check is done inside, of course.) My favorite part: It seems to be ajax-enabled and even helpfully links to the uploaded file so you know where it is. No way this could be used for bad things, nope. (At least it seems to be completely unused, and isn't linked anywhere.)


quote:

"Security through obscurity" is the phrase that springs to mind.
And yes, this place is all over security by obscurity. It's a real pain in the rear end when you have to try to remember what the name of an important folder is, but if people employed here can't remember it, then surely some hacker can't! :pseudo:

hobbesmaster
Jan 28, 2008


A lack of intellisense for C++/CLI was a pretty amazing horror in 2010. I think I've whined about that in this thread before actually...

akadajet
Sep 14, 2003

hobbesmaster posted:

A lack of intellisense for C++/CLI was a pretty amazing horror in 2010. I think I've whined about that in this thread before actually...

I'm pretty much appalled every time I open a C++ project in Visual Studio. First usually by the C++, then by Visual Studio. :v:

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

bucketmouse posted:

E: Probably the wrong thread for this. Visual Studio is terrible anyways.

VVV : tl;dr There's some weird quirk that will make the runtime crash violently (complete with call-stack corruption!) if it calls a method declared virtual within a C++ template. I've got no idea what causes it but I spent a good 4 hours today debugging what I thought was a memory corruption issue. I thought it was the original coder's fault (and was going to complain about it) but the code compiles and runs fine via g++ so I've got no idea.

That's a sign you need to start playing with your project compiler settings - are you using COMDAT folding or other optimizations?

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

hobbesmaster posted:

A lack of intellisense for C++/CLI was a pretty amazing horror in 2010.

C++ doesn't have a grammar, and I'm pretty sure that isn't Microsoft's fault.

Impotence
Nov 8, 2010
Lipstick Apathy
Can we post HTML?



:psyduck:

Chopper
Feb 13, 2006

Biowarfare posted:

Can we post HTML?



:psyduck:


Mother of GOD. My browser is crying, how could they possibly need so many fonts?!

Zamujasa
Oct 27, 2010



Bread Liar

Biowarfare posted:

Can we post HTML?



:psyduck:

:psypop:

All of those fonts, and then a ton of layers of Javascript bolted on, too.

Did they just copy every loving font Google offers?

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Biowarfare posted:

Can we post HTML?



:psyduck:

Well, the important thing to remember is that all those font loads don't slow down the page load. Oh, wai

:suicide:


I'm going to pretend that's a page designed simply to show off every google font in a list. Because my small designer brain can't handle any other possibility.

FrantzX
Jan 28, 2007
Does it count as a horror to post a picture of HTML?

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

FrantzX posted:

Does it count as a horror to post a picture of HTML?

No. Next question?

theratking
Jan 18, 2012
what about huge blocks of javascript within a django for macro... So much generated code :aaa:

PhonyMcRingRing
Jun 6, 2002
Does that site even render in IE? I thought IE had a limit of 31 stylesheets.

Sapozhnik
Jan 2, 2005

Nap Ghost
I actually had no idea Google Web Fonts was even a thing :shobon:

Looks pretty awesome... obviously not going to use all 500ish of them though (where did 500 open source fonts spring up from overnight, anyway?)

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Mr Dog posted:

I actually had no idea Google Web Fonts was even a thing :shobon:

Looks pretty awesome... obviously not going to use all 500ish of them though (where did 500 open source fonts spring up from overnight, anyway?)

They're not all open-source, some of them are just free for web use. They contacted a lot of big font libraries for this, and most of them released some of their content.

When Google recommends you want more fonts, they recommend a place like FontSquirrel or TypeKit, which provides a lot more fonts, but for a price.

Of course, there are a few open-source fonts on there, like the Liberation, Droid, DejaVu (Bitstream Vera) series that Red Hat/Google contracted. And if you didn't here, Adobe has a new open-source font that looks pretty loving sweet.

revmoo
May 25, 2006

#basta
I ran into a piece yesterday it was basically this:
php:
<?
function getSomeShit() {
    $obj = $this->db->query("SELECT SOME SHIZ")->result_object();
    if ($obj) {
        foreach ($obj as $o) {
            $output[] = $o;
    }
    return $output;
}
?>

Golbez
Oct 9, 2002

1 2 3!
If you want to take a shot at me get in line, line
1 2 3!
Baby, I've had all my shots and I'm fine

revmoo posted:

I ran into a piece yesterday it was basically this:
php:
<?
function getSomeShit() {
    $obj = $this->db->query("SELECT SOME SHIZ")->result_object();
    if ($obj) {
        foreach ($obj as $o) {
            $output[] = $o;
    }
    return $output;
}
?>

So basically this could be condensed to:
PHP code:
function getSomeShit() {
    return ($this->db->query('SELECT SOME SHIZ')->result_object()) ?: array();
}

Deus Rex
Mar 5, 2005

Golbez posted:

So basically this could be condensed to:
PHP code:
function getSomeShit() {
    return ($this->db->query('SELECT SOME SHIZ')->result_object()) ?: array();
}

that will return an object, not an array (also the original function returns NULL if result_object() returns NULL. not the empty array)

it could be written even simpler as:

PHP code:
function getSomeShit() {
    return $this->db->query('SELECT SOME SHIZ')->result_array();
}
of course it should probably use result_assoc anyhow

edit: aren't these methods called fetch_*, by the way?

Deus Rex fucked around with this message at 10:43 on Aug 6, 2012

Golbez
Oct 9, 2002

1 2 3!
If you want to take a shot at me get in line, line
1 2 3!
Baby, I've had all my shots and I'm fine

Deus Rex posted:

that will return an object, not an array (also the original function returns NULL if result_object() returns NULL. not the empty array)

it could be written even simpler as:

PHP code:
function getSomeShit() {
    return $this->db->query('SELECT SOME SHIZ')->result_array();
}
of course it should probably use result_assoc anyhow

edit: aren't these methods called fetch_*, by the way?

I didn't know anything about the actual methods; I was just seeing 'foreach [result]: put it in another array' and assuming $obj was an array, so it made no sense for him to put it in another array.

Is that the horror? :shobon:

Strong Sauce
Jul 2, 2003

You know I am not really your father.





I'm assuming it's CodeIgniter or some variant. The "horror" is that result_object is already an array of objects so iterating through them and appending them to a completely new array is pointless and also a waste of memory.

result_object also returns an empty array if there are now resulting rows.

Bhaal
Jul 13, 2001
I ain't going down alone
Dr. Infant, MD

revmoo posted:

I ran into a piece yesterday it was basically this:
php:
<?
function getSomeShit() {
    $obj = $this->db->query("SELECT SOME SHIZ")->result_object();
    if ($obj) {
        foreach ($obj as $o) {
            $output[] = $o;
    }
    return $output;
}
?>
Everything else aside, and maybe this is a horror/dinosaur habit of mine, whenever I come across a variable in php that is assigned in some inner scope but used outside of it, I grind my teeth and add something declarative and RAII'ish before it sees any use. In this case (assuming I left the rest alone) $output = array(); would be the first line of that function.

Sedro
Dec 31, 2008
That seems like a good habit. There are code paths where that method could return whatever was previously in $output. Although I'm sure the calling code would somehow continue on regardless of the return value.

thathonkey
Jul 17, 2012
At work on the production site, we have a single *.js file which is a bunch of other JS fileds minified+concatenated.

We were having some issues with the Console object behaving inconsistently across browsers and versions. As you know, IE7 has no Console object and it is a pain to clean out log calls every time you want to test IE. So most people define a dummy Console object with the appropriate methods for browsers like IE7 that don't have it.

I was trying to debug an IE7 issue in a 3rd party widget which we run on the site (and this is a separate horror in and of itself almost) that was throwing tons of console.log in browsers that supported it. IE7's terrible debug tools actually manage to point out the line in the 3rd party's script - the first call to console.log().

I quickly throw in my own version of the console fix just to make sure it is that, something I hastily wrote like-

code:
if (typeof console === 'undefined') {
    window.console = { 'log': function () { } };
}
I put it in the top of the script order in <head/>. IE still not working, in fact it is still reporting the same line number as the problem. I move my script below all the other scripts, and the core JS package and it works.

Great. There is a problem somewhere in the bowels of our giant, bloated core package. I open up all 10 of the files that the build script minifies into the package and do a search for 'console'

Turns out 6 of the 10 scripts all implemented their own safe Console object. They all somehow managed to do a fairly lovely job of it, but of course the first script to act is the worst offender. It does the same undefined check I do above, then iterates over an array of all the Console methods to add a dummy function. Great right? Wrong. They left 'log' out of that array, so a Console object was being defined in IE, causing all the other workarounds to subsequently be disregarded because they all check 'typeof console' but it left off by far the most frequently used method.

That took up a good portion of my day.

thathonkey fucked around with this message at 00:35 on Aug 7, 2012

Bhaal
Jul 13, 2001
I ain't going down alone
Dr. Infant, MD
EDIT: ^^^^^

That reminds me of another story. So there's this thing called Chosen which is pretty drat handy in some situations. One detail about it though is your search value is checked against each option word for word (space delimited), and it only matches if your search value is found at the beginning of a word. However, you can pass an initialization option with a flag that will change the internal regex to look for your search value ANYWHERE inside of a word (basically dropping the '^' in the regex). This was exactly what I needed in one situation. So, awesome, and it was the first time we had used chosen in our site so I also chucked the .js into source control and off it went.

Well, I don't go into the production instance that often, at least for the area that this was implemented in, but one day I was in there and noticed the filtering wasn't working properly. It hadn't all along, really. Long story short, it worked on my local, it worked on the dev instance, but not on production. Why? Well, that flag in the options was at the time a reasonably new addition, version 0.9.7. What happened was a coworker (who's been showcased in this thread before) had 0.9.5 on his local machine from long before when he was toying with the idea of adding it in to one of the things he was building. Well, about 10 days after I checked in the file and deployed it, he deployed his own code that utilized it, but instead of...doing anything right, he checked in his code, sans his chosen.js because he has absolutely zero deployment discipline, and manually chucked his (older) version of the file right onto the production server. That overrode the (newer version) chosen.js already up there and regressed out the initialization option that my own stuff relied on to be actually useful. I had to of course sleuth this all together and only knew it was him because 1) the file timestamp lined up with his code checkins, and 2) it's him, he's always the immediate suspect for anything dumb like this.

I'd talk about the day he was doing straight up dev work on a very visible customer facing part of our site, but it's not healthy to my blood pressure to go into too much detail. I'm talking edit->save->immediately push to production and test it there from his browser. The CTO noticed this when passing by his screen, and then directly told him to not do that at all ever, aaaand the next morning I came in to find him doing it yet again on the same exact piece of dev work. "But I'm wrapping everything around if( userid==4) so nobody else will see it" was his rationale.

Sedro posted:

That seems like a good habit. There are code paths where that method could return whatever was previously in $output. Although I'm sure the calling code would somehow continue on regardless of the return value.
Yeah, that's the risk. Something somewhere could very well be relying on that function to return either null or an array with elements but never an empty array, and now suddenly I've broken something downstream in some unexpected way by sending an empty array instead of null.

And good luck guaranteeing that the entire codebase was checked against a change like that, because that "something somewhere" could be calling this function via: $func(); and the actual function name could be coming in from who knows where at runtime.

Bhaal fucked around with this message at 02:20 on Aug 7, 2012

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
Doing a search when I get linked to one of those loving people lookup sites. But wait, something looks wrong here... wonder if it's wrong everywhere?

welp

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
There's an Energy, Texas?

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Aleksei Vasiliev posted:

Doing a search when I get linked to one of those loving people lookup sites. But wait, something looks wrong here... wonder if it's wrong everywhere?

welp

Jay Harris I've finally tracked you down...

This isn't a horror, it's awesome. I hate those no-effort/no-privacy aggregator sites with a passion.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Bhaal posted:

Yeah, that's the risk. Something somewhere could very well be relying on that function to return either null or an array with elements but never an empty array, and now suddenly I've broken something downstream in some unexpected way by sending an empty array instead of null.

And good luck guaranteeing that the entire codebase was checked against a change like that, because that "something somewhere" could be calling this function via: $func(); and the actual function name could be coming in from who knows where at runtime.

It's probably a good idea to explicitly codify the actual behaviour of the function though, as in

code:
function getSomeShit() {
    $obj = $this->db->query("SELECT SOME SHIZ")->result_object();
    if ($obj) {
        $output = array();
        foreach ($obj as $o) {
            $output[] = $o;
        }
        return $output;
    }
    return null;
}
just so that it's clear what is happening and there are no undefined variable notices (whether or not you are seeing them).

Zamujasa
Oct 27, 2010



Bread Liar
Here's an old one. This was designed to save load on an outgoing mail server by sending mails in chunks instead of all at once.

php:
<?
// Pretend this is an array of about 30,000+ client email addresses
$emails = array( ... );
$chunk  = 1000;

$it = floor(count($emails) / $chunk);

for ($i = 0; $i <= $it; $i++) {

    $start = $i * $chunk;
    $end = ($i + 1) * $chunk - 1;

    $out = array_slice($emails, $start, $end);
    sendMarketingMail($out, "* typical marketing spam *");

}?>
This was run for the first time without any sort of testing (e.g., using a dummy function that would output the emails it was sending).

It took me a few seconds to see the little flaw in his brilliant plan. (The actual incident was much worse than the above, too.)



quote:

And good luck guaranteeing that the entire codebase was checked against a change like that, because that "something somewhere" could be calling this function via: $func(); and the actual function name could be coming in from who knows where at runtime.
If everything is done right, then you should be able to search for functionName. It should still turn up in $func = 'doSomeShit'; somewhere.

But since it probably isn't, you could at least trigger an E_USER_DEPRECATED and use a custom error handler to log the locations and methods that are calling the function.

ijustam
Jun 20, 2005

Coding anything around financial dates is just the worst.

Custom dates for quarter end and special cases for when quarters start/end on weekends :psyduck:

Ari
Jun 18, 2002

Ask me about who Jewish girls should not marry!

Zamujasa posted:

It took me a few seconds to see the little flaw in his brilliant plan. (The actual incident was much worse than the above, too.)

I see at least the one, which is that the third argument is the length, not the end. But the other might be that array_slice returns an array. Does sendMarketingMail take in an array to be iterated through as its first argument, or just a single email address? If it takes an array, why not just give it a 1000-length array of email addresses to begin with?

Zhentar
Sep 28, 2003

Brilliant Master Genius

Ari posted:

If it takes an array, why not just give it a 1000-length array of email addresses to begin with?

That's what the code is trying to do...

Zamujasa
Oct 27, 2010



Bread Liar

Ari posted:

I see at least the one, which is that the third argument is the length, not the end. But the other might be that array_slice returns an array. Does sendMarketingMail take in an array to be iterated through as its first argument, or just a single email address? If it takes an array, why not just give it a 1000-length array of email addresses to begin with?

The length bit is the horror, yes. (I should have added a sleep() in there after the sending, but forgot.)

What it was supposed to do is send out these things in chunks, to avoid overloading a server with send requests. Then it'd move on to the next thousand, and so on. What it ended up doing is... hard to explain easily, but needless to say the further down the line you were, the more copies of the email you were sent.

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Zamujasa posted:

The length bit is the horror, yes. (I should have added a sleep() in there after the sending, but forgot.)

What it was supposed to do is send out these things in chunks, to avoid overloading a server with send requests. Then it'd move on to the next thousand, and so on. What it ended up doing is... hard to explain easily, but needless to say the further down the line you were, the more copies of the email you were sent.

I hope someone was chewed out for this at least.

I wonder how many of these PHP errors caused by these developers would be mitigated by having a built-in REPL. I know Facebook has a PHP REPL but most people aren't going to go and download that.

McGlockenshire
Dec 16, 2005

GOLLOCKS!

Strong Sauce posted:

I wonder how many of these PHP errors caused by these developers would be mitigated by having a built-in REPL. I know Facebook has a PHP REPL but most people aren't going to go and download that.

php -a has popped open a REPL since PHP 5.0. It stopped sucking in 5.3, and is pretty awesome in 5.4.

Golbez
Oct 9, 2002

1 2 3!
If you want to take a shot at me get in line, line
1 2 3!
Baby, I've had all my shots and I'm fine
What's a REPL and what's it for? :downs:

Adbot
ADBOT LOVES YOU

Strong Sauce
Jul 2, 2003

You know I am not really your father.





McGlockenshire posted:

php -a has popped open a REPL since PHP 5.0. It stopped sucking in 5.3, and is pretty awesome in 5.4.

It seems to not work at all in Windows, and requires you to compile readline to have it run in Unix/Mac OSX. Not sure if that is the default

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply