At Wed, 30 Apr 2025 00:06:20 +0600, unadvised%airmail.cc@localhost wrote:
Subject: Why so many .core files being created?
>
> 1. Why are .core files created?
Usually it is because of bugs in the programs that crash.
> 2. How can I disable creating .core files (without solving the crash)?
> Is there any config somewhere, like FreeBSD's kern.coredump sysctl
> switch?
There are some sysctl knobs related to core dumps:
$ /sbin/sysctl -a | fgrep core
kern.defcorename = %n.core
kern.coredump.setid.dump = 1
kern.coredump.setid.path = /var/crash/%u-%n-%p.core
kern.coredump.setid.owner = 0
kern.coredump.setid.group = 0
kern.coredump.setid.mode = 0600 (rw------- )
proc.curproc.corename = %n.core
proc.curproc.rlimit.coredumpsize.soft = unlimited
proc.curproc.rlimit.coredumpsize.hard = unlimited
(the last three are not exactly relevant)
Basically though to stop core dumps you want to set the rlimits for
coredumpsize to zero, and that can be done in a wide variety of ways,
including via /etc/login.conf or in your ~/.profile, etc.
To do this via your ~/.profile you would use the "ulimit" command. This
would only affect processes started by your login shell, not those
started from an X11 session.
So, using /etc/login.conf is probably best if you are using xdm to login
to an X11 session, but you may have to set up a specific login class for
your user unless you're willing to brute-force it for every user with
the "default" class. See login.conf(5) for details of course. I leave
the kernel defaults untouched for coredumpsize, except for a class I
created for the superuser (that I named "rootclass"), and for it I set
the limits to "inf":
rootclass|Special login class used by root account:\
:coredumpsize-max=inf:\
:coredumpsize-cur=inf:\
:cputime-max=inf:\
:cputime-cur=inf:\
:datasize-max=inf:\
:datasize-cur=inf:\
:filesize-max=inf:\
:filesize-cur=inf:\
:ignorenologin:\
:login-retries=3:\
:login-backoff=5:\
:maxproc-max=inf:\
:maxproc-cur=500:\
:maxthread-max=inf:\
:maxthread-cur=inf:\
:memoryuse-max=inf:\
:memoryuse-cur=inf:\
:memorylocked-max=inf:\
:memorylocked-cur=2G:\
:minpasswordlen=8:\
:openfiles-max=inf:\
:openfiles-cur=2000:\
:passwordtime@:\
:path=/root/bin /sbin /usr/sbin /bin /usr/bin /usr/X11R7/bin /usr/pkg/sbin /usr/pkg/bin /usr/local/sbin /usr/local/bin:\
:requirehome@:\
:sbsize-max=inf:\
:sbsize-cur=inf:\
:stacksize-max=inf:\
:stacksize-cur=32M:\
:vmemoryuse-max=inf:\
:vmemoryuse-cur=32G:\
:tc=default:
> 3. How can I solve the issue so that there are no more crashes+*.core?
Well, that will depend on your programming and bug fixing skills! :-)
> For #3 I have a feeling it might be something relating to limited RAM
> given to programs by NetBSD in default setup. I was thinking if
> login.conf can solve this? My /etc/login.conf is mostly commented
> except I have a rule for tor. In case needed, dmesg on the machine
> says:
>
> avail memory = 3736 MB
I doubt that's the cause of things like SIGSEGV -- usually you would see
other problems first, though sometimes programs won't check for memory
allocation failures and will then do bad things, such as dereference a
null pointer, and that will of course cause a SIGSEGV.
--
Greg A. Woods <gwoods%acm.org@localhost>
Kelowna, BC +1 250 762-7675 RoboHack <woods%robohack.ca@localhost>
Planix, Inc. <woods%planix.com@localhost> Avoncote Farms <woods%avoncote.ca@localhost>
Attachment:
pgp5MggJf5KJb.pgp
Description: OpenPGP Digital Signature