C++ :: Program Crashing On Exit While Multithreading

May 11, 2014

I was writing a program and it started crashing on exit (segment fault), after the 'return 0' in main(). I figure it's an std destructor.

I started with the program I was writing and just stripped out as much as I could, while making sure the crash persisted. If I remove any of the remaining code the crash disappears, even the seemly unrelated or scoped code.

#include <iostream>
#include <fstream>
#include <condition_variable>
#include <mutex>
#include <thread>

/* Call stack results:

[Code] ....

View 2 Replies


ADVERTISEMENT

C++ ::  program Is Crashing When Trying To Call

Sep 5, 2013

My program is crashing when I'm trying to call b = a. What has me confused is that when I call c = d = b, it all works fine.

I actually think I see it now that I posted this. In operator= I'm changing the size, but I'm not changing the size of the array that it's pointing to correct? I'm keeping it as 'p = new T[size]' rather than changing it to 'p = new T[x.size]' correct?

#include <iostream>
#include "Array.h
int main() {
std::cout << "creating Array< int > object a ...

[code]....

View 13 Replies View Related

C++ :: Program Crashing When Initialized

Oct 13, 2014

I just finished coding a program that is based on polymorphism and inheritance but when I ran the program it crashed? I do not know what is the cause of the program crashing.

#include<iostream>
#include<string>
using namespace std;
class Shape{
float density;

[code].....

View 9 Replies View Related

C++ :: 0 Does Not Exit The Program

Feb 4, 2015

I've been reading my code for the past 3 days and I cannot get 0 to exit the program.

#include <iostream>
#include <cctype>
#include <cstring>
#include <cstdlib>
#include <fstream>
using namespace std;

size_t dub_count = 0;
size_t op_count = 0;

[Code] .....

View 4 Replies View Related

C :: Program Crashing When Deleting A Record

May 5, 2013

Code:

#include<stdio.h>
//bookData structure
struct bookData {
int recordNum;
char description[ 15 ];
int booksBought;
double bookCost;

[code]...

I am able to add records and show records, no problem. But when I go to delete a record, it crashes immediately after inputting the record number I want to delete. I don't see why. I've set it up exactly like the example in my book, having of course changed the variable names for my program. Does it have something to do with the pointer?

View 3 Replies View Related

C :: Program Seems To Be Crashing At Random Numbers

Mar 3, 2014

When I go to run the Fibonacci function ( fib ), it begins to return incorrect calculations towards the higher numbers, but then seems to correct itself for a little bit, but then does it again and ultimately crashes. And the program seems to be crashing at random numbers. Sometimes the it will make it up to F(55), other times it will only get to F(20).

Also, when I go to run the program on a Linux server, it segfaults, but it doesn't when I just run it on my IDE. the function adds two arrays with individual digits together. It does this to allow the program to add numbers that would exceed the boundaries of INT_MAX.

Here is the header file "Fibonacci.h":

Code:

#ifndef __FIBONACCI_H
#define __FIBONACCI_H
typedef struct HugeInteger
{
// a dynamically allocated array to hold the digits of a huge integer
int *digits;
// the number of digits in the huge integer (approx. equal to array length)
int length;
} HugeInteger;
}

[code]....

View 12 Replies View Related

C :: Program Keeps On Crashing When It Finishes Case 1?

Oct 18, 2013

The program keeps on crashing when it finishes case 1

View 5 Replies View Related

C :: Program With Fscanf Keeps Crashing - Using Eclipse Kepler

Oct 13, 2013

So this program I have to make keeps spitting out an error report when I try and run it. I am using eclipse C kepler.

The file it is supposed to read has the following text;

R1 N001 N003 20
R2 N002 N001 5
R3 N001 0 10
R4 N002 N003 10
R5 N003 N000 5
I1 0 N002 10

View 2 Replies View Related

C/C++ :: Program Crashing On A Function Call In Main?

May 5, 2014

i have this program I am working on and it seems to crash after the function call getdata()

here is the code

#include<iostream>
#include<string>
#include<cstdlib>

[Code].....

View 1 Replies View Related

C++ :: Program Crashing When Reading Text From Files

Feb 5, 2014

I'm writing a code obfuscator in C. Debugger shows no errors in the code, but the program crashes after compiling -- I'm guessing it has something to do with while loops or reading data from files.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
// list off all replaced elements
typedef struct ReplaceList {
char *from;// from string
char *to;// to string (random)

[Code] ....

View 3 Replies View Related

C++ :: How To Allow User Input To Exit The Program

Feb 20, 2013

I need to create a command where the user inputs a character and it'll exit out the program rather than executing any of the other code.

For example :

If I wanted to do like
char key;
if (key == D || key == d)
{
}

What would I need to put in between those brackets under the if statement to allow the user to enter the letter D and it would close out the program?

View 2 Replies View Related

C++ :: Exit Two-threaded Program With User Input?

Sep 9, 2014

// clang++ -g -std=c++11 main.cpp -pthread
#include <iostream>
#include <thread>
#include <unistd.h>
void thread1(void) {
while(1)

[code]....

Thread 1 does some background work, and thread2 is waiting for the user's input. If I join thread1 then the app can never exit. If I neither join nor detach thread1 then I get "terminate called without an active exception Aborted" which is not a good thing to have. If I do detach on thread1 does thread1 ever terminate? If not, how to terminate it? Also, how do I check if it's terminated or not?

View 2 Replies View Related

C++ :: Exit Two Threaded Program With User Input?

Sep 8, 2014

Code:

// clang++ -g -std=c++11 main.cpp -pthread
#include <iostream>
#include <thread>
#include <unistd.h>
void thread1(void) {
while(1) {
int i = 88 * 2;

[Code]...

Thread1 does some background work, and thread2 is waiting for the user's input.

If I join thread1 then the app can never exit. If I neither join nor detach thread1 then I get "terminate called without an active exception Aborted" which is not a good thing to have.

If I do detach on thread1 does thread1 ever terminate?
If not, how to terminate it?
Also, how do I check if it's terminated or not? -- I realize it's platform specific, I am on Linux.

View 5 Replies View Related

C++ :: Program Not Working - Debug Exit Code 1073741510 (0xc000013a)

Aug 8, 2013

I'm not sure what I'm missing. It is supposed to input and display player's name and score, calculate the average score, and display the players who scored below average.

It simply doesn't work. All I get is a black screen. Debug spits out an exit code of 1073741510 (0xc000013a).

Code:
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

const int arSize = 100;
int inputPlayerData (string playerName [], int playerScore [], int &numPlayers);

[Code] ....

View 6 Replies View Related

C++ :: Reverse Polish Calculator - How To Make Program Exit If User Enters Only 0

Oct 11, 2013

I have my Reverse Polish calculator compiling and everything but for the assignment I need to handle a few exceptions that I can't seem to get. First off I'm trying to make the program exit if the user enters only "0" but since the input i'm using is string, I cant figure out how to code

"If the first node is 0 and the next node = NULL, return true"

Here is my code:
#include<iomanip>
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<string>
#include<sstream>
using namespace std;

class Stack {

[Code] .....

View 1 Replies View Related

C/C++ :: How To Use Map In Multithreading

Jan 11, 2013

I have one input file having almost trillions of records.

Input:
Key Value
a XYZ
b xyz
. ...
. ...

How to store the above data in multithreaded map and retrieve in the same manner?

View 2 Replies View Related

C++ :: Multithreading - Demonstrate Use Of Semaphores

Feb 27, 2014

I have come across below code to demenostrate the use of semaphores

#include <pthread.h>
#include <semaphore.h>
#include <stdio.h>
#include <stdlib.h>
#define NITER 1000000
int count = 0;
void * ThreadAdd(void * a)

[Code] ....

Why the question of syncronising threads and mutexes and semaphores come into the picture when we join threads?

Like in the above example we have joined the first thread and then second thread so that main process will pause for the first thread to finish as its joined and then main process resumes and gives control to second thread and pauses till its finished as this thread is also joined.

Then where is question of simultaneous access?

First thread does its job and ends itself.
Second thread does its job and ends itself.

I wonder why there is need to use semaphores or mutexes in this example? I am very new to Multithreading and this question bothers me as to why we have to worry about simeltaneous access when we can join threads and can make control wait till that thread ends?

View 10 Replies View Related

C++ :: Multithreading - How To Modify Shared Object

Aug 24, 2014

class MyOwner {
...
int m_count;
bool b_locked;
};

[Code] ....

I am using an API where I create many MyObjects on the heap, and the API uses a separate thread to send messages to each object. Each MyObject contains a pointer to MyOwner.

Suppose I want to keep a count of all messages received in all MyObjects: How can I do this in a thread safe way?

I am assuming that the code I have written above will not be safe--at the very least it seems that it would potentially miss message counts when it was locked--not the worse case scenario for me. I am most concerned about not causing the application to crash.

View 5 Replies View Related

C/C++ :: Simultaneous Reading And Write From And To Text File Using Multithreading

Feb 13, 2013

Simultaneous Reading and write from and to a text file using Multithreading in c/C++

View 1 Replies View Related

C++ :: Creating Databases And Indexing One Image Per Database - Multithreading Synchronization

Nov 1, 2013

My below code is createing databases(database here is a kd tree) and indexing one image per database. I have two classes LastDatabaseTndexingPolicy and another forwardingDatabaseaccessor.cpp .

I am calling the GetDatabaseToAccess() function from forwardingDatabaseAccessor.cpp class .GetDatabaseToAccess() function is present in LastDatabaseTndexingPolicy class and it returns the database created as a pointer and using that database pointer we call another function which actually indexes the image to the database .

Now my issue is i am not able to have multiple threads act on the following functions as DatabaseAccessor_ptr db which is in the following file is coupled with two functions and however i put locks in the LastDatabaseTndexingPolicy file as below i end up getting synchronization issue ..........

Hence now i am using a single lock in forwardingDatabaseAccessor.cpp and serializing the code,. How can i change my design to parallelize this code .........

In ForwardingDatabaseAccessor.cpp we are calling function from LastDatabaseTndexingPolicy as shown below:-

DatabaseAccessor_ptr db is something which needs to be synchroinized. I tried createing 256 databases with one image each and when i run this code i ended up creating 175 databses and though i was restricting in code with locks that every database has only one image i ended up having two images in single database ..... ideally i had to get only one image per database but i got two images in few of them hence instead of 256 database this code created 175 or so databases.

indexing::IndexReturnValue ForwardDatabaseAccessor::index(cv::Mat image,
const std::string& imageName, features::Camera::Type indexCameraType,
features::Camera::Type recogCameraType) {
DatabaseAccessor_ptr db = this->IndexingPolicy_ptr->GetDBToIndex();

[Code] .....

View 1 Replies View Related

C :: Compiler Keeps Freezing / Crashing

Feb 11, 2014

I wrote this code as an assignment

Code:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
main(){

int story, age=0;
int ranColor, ranCar, ranItem;

[Code] ....

And my compiler keeps freezing/crashing. using Dec C++

View 4 Replies View Related

C++ :: Console Applications Keep Crashing

Jan 11, 2013

Any time I run my program after I make a selection from the menu the output is printed on the console screen then immediately a windows screen comes up saying project.exe has stopped working.

Below is my code, and I suspect the error has something to either

A) due with how I'm calling the method or
B) how I have the method coded.

Main
#include <iostream>
#include <fstream>
#include <string>
#include "telephone.h"
#include "tbook.h"

[Code] .....

View 4 Replies View Related

C/C++ :: Red Black Tree - App Keeps Crashing

Dec 8, 2014

Red Black Trees. [URL] .....

My app keeps crashing after about the 49th insert.

I tried debugging and it keeps pointing to this area in the Fixup:

if (z->parent == z->parent->parent->left) {
y = z->parent->parent->right;

View 13 Replies View Related

C++ :: Using Z To Exit?

Jun 4, 2014

Not sure what am doing wrong on this program, trying to use atoi to hit 'Z' to exit from the console:

<
#include "stdafx.h"
#include <iostream>
using namespace std;
#include <cstring>
#include <cstdlib>
int _tmain(int argc, _TCHAR* argv[])//main program begins here.

[Code] .....

View 6 Replies View Related

C++ :: Tail Stiva Crashing To Print?

Nov 17, 2014

i am trying to break a string and store it to a stiva (tail) i need my program to take one function like this

(a+10)* ((b+c)/(d-5)) + (9*2)

and return if it is editorial correct for example for the apper function has to return true but for this function

((a+10)*((b+c)/(d-5)) + (9*2)

has to return false.it crashes in the last part of my list i will put a comment

Code: #include<iostream>
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
#include<string>
using namespace std;
struct node{
char info;
node *back;
};

[code]....

View 2 Replies View Related

C++ :: Copy Constructor With Array Crashing

Oct 7, 2014

I know everything works except my copy constructor! There are no errors. The program crashes when it goes to access the copy constructor. why the copy constructor isn't working?

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <cstring> // access to C str functions
#include "String.h" // access String class
using namespace std;
String::String( int size )// default constructor

[code].....

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved