<Profpatsch>
IdleBot_6d92ac96: Yes, you *always* have to check your malloc
<Profpatsch>
not doing so is straight UB iirc
<Profpatsch>
(says the person who never touches C)
<V>
well... not checking isn't UB, but dereferencing a null pointer or passing it to a stdlib function is
<Profpatsch>
That is effectively the same …
<Profpatsch>
At least semantically is
<Profpatsch>
C is very good at conflating semantics and implementation details …
<V>
well not exactly
<V>
free(malloc(42)) is defined
<V>
as is never looking at the value
<V>
for (;;) malloc(1024); is UB but for different reasons
<Profpatsch>
I didn’t say the semantics were sensible …
<Profpatsch>
The free example above just accidentally works because `NULL` is very overloaded
<Profpatsch>
But the NULL pointer you pass to free() is something very different from the “error in malloc” NULL value that is returned by malloc
<V>
NULL is just a number :p
<Profpatsch>
Well, now you are just agreeing with8 me
<V>
overall I agree with everything you've said
<Profpatsch>
lel
<Profpatsch>
Well, I guess it was what it was on the PDP-8 or something
<V>
C is lovely, it doesn't even let you assume you have a von neumann architecture
<Profpatsch>
But POSIX makes you assume you are so singlethreaded that errno is implemented as a global variable, so everything is fine again
<V>
:))))))
<raboof>
do people actually turn off memory overcommit in practice? does that work? wouldn't that break fork() copy-on-write, which seems like something many programs rely on?
<V>
a) I turn off overcommit, b) you still get the speed benefits of CoW but you must have enough space for the process to write to every single page it owns
<V>
or
<V>
I have turned off overcommit in the past
<qyliss>
I have a background in illumos, where fork doesn't CoW
<qyliss>
s/in/with/ (I wasn't even involved in the project, just worked for a user)
<V>
I should turn it on again now that I have 32 gigs of RAM; I turned it off in the past b/c browsers just segfault instead of cleanly handling memory allocation failures :/
<qyliss>
*ever
<V>
also, fork is an awful interface
<V>
vfork is slightly better, but spawn-like interfaces are where it's at
<raboof>
yeah, I wasn't claiming it was good, just that I expected it to be widely used, so disabling overcommit would waste memory to the point of the system becoming unusable in a development desktop scenario
<V>
is there actually any OS that uses it other than linux?
cole-h has joined #spectrum
tilpner has quit [Quit: tilpner]
tilpner has joined #spectrum
tilpner has quit [Quit: tilpner]
tilpner has joined #spectrum
tilpner has quit [Remote host closed the connection]
tilpner has joined #spectrum
<IdleBot_6d92ac96>
Note that exiting on failure to allocate is a check on malloc result, but not a decision how to handle failure. Failure to get locked pages with success getting non-protected pages is a case where one probably needs to let user set some kind of policy or whatever