NEW ANSWER VERSION
1: Where linux dumps core by default:
ls -lA /var/lib/systemd/coredump/
2: The content is essentially:
- Stack trace: Shows what function calls led to the crash.
- Registers and memory state: Helps pinpoint invalid memory accesses.
- Variable values: Useful for debugging unexpected behavior.
3: Core dumps can be a gem for debugging. You can analyze facts about almost anything running on your Linux with them.
OLD ANSWER VERSION:
When I configured my Linux, researching a bit about hardening and specific optimization for my user, I created this file (and several others) as my knowledge base for my installations. I made this simple inline documentation to remember what each thing did. I won't know some of the more detailed reasons right now, but if I need it, I'll research it again and provide it to you. Anyway, the configuration I have saved is the one below. It avoids what you're going through. At least for me, it solved a lot of things. I hope it helps you and others who need it too.
Here are the contents of the file:
Replace user with your username, don't forget it!!
# /etc/security/limits.conf
#
#This file sets the resource limits for the users logged in via PAM.
#It does not affect resource limits of the system services.
#
#Also note that configuration files in /etc/security/limits.d directory,
#which are read in alphabetical order, override the settings in this
#file in case the domain is the same or more specific. #That means, for example, that setting a limit for wildcard domain here
#can be overridden with a wildcard setting in a config file in the
#subdirectory, but a user specific setting here can be overridden only
#with a user specific setting in the subdirectory.
#
#Each line describes a limit for a user in the form:
#
#<domain> <type> <item> <value>
# Disable core dump for everyone (https://linux-audit.com/software/understand-and-configure-core-dumps-work-on-linux)
* hard core 0
# Open files (this is to avoid fd exhaustion)
user soft nofile 65535
user hard nofile 131072
# This is to avoid "fork bombs"
user soft nproc 4096
user hard nproc 16384
# Memory lock (This is to avoid memory lock DoS)
user soft memlock 67108864
user hard memlock 134217728
# Core dump size (this is for debugging, 0 disables it)
user soft core 0
user hard core 0
# CPU time (Prevents process from frying the CPU more than it should)
user soft cpu unlimited
user hard cpu unlimited
# Real time priority
user soft rtprio 0
user hard rtprio 0
# End of file
gdb path-to-your-binary path-to-corefile, theninfo stackfollowed byCtrl-d. The only worrying thing is that core-dumping is a usual thing for you.