Skip to content

Instantly share code, notes, and snippets.

@Cryptophobia
Last active October 25, 2019 19:22
Show Gist options
  • Save Cryptophobia/974c257a1a97766edf9044a60c1a44d0 to your computer and use it in GitHub Desktop.
Save Cryptophobia/974c257a1a97766edf9044a60c1a44d0 to your computer and use it in GitHub Desktop.
SegmentationFault.sh
#!/bin/bash
# recursive.sh
#
# ./recursive.sh
# Segmentation fault (core dumped)
#
# set -e
# trap 'case $? in
# 139) echo "segfault occurred"; sleep 20;
# esac' CHLD && ./recursive.sh
recursive() {
# Recursion to make stack grow
# Stack is allocated each time function is called
while true; do
recursive
done
}
recursive
set -e
trap 'case $? in
139) echo "segfault occurred"; sleep 20;
esac' CHLD
@Cryptophobia
Copy link
Author

Next, figure out how to catch SIGSEGV within bash and how to change ulimits during execution of the recursion. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment