News for hackers. Stuff that matters.
Re:Malloc Never Fails (2012) by kazinator on Monday June 10, 2019 @03:46PM (#20150089)
> Linux blatantly violates the language specification with no remorse.

We may be able to argue that it doesn't. ISO C says in 1. Scope, this:

This International Standard does not specify

[...]

— the size or complexity of a program and its data that will exceed the capacity of any specific data-processing system or the capacity of a particular processor.

It seems that these weasel words have an interpretation that can be bent around overcommitted memory allocation.

Re:Malloc Never Fails (2012) by mehrdadn on Monday June 10, 2019 @07:53PM (#20151996)
No it wouldn't. They clearly included the ability to return null to allow for when the data exceeds the capacity of the system. There is no provision for returning a pointer to memory that cannot be used.
Re:Malloc Never Fails (2012) by kazinator on Monday June 10, 2019 @08:18PM (#20152103)
You might think, but that's not how how conformance (of an ISO C implementation to the standard) works.

For an implementation to be deemed conforming, it just has to be demonstrated to successfully translate and execute one program that tests each of the minimum implementation limits.

See 5.2.4.1 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf

Only if no such program can be found can we then conclude that the implementation is nonconforming (and if the reason for not finding such a program is this overcommit issue, then we can blame that issue).

Your Linux system is indeed nonconforming if it is so low on memory that, for instance, no C program can allocate a 65535 byte object (that can be actually initialized, and used: a real object). Basically the memory situation has to be so severe that it takes the implementation below the minimum limits, whereby we can clearly demonstrate nonconformance.