Why do I get a segmentation fault in my recursive function. It happens every time i call it when a value greater than 4 as a parameter
#include <iostream>
#include <limits>
using namespace std;
int printSeries(int n){
if(n==1){
return 1;
}
else if( n==2){
return 2;
}
else if( n==3){
...
I just finished a project for my cryptography class and it all seems to go well (mostly). Because the key is generated randomly, I wanted to ensure it would work for all keys. Anyway, I ran it a bunch of times and hit a segfault at around the 30th run. I haven't been able to reproduce this segfault in gdb. Does gdb have a command, or is ...
I am using Postgres-8.3.7 on fedora core 2 linux box. And Postgres service is crashing.
When I restart the system, it is working fine for some time. At some random time it is crashing again.
What could be the possible reasons for this segfaults which are random?
FATAL: the database system is in recovery mode
LOG: autovacuum launcher ...
So I'm trying to get some ruby code a friend of mine wrote running on my laptop, but it segfaults every time I fire it up. After a little debugging, it looks like FXRuby is the culprit, and the behavior is trivially reproducible by typing require 'fox16' in to irb. I'm running OS X and my friend runs Linux, but anecdotally this code wo...
Hello folks,
This one is probably very simple, but I can't seem to get it working.
I have this very simple snippet of code:
#include <stdio.h>
#include <string.h>
int main(void)
{
char buf[100];
char *p = buf;
strcpy(p, "Test string");
printf("%s\n", *p);
}
Which causes a segmentation fault when I run it. GDB outputs:
...
Hello,
I have c/gtk+ application and GList which filled three elements, when i try to run following code with gdb:
if (g_list_length(mw->img_list) > 0)
printf(">0");
else
printf("<0");
i see:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb73c4700 (LWP 7936)]
IA__g_list_length (list=0x6e6920) at g...
I'm trying to solve the following problem: Say I have a Python script (let's call it Test.py) which uses a C++ extension module (made via SWIG, let's call the module "Example"). I have Test.py, Example.py, and _Example.so in the same directory.
Now, in the middle of running Test.py, I want to make a change to my Example module, recomp...
I don't normally go to stackoverflow for sigsegv errors, but I have done all I can with my debugger at the moment.
The segmentation fault error is thrown following the completion of the function. Any ideas what I'm overlooking? I suspect that it is due to the casting of the sockaddr to the sockaddr_in, but I am unable to find any mistak...
I am refreshing openmp a bit, and got into this weird situation. Shaved off the bunch, I created this minimal trivial case that shows the issue
program ex2
implicit none
integer, parameter :: n=10000000
integer :: i
real :: x(n)
do i=1,n
x(i) = 0.0d0
enddo
end program
with no flags specified, gfortran...
My application segfaults sometimes and mainly in malloc() and malloc_consolidate() when I look at the backtrace in gdb.
I verified that the machine has enough memory available, it didn't even start swapping.
I checked ulimits for data segement and max memory size and both are set to 'unlimited'.
I also ran the application under valgrind...
I have a void *, call if data which length I know, but is not terminated. I make a call like this snprintf(line, sizeof(line), "%*s", n, (const char*)data) where n is the known length. Almost always this works, but occasionally it results in a segfault.
Whenever the segfault occurs, the back trace says the problem is inside strlen. ...
I have a struct defined in a header as follows:
#define LC_ERR_LEN 300
typedef struct dLC_ERRMSG {
short nr;
short strategy;
char tx[LC_ERR_LEN];
} LC_ERRMSG;
Which I use in my code as such:
LC_ERRMSG err;
char *szError;
szError = strerror(sStatus);
snprintf(err.tx,LC_ERR_LEN," %s - %s",szFilename,szError);
/* do something w...
I'm building with g++, and yesterday a helpful person on SO told me to compile with the -D_GLIBCXX_DEBUG and -D_GLIBCXX_DEBUG_PEDANTIC flags. I did so, and I spent most of yesterday tweaking my code to conform to these flags. Now it's complaining about my use of boost::signal, and I'm not sure where the problem is.
I have a class Yarl...
Bear with me. I have not coded in c in 8 years and am totally baffled why my string manipulation is not working. I am writing a program that loops forever. In the loop I initialize two char pointers each is passed to a function that add text to the char pointer (array). When the functions are done I print the char pointer and free the tw...
Hey there,
for a little project i wanted to use a struct with an stl container in it.
This thingy is then packet into a dynamic 2 dim. array, but when i try to delete it,
it segfaults.
Here is the code:
struct cell{
list<pair<double, double> > alist;
};
int main()
{
struct cell ** myAr = new cell*[5];
for(int i = 0; i < 5; ...
That's a single threaded code.
In particular: ahocorasick Python extension module (easy_install ahocorasick).
I isolated the problem to a trivial example:
import ahocorasick
t = ahocorasick.KeywordTree()
t.add("a")
When I run it in gdb, all is fine, same happens when I enter these instructions into Python CLI. However, when I try to...
I have this bit of code:
cerr << client->inventory.getMisc().front()->getName() << endl;
vector<itemPtr>::iterator it;
it = client->inventory.getMisc().begin();
cerr << (*it)->getName() << endl;
Let me explain that a bit:
client is a tr1::shared_ptr that points to an object that has a member named inventory that has a private vector...
Hi,
I'm having a bit of a problem with strcat and segmentation faults. The error is as follows:
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
0x00007fff82049f1f in __strcat_chk ()
(gdb) where
#0 0x00007fff82049f1f in __strcat_chk ()
#1 0x0000000100000adf i...
I've been working through a small tutorial on how to build a basic packet sniffer for Linux. I got everything working, and I now want to add IP-to-host mapping.
Everything was working before I added this function:
void IPtoHostname(char *ipaddress, char *hostname){
struct hostent *host;
in_addr_t ip = inet_addr(ipaddress);
...
Hi folks,
I wrote a variadic C function which mission is to allocate the needed memory for a buffer, and then sprintf the args given to this function in that buffer. But I'm seeing a strange behavior with it. It works only once. If I have two calls for this function it segfaults.
#include <stdio.h>
#include <string.h>
#include <stdlib....