gym_fuzz1ng
gym_fuzz1ng copied to clipboard
posix_ipc.ExistentialError: No shared memory exists with the specified name
Hello. Nice work wrapping AFL as an OpenAI gym environment :)
I am writing about a shared memory error that seems like a simple bug for someone who's familiar with the inter-process communication libraries ("posix_ipc" I think) used in this code base.
What I did
- Followed install instructions in README.md.
- Ran
make all
for gym_fuzz1ng/gym_fuzz1ng/mods/Makefile. - Ran
python dummy_simple_bits.py
which gave the following
~/code/gym_fuzz1ng$ python ./test/dummy_simple_bits.py
Starting afl-forkserver...
Traceback (most recent call last):
File "./test/dummy_simple_bits.py", line 62, in <module>
main()
File "./test/dummy_simple_bits.py", line 7, in main
env = gym.make('FuzzSimpleBits-v0')
File "/home/dl/anaconda3/envs/gymfuzz/lib/python3.5/site-packages/gym/envs/registration.py", line 167, in make
return registry.make(id)
File "/home/dl/anaconda3/envs/gymfuzz/lib/python3.5/site-packages/gym/envs/registration.py", line 119, in make
env = spec.make()
File "/home/dl/anaconda3/envs/gymfuzz/lib/python3.5/site-packages/gym/envs/registration.py", line 86, in make
env = cls(**self._kwargs)
File "/home/dl/anaconda3/envs/gymfuzz/lib/python3.5/site-packages/gym_fuzz1ng/envs/fuzz_simple_bits_env.py", line 16, in __init__
super(FuzzSimpleBitsEnv, self).__init__()
File "/home/dl/anaconda3/envs/gymfuzz/lib/python3.5/site-packages/gym_fuzz1ng/envs/fuzz_base_env.py", line 16, in __init__
self.engine = coverage.Afl(self._target_path, args=self._args)
File "/home/dl/anaconda3/envs/gymfuzz/lib/python3.5/site-packages/gym_fuzz1ng/coverage/coverage.py", line 100, in __init__
self.fc = ForkClient(target_path, args)
File "/home/dl/anaconda3/envs/gymfuzz/lib/python3.5/site-packages/gym_fuzz1ng/coverage/forkclient.py", line 107, in __init__
_shm = SharedMemory(SHARED_MEM_NAME)
posix_ipc.ExistentialError: No shared memory exists with the specified name
Solved
Turns out afl-forkserver
has checks that would abort the program if /proc/sys/kernel/core_pattern
and /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
were not set to expected values. dummy_simple_bits.py
pipes afl-forkserver
's output to /dev/null so messages concerning the abort wouldn't show. Writing expected values to core pattern and cpu freq scaling governor solves this.
Just FYI:
As of writing this, core pattern file is expected to contain value core
.
As of writing this, all cpus' scaling governor files are expected to contain value performance
I also encountered the same issue, but when I run the program in a virtual machine, I found that the file "/sys/devices/system/cpu/cpu*/cpufreq/scaling_governor" does not exist. How can I solve it? And by the way, did you run the program on a virtual machine or a physical machine?