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
Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

b0lt posted:

C++ code:
        threads.emplace_back(

What a method name :stare:

This is what I get for being out of C++ for so long and not having a reason to play with the new standard.

Adbot
ADBOT LOVES YOU

b0lt
Apr 29, 2005

hackbunny posted:

Ugggh gross, use a condition variable, you monster

but but but... syscall! :saddowns:

Zamujasa
Oct 27, 2010



Bread Liar

b0lt posted:

Parallel fizzbuzz:

:rice:

This is art. :aaa:

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av

Flobbster posted:

What a method name :stare:

This is what I get for being out of C++ for so long and not having a reason to play with the new standard.

C++11 is really good, you can finally write C++ without being forced to use C-isms anywhere. I only wish MSVC implemented more of it, or that LLVM supported PDB debugging information, or that the Microsoft debugger supported DWARF symbols (I should try Wine's dbghelp.dll some time...)

e: and I wish clang actually implemented __try/__except/__finally as something other than purely syntactical black holes (clang really likes to delete code without warning, doesn't it?)

hackbunny fucked around with this message at 02:31 on May 22, 2013

Suspicious Dish
Sep 24, 2011

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

hackbunny posted:

C++11 is really good, you can finally write C++ without being forced to use C-isms anywhere.

What a shame.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

hackbunny posted:

C++11 is really good, you can finally write C++ without being forced to use C-isms anywhere. I only wish MSVC implemented more of it, or that LLVM supported PDB debugging information, or that the Microsoft debugger supported DWARF symbols (I should try Wine's dbghelp.dll some time...)

e: and I wish clang actually implemented __try/__except/__finally as something other than purely syntactical black holes (clang really likes to delete code without warning, doesn't it?)

On some level, that's on me.

A lot of our MSVC compatibility code was initially contributed by people who just wanted to parse to an AST for various reasons, so they've specifically wanted us to not complain about it. Those people generally only implement enough for us to parse and make ASTs for those constructs. I try to get them to at least ensure the compiler complains about generating code for unimplemented features, but there's a problem: that tends to block some people who manage to have code containing that construct but don't really care. For example, I'm sure there's plenty of code in headers that contains __try statements to handle some obscure corner case, but in practice users of those headers don't run into that condition.

Ultimately, given that I feel that people generally know that clang targeting Windows (for C++ or any of the weirder Windows features) is extremely alpha, if a contributor pushes back hard enough, I'd rather encourage them to keep contributing than be a hard-rear end. When we're closer to feature-complete, that'll change. Although... SEH support specifically might be pretty long coming.

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av

rjmccall posted:

On some level, that's on me.

A lot of our MSVC compatibility code was initially contributed by people who just wanted to parse to an AST for various reasons, so they've specifically wanted us to not complain about it. Those people generally only implement enough for us to parse and make ASTs for those constructs. I try to get them to at least ensure the compiler complains about generating code for unimplemented features, but there's a problem: that tends to block some people who manage to have code containing that construct but don't really care. For example, I'm sure there's plenty of code in headers that contains __try statements to handle some obscure corner case, but in practice users of those headers don't run into that condition.

Ultimately, given that I feel that people generally know that clang targeting Windows (for C++ or any of the weirder Windows features) is extremely alpha, if a contributor pushes back hard enough, I'd rather encourage them to keep contributing than be a hard-rear end. When we're closer to feature-complete, that'll change. Although... SEH support specifically might be pretty long coming.

It's on me too, I guess :shobon:. I am some sort of SEH "expert", no, more like a SEH buff, and a MSVC internals buff as well. My single biggest credential in this field is an embarrassing implementation of SEH constructs for GCC (which contains such terrifying constructs as "A no-op side effect that scares GCC" and "GCC doesn't know that this equals zero", and an inline function trampoline disassembler so as not to require an executable stack), which was nevertheless good enough that ReactOS is still using it after 5 years (in kernel mode too, no less) and only a few months ago was considered for replacement

My biggest regret is trying, and failing, to add SEH support to GCC (in my defense, the GCC code is impenetrable), but it's objectively hard considering that both the API and ABI of SEH are fundamentally incompatible with Unwind: not just different, more like irreconcilable, what with SEH unwinding the stack in one big shot and Unwind doing it frame by frame; SEH calling unwind blocks as nested functions and Unwind as inline code; SEH exceptions being restartable (in fact, the most useful use cases of SEH involve restartable exceptions); and SEH requiring the generation of code, not just unwind data, on x86 (code that is, inexplicably, patented)

I actually downloaded the LLVM source code some time ago (and was very impressed that it compiles cleanly in Visual Studio, by the way), with the intention of at least trying to add SEH support, but eh, if it turns out I have to make changes the backend or, god forbid, the intermediate language, I doubt that would be received well. Sooo, I'm not making promises or anything, but does anyone care enough about SEH?

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
I think we're still a bit sensitive about some of the legal issues around SEH (it's still under patent); I would email Chandler Carruth at Google (privately) and ask his opinion.

Technically, I think the right approach would be a late-staged LLVM pass (there's an analogous one for DWARF exceptions) that does the sub-function extraction, inserts the appropriate runtime calls, and maintains the context index. It's possible, maybe even likely, that you'll need to add some new intrinsics to handle some of the peculiarities of the runtime interaction there; I only know the main thrusts of the design, not the specifics like how to register stuff with the runtime.

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av

rjmccall posted:

I think we're still a bit sensitive about some of the legal issues around SEH (it's still under patent); I would email Chandler Carruth at Google (privately) and ask his opinion.

Technically, I think the right approach would be a late-staged LLVM pass (there's an analogous one for DWARF exceptions) that does the sub-function extraction, inserts the appropriate runtime calls, and maintains the context index. It's possible, maybe even likely, that you'll need to add some new intrinsics to handle some of the peculiarities of the runtime interaction there; I only know the main thrusts of the design, not the specifics like how to register stuff with the runtime.

Ludicrously simple, I think it was specifically designed so that it could be implemented in MASM macros or even inline assembler for backwards compatibility with compilers that didn't natively support it *. You just build a singly-linked list entry on the stack and push it on top of the SEH frame stack; you pop it in the function epilogue, and that's pretty much 50% of the whole ABI right there. That's what makes the Borland patent such horseshit, and I would be surprised if similar mechanisms like pthread_cleanup_push/pthread_cleanup_pop didn't toe the line of infringement

e: * in fact, the MSVC implementation quacks just like an ascended inline asm implementation. For example, __except() expressions and __finally blocks are emitted as labels followed by a RET, not true nested functions, and they don't bother making a closure of the local variables they actually use, they just restore EBP and call it a day. Super hacky stuff. For contrast - and I know this for a fact having personally disassembled PowerPC, MIPS and Alpha executables - on all other architectures SEH is implemented like you'd expect, with proper nested functions (named, even) and closures

hackbunny fucked around with this message at 12:36 on May 22, 2013

bobthecheese
Jun 7, 2006
Although I've never met Martha Stewart, I'll probably never birth her child.
Are we still talking fizzbuzz?

php:
<?while($i++<100)echo$i%3?!$$i=$i:Fizz,$i%5?$$i:Buzz,~õ?>
Explanation of this horror is here, and it probably won't work on most copies of PHP.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

hackbunny posted:

Ludicrously simple, I think it was specifically designed so that it could be implemented in MASM macros or even inline assembler for backwards compatibility with compilers that didn't natively support it *. You just build a singly-linked list entry on the stack and push it on top of the SEH frame stack; you pop it in the function epilogue, and that's pretty much 50% of the whole ABI right there. That's what makes the Borland patent such horseshit, and I would be surprised if similar mechanisms like pthread_cleanup_push/pthread_cleanup_pop didn't toe the line of infringement

IIRC the patent is specific to its use to implement exceptions.

Is pushing onto the SEH frame stack done inline in the frame? I guess it's presented as some thread-local variable — ah, yes, apparently it's fs:0.

If you're really interested in working on this, we sold probably take this to llvm-dev (but CC me; I can't keep up with that list normally).

hobbesmaster
Jan 28, 2008

bobthecheese posted:

Are we still talking fizzbuzz?

php:
<?while($i++<100)echo$i%3?!$$i=$i:Fizz,$i%5?$$i:Buzz,~õ?>
Explanation of this horror is here, and it probably won't work on most copies of PHP.

The ~õ is perfect.

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"
This horrible thing that just got made public is apparently what powers Instagram on the web, and Facebook contributes to it too.

http://facebook.github.io/react/

code:
/** @jsx React.DOM */
var HelloMessage = React.createClass({
  render: function() {
    return <div>{'Hello ' + this.props.name}</div>;
  }
});

React.renderComponent(<HelloMessage name="John" />, mountNode);
:stare:

code:
        <div
          className="content"
          dangerouslySetInnerHTML={{
            __html: converter.makeHtml(this.state.value)
          }}
        />
:psypop:

This is a joke, right?

McGlockenshire
Dec 16, 2005

GOLLOCKS!

Flobbster posted:

:psypop:

This is a joke, right?

What, you haven't seen Facebook's XHP?
php:
<?php
$list = <ul />;
foreach ($items as $item) {
  $list->appendChild(<li>{$item}</li>);
}
Facebook is full of batshit insanity.

SharpenedSpoonv2
Aug 28, 2008
Any hints as to the particulars of why React is so awful, for those of us who can't spot it quite as readily?

Doctor w-rw-rw-
Jun 24, 2008

McGlockenshire posted:

What, you haven't seen Facebook's XHP?
php:
<?php
$list = <ul />;
foreach ($items as $item) {
  $list->appendChild(<li>{$item}</li>);
}
Facebook is full of batshit insanity.

To be fair, Scala also has XML literals and I think Marcel Laverdet (creator of XHP) left Facebook ages ago. Not sure if it's enjoyed much usage internally since it's been a couple of years.

Sang-
Nov 2, 2007

Doctor w-rw-rw- posted:

To be fair, Scala also has XML literals and I think Marcel Laverdet (creator of XHP) left Facebook ages ago. Not sure if it's enjoyed much usage internally since it's been a couple of years.

scala's xml literals make the language a colossal pain to parse

Brecht
Nov 7, 2009
code:
public CommandResult update() {
    CommandResult res = null;
    try {
        ...
    } catch (Exception e) {
        if (!((_ok) ? true : (Math.random() > 0.1))) {
            return res;
        }
        ...
    }
    return res;
}

ymgve
Jan 2, 2004


:dukedog:
Offensive Clock
Wait, what?

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
It makes slightly more sense untrimmed - the only thing in the catch block is some logging and the server being periodically unreachable is expected.

Sang-
Nov 2, 2007
In the spirit of things:

code:
class FizzBuzz[K, J](space: Iterable[K], outputs: Map[(K => Boolean), (K => J)], otherwise: (K => J)) {
    for(input <- space) {
        outputs.filter(t => t._1(input)).headOption.map(_._2).getOrElse(otherwise)(input)
    }
}
Called with:

code:
object FizzBuzz extends App {

    def createArgument(succeed: Int, output: String):((Int => Boolean), (Int => Unit)) = {
        val mod: (Int, Int) => Boolean = _ % _ == 0
        ((mod(_: Int, succeed)) -> {x: Int => println(output)})
    }

    new FizzBuzz[Int, Unit](1 to 100, Map(
        (createArgument(15, "FizzBuzz")),
        (createArgument(3,  "Fizz")),
        (createArgument(5,  "Buzz")),
        ({x: Int => true} ->  {case x: Int => println(x)})
    ))
}

Deus Rex
Mar 5, 2005

McGlockenshire posted:

What, you haven't seen Facebook's XHP?
php:
<?php
$list = <ul />;
foreach ($items as $item) {
  $list->appendChild(<li>{$item}</li>);
}
Facebook is full of batshit insanity.

Actually XHP owns. Static guarantees that strings are escaped properly depending on context while using a very natural syntax is totally a good thing.

Impotence
Nov 8, 2010
Lipstick Apathy

Plorkyeran posted:

the server being periodically unreachable is expected.

Why would this be a good thing?

Hughlander
May 11, 2005

Probably so that you don't spam the log files thousands of times a second with the same error, now it'll only spam HUNDREDS of times a second!

Hughlander fucked around with this message at 02:00 on May 31, 2013

FateFree
Nov 14, 2003

I was cleaning out a development folder and I found a file called MP.java. I had no recollection until I opened it and it all came rushing back to me. I suppose this falls under the category of code that makes you laugh.

When I was a younger buck working at Morgan Stanley, I thought I would die from the boredom of writing loan reporting applications. My boss sat directly behind me so I couldn't slack off and read the internet. To pass the time I would try to code things that would keep me entertained. So I created this little work of art.

If you have a Java IDE, run it as a java application and watch the console - but the console needs to be sized correctly. Shrink it down until you can only see one square frame. Enjoy.

http://imadp.com/static/MP.java

ephphatha
Dec 18, 2009




That's amazing. For the lazy set your console window to 65x17 and run java -jar MP.jar.

zergstain
Dec 15, 2005

code:
Exception in thread "main" java.lang.UnsupportedClassVersionError: MP$Life : Unsupported major.minor version 51.0
:(

Does this require Java 7? Surprisingly I only have Java 6 in my shell, but Java 7 in my browser.

ephphatha
Dec 18, 2009




Oh gently caress, probably. I compiled and built the jar using Java 7. You should be able to compile the source in any version of Java.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

FateFree posted:

I was cleaning out a development folder and I found a file called MP.java. I had no recollection until I opened it and it all came rushing back to me. I suppose this falls under the category of code that makes you laugh.

When I was a younger buck working at Morgan Stanley, I thought I would die from the boredom of writing loan reporting applications. My boss sat directly behind me so I couldn't slack off and read the internet. To pass the time I would try to code things that would keep me entertained. So I created this little work of art.

If you have a Java IDE, run it as a java application and watch the console - but the console needs to be sized correctly. Shrink it down until you can only see one square frame. Enjoy.

http://imadp.com/static/MP.java


Ephphatha posted:

That's amazing. For the lazy set your console window to 65x17 and run java -jar MP.jar.

:golfclap:

Your tree was planted in the very soul of the 1 minute I spent downloading and running this artistic masterpiece.

The Gripper
Sep 14, 2004
i am winner

zergstain posted:

code:
Exception in thread "main" java.lang.UnsupportedClassVersionError: MP$Life : Unsupported major.minor version 51.0
:(

Does this require Java 7? Surprisingly I only have Java 6 in my shell, but Java 7 in my browser.
You should just be able to do javac MP.java && java MP$Life if that there .jar doesn't work!
edit; oh wait javac is only in the JDK I am dumb.

The Gripper fucked around with this message at 14:27 on May 31, 2013

MononcQc
May 29, 2007

It's MongoDB time! User-triggerable NULL pointer dereference due to utter plebbery

quote:

Steps to reproduce:

Step 1. Use Mongo as WEB SCALE DOCUMENT STORE OF CHOICE LOL

Step 2. Assume basic engineering principles applied throughout due to HEAVY MARKETING SUGGESTING AWESOMENESS.

Step 3. Spend 6 months fighting plebbery across the spectrum, mostly succeed.

Step 4. NIGHT BEFORE INVESTOR DEMO, TRY UPLOADING SOME DATA WITH "{$ref: '#/mongodb/plebtastic'"

Step 5. LOL WTF?!?!? PYMONGO CRASH?? :OOO LOOOL WEBSCALE

Step 6. It's 4am now. STILL INVESTIGATING

b4cb9be0 pymongo/_cbsonmodule.c (Mike Dirolf 2009-11-10 14:54:39 -0500 1196) /* Decoding for DBRefs */

Oh Mike!!!

Step 7. DISCOVER PYMONGO DOES NOT CHECK RETURN VALUES IN MULTIPLE PLACES. DISCOVER ORIGINAL AUTHOR SHOULD NOT BE ALLOWED NEAR COMPUTER

0558b0d4 pymongo/_cbsonmodule.c (Mike Dirolf 2009-06-08 15:06:12 -0400 1197) if (strcmp(buffer + position + 5, "$ref") == 0) { / DBRef */
f3da57be pymongo/_cbsonmodule.c (sibsibsib 2010-08-03 13:24:14 +0800 1198) PyObject* dbref;
b4cb9be0 pymongo/_cbsonmodule.c (Mike Dirolf 2009-11-10 14:54:39 -0500 1199) PyObject* collection = PyDict_GetItemString(value, "$ref");
...
30c253e6 pymongo/_cbsonmodule.c (Mike Dirolf 2010-06-22 12:29:20 -0400 1206) PyDict_DelItemString(value, "$id");
...
6b0a9ccb pymongo/_cbsonmodule.c (Mike Dirolf 2010-06-21 15:15:00 -0400 1220) Py_DECREF(id);

LOOOOL!

OH MIKE OH MIKE!! BUT WHAT IF $ref DOESNT HAVE $id KEY? LOOL

Step 8. REALIZE I CAN CRASH 99% OF ALL WEB 3.9 poo poo-TASTIC WEBSCALE MONGO-DEPLOYING SERVICES WITH 16 BYTE POST

Step 9. REALIZE 10GEN ARE TOO WORTHLESSLY CLUELESS TO LICENCE A STATIC ANALYZER THAT WOULD HAVE NOTICED THIS PROBLEM IN 0.0000001 NANOSECONDS?!!?!?@#

Step 10. TRY DELETING _cbson.so.

Step 11. LOOOOOOOOOOOOL MORE NULL PTR DEREFS IN _cmessage.so!!?!? LOLLERPLEX??!? NULL IS FOR LOSERS LOLOL

Steps to fix:

1. MIKE WAS BORN A TECH WRITER. REVOKE COMMIT PRIVS TODAY

2. BUY A GODDAMNED COVERITY LICENCE YOU AMATEURS

3. ADD process_dbrefs=False TO ALL THE DRIVERS

4. FIX NULL PTR DEREFERENCE

5. PUBLISH SECURITY ADVISORY OR I WILL DO IT FOR YOU

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

I'd probably care more if he wrote it up seriously and didn't come off like a 14 year old/JeffK. "LOLLERSK8Z WEB 3.9", jesus christ

Foiltha
Jun 12, 2008

Ithaqua posted:

I'd probably care more if he wrote it up seriously and didn't come off like a 14 year old/JeffK. "LOLLERSK8Z WEB 3.9", jesus christ

Yeah, seriously. The biggest horror here is that somebody has to work with that guy.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Foiltha posted:

Yeah, seriously. The biggest horror here is that somebody has to work with that guy.

And the bug is fixed now.

So the timeline is:
5/31: Guy discovers a bug and is a douchebag about it
5/31: Bug is fixed

That was nowhere near as fun as the maintainer of Calibre repeatedly defending bad practices and being a prick in the face of overwhelming evidence.

Munkeymon
Aug 14, 2003

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



I'd be pretty petulant about that at the end of a legitimate ~20 hour workday, too, assuming that stuff about it being 4 AM wasn't bullshit.

Ithaqua posted:

That was nowhere near as fun as the maintainer of Calibre repeatedly defending bad practices and being a prick in the face of overwhelming evidence.

:allears:

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Ithaqua posted:

And the bug is fixed now.

So the timeline is:
5/31: Guy discovers a bug and is a douchebag about it
5/31: Bug is fixed

That was nowhere near as fun as the maintainer of Calibre repeatedly defending bad practices and being a prick in the face of overwhelming evidence.

On the other hand, it was refreshing to see the comments stay civil despite the douchey report (and the report's author even apologized for his tone).

zergstain
Dec 15, 2005

The Gripper posted:

You should just be able to do javac MP.java && java MP$Life if that there .jar doesn't work!
edit; oh wait javac is only in the JDK I am dumb.

Don't worry, I have the JDK. Just not JDK 7. I thought I did.

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av

That was painful to read

Suspicious Dish
Sep 24, 2011

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

Ithaqua posted:

That was nowhere near as fun as the maintainer of Calibre repeatedly defending bad practices and being a prick in the face of overwhelming evidence.

And, unfortunately, some of that personality is owed to part of the Linux mentality. Part of his argument was that "I can't depend on udisks because users asked for it to not be a dependency", which is like a Windows software developer saying "I can't depend on user32.dll because some customers delete it from the base install".

It's an unfortunate state because Linux app developers can't depend on any base system library being there, and if they do, users will complain.

Adbot
ADBOT LOVES YOU

Dren
Jan 5, 2001

Pillbug

DaTroof posted:

On the other hand, it was refreshing to see the comments stay civil despite the douchey report (and the report's author even apologized for his tone).

It's kind of a stretch to call

quote:

Apologies to anyone offended by this report. Thanks for your effort!
an apology. It's the same as saying "sorry you were offended", which is not an apology at all. The mongo guys, on the other hand, were very gracious.

Mongo catches a ton of poo poo but it can be really hard to suss out when it's well-deserved since the complaints are often phrased as tirades, are hardly substantiated, or contain complaints that have been addressed in newer versions of mongodb than the author is using.

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