The code in red was not there, so for a line that would start with # comment the code tries to access buf[-1]. How peculiar that the error lingered there and was never causing troubles before my stack shifted as a result of arrays size growth.
Interesting.
Negative array indexes aren't specifically wrong per se, since you're allowed to do
It's certainly not encouraged though.
Nothing to do with your stack though -- malloc() doesn't come from there.
Making malloc() larger may have ended up putting the block into a different heap, so the crashing code was more likely to hit invalid memory than to harmlessly nudge the end of your big array when loading a config file. Or could have been something else entirely. Difficult to tell.
Hi.
Can someone to help me in a segfault problem?
I have a big C++ program that crash from time to time because it receive the SIGSEGV signal.
So my question is: Can I find, without using gdb or other debugging tools, which line from source code cause that problem? Or if exist some gdb API... (1 Reply)
Here is my initiating code:
#define NUM 20
static struct tab {
int count;
int use;
} tab;
int curtab = 0;
int tab_create(int tab_count)
{
curtab++;
tab.use = 1;
tab.count = tab_count;
kprintf("here!");
return curtab;
} (2 Replies)
Hello - I am finding difficulty in creating and allocating correct size to File Systems on solarix x86 box. Please see below contents I followed on screen and in the end It shows that /app file system is created of size 135GB , I wanted it to be 30gb as mentioned during 'format' command in 'Enter... (7 Replies)
Hi
I am getting a strange segmentation fault during the unwind
process. I am trying to throw an object of an Exception class.
During the DoThrow (in libC.a) the stack starts growing until a
Signal is received.
The object thrown is of a class that inherits from a common class,
and the signal... (0 Replies)
i wrote handler for sigsegv such that i can allocate memory for a variable to which
sigsegv generated for illlegal acces of memory.
my code is
#include <signal.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char *j;
void segv_handler(int dummy)
{
j=(char *)malloc(10);
... (4 Replies)
Hello,
One of our customer is getting segmentation fault when he runs his shell script which invokes our executable on AIX 6.1.
On AIX 5.3, there were no issues.
Here is the truss output.
811242: __loadx(0x0A040000, 0xF0D3A26C, 0x00000000, 0x00000009, 0x00000000) = 0xF026E884... (0 Replies)
I receive a sigsegv failure. I was under the impression that a core file is created everytime a sigsegv occurrs and the process is terminated. I have had two recent occurrances of a core file not being created. Does anyone know why a core file would not be created. (2 Replies)
While running script I am getting an error like
Few lines in data are not being processed.
After googling it I came to know that adding such line would give some memory to it
ini_set("memory_limit","64M");
my input file size is 1 GB.
Is that memory limit is based on RAM we have on... (1 Reply)
Hi
I want to create a SIGSEGV when program tries to access one particular area in memory. Is this possible. If so whats the command. (4 Replies)
Discussion started by: jionnet
4 Replies
LEARN ABOUT OSX
backtrace
backtrace(3) BSD Library Functions Manual backtrace(3)NAME
backtrace, backtrace_symbols, backtrace_symbols_fd -- call stack backtrace and display functions
SYNOPSIS
#include <execinfo.h>
int
backtrace(void** array, int size);
char**
backtrace_symbols(void* const* array, int size);
void
backtrace_symbols_fd(void* const* array, int size, int fd);
DESCRIPTION
These routines provide a mechanism to examine the current thread's call stack.
backtrace() writes the function return addresses of the current call stack to the array of pointers referenced by array. At most, size
pointers are written. The number of pointers actually written to array is returned.
backtrace_symbols() attempts to transform a call stack obtained by backtrace() into an array of human-readable strings using dladdr(). The
array of strings returned has size elements. It is allocated using malloc() and should be released using free(). There is no need to free
the individual strings in the array.
backtrace_symbols_fd() performs the same operation as backtrace_symbols(), but the resulting strings are immediately written to the file
descriptor fd, and are not returned.
EXAMPLE
#include <execinfo.h>
#include <stdio.h>
...
void* callstack[128];
int i, frames = backtrace(callstack, 128);
char** strs = backtrace_symbols(callstack, frames);
for (i = 0; i < frames; ++i) {
printf("%s
", strs[i]);
}
free(strs);
...
HISTORY
These functions first appeared in Mac OS X 10.5.
SEE ALSO dladdr(3), malloc(3)Mac OS X February 15, 2007 Mac OS X