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
NFX
Jun 2, 2008

Fun Shoe
I wrote this masterpiece today:
C++ code:
void complexFlip(float* data, int num)
{
  for (int i = 0; i < num/2; i++)
  {
    int re1 = 2*i;
    int im1 = 2*i + 1;
    int re2 = num - 2*i - 2;
    int im2 = num - 2*i - 1;
    float a = data[re1];
    float b = data[im1];
    data[re1] = data[re2];
    data[im1] = data[im1];
    data[re2] = a;
    data[im2] = b;
  }
}
And spent way too long wondering why it didn't do anything.

Adbot
ADBOT LOVES YOU

Suspicious Dish
Sep 24, 2011

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

Otto Skorzeny posted:

Is this too long for a username? :getin:

Yep. By three characters.

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

prefect posted:

Whoops. I had been unaware. :blush:

There are a couple of interesting things in there, as long as you don't try to take it very seriously. (Also some stupid poo poo.) Although I tend to think of developers as a bunch of raving whackaloons who want to try crazy new poo poo, while DBAs and operations folks are dedicated to making sure nothing ever changes, because then something will break.

This is a great post just for the hilarious reactions of nerds fumbling and scrambling and rationalizing to try and not be software conservatives.

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

Factor Mystic posted:

This is a great post just for the hilarious reactions of nerds fumbling and scrambling and rationalizing to try and not be software conservatives.

quote:

I want to say it's a well-written article, but the definitions of conservative and liberal don't make sense, and judging the reaction of the programmers, I'm on to something.
American conservatism is about preserving the Constitution and keeping the government subject to it (and as a result, the people of the US). It's more of a "don't tread on me" philosophy, which is why conservatives and libertarians get along so well.
Liberalism is about the government gradually becoming less subject to the Constitution and more about political bodies having control (and its by-product is people slowly become subject to their government). While there is some truth to this article, the bottom line is that conservatism puts political power in the hands of people, with government as the subject, whereas liberalism does the opposite; puts people subject to bureaucracy (and by default, politicians). This article misses this very obvious point, which is where it goes wrong.

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice
We *are* the horror.

Everything just reduces down to that.

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Otto Skorzeny posted:

Here is the post from Steve "Fred Lowenol" Yegge that suspicious dish was referring to in case you were blissfully unaware https://plus.google.com/110981030061712822816/posts/KaSKeg4vQtz

What is the reference to Fred Lowenol?

shrughes
Oct 11, 2008

(call/cc call/cc)
floWenoL is Steve Yegge, we doxxed him.

FamDav
Mar 29, 2008
same but what did flowenol do

Pollyanna
Mar 5, 2005

Milk's on them.


Is there a particular reason that the HTML has to have divs everywhere like this?

http://jsfiddle.net/dmV8v/

HTML code:
edit: oh god that was a bad idea. pretend the html in that link is in here. its a doozy

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
<div> is the staple tag for "I have no idea what I'm doing". Most of that stuff should be in <p> tags instead.

nielsm
Jun 1, 2009



Looks like the output of a WYSIWYG editor. (Also see previous)

EAT THE EGGS RICOLA
May 29, 2008

Pollyanna posted:

Is there a particular reason that the HTML has to have divs everywhere like this?

http://jsfiddle.net/dmV8v/

HTML code:
edit: oh god that was a bad idea. pretend the html in that link is in here. its a doozy

Kill this person for not knowing what a bullet point is.

Pollyanna
Mar 5, 2005

Milk's on them.


Suspicious Dish posted:

<div> is the staple tag for "I have no idea what I'm doing". Most of that stuff should be in <p> tags instead.

I started getting suspicious when I saw this long line of "Path: body»div.posting»div.posting»div.posting»div.posting»div.posting»div.posting" showed up at the bottom of the screen. Even I know this isn't how it works. :psyduck:

EAT THE EGGS RICOLA posted:

Kill this person for not knowing what a bullet point is.

The WYSIWYG coder or me? :saddowns:

nielsm posted:

Looks like the output of a WYSIWYG editor. (Also see previous)

oh my god

EAT THE EGGS RICOLA
May 29, 2008

Pollyanna posted:

I started getting suspicious when I saw this long line of "Path: body»div.posting»div.posting»div.posting»div.posting»div.posting»div.posting" showed up at the bottom of the screen. Even I know this isn't how it works. :psyduck:


The WYSIWYG coder or me? :saddowns:


oh my god

Not you!

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
To this day, it still blows my mind that flowenol was Yegge. flowenol was always rather succinct in his posts…

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
I can't tell if you're joking or not. Was LoneWolf really Yegge?

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
I could swear he had admitted it at some point, but now I can't remember when, so now that you ask, I'm having doubts again!

JawnV6
Jul 4, 2004

So hot ...
It's the stupidest running "joke"

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
Feels good to be the last person to fall for it, and probably for the longest time :smith:

Suspicious Dish
Sep 24, 2011

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

Mustach posted:

I could swear he had admitted it at some point

Here?

shrughes
Oct 11, 2008

