Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I got a segmentation fault when trying to use one cpp file and tried to locate the error using Valgrind, but I'm confused.
Since the code is very large, I will only post a short portion of it below:
It looks like you are running valgrind on the compiler. Unless you are trying to debug the compiler, you should be running valgrind on your application instead:
valgrind --leak-check=yes ./MyApp
(replace ./MyApp with the appropriate executable name and arguments, of course)
(Explanation: valgrind is a run-time analysis tool; it takes your application as input. It is not a compiler tool like some of the other debugging tools that are out there)
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
}
but when I run it it says segmentation fault and apart from that, I don't know if the code is correct.
You have a j++ at line 18 that was almost certainly supposed to be a g++. Also, your x+=g; on line 19 is probably supposed to be an x++. You only want to add one each time.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I have a big project, compiles fine, but sometimes when I run in terminal(sometimes not)
./run
it gives bad_alloc exception, so i think it might be helpful to backtrace using gdb, so I do
gdb ./run
run
and it weirdly exit normally, nothing wrong shows up, even though I tried a lot of times.
Has someone met similar issues before?
See this answer for what may be different "inside" vs. "outside" of GDB, and what to do about it.
If you can enable core dumps (ulimit -c unlimited), that should give you another way to get the stack trace.
In my experience, most bad_allocs result from one of two root causes:
Uninitialized size:
int size;
if (something) {
// assign to size here
}
std::vector v(size); // Oops: size may be unintialized.
Arithmetic underflow:
std::vector v(other_vector.size() - 20);
Here, if other_vector.size() < 20, you'll get humongous value.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I added the include directory of chaiscript to my Projects Additional Dependencies and compiled this example successfully.
If I execute it though, it throws this exception:
Unhandled exception at 0x753D5B68 in CHAISCRIPT_TEST.exe: Microsoft C++ exception: chaiscript::exception::load_module_error at memory location 0x0103F0D8.
After further testing around chaiscript seems to complain about not finding the module chaiscript_stdlib-5.8.0
How do I fix that?
Found the solution. The std_lib module has to be initialized the way the example shows.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
So I was writing some socket programming in C++. I'm new to the concept in general. I was following this tutorial, but when I go to compile it, my compiler g++ says the header files are not found. I'm on linux (Netrunner 14 Frontier), so I updated all my headers but I still get the error. Is there any way to fix this? If not, any recommendations for how to do socket programming in linux?
These files are not part of the Linux system. If you look at the bottom of the page, it says:
The following files make up our example:
Beneath that line is a list of links to other files / dependencies, including those ones.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I have tried searching for this online, but I haven't had any luck. I'm hoping there are some theories here. We were able to get our code to crash on this line:
pipe = popen(cmd, "w");
cmd has recently been allocated, but the allocation was checked to verify that it wasn't null and inspecting the core file reveals that it is indeed a valid string. I'm curious what else would cause popen to segfault if the parameters passed in are valid ? Will popen segfault if there are no more available file descriptors on the system? Are there any other things I can look into for why this might've failed?
Thanks.