07-05-2012
No.
Your code has done pointer arithmetic on the pointer object you are trying to free.
malloc() keeps data about the pointer adjacent to the actual place in memory the pointer references at the start, so free() thinks it has to work on memory the process does nto own. Boom.
Use Electric Fence or valgrind to find where. These are available for a lot of platforms.
Failing that look at driver's code here:
memory stack problem
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
We are running a SQR program on Unix Platform with Oracle RDBMS.
It's an interfacing program to integrate data from foreign sites to
PeopleSoft database, using a flat file input.
After many hours of processing, the program stops with a coredump error (memory fault). With top command we noticed... (1 Reply)
Discussion started by: araziki
1 Replies
2. Programming
Dear All,
I made a program which do some simple jobs like reading data from other process's shared memory and writing messages to the queues of other process.
what happens is my program works fine and do all the task as expected but then then program ends it give Memory fault(coredump). I... (0 Replies)
Discussion started by: ralo
0 Replies
3. AIX
Hi All
Can anybody help me?
When ever am trying to run topas system gives me an error Segmentation fault(coredump)
does anybody ahve solution for this? (4 Replies)
Discussion started by: vjm
4 Replies
4. Ubuntu
Hey guys,
I am new to the Linux world and have a question to post.
When I ssh from a HP-UX machine to a ubuntu machine I get the following error message
Memory fault(coredump)
i.e. ssh 192.168.1.3
I get this message as shown below
Memory fault(coredump)
Can someone please explain... (2 Replies)
Discussion started by: fkaba81
2 Replies
5. Solaris
Getting memory fault (coredump) and segmentation fault(coredump)
when i tried javac or java -version. what could be the problem?
Regards
Eswar (2 Replies)
Discussion started by: BhuvanEswar
2 Replies
6. Shell Programming and Scripting
I'm getting this error when trying to run a Acucobol program thru UNIX..
Segmentation Fault(coredump)
Precompiler error prevents compilation of xxxxxx.co.
Please help me in this case.. (1 Reply)
Discussion started by: Manish4
1 Replies
7. Programming
Hi,
Actually I am facing one issue while using the getenv() in the C/C++ program.
I want to take the file path from environment variables and if am not defining the environment path, its showing the message like this…!
Memory fault(coredump)
Actually I want to handle the error ,... (6 Replies)
Discussion started by: Kattoor
6 Replies
8. Shell Programming and Scripting
i have few log files that are input to my perl script...
i am executing the script as below
cat RTR*.log | test.pl
and getting the following error
-ksh: 25014: Memory fault(coredump)
cat: write error: Connection reset by peer
can anyone help me on this....
Thanks in... (2 Replies)
Discussion started by: niteesh_!7
2 Replies
9. AIX
Hi Experts,
While running a command, i saw this error below
# ls -lrt
total 74008
-rw-r--r-- 1 rr57104 edcfes 37889134 May 16 12:41 LGTOnw.clnt.7.4.2.0.bff.tar.gz
drwxr-xr-x 2 root system 256 May 18 12:42 lost+found
# gunzip LGTOnw.clnt.7.4.2.0.bff.tar.gz
Memory fault(coredump)
... (2 Replies)
Discussion started by: EngnrRG
2 Replies
10. Homework & Coursework Questions
I am writing a program that copies a program and prints the program with a line count.
this is the program I wrote:
#include <stdio.h>
main()
{
int c;
int nl_cnt = 0;
while((c = getchar()) != EOF){
if(c = '\n'){
nl_cnt++;... (3 Replies)
Discussion started by: heywoodfloyd
3 Replies
LEARN ABOUT LINUX
realloc
REALLOC(P) POSIX Programmer's Manual REALLOC(P)
NAME
realloc - memory reallocator
SYNOPSIS
#include <stdlib.h>
void *realloc(void *ptr, size_t size);
DESCRIPTION
The realloc() function shall change the size of the memory object pointed to by ptr to the size specified by size. The contents of the
object shall remain unchanged up to the lesser of the new and old sizes. If the new size of the memory object would require movement of the
object, the space for the previous instantiation of the object is freed. If the new size is larger, the contents of the newly allocated
portion of the object are unspecified. If size is 0 and ptr is not a null pointer, the object pointed to is freed. If the space cannot be
allocated, the object shall remain unchanged.
If ptr is a null pointer, realloc() shall be equivalent to malloc() for the specified size.
If ptr does not match a pointer returned earlier by calloc(), malloc(), or realloc() or if the space has previously been deallocated by a
call to free() or realloc(), the behavior is undefined.
The order and contiguity of storage allocated by successive calls to realloc() is unspecified. The pointer returned if the allocation suc-
ceeds shall be suitably aligned so that it may be assigned to a pointer to any type of object and then used to access such an object in the
space allocated (until the space is explicitly freed or reallocated). Each such allocation shall yield a pointer to an object disjoint from
any other object. The pointer returned shall point to the start (lowest byte address) of the allocated space. If the space cannot be allo-
cated, a null pointer shall be returned.
RETURN VALUE
Upon successful completion with a size not equal to 0, realloc() shall return a pointer to the (possibly moved) allocated space. If size is
0, either a null pointer or a unique pointer that can be successfully passed to free() shall be returned. If there is not enough available
memory, realloc() shall return a null pointer and set errno to [ENOMEM].
ERRORS
The realloc() function shall fail if:
ENOMEM Insufficient memory is available.
The following sections are informative.
EXAMPLES
None.
APPLICATION USAGE
None.
RATIONALE
None.
FUTURE DIRECTIONS
None.
SEE ALSO
calloc() , free() , malloc() , the Base Definitions volume of IEEE Std 1003.1-2001, <stdlib.h>
COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol-
ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE
and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained
online at http://www.opengroup.org/unix/online.html .
IEEE
/The Open Group 2003 REALLOC(P)