(call/cc call/cc)
Here's a coding horror I made. The C++ software I work on runs on userland threads or "coroutines" that are cooperatively threaded and have their own stacks. It turns out that OS X's backtrace() function doesn't work right because instead of using the current state of certain registers or something to figure out the stack location, instead it uses values of the original pthread stack, accessible via pthread_get_stacksize_np and pthread_get_stackaddr_np.

You could just copy/paste in the Darwin implementation and then edit it to use the right bounds, but that code's license isn't compatible with the AGPLv3 (or any GPL). So what do you do?

Well it turns out that on OS X, a pthread_t is actually a pointer to a structure. And there are fields in this structure (if you look at the Darwin source) called size_t stacksize and void *stackaddr. And in different versions of the system libraries, the fields have different offsets. In the user-visible headers there's just three fields, the third of which is a long char array named __opaque, of length __PTHREAD_SIZE__, behind which the other fields lie.

So if you want to do a backtrace for a different stack, you just need to go and find the fields, modify them, run the backtrace call, and then (optionally?) set them back to their original values.

Adding to the horror is that I used __MACH__ to ifdef which OS it was (who knows what to use? __APPLE__? Pshaw.) and the general lack of commenting about what this code is trying to do.

Also contributing to the horror is that it comes to mind that if the field offsets can change then maybe so can the struct size itself. Maybe this walks off the end of the structure when the binary's run on different versions of OS X.

(For the record this code is redistributable under the AGPLv3.)

code:
#include "rethinkdb_backtrace.hpp"

#ifdef __MACH__

#include <execinfo.h>
#include <pthread.h>
#include <stdlib.h>

#include "arch/runtime/coroutines.hpp"
#include "arch/runtime/context_switching.hpp"

struct pthread_t_field_locations_t {
    size_t stackaddr_offset;
    size_t stacksize_offset;
};

bool get_pthread_t_stack_field_locations(pthread_t th, pthread_t_field_locations_t *locations_out) {
    void *const stackaddr = pthread_get_stackaddr_np(th);
    const size_t stacksize = pthread_get_stacksize_np(th);

    pthread_t_field_locations_t locations;
    bool found_stackaddr = false;
    bool found_stacksize = false;

    const size_t step = std::min(sizeof(size_t), sizeof(void *));
    for (size_t i = 0; i < __PTHREAD_SIZE__; i += step) {
        char *const p = th->__opaque + i;
        if (!found_stackaddr
            && i <= __PTHREAD_SIZE__ - sizeof(void *)
            && *reinterpret_cast<void **>(p) == stackaddr) {
            void *const test_value = static_cast<char *>(stackaddr) + 8;
            *reinterpret_cast<void **>(p) = test_value;
            if (pthread_get_stackaddr_np(th) == test_value) {
                locations.stackaddr_offset = i;
                found_stackaddr = true;
            }
            *reinterpret_cast<void **>(p) = stackaddr;
        }

        if (!found_stacksize
            && i <= __PTHREAD_SIZE__ - sizeof(size_t)
            && *reinterpret_cast<size_t *>(p) == stacksize) {
            const size_t test_value = stacksize + 8;
            *reinterpret_cast<size_t *>(p) = test_value;
            if (pthread_get_stacksize_np(th) == test_value) {
                locations.stacksize_offset = i;
                found_stacksize = true;
            }
            *reinterpret_cast<size_t *>(p) = stacksize;
        }
    }

    if (found_stackaddr && found_stacksize) {
        *locations_out = locations;
        return true;
    } else {
        return false;
    }
}

void substitute_pthread_t_stack_fields(pthread_t th, pthread_t_field_locations_t locations,
                                       void *addr, size_t size) {
    *reinterpret_cast<void **>(th->__opaque + locations.stackaddr_offset) = addr;
    *reinterpret_cast<size_t *>(th->__opaque + locations.stacksize_offset) = size;
}

int rethinkdb_backtrace(void **buffer, int size) {
    coro_t *const coro = coro_t::self();
    if (coro == NULL) {
        return backtrace(buffer, size);
    } else {
        pthread_t_field_locations_t field_locations;
        pthread_t self = pthread_self();
        if (!get_pthread_t_stack_field_locations(self, &field_locations)) {
            fprintf(stderr, "Could not retrieve pthread stack field locations.\n");
            return 0;
        }

        void *const stackaddr = pthread_get_stackaddr_np(self);
        const size_t stacksize = pthread_get_stacksize_np(self);

        artificial_stack_t *const stack = coro->get_stack();
        void *const coro_addr = stack->get_stack_base();
        const size_t coro_size = static_cast<char *>(coro_addr)
            - static_cast<char *>(stack->get_stack_bound());

        substitute_pthread_t_stack_fields(self, field_locations, coro_addr, coro_size);
        const int res = backtrace(buffer, size);
        substitute_pthread_t_stack_fields(self, field_locations, stackaddr, stacksize);
        return res;
    }
}

#else
#include <execinfo.h>

int rethinkdb_backtrace(void **buffer, int size) {
    return backtrace(buffer, size);
}
#endif  // __MACH__

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Did you report that bug about backtrace(); to Apple?

