I’m trying to create a memory mapping of length greater than the underlying file. When I access pages of the mapping (which are not correspondingly mapped to a file), a SIGBUS is caused. However when I try to access the memory outside the memory mapping length, it should cause SIGSEGV (but isn’t), why is that? Answer Stopping your program and
Tag: segmentation-fault
Idiomatic way to handle signals in a shared library
I have a shared library that occasionally throws SIGSEGV by design. I can find out if a SIGSEGV is caused by me, and if it is then handle it. However I ran into some problems when implementing the other branch (ie. when it isn’t my SIGSEGV). My primary problem is what if a handler was set to SIG_DFL. This is
How to prevent a Linux C++ library from crashing on an out-of-bounds read?
I am using a closed-source 3rd party Linux lib (.so) compiled for an older version of Linux on an older version of gcc. Unfortunately, it crashes occasionally with a read of an invalid memory address. This is certainly undesirable, and it would be fantastic to fix the library. But as that is absolutely impossible, and it still functions perfectly well
Execute binary file inside C code (No system())
I am trying to execute a binary executable file inside C code without using system since it has security and resource management issues. The system used here is Debian Buster with kernel 5.4.0-2-amd64 and gcc 9.2.1. I used the method in this question: execute binary machine code from C which is to convert executable into hexadecimal code with xxd -i,
Segmentation Fault with g++ in Linux Ubuntu, but not with g++/MingW in Windows, when printing a char string in C++ [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 3 years ago. Improve this question
Why is MAP_GROWSDOWN mapping does not grow?
I tried to create MAP_GROWSDOWN mapping with the expectation it would grow automatically. As specified in the manual page: MAP_GROWSDOWN This flag is used for stacks. It indicates to the kernel virtual memory system that the mapping should extend downward in memory. The return address is one page lower than the memory area that is actually created in the process’s
Segmentation Fault in pthreads, Linux Ubuntu
I’m getting a Segmentation Fault when I run this code. Surprisingly, when I set thread_count to 16 or less, it doesn’t give any error. When I debug the code using gdb, the code gets an error at line local_answer += vec_1[j] * vec_2[j]; in the Calculate() thread function. What is the reason for this behavior? How can I fix that?
Debugging segmentation fault with backtrace in cpp
In my code (written in cpp) I am getting a segmentation fault with following backtrace: So is there a way to debug this and get on which line segfault occurs? (I could not find any posts like this here, if it’s duplicate I will delete this). The code itself is pretty big so typing it here would not be correct
Segmentation fault appears when I use shared memory only from statically build program
When I built a program with –static option and it calls shm_open() function I get Segmentation fault. Without -static option all works like a charm. Does anybody know why? Below I have cited a debug info and a part of truncated source code from a big project. You can comment/uncomment string from Makefile to reproduce the bug. $ gdb –args
Segmentation fault core dumped 2d array
I’m trying to compile a c code under linux using gcc-4.9 (tried also 5.4) while so, I faced a segmentation fault error. this is the part of code where the problem exists: automorf is an array n x n long (int automorf[n][n]) Can you please help correcting the problem? Answer Try this and see output we have not p3[3]; and