linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* unused shared memory is written into core dump - bug or feature?
@ 2001-06-12 14:04 Peter Niemayer
  2001-06-12 14:56 ` Christoph Rohland
  2001-06-12 16:01 ` Alan Cox
  0 siblings, 2 replies; 3+ messages in thread
From: Peter Niemayer @ 2001-06-12 14:04 UTC (permalink / raw)
  To: linux-kernel

Hi everybody,

I just noticed that when I attach some SYSV shared memory segments
to my process and then that process dies from a SIGSEGV that _all_
the shared memory is dumped into the core file, even if it was never
used and therefore didn't show up in any of the memory statistics.

One may say: "Oh, that's just a feature". But for some reason, this
is a small catastrophy:

I try to share some memory between the child processes of an application.
At the time when the child processes are fork()ed, it is not known how
much shared memory will be needed later. No other processes should see
that memory.

I searched through the literature how this could be done, but alas,
the recommended methods such as mmap()ing "/dev/zero" with MAP_SHARED
or using MAP_ANON are not implemented in Linux as they are within
other Unices, and so using "ftruncate" to expand the shared memory
region doesn't work either.

So the only work-around I found was to attach the very maximum of
what is to be used as shared memory using the SYSV shared memory
functions, and allocating/using subsets of this memory later on
the "logical" level.

This of course means that any "parent" process starts by attaching
~512MB of shared memory, but since they are not mapped at that time,
there's no undue performance or memory/swap consumption.

But if one of the programs crashes (and you know, this is nothing
you can be sure to never happen :-), it stymies the whole system,
as the kernel first seems to map all the 512MB, then dumps them
into the core file.

Please tell me there is either a way to keep the kernel from dumping
these unused pages (but generate the much appreciated core-dump anyway)
or there is some better method to share memory with one's child processes
(not with the whole universe)  in a way that allows either the child or
the parent to extend the amount of shared memory... 

Thanks for any hints in advance,

Peter Niemayer

PS: Please CC me if you reply - thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: unused shared memory is written into core dump - bug or feature?
  2001-06-12 14:04 unused shared memory is written into core dump - bug or feature? Peter Niemayer
@ 2001-06-12 14:56 ` Christoph Rohland
  2001-06-12 16:01 ` Alan Cox
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Rohland @ 2001-06-12 14:56 UTC (permalink / raw)
  To: Peter Niemayer; +Cc: linux-kernel

Hi Peter,

On Tue, 12 Jun 2001, Peter Niemayer wrote:
> I just noticed that when I attach some SYSV shared memory segments
> to my process and then that process dies from a SIGSEGV that _all_
> the shared memory is dumped into the core file, even if it was never
> used and therefore didn't show up in any of the memory statistics.

Fixed in recent kernel versions (2.2 and 2.4). It will create sparse
files and not touch the unused address space.

Greetings
		Christoph



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: unused shared memory is written into core dump - bug or feature?
  2001-06-12 14:04 unused shared memory is written into core dump - bug or feature? Peter Niemayer
  2001-06-12 14:56 ` Christoph Rohland
@ 2001-06-12 16:01 ` Alan Cox
  1 sibling, 0 replies; 3+ messages in thread
From: Alan Cox @ 2001-06-12 16:01 UTC (permalink / raw)
  To: Peter Niemayer; +Cc: linux-kernel

> you can be sure to never happen :-), it stymies the whole system,
> as the kernel first seems to map all the 512MB, then dumps them
> into the core file.

2.2.20pre dumps only the non zero pages and leaves holes for empty pages
2.4 likewise



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-06-12 16:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-12 14:04 unused shared memory is written into core dump - bug or feature? Peter Niemayer
2001-06-12 14:56 ` Christoph Rohland
2001-06-12 16:01 ` Alan Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).