shrughes
Oct 11, 2008

(call/cc call/cc)
Is it really a bug? Also no I don't report bugs to Apple. They want you to sign up for a developer account and agree to some contract just to access their bug reporting infrastructure so they're welcome to gently caress off. Also they rejected my Hacker News iPhone app like 3 years ago. I also didn't report a race condition in unix domain sockets.

Pollyanna
Mar 5, 2005

Milk's on them.



It says "bullet points" but everyone else posts fuckoff long essays, I feel like I need to keep up :downs:

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
No, some other dumb, vague memory of mine. I'm a coding horror

a lovely poster
Aug 5, 2011

by Pipski
We should do a coding horror thread where you can only post your own code.

Woodsy Owl
Oct 27, 2004
A Git horror from today: I'm still learning my way around git, okay? So I was making a new local repository and I staged some files to commit, but then I decided I wanted to unstage them. git status says this:

pre:
use "git rm --cached <file>..." to unstage
And like an idiot I did

pre:
git rm . -r -f
It definitely worked. It definitely unstaged the files, that's for loving certain.

Hughlander
May 11, 2005

shrughes posted:

Is it really a bug? Also no I don't report bugs to Apple. They want you to sign up for a developer account and agree to some contract just to access their bug reporting infrastructure so they're welcome to gently caress off. Also they rejected my Hacker News iPhone app like 3 years ago.

Doesn't them rejecting your app imply you already have an account and have agreed to the contract?

FamDav
Mar 29, 2008

Woodsy Owl posted:

A Git horror from today: I'm still learning my way around git, okay? So I was making a new local repository and I staged some files to commit, but then I decided I wanted to unstage them. git status says this:

pre:
use "git rm --cached <file>..." to unstage
And like an idiot I did

pre:
git rm . -r -f
It definitely worked. It definitely unstaged the files, that's for loving certain.

Unstaging in git is weird and not weird.

Normally to unstage changes, you would do "git reset HEAD file". This only works on files which you are modifying, not adding to your repo. To unstage adds, you have to use "git rm --cached file". If you use the latter on a file which is in your repo, it will actually delete it from the repo if you commit, but keep the file around unversioned.

You would think there would be a git unstage command that would do the correct thing, but then you'd expect git to be sensible.

shrughes
Oct 11, 2008

(call/cc call/cc)

Hughlander posted:

Doesn't them rejecting your app imply you already have an account and have agreed to the contract?

I don't remember what that account info was, and it's probably changed since then so I'd have to reread it, and creating a new account would probably be agreeing to it on behalf of my employer, and gently caress no I'm not going to go through that just to help them. No free bugs.

teamdest
Jul 1, 2007

shrughes posted:

I don't remember what that account info was, and it's probably changed since then so I'd have to reread it, and creating a new account would probably be agreeing to it on behalf of my employer, and gently caress no I'm not going to go through that just to help them. No free bugs.

Not to belabor the point, but if they fix the stack trace issue, you wouldn't need an ugly and possibly broken hack to do what you originally wanted. You benefit from bug fixes in anything you work under.

Dren
Jan 5, 2001

Pillbug
Yeah but now shrughes has a functional debugger and his competitors don't.

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.

teamdest posted:

Not to belabor the point, but if they fix the stack trace issue, you wouldn't need an ugly and possibly broken hack to do what you originally wanted. You benefit from bug fixes in anything you work under.

I agree with Shrughes that it'd be a huge waste of time. Like, chances are a bug report like that, the person evaluating the bug would laugh unless you provided a minimal test case app, which might take days to write and test. Assuming you had the minimal test case, and the person you provide the test case app can actually get your stuff to build, you'd also have to match it with a defect report the person on the other side would understand, and answer their questions if needed. Congratulations, your bug will get marked no-fix or at the very least take months if not years to get fixed.

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Also it's Apple so they will just ignore the bug report anyways.

Gul Banana
Nov 28, 2003

i sent apple a bug report about a gcc crash and they fixed it. it was something to do with using c++ templates, blocks, and closure-by-reference..

JawnV6
Jul 4, 2004

So hot ...
Maybe you have to mimic their internal style. So be accusatory, pretend there's no possible way any action of yours could be at fault, and include proof you're throwing a teammate under a bus.

Doctor w-rw-rw-
Jun 24, 2008
My team has submitted radars and gotten a pretty good hit rates for fixes, so can we not shitpost about how Apple doesn't respond, without concrete incidents?

shrughes
Oct 11, 2008

(call/cc call/cc)
I think in this case it'd go something like this:

:hehe: Hey we changed the value of %rsp with some inline assembly code and now backtraces aren't working!

;-* :ughh:

pseudorandom name
May 6, 2007

Does backtrace() work if you use swapcontext()?

Adbot
ADBOT LOVES YOU

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

shrughes posted:

I think in this case it'd go something like this:

:hehe: Hey we changed the value of %rsp with some inline assembly code and now backtraces aren't working!

;-* :ughh:

That's sure as hell how I'd resolve that bug.

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