Reputation: 333
Is there a way to check which memory protection machenizem is used by the OS?
I have a program that fails with segmentation fault, in one computer (ubuntu) but not in another (RH6).
One of the explanations was memory protection mechanizem used by the OS. Is there a way I can find / change it?
Thanks,
Upvotes: 0
Views: 1709
Reputation: 1
You might want to learn more about virtual memory, system calls, the linux kernel, ASLR.
Then you could study the role and usage of mmap & munmap system calls (also mprotect). They are the syscalls used to retrieve memory (e.g. to implement malloc
& free
), sometimes with obsolete syscalls like sbrk
(which is increasingly useless).
You should use the gdb
debugger (its watch
command may be handy), and the valgrind utility. strace could also be useful.
Look also inside the /proc pseudo file system. Try to understand what
cat /proc/self/maps
is telling you (about the process running that cat
). Look also inside /proc/$(pidof your-program)/maps
consider also using the pmap utility.
If it is your own source code, always compile it with all warnings and debuggiing info, e.g. gcc -Wall -Wextra -g
and improve it till the compiler don't give any warnings. Use a recent version of gcc
(ie 4.7) and of gdb
(i.e. 7.4).
Upvotes: 1