Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #142145
| Message-ID | <i5qamf-o71.ln1@wilbur.25thandClement.com> (permalink) |
|---|---|
| From | William Ahern <william@25thandClement.com> |
| Subject | Re: heap memory indexed as an array |
| Newsgroups | comp.lang.c |
| References | <5b6ce6dd-178a-4fb6-9d80-af5349c0cec2@googlegroups.com> <1bk1gu8bdp.fsf@pfeifferfamily.net> <aDpYuPXgbPvO0TB2QttltgH9QFlBQ@bongo-ra.co> <5c925e27.171165954@news.xmission.com> <d5ukE.129284$%55.80346@fx40.iad> |
| Date | 2019-03-20 15:07 -0700 |
Scott Lurndal <scott@slp53.sl.home> wrote: > nobody@example.org (Scott) writes: >>On Wed, 20 Mar 2019 04:40:25 GMT, Spiros Bousbouras <spibou@gmail.com> >>wrote: >> >>>But you don't get to do error checking either and if there isn't enough >>>memory to allocate the array , the programme will probably crash with an >>>uninformative error message. >> >>Well, maybe. On some contemporary operating systems, a malloc return >>value of non-null does not guarantee that the allocated memory >>actually exists. It can appear to succeed, and only explodes when you >>try to write to that phantom memory -- and there's no way to trap that >>fault in C. > > Correction, no "standard C" method. One may always catch SIGSEGV. On systems that overcommit memory (e.g. Linux, FreeBSD) a process is usually killed with SIGKILL and it's not necessarily the process that triggered the original fault. Note that overcommit is distinct from unreserved allocations, e.g. mmap+MAP_NORESERVE. The latter is documented to send SIGSEGV. On Windows the nomenclature is slightly different: MAP_RESERVE doesn't commit; one must use MAP_COMMIT in addition to MAP_RESERVE. But Windows doesn't overcommit memory in the same manner as Linux. For one thing, overcommit is a system-level option in Linux, beyond the control of a process. In fact, as I recently had the unfortune to discover, even if you theoretically mapped all your process memory to a backing store like a disk file, which *should* guarantee availability, overcommit logic and heuristics are so pervasive in the kernel that you can still get shot down, both when triggering your own page fault or someone else triggering a page fault.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
heap memory indexed as an array sinbad <sinbad.sinbad@gmail.com> - 2019-03-19 20:05 -0700
Re: heap memory indexed as an array Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2019-03-19 21:37 -0600
Re: heap memory indexed as an array Spiros Bousbouras <spibou@gmail.com> - 2019-03-20 04:40 +0000
Re: heap memory indexed as an array nobody@example.org (Scott) - 2019-03-20 15:56 +0000
Re: heap memory indexed as an array scott@slp53.sl.home (Scott Lurndal) - 2019-03-20 16:43 +0000
Re: heap memory indexed as an array fir <profesor.fir@gmail.com> - 2019-03-20 10:00 -0700
Re: heap memory indexed as an array William Ahern <william@25thandClement.com> - 2019-03-20 15:07 -0700
Re: heap memory indexed as an array fir is a sexy shemale <cdalten@gmail.com> - 2019-03-20 23:52 -0700
Re: heap memory indexed as an array nobody@example.org (Scott) - 2019-03-21 16:50 +0000
Re: heap memory indexed as an array scott@slp53.sl.home (Scott Lurndal) - 2019-03-21 17:23 +0000
Re: heap memory indexed as an array nobody@example.org (Scott) - 2019-03-22 04:29 +0000
OT: crashing malloc [was Re: heap memory indexed as an array] nobody@example.org (Scott) - 2019-03-23 15:27 +0000
Re: heap memory indexed as an array Spiros Bousbouras <spibou@gmail.com> - 2019-03-23 19:24 +0000
Re: heap memory indexed as an array Melzzzzz <Melzzzzz@zzzzz.com> - 2019-03-23 20:20 +0000
Re: heap memory indexed as an array Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-03-21 22:35 -0700
Re: heap memory indexed as an array Jorgen Grahn <grahn+nntp@snipabacken.se> - 2019-03-20 07:05 +0000
Re: heap memory indexed as an array Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-03-20 12:12 +0000
csiph-web