Questions tagged [double-free]

94 questions
53
votes
4 answers

What does "double free" mean?

As the title suggests I am new to C and have a mid-term coming up shortly. I am revising from past papers currently and a recurring theme is the double free problem. I understand that it is the process of calling free() on the same memory location…
chris edwards
  • 1,332
  • 4
  • 13
  • 31
17
votes
1 answer

double free or corruption (fasttop)

The following section of my code gives me this messege when executing * glibc detected ./a.out: double free or corruption (fasttop): 0x08e065d0 ** i have gone through the code many times but i cant clealry see how i am misusing the free…
Thair Abdalla
  • 279
  • 1
  • 5
  • 16
11
votes
2 answers

c++ program crashes when linked to two 3rd party shared libraries

I have two outsourced shared libraries for linux platform (no source, no document). The libraries work fine when they are linked to program separately (g++ xx.cpp lib1.so, or g++ xx.cpp lib2.so). However, when any c++ program is linked to these…
fanbin
  • 303
  • 3
  • 10
9
votes
1 answer

Static library loaded twice

I have shared object A.so which statically links to libssl.a & another shared object B.so which also statically links libssl.a . A.so & B.so has symbols from libssl.a in GLOBAL scope. I checked this by readelf -s A.so I have an executable a.out…
KodeWarrior
  • 3,538
  • 3
  • 26
  • 40
5
votes
1 answer

SEGFAULT when using shared_ptr

I'm trying to implement the Lazy Concurrent List-based Set in C++ by using shared_ptr. My reasoning is that unreachable nodes will be automatically freed by the last shared_ptr. As per my understanding, increment and decrement operation on a…
4
votes
2 answers

Vala: Invalid read when a joined thread gets unreferenced

When I compile and run the code below in valgrind, it looks like the thread gets free'd when I join the thread, and then later when it gets unreferenced some memory that is already free'd gets read. Is this a "false positive" from valgrind? If not,…
lockner
  • 201
  • 1
  • 7
4
votes
2 answers

Swapping an object within itself

I'm trying to swap an object within itself. It works but when I add a destructor it gives me a double free error. Is there a way to prevent this? The method I'm talking about is void swap(SimpleArray &object). (Sorry if you read this before I had…
avoliva
  • 3,181
  • 5
  • 23
  • 37
4
votes
2 answers

double free*** set a breakpoint in malloc_error_break to debug in ARC

I am using ARC in my application with core data and threading etc, after doing all that hard work to get core data work with threading without any crashes now I am getting a new crash with the reason- double free*** set a breakpoint in…
3
votes
1 answer

What wording makes this double-free-causing call `std::vector::clear()` in `T`'s constructor undefined behavior?

Consider the following code: #include #include struct Foo; std::vector v; struct Foo { std::string s = std::string(10000, 'x'); Foo() {} Foo(int) { v.clear(); } }; int main() { v.resize(1); // required,…
yeputons
  • 8,478
  • 34
  • 67
3
votes
0 answers

pygattlib error: Error in `python': double free or corruption (fasttop)

I have been trying for a while to use this pygattlib library I have followed all the steps exactly as mentioned in the documentation. I tried this on a Raspberry Pi 3, and also a Raspberry Pi Zero W running RASPBIAN STRETCH LITE (Kernel…
R.W
  • 530
  • 1
  • 12
  • 34
3
votes
2 answers

What are all the ways use_count of std::shared_ptr is incremented?

I have two shared_ptrs pointing to the same int, i.e. calling get() on them returns the same address. But calling use_count() on them returns 1. When the last of them goes out of scope, it tries to free up the memory already freed by the other one,…
CodeBricks
  • 1,771
  • 3
  • 17
  • 37
3
votes
5 answers

Dangling pointers and double free

After some painful experiences, I understand the problem of dangling pointers and double free. I am seeking proper solutions. aStruct has a number of fields including other arrays. aStruct *A = NULL, *B = NULL; A = (aStruct*) calloc(1,…
user151410
  • 776
  • 9
  • 22
3
votes
2 answers

double free without any dynamic memory allocation

In general, what could cause a double free in a program that is does not contain any dynamic memory allocation? To be more precise, none of my code uses dynamic allocation. I'm using STL, but it's much more likely to be something I did wrong than…
Dan Albert
  • 10,079
  • 2
  • 36
  • 79
3
votes
2 answers

How to detect who's issuing a wrong kfree

I am suspecting a double kfree in my kernel code. Basically, I have a data structure that is kzalloced and kfreed in a module. I notice that the same address is allocated and then allocated again without being freed in the module. I would like to…
smichak
  • 4,716
  • 3
  • 35
  • 47
2
votes
1 answer

Double-free error when using std::ptr::read in Rust

i am trying to read a value from pointer but i always get a double-free error. Do you guys know a way to fix it? I am using mem::forget to block the free operation but i still get the same result. use std::ptr; use std::mem; fn main() { let…
aiocat
  • 15
  • 1
  • 4
1
2 3 4 5 6 7