|
|
Subscribe / Log in / New account

GMP and assert()

GMP and assert()

Posted Feb 28, 2019 20:30 UTC (Thu) by HenrikH (subscriber, #31152)
In reply to: GMP and assert() by sorokin
Parent article: GMP and assert()

And there is #3 when any of the errors are triggered due to memory being randomly being overwritten by a buffer overrun, random hardware error and so on, and in this case recovering is completely out of the picture and process termination is IMHO the only way to go.

Or when malloc() returns NULL on a kernel with overcommit (the default), even logging the error would require more memory to be allocation and thus also fail.


to post comments

GMP and assert()

Posted Feb 28, 2019 22:42 UTC (Thu) by devkev (subscriber, #74096) [Link]

> when malloc() returns NULL ... even logging the error would require more memory to be allocation and thus also fail

This is not true. First of all, maybe the condition which caused malloc() to fail was transient, and subsequent mallocs will succeed. But even if not, the proper behaviour in this case is to pre-allocate (or use static allocation) a reasonable sized buffer to use for this logging. This is why things like sigaltstack() exist, for example.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds