Hacker News new | past | comments | ask | show | jobs | submit | mihai_ionic's comments login

Is there any reason why something like the following should not work?

    while (condition)
    {
        a();
        if (!condition)
            break;
        b();
    }


Your example assumes that you can inline the calls to a and b. If you can't (for example if one of them calls themselves) then your optimization won't work.


Yes, for example this bug affects 'file': https://sourceware.org/bugzilla/show_bug.cgi?id=16825

The code in 'file' tries to parse the given file with every built-in format loader, so there are likely many more vulnerabilities like this one.


The binutils maintainers aren't exactly responsive when it comes to following up on security-impacting bug reports: https://sourceware.org/bugzilla/show_bug.cgi?id=16825


Here's what the final example from the blog would look like, if you were to directly translate it into C++: http://coliru.stacked-crooked.com/a/265c6ec6fb6751a9

Now, of course, no one would program that way, but I think it does help visualize what really happens.

The obvious cost from delaying the printing is that you have to branch a second time, later in the code, to consume the value. I wonder how feasible it would be to introduce some kind of compiler transform that could invert the control flow, essentially pasting the surrounding code into the inner branches, to make this abstraction cost-free.


One use case where Postgres FTS fails spectacularly is when your search has to return results ordered by some field (e.g., timestamp). This is critical for applications that have to return close-to-realtime results due to the queried content being time-sensitive.

Neither GIN nor GiST indices support such document ordering. For a top-N query of the most recent results, the entire result set has to be processed. With common domain-specific words, this can be more than 50% of the entire document set. As you can imagine, this is insanely expensive. When you are in this situation, it helps to set gin_fuzzy_search_limit to a conservative number (20000 works for me, less if you expect heavy traffic) in postgresql.conf, so that pathological queries eventually finish without processing every result. Result quality will take a hit, because many documents are skipped over.

If you need any type of ordered search on more than a hundred thousand documents, do yourself a favor and use something else than Postgres.

I'm not sure what search back-end Wikipedia is using, but it seems like they are not quite immune to this problem either: https://en.wikipedia.org/w/index.php?search=a+the


Or, as I prefer to think of it, the state of a distant object is undetermined with respect to your state (in a superposition of all reachable states since your last interaction) until you actually interact with it, at which point both get reconciled into a compatible state. Of course, it's slightly more complicated than that, because this applies to every particle you're made of individually. And then the particles are actually merely excitations of a field.

I'll leave the rest to actual physicists. :)


Likewise, I've witnessed a reversible variant of SHA-1. They must have somehow messed up the break condition because it essentially only did one round.


Oh my, yes. 128-bit RSA signatures, anyone? AES-256... in ECB mode, with a static key that's the MD5 of a super-secret string in the binary with each byte sign-extended to 16-bit? ^0xA5? ROT13? I have seen them all, and I have despaired.

So many vendor "engineering" backdoors, too. Gah.


This decision is very disturbing indeed.


According to the C++11 standard, the compiler may assume that any loop terminates, so unless you mark ring_bell as [[noreturn]], the code will be assumed reachable.

Furthermore, when undefined behaviour is invoked anywhere within a program, the whole program is undefined.


As far as I remember, you are wrong: a loop with side effects (either external IO or volatile reads/writes) is allowed to never terminate.


> Q: Can I use a pizza box for the cardboard? A: Yes. Make sure you order an extra large.

I'm not sure I'd want to stick my phone into a soaked pizza box though.


Well don't use the bottom half....


Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: