C++ :: Crash Normally But Not When Debugging (SDL Malloc)
Jul 16, 2013
Notes: Im Using SDL, Im using Codeblocks to code
Ive narrowed down my crashing problem ( using printf's ) to a malloc call I had to use printf's because when i ran the program in Codeblocks debugging mode, it did not crash and ran fine, but when i ran it normally, it would crash, giving me this error:
fatal signal segmentation fault (sdl parachute deployed)
Inside my code, I created a malloce function that checks malloc for me ( so i dont have to do it )
( general.h )
void* malloce ( size_t size )
{
printf ( "start malloce %i
", size );
[Code]....
funny thing is that i called this malloce function about 20 times before it hits this part of the code, it is unknown behavior to me!
View 10 Replies
ADVERTISEMENT
Jan 16, 2014
whats wrong with this code, I'm trying to parse a .js file and replace all the ";" with "; " i.e add a new line after each ";". So I load the file into a char[] buffer then assign a string to this contents of this buffer. Then loop char by char through using an iterator and check for a ";", if found use replace. So int i gets to about 85898 then crashes with unknown error, 'i' should reach about 175653. It does work up till it crashes. And, is this not a simpler way to load a file into a buffer, there is in C.
Code:
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <stdlib.h>
int main()
[code]....
View 8 Replies
View Related
Nov 6, 2012
I have a function such that one of its parameters is a 2D array of type int. The parameter is defined as follows:
[code]
int topoGraph [][MAX_VERTICES]
[code]
However, the following code snippet from the body of the function crashes at the specified line:
Code :
if( counter >= 4 && !adjMatrixAlreadySet) {
if( edgeCost == 10 ) {
topoGraph[srcVertex][dstVertex] = 1; <<<<<---------- The point of crash
}
else if( edgeCost == 100000 )//restricted link {
topoGraph[srcVertex][dstVertex] = edgeCost;
[code]....
It seems like there is an undefined behaviour at the specified point of crash since it crashes with different values of srcVertex and dstVertex each time I run it.
What might be the reason for this crash ?
View 4 Replies
View Related
Nov 26, 2012
Why I get a crash when initializing the indices array below (bottom)-
Code:
struct TerrainGroupData {
TerrainGroupData(){};
TerrainGroupData(Ogre::Vector3 ** iVertices, unsigned long ** iIndices, size_t* iFaceNum, size_t* iVertNum) {
vertices = iVertices;
indices = iIndices;
[Code] ...
View 9 Replies
View Related
Jul 5, 2012
I have a question about allocating 2MB memory then filling it...
@ Platform:
=> DOS, and application is compiled/linked via Watcom C + DOS32/A (...memory model is "flat" mode)
@ phenomenon:
1. I allocate 2M memory by calloc() function. Then I got "!NULL" and it means allocating 2MB memory is ok( right ? )
2. then I tried to "fill" this 2MB memory by for loop(one byte by one byte) like below:
for( DWORD i=0; i<0x200000; i++) {
*((BYTE *)(A[0].B[0]->C) + i ) = 0x5A; // C is 4-byte address value
}
here :
* DWORD means "unsigned long(4-byte)" and 0x200000 means "2MByte"
* in actual case the value of pointer(to allocated memory) is 3019AF3C(~768MB) <- running in flat mode...
3. after filling this range of memory(2MB) the application crashed...
@ my observations:
1. if allocating 2MB and no fill(no write data to memory) => OK
2. if allocating 2MB and just fill the former 32 bytes => OK
3. if allocating 4KB and fill all => OK
my question is: why can't I filling this 2M memory totally "even memory allocation succeeds" ?
View 5 Replies
View Related
Mar 17, 2013
I'm getting an error message that I can't seem to fix. The error clearly states that during the link aspect of the debugging and build there is an error that says that the stdio.h file is either missing, invalid or corrupt. When I try to program using any of the other headers I'm getting the same error. The files are there I can see them in the include folder, so I'm asking what can I do to fix all these headers and beware I am a beginner at programming and using any kind of compiler.
This is the error I receive.
1>------ Build started: Project: hello, Configuration: Debug Win32 ------ 1>LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped =========
This is the compiler I am required to use for an online course and all instruction is given for the Microsoft visual 2010 express edition. Also the only file I think that's being referenced is the #include <stdio.h>.
View 1 Replies
View Related
Apr 11, 2013
I have a code that I'd like to debugg it.
Question
1 - What is the correct command line to use the debugger ?
2 - Do I need to install additional software for the debugger ?
if yes what it's name?
I use ububtu 12.4compiling command: gcc abc.c -lpthread -o abc
View 3 Replies
View Related
Oct 7, 2014
I am remaking this code for my gain, and it seems that I cant debug the error..
Are there any comments on the structure of the code? Why are there errors in calling the functions?
#include <iostream>
#include <cmath>
#include <iomanip>
[Code].....
View 6 Replies
View Related
Oct 13, 2014
I have a bug and when I debugged in some point i needed to know whats inside my char **grid , when i hold mouse over this variable in debug mode i can only see hex or address.. ! i cant see my values grid is 10 * 10 table which hold a number from 1 to 3 .... is there any way for me to see whats inside ?
I'm using visual studio 2013 ultimate ....
View 2 Replies
View Related
Oct 24, 2014
This function is apparently causing infinite recursion, but I have no clue what's causing it:
Code:
int pow( int base, int exp ) { int somevariable = pow(base,exp-1);
if (exp == 0) {
return 1;
}
else {
return base * pow(base,exp-1);
}
}
View 10 Replies
View Related
Feb 17, 2014
cant write to binary file
#include <stdio.h>
#include <stdlib.h>
typedef struct {
int number;
} something;
void main() {
int numbers[10]={1,2,3,4,5,6,7,8,10,12};
[Code] .....
View 2 Replies
View Related
Jun 26, 2014
On a project I'm working on, I need to update many QLabels very quickly. Each label needs to be updated at about 20 to 50 hertz and there can be over 50 labels at any given time. The problem I'm having is after running the program for about a minute, the labels freeze and the whole program crashes about 10 seconds later. If I comment out the setText() and setNum() calls and reroute the outputs to the console, it runs fine and never crashes. Why does calling SetText() and setNum() so quickly cause the program to crash and how can I prevent this?
View 5 Replies
View Related
Apr 15, 2013
I want to know what was wrong with my code when I submitted. It's a Traveling Salesperson Problem, and the code is complete for the most part. I just can't seem to find what's causing the segmentation fault even after attempting to debug with gdb. Something is supposed to be wrong with line 76, but I don't see how my arrays are messing up. I've looked through this code countless times, and I know I'm just missing something small. I just don't want to end up making whatever mistake I made on this again in the future.
Code:
#include <stdio.h>
#include <stdlib.h>
#define SIZE 20
[Code]....
View 9 Replies
View Related
Oct 6, 2014
I have something like this
string rid = row.Cells[0].Value.ToString();
string identification = row.Cells[9].Value.ToString();
IDLabel.Text = "ID: " + rid + " <Identification: " + identification + ">";
I checked that while identification has a value, the IDLabel.Text was run just fine, but if identification has null value, IDLabel.Text was skipped totally...
View 13 Replies
View Related
Aug 14, 2013
It's common to see the following macros:
Code:
#define DEBUG_NEW new(__FILE__, __LINE__)
#define new DEBUG_NEW
and overloading operator new for debugging purposes. It usually works but there is a problem when use operator new syntax in code instead of directly use new. I can change my code but i can't change third party's code. Something like this:
Code:
int* j = static_cast<int*>(::operator new(sizeof(int)));
It's not common, but it appears occassionally.With that syntax, new macro generates compilation errors.
Is there any way to fix this problem?
View 2 Replies
View Related
May 10, 2013
I am new to C. I've been trying to use C to code some statistical functions originally coded in R. I've encountered an interesting phenomenon. In the function foo1, I declared the array v1v2b using an actual value 1999000. The function runs fine when I call it in R.
Code:
void foo1(double *x, double *y, int *nsamp){
int i, j, k, oper=2, l;
double* v1v2=malloc(sizeof(double)*((*nsamp)*(*nsamp-1)/2 + 1));
outer_pos(x, y, nsamp, &v1v2[0]);
double v1v2b[1999000]; //<-------HERE
for(i=1; i<= 1999000]; i++){
v1v2b[i-1]=1;
} }
However, in foo2, I first create an integer variable called index, and store the value 1999000 in it. I then use it to initialize the same array. When I tried calling this function in R, it either led to a stack overflow error, or completely crashed R.
Code:
void foo2(double *x, double *y, int *nsamp){
int i, j, k, oper=2, l;
double* v1v2=malloc(sizeof(double)*((*nsamp)*(*nsamp-1)/2 + 1));
[Code] .....
View 9 Replies
View Related
Dec 13, 2013
I have a class which dynamically allocates memory for three data arrays, and as such in the destructor I told it to delete those data arrays.
However, when I've created a new class, and inherited the previous class - it will always crash AFTER running the program, unless I don't have the previous destructor present.
View 3 Replies
View Related
Oct 30, 2014
while(!secList.empty()){
Security se = Security();
se = secList.extract(); // CRASH
cout << "Security info: " << se.security << endl;
cout << "Transaction List: " << endl;
while(!se.tranList.empty()){
Transaction tr = Transaction();
[code]....
my program crash when it try to assign the return value of the function to the local value. extract function does return correct value, but it just crash when done executing.
View 4 Replies
View Related
Oct 18, 2014
I'm strugling to understand why my app is crashing if there is no internet connection.
Code:
int main() {
WSADATA wsaData;
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) {
std::cout << "WSAStartup failed.
[Code] ....
Debug crash code:
Code:
First-chance exception at 0x00161831 in ConsoleApplication1.exe: 0xC0000005: Access violation reading location 0x0000000C.
Unhandled exception at 0x00161831 in ConsoleApplication1.exe: 0xC0000005: Access violation reading location 0x0000000C.
It works well as long as the computer is connected to internet but if i disconect from internet the application crash but don't understand why.
View 4 Replies
View Related
Oct 31, 2013
When running my code in Visual Studio, there is a particular point in the code where my program is crashing. To debug this, I am adding a break point in Debug mode just before that point, and observing what happens as I step through the code. However, to get to this break point in the code takes about a minute of running the program. So I'm wondering if there is a tool in Visual Studio to reload the state of a program's memory from a previous run, so that I can immediately get to the break point without having to wait for a minute each time?
View 6 Replies
View Related
Apr 21, 2014
I have the following code. however, when I debug it gives an error saying" vector subscript out of range"
Vector based mufti-dimensional arrays
Vectors are a STL container that allow you to store pretty much anything in them. When used correctly they can be very powerful containers.
They provide an added benefit that they will automatically remove the memory they use when they go out of scope. This means that objects stored within a vector do not need to be de-allocated (but pointers to objects do). You can also do some interesting things with dynamic multidimensional arrays with vectors.
For example, if you only allocate the first dimension, then use the .push_back() to add records to the 2nd dimension it's no longer a grid, but an array with a dynamically sized 2nd dimension (much like a street of buildings each with a different amount of floors).
This functionality can be achieved using pointers, but is much harder to do.
#include <iostream>
#include <vector>
#include<conio.h>
using std::vector;
using namespace std;
[code]...
View 8 Replies
View Related
May 10, 2014
I am making a MFC application with VC++2012 with receiving data from Serial Port and the data is stored in a Listbox, then after processing (convert into numbers) and get these data to draw a sine wave on the chart. (I intend to make a virtual oscilloscope).
Everything works ok at the beginning, but after receiving about 300 items or above (in the Listbox) the value seem stucking (or lagging) and work very slowly.
I receive data by the SerialPort_DataReceived() method, and process of converting and drawing chart also in this method, I think this makes the system overload!!
View 1 Replies
View Related
Aug 12, 2013
I have a crash on a application the customer machine i couldn't reproduce it yet on my machine... all i have is the error message
The Instruction 0x0070478b referencing to the memory 0x00000000 could not be written.
And that's all i have how do i track that instruction on my program from that address? is it possible?
View 4 Replies
View Related
Nov 4, 2012
I see there's something called a manifest file but VS C++ EXPRESS seems different than non-express. The solutions I've seen show applets/tabs that I don't have in Express.
In one of my physical DEBUG folders are some .manifest. files and some a .res and .rc file.
I know you need to edit the XML and change asInvoker to requiredAdministrator (or something like that).
The confusing part is if I go into Project Properties, MANIFEST TOOL caret/tree, under INPUT AND OUTPUT, it shows this .manifest file is OUTPUT. It's as if it rewrites it every time with some defaults? I have edited it, but I see it's back to asInvoker. There is a spot to put in a ADDITIONAL manifest file (or .res file).
Does a manifest somehow affect the physical .exe file (something is imbedded in it??)?
How do I change my project to make sure that the .exe always runs as Admin? Will doing this ALSO allow me to DEBUG it in VS C++ EXPRESS without having to do anything different (play with manifest or run VS outright with Admin level)?
View 2 Replies
View Related
Jul 16, 2014
I've tried a bunch of alternative methods to prevent an assertion error. "not understanding" the bug and why I'm getting it are relevant here, not proper, (or more appropriate), coding methods. I would write it in another way to prevent the error, I simply want to understand what is happening during run-time that causes the situation.What is the bug?
---------------------------------------
[assertion error]
[expression _block_type_is_valid(phead->nBlockUse)]
--------------------------------
Code:
#include <iostream>
#include <string>
using namespace std;
int main() {
cout << "Enter your name : ";
string Name;
[code]...
View 1 Replies
View Related
Dec 20, 2012
I am debugging a library. I can step into the code however the watch window doesn't show the values of any variables. It will display a message in the value field:
Code:
m_pParentCXX0017: Error: symbol "m_pParent" not found
Interestingly it does show values for local variables in that function but not member functions. Most of my data members are member function though that I want to debug. I am using VS2010.
View 3 Replies
View Related