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
Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today

UraniumAnchor posted:

From a few pages back but I worked on a game where certain computers would mishandle a rig calculation and lock the player's head in the exact opposite angle that it should have been.

Turns out that those computers were returning some very slightly different result from a floating point calculation and brushing up against some weird edge case.

This wasn't even different architecture, or even AMD vs Intel. All machines involved were 64-bit Intel chips (so no, not FDIV :v:). I forget what the determining factor ending up being, or even how they fixed it.
Was it the same build of the game, byte-for-byte? Often compiler optimizations that treat floats as real numbers are to blame for this sort of thing, and those can be sensitive to small changes in build configuration or code or compiler version or ...

It's also not unheard of for very high performance code to select different implementations at runtime depending on available CPU features, but I don't know how much if that you tend to see in games.

Adbot
ADBOT LOVES YOU

UraniumAnchor
May 21, 2006

Not a walrus.

Ralith posted:

Was it the same build of the game, byte-for-byte? Often compiler optimizations that treat floats as real numbers are to blame for this sort of thing, and those can be sensitive to small changes in build configuration or code or compiler version or ...

It was Unity based so it's entirely possible it was some weird JIT thing with Mono, but otherwise was the same package, yes. It would only happen on certain computers, but it would reliably happen there.

b0lt
Apr 29, 2005

hobbesmaster posted:

Because reinterpret_cast worked so well for C++

reinterpret_cast works perfectly well, it's a big red flag that says "PAY ATTENTION" in code reviews(/port-mortem debugging)

csammis
Aug 26, 2003

Mental Institution
I was really tired at the end of the day earlier this week and wrote

code:
std::vector<unsigned char>::const_iterator index;

...

char* ptr = reinterpret_cast<char*>(const_cast<unsigned char*>(&(*index)));
I must've really wanted that char* :psyduck:

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today

UraniumAnchor posted:

It was Unity based so it's entirely possible it was some weird JIT thing with Mono, but otherwise was the same package, yes. It would only happen on certain computers, but it would reliably happen there.

Man, who even knows what weird nondeterminisms lurk in Unity's ancient version of Mono's JIT. It almost certainly wasn't the CPU's fault.

The real problem in this sort of situation is usually that you're using a numerically unstable algorithm. Correct behavior in most applications shouldn't depend on exact error characteristics.

Apex Rogers
Jun 12, 2006

disturbingly functional

Saw this in a piece of code that my driver interacts with.

code:
If (!device) {
    ERR("Device %s not found!", device->name);
    return -1;
}
It's not inspiring much confidence in the rest of the code...

Absurd Alhazred
Mar 27, 2010

by Athanatos

Apex Rogers posted:

Saw this in a piece of code that my driver interacts with.

code:
If (!device) {
    ERR("Device %s not found!", device->name);
    return -1;
}
It's not inspiring much confidence in the rest of the code...

It's conceivable that ! was overloaded... although it's a pointer, so that would probably require !(*device)?

hobbesmaster
Jan 28, 2008

Dr. AA Hazredstein posted:

It's conceivable that ! was overloaded... although it's a pointer, so that would probably require !(*device)?

You assume it's a raw pointer and -> isn't overloaded as well. If it works though that moves the horror to whoever defined the behavior of those operators.

Absurd Alhazred
Mar 27, 2010

by Athanatos

hobbesmaster posted:

You assume it's a raw pointer and -> isn't overloaded as well. If it works though that moves the horror to whoever defined the behavior of those operators.

Good point. Horror-worthy code either way.

Carbon dioxide
Oct 9, 2012

http://jazcash.com/a-javascript-journey-with-only-six-characters/

The following is valid, executable javascript. Run it in your browser console if you don't believe me.

[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]+(!![]+[])[+[]]+(![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]+([]+[])[(![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(!![]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]()[+!+[]+[!+[]+!+[]]]+(+(!+[]+!+[]+!+[]+[!+[]+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(+![]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(+![]+[![]]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]](!+[]+!+[]+!+[]+[!+[]+!+[]+!+[]])+(!![]+[])[+[]]+(![]+[])[+[]]+([]+[])[(![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(!![]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]()[+!+[]+[!+[]+!+[]]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]])()

Space Kablooey
May 6, 2009


Carbon dioxide posted:

http://jazcash.com/a-javascript-journey-with-only-six-characters/

The following is valid, executable javascript. Run it in your browser console if you don't believe me.
*snip*

Allowing JavaScript but disallowing alphanumeric characters is almost daring those people to make up things like that.

Cuntpunch
Oct 3, 2003

A monkey in a long line of kings
JS's unicode support also produces fun stuff: http://thedailywtf.com/articles/javascript-obfuscation

fritz
Jul 26, 2003

Carbon dioxide posted:

if you don't believe me.

I know better than to doubt horrors in this thread.

Arson Fire
Oct 8, 2010

Oath Breaker about to hit warphead nine Kaptain!
This... interesting means of loading a value from a database was recently found in our code.
code:
mbPrinterUseRegn = Convert.ToBoolean(Strings.UCase(Convert.ToString(moDBEngine.ResultsValue("PRegn") == "Y")));
Working with a legacy codebase is kinda fun, in a macabre sort of way. There's always some new twisted abomination to uncover.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Arson Fire posted:

This... interesting means of loading a value from a database was recently found in our code.
code:
mbPrinterUseRegn = Convert.ToBoolean(Strings.UCase(Convert.ToString(moDBEngine.ResultsValue("PRegn") == "Y")));
Working with a legacy codebase is kinda fun, in a macabre sort of way. There's always some new twisted abomination to uncover.

Is this not equivalent to the inner-most expression? lol

Stoatbringer
Sep 15, 2004

naw, you love it you little ho-bot :roboluv:

I came across this little gem recently. I don't know if it used to do something and the functionality gradually got removed, or if it was a joke or just stupidity/ignorance or what.
code:
String getEmptyStr()
{
    StringBuffer buf = new StringBuffer();
    buf.append("");
    return buf.toString();
}
On a similar note, I also found (and removed) something which took a String, parsed it to an Integer, took the intvalue and converted it back to a String. For some reason.

Stoatbringer fucked around with this message at 21:02 on Oct 10, 2016

baquerd
Jul 2, 2007

by FactsAreUseless

leper khan posted:

Is this not equivalent to the inner-most expression? lol

It is until there's that one weird bug that makes it not equivalent. Of course, there will be no unit test for this behavior.

Klades
Sep 8, 2011

Stoatbringer posted:

On a similar note, I also found (and removed) something which took a String, parsed it to an Integer, took the intvalue and converted it back to a String. For some reason.

Maybe the intention was to take a string that had int-y bits and non-int-y bits, and just get the int-y bits? Depending on how that particular parser works, anyway.

Sedro
Dec 31, 2008

Stoatbringer posted:

I came across this little gem recently. I don't know if it used to do something and the functionality gradually got removed, or if it was a joke or just stupidity/ignorance or what.
code:
String getEmptyStr()
{
    StringBuffer buf = new StringBuffer();
    buf.append("");
    return buf.toString();
}
On a similar note, I also found (and removed) something which took a String, parsed it to an Integer, took the intvalue and converted it back to a String. For some reason.

It should be calling getEmptyStr() instead of appending that magic value

SupSuper
Apr 8, 2009

At the Heart of the city is an Alien horror, so vile and so powerful that not even death can claim it.

Stoatbringer posted:

On a similar note, I also found (and removed) something which took a String, parsed it to an Integer, took the intvalue and converted it back to a String. For some reason.
I see this used a lot with numbers and dates in an attempt to discard unwanted parts from the data. They never use CultureInvariant either. :eng99:

canis minor
May 4, 2011

Apparently there is still a payment gateway that requires ActiveX - I truly hope that what I saw on my bosses screen is for research purposes only, as I'm not too keen to be integrating that.

Volte
Oct 4, 2004

woosh woosh

canis minor posted:

Apparently there is still a payment gateway that requires ActiveX - I truly hope that what I saw on my bosses screen is for research purposes only, as I'm not too keen to be integrating that.
Considering there's not a single browser that still supports ActiveX I don't think you have much to worry about.

edit: at least not the latest version of any browser

canis minor
May 4, 2011

Volte posted:

Considering there's not a single browser that still supports ActiveX I don't think you have much to worry about.

edit: at least not the latest version of any browser

I'm imagining scenario where we tell the users to install ActiveX to continue with their payment :suicide:

Su-Su-Sudoko
Oct 25, 2007

what stands in the way becomes the way

canis minor posted:

Apparently there is still a payment gateway that requires ActiveX - I truly hope that what I saw on my bosses screen is for research purposes only, as I'm not too keen to be integrating that.

maybe it's south korean

astr0man
Feb 21, 2007

hollyeo deuroga

Su-Su-Sudoko posted:

maybe it's south korean

It probably is.

beuges
Jul 4, 2005
fluffy bunny butterfly broomstick

SupSuper posted:

I see this used a lot with numbers and dates in an attempt to discard unwanted parts from the data. They never use CultureInvariant either. :eng99:

A project I'm maintaining does something like this all over:
code:
  string v = "1.14";
  decimal vat = decimal.Parse(v);

Not sure if the original dev didn't know how to properly initialize decimals or something... maybe he tried something like
code:
decimal vat = 1.14;
and didn't realise it needed to be
code:
decimal vat = 1.14M;

and just did the string parsing because it worked. I keep seeing this randomly throughout the project because my region settings use a comma as the decimal point, so it keeps throwing exceptions at the most unexpected times, because they obviously didn't use InvariantCulture either.

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

beuges posted:

A project I'm maintaining does something like this all over:
code:
  string v = "1.14";
  decimal vat = decimal.Parse(v);
Not sure if the original dev didn't know how to properly initialize decimals or something... maybe he tried something like
code:
decimal vat = 1.14;
and didn't realise it needed to be
code:
decimal vat = 1.14M;

and just did the string parsing because it worked. I keep seeing this randomly throughout the project because my region settings use a comma as the decimal point, so it keeps throwing exceptions at the most unexpected times, because they obviously didn't use InvariantCulture either.

i have heard of some places banning using decimal/float/double/etc literals for whatever loving reason, so maybe that was his workaround?

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
When confronted with static typing some people jam everything into string literals to shut the compiler up. It's basically a form of weak typing. I've seen numbers, bools, and what ought to be enumerations handled this way.

Absurd Alhazred
Mar 27, 2010

by Athanatos

HappyHippo posted:

When confronted with static typing some people jam everything into string literals to shut the compiler up. It's basically a form of weak typing. I've seen numbers, bools, and what ought to be enumerations handled this way.

That's when you encourage them to pursue a career closer to their proclivities.

Fergus Mac Roich
Nov 5, 2008

Soiled Meat

Dr. AA Hazredstein posted:

That's when you encourage them to pursue a career closer to their proclivities.

TCL programmer?

Absurd Alhazred
Mar 27, 2010

by Athanatos

Fergus Mac Roich posted:

TCL programmer?

TCL, Python, Javascript, Visual Basic, anything away from your code!

Bongo Bill
Jan 17, 2012

HappyHippo posted:

When confronted with static typing some people jam everything into string literals to shut the compiler up. It's basically a form of weak typing. I've seen numbers, bools, and what ought to be enumerations handled this way.

It's called "stringly typed"

vOv
Feb 8, 2014

Dr. AA Hazredstein posted:

That's when you encourage them to pursue a career closer to their proclivities.

Weaving?

Linear Zoetrope
Nov 28, 2011

A hero must cook

vOv posted:

Weaving?

I do weaving and it's p chill and reminds me a lot of a more zen, visual version of programming, actually.

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

Bongo Bill posted:

It's called "stringly typed"

:golfclap:

VikingofRock
Aug 24, 2008




Recently I've had to write some TCL stuff for my research, and I can't help but find the "everything is a string" thing kind of endearing.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
TCL is nice for programs of up to maybe 50 lines.

Shell also does "everything is a string", but much worse.

return0
Apr 11, 2007

Bongo Bill posted:

It's called "stringly typed"

I worked in the team that invented this term, seriously. It was hell.

ChickenWing
Jul 22, 2010

:v:

Ugh, I'd never encountered "stringly typed" in the wild until I caught the most egregious coding horror version of it - someone was using a string as a makeshift tuple. I threw up a little in my mouth when I realized exactly what was going on there.

Adbot
ADBOT LOVES YOU

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



ChickenWing posted:

Ugh, I'd never encountered "stringly typed" in the wild until I caught the most egregious coding horror version of it - someone was using a string as a makeshift tuple. I threw up a little in my mouth when I realized exactly what was going on there.

It was standard practice for a different team at the place I used to work to do this:

code:
<head>
    <title>Sensible, reasonable page title             google|analytics|tags|over|here</title>
They might even still be doing it. I always wondered when they'd accidentally trip some character limit in some browser's bookmark handling code and what would happen.

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