On 2016-05-10, Pau Amaro-Seoane <pau.amaro.seo...@gmail.com> wrote:
>        :datasize-cur=infinity:\
>        :datasize-max=infinity:\

These settings make it easier to run your machine out of RAM which will
probably hang or crash the kernel if it happens (OpenBSD doesn't deal
with that situation well). I'd often go for somewhere around a third of
the amount of physical RAM for datasize-cur on a workstation with a
reasonable but not massive amount of memory (to reduce the chance of
two large-ish concurrent processes running me out of memory) but it
depends what the machine is doing.

>        :stacksize-cur=32M:\

That's a *lot* of stack to allow for one process. "ps -o ssiz -uwax |
sort -n" will show you how much you're currently using in your
processes. You're unlikely to need more than 8M unless you're using
some program that places inadvisable amounts of data on the stack
rather than in malloc'd memory, or does very deep recursion (functions
that call themselves within limits; this is a perfectly valid
programming technique and each function doesn't take much space
on the stack - going above 8MB for this would be already be
excessive and more likely due to a bug than found in normal use).

I'm struggling to find anything using more than 500K of stack in
one process, and the majority of things around under 200K; by the time
the default stack limit is exhausted a process is already likely to be
doing something pretty stupid or is broken (runaway recursive process
stuck in a loop).

As an aside:

The stack holds return addresses for function calls and other
information so that when a function has finished it returns control
to the correct place - this is something that attackers often try
to subvert, to return control to code of their choosing rather than
the expected place - and also holds "automatic" variables i.e.
ones defined directly in functions - not global variables and not
malloced.

You can find much better explanations online, these seem pretty good:
http://duartes.org/gustavo/blog/post/anatomy-of-a-program-in-memory/
http://duartes.org/gustavo/blog/post/journey-to-the-stack/
and there are some other bits in
http://duartes.org/gustavo/blog/category/software-illustrated/
if you're interested in learning more about this sort of thing.


_______________________________________________
Openbsd-newbies mailing list
Openbsd-newbies@sfobug.theapt.org
http://mailman.theapt.org/listinfo/openbsd-newbies

Reply via email to