Hello,
I'm trying to delete whole linked list but getting segmentation fault and not able to detect what is the real problem. When I tried debugging using gdb, it is able to remove the first node but throw segmentation fault when deleting second node. Please suggest me what can be the possible reason.
#include <iostream>
using namespac...
I have a program which accepts 2 N-digit numbers, multiplies them using threads & prints the output.
The number of threads created here are 2 * N - 1.
whenever I run the program for N > 151, the program gives me a segmentation fault.
Is there a cap on maximum number of threads a process can get from the thread pool?
If so, could thi...
When I call /usr/local/bin/pdftk from PHP in Apache (via shell_exec(), exec(), system(), etc.), it returns the SYNOPSIS message as expected.
When I call /usr/local/bin/pdftk input.pdf fill_form input.fdf output output.pdf flatten via shell_exec(), nothing returns.
When I copy and paste the exact same string to the same path in the shel...
I have simple OpenGL C program (from NeHe lesson 2). There is initialization function InitGL.
And i have function foo in my static library:
void foo(double *p)
{
p[0] = 1.0;
}
When i define array of double at start of InitGL:
double arr[1000];
and modify it in InitGL all works fine.
When i allocate memory for this array dynam...
I am aware the following isn't the fastest way of generating a list of primes however I posed myself the problem and before googling wrote the following program. It works fine for numbers < ~ 44,000 but then gives a segmentation fault when ran on my 2Ghz Core 2 Duo Macbook. I am not really interested in alternative methods at the moment ...
Hey guys I'm trying to write a program that takes in a plaintext file as it's argument and parses through it, adding all the numbers together and then print out the sum. The following is my code:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
static int sumNumbers(char filename[])
{
int sum = 0;
FILE *file = fopen(fi...
Possible Duplicate:
Modified a constant in c
const int z = 420;
const void *v;
v = &z;
printf("\n%d | %d",z,*(int *)v);
//420 | 420
printf("\n%d | %d",*(char *)&z,*(char *)v); //0th-Bit same value
//-92 | -92
printf("\n%d | %d",*((char *)&z+1),*((char *)v+1) ); //1st-Bit same value
//1 | 1
/*************************...
I'm trying to use G++ to compile some C++ code. It seems to work fine in other compilers, but for whatever reason, G++ won't produce working output.
Disclosure: This is part of a homework assignment, but I feel like it's more of a compiler issue, since it works in other compilers.
Here's the snippet that's wreaking havoc:
set<int> t1,...
I'm developing my own PHP extension with a class in it. I recently upgraded from Ubuntu 9.04 to 9.10 and the extension broke. I since tried to update to 10.04 to see if it fixes it as my dev environment is 10.04 and it works fine on there. The only major difference from what I can understand is the server is 64 bit and my laptop 32 bit a...
When try to run my Rails application (either by running rake, ./script/console or ./script/server), I get src/tcmalloc.cc:353] Attempt to free invalid pointer or Segmentation fault (depending on if running on REE or MRI). It's been running just fine till yesterday, when with no particular reason (did not install any new gems, did not upd...
#include<stdio.h>
#include<ctype.h>
int main() {
FILE *fpin = fopen("in.txt", "r");
fprintf(fpin, "hello, world!");
fclose (fpin);
char c;
fpin = fopen("in.txt", "r");
FILE *fpout = fopen("out.txt", "w");
while ((c = fgetc(fpin)) != EOF) {
fputc (toupper(c), fpout);
}
fclose (fpout);
fc...
Edit: This issue only seems to happen with the combination of joint_view and shared_ptr. Raw pointers seem to work fine in the same scenario, as do shared pointers in a plain fusion container constructed w/ all its items at once, without adding anything more to it. Details below:
I'm using mingw gcc 4.5.1
Running into a peculiar issue...
Here is my code:
/*
* main.c
*
* Created on: 15 Oct 2010
* Author: mohit
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/dir.h>
#include <sys/unistd.h>
void print_usage();
int main(int argc, char *argv[])
{
int i;
char *directory;
char *name;
//Iterate through command line argum...
Getting a weird segmentation fault on following code when I try to pass a number into my application on command line.
int offset = 3;
int main(int argc, char *argv[]) {
// Check for arguments to see whether there is a custom offset
if (argc == 2) {
// If argc == 2 then we have a offset?
if (isdigit((unsigned cha...
I'm a little new to object oriented programming, and very new to Qt and GUIs in general.
I am now playing with this example in Nokia's Qt tutorial:
http://doc.qt.nokia.com/4.1/tutorial-t5.html
I tried to extend the code; this is what I have now:
#include <QApplication>
#include <QFont>
#include <QLCDNumber>
#include <QPushButton>
#incl...
Hi,
The last couple of days I've been working on a strange segmentation fault. The following code works just fine on my PC running Linux. But using the ARM crosscompiler suppplied by the manufactor of our embedded device, it gives a segmentation fault in routine s(). The SIGSEGV occurs at the destruction of a std::string. This also happ...
I wrote a php extension but couldn't find the reason why it reported segmentation fault.
related code:
char *tkey = (char *)emalloc(sizeof(char)*(result_pair[num-1].length+1));
std::memcpy(tkey, (text+i),result_pair[num-1].length);
tkey[result_pair[num-1].length]='\0';
if ...
I am working on a uni assignment, which is to be done in C. This is my firs time programming in C, and I am VERY close to having a workable solution, but my code is throwing a Segmentation Fault during runtime and I simply cannot locate the cause.
Here is my code:
#include "./shared.h"
#include "./scheduler.h"
PCB_entry *ready_q...
We're running Ruby workers across a large number of machines using Resque. Every once in a while, we see segmentation faults in our Resque worker processes. It's hard to debug these, because they're fairly rare, and we must run tens of thousands of distributed jobs to trigger a crash.
Ideally, we'd like to capture backtraces and core fi...
Ok basically I'm writing a program that takes in two directories and processes them based on what options are supplied. Thing is it's giving me segmentation errors at times when I don't see a problem. The code that is causing the problem is the following:
EDIT: Update the code to include my entire source file
#include <unistd.h>
#inclu...