News for hackers. Stuff that matters.
Re:Achievement unlocked: rustc segfault by tedunangst on Sunday April 10, 2022 @09:50PM (#30983669)
If you call free((void *)-1) in C code, it will very likely crash, but it will crash in libc, not your program. Is that a bug in libc?
Re:Achievement unlocked: rustc segfault by MaxBarraclough on Monday April 11, 2022 @03:47PM (#30993835)
I think even deriving the argument might invoke undefined behaviour here, but I'm not certain.

If I understand correctly, it's undefined behaviour to do this:

    int *ptr = (int*)42;
As, in order to avoid undefined behaviour, ptr should only be assigned a valid address of an int, or the 'address' one past the end of an array of int, or NULL (logical zero).

It's possible things are different when the type is void*, I'm not certain.

Re:Achievement unlocked: rustc segfault by tedunangst on Monday April 11, 2022 @04:19PM (#30994317)
Make it free(free) if you want it to be a valid pointer.
Re:Achievement unlocked: rustc segfault by kelnos on Friday April 15, 2022 @12:51AM (#31036691)
No, because the defined contract for free() is that you pass it a pointer that was previously returned from malloc(), that you don't try to free() it twice, etc.
Re:Achievement unlocked: rustc segfault by Thorrez on Monday April 11, 2022 @12:15AM (#30984598)
That's documented undefined behavior.

Is it documented undefined behavior to feed bad IR into LLVM?

Re:Achievement unlocked: rustc segfault by scatters on Monday April 11, 2022 @02:51AM (#30985487)
Of course. If there's an input checking mode, and you disable the checks, then you're guaranteeing that you won't supply invalid input.