Questions tagged [electric-fence]

Electric fence (eFence for short) is a popular memory debugger tool.

Electric Fence (or eFence) is a memory debugger written by Bruce Perens. It consists of a library which programmers can link into their code to override the C standard library memory management functions. eFence triggers a program crash when the memory error occurs, so a debugger can be used to inspect the code that caused the error.

14 questions
8
votes
2 answers

Understanding the output of electric fence and gdb

When debugging a program that terminates with a segfault, electric fence, in conjunction with gdb, returns this: "ElectricFence Exiting: mprotect() failed: Cannot allocate memory [Thread 0xb0bd4b70 (LWP 5363) exited] Program exited with code 0377. I…
Ricky Robinson
  • 21,798
  • 42
  • 129
  • 185
6
votes
3 answers

Heap corruption not detected by Valgrind or Electric Fence. Should I be suspicious? (C++)

I recently encountered my first battle (solved) with heap corruption. On my linux machine at home the culprit code exits without error using valgrind and electric-fence(with gdb). Yet on the windows machine in our lab, I consistently get the heap…
ryguy
  • 249
  • 2
  • 10
5
votes
4 answers

using electric fence in a c++ program

I've been experimenting with Electric Fence lately and I can't figure out how to use it with c++ code. Here's an example: // test.cpp #include
Nick Borodulin
  • 3,065
  • 4
  • 21
  • 21
4
votes
1 answer

c++ STL map::operator[] done on an entry being deleted

std::map bar; int foo(int key) { bar.erase(key); return 1; } int main() { bar[0] = foo(0); return 0; } This code compiled with GCC 4.8 segs fault when checking memory usage with electric fence. LD_PRELOAD=libefence.so.0.0…
Slek
  • 63
  • 6
4
votes
5 answers

Why electric fence/Valgrind is unable to catch this buffer-overflow issue?

I have created a buggy program - buggy.c - this is a buffer-overflow scenario for buffer t. You can see that I am writing more than 5 indexes. It works fine. It never throws me an error. I was wondering, why is it like that? I tried even Valgrind,…
dexterous
  • 6,422
  • 12
  • 51
  • 99
3
votes
1 answer

Using Electric Fence (libefence) just for a shared library

In order to diagnose a tricky memory corruption bug (memory is getting randomly overwritten) I thought about utilizing Electric Fence + some custom mprotect calls to ensure that the corrupted data structures are only writable when I want them to be…
Thilo-Alexander Ginkel
  • 6,898
  • 10
  • 45
  • 58
3
votes
1 answer

Debugging segfault with no apparent cause in gdb?

gdb was reporting that my C code was crashing somewhere in malloc(), so I linked my code with Electric Fence to pinpoint the actual source of the memory error. Now my code is segfaulting much earlier, but gdb's output is even more confusing: Program…
ashastral
  • 2,818
  • 1
  • 21
  • 32
3
votes
1 answer

Openmpi segfault when using electric-fence

I'm trying to find some memory errors in a program of mine using electric fence. My program uses OpenMPI and when I try to run it, it segfaults with the following back trace: Program received signal SIGSEGV, Segmentation fault. 2001 …
Kurtis Nusbaum
  • 30,445
  • 13
  • 78
  • 102
2
votes
3 answers

electric-fence with pthread

I'm working on a multithreaded (pthread based) project. The project uses a library that I'm writing. In order to check it I linked it with -lefence and it gave me SIGSEGV. After a lot of time spent in figuring out what's wrong, I finally decided to…
Dacav
  • 13,590
  • 11
  • 60
  • 87
2
votes
1 answer

electric-fence segfaults in malloc

I've got a rather complicated program that does a lot of memory allocation, and today by surprise it started segfaulting in a weird way that gdb couldn't pin-point the location of. Suspecting memory corruption somewhere, I linked it against…
Michael
  • 9,060
  • 14
  • 61
  • 123
1
vote
1 answer

libcurl HTTPS redirect triggers electric-fence error

I'm currently working on an ArchLinux 4.7.2-1 x86_64 Server and try to write an application using libcurl for HTTP(S) requests. So for example I do something like this: #include int main(void) { CURL* curl_handle =…
1
vote
3 answers

"address not from malloc()" error using electric fence

I've been writing a test case program to demonstrate a problem with a larger program of mine, and the test case has a bug that the original program does not. Here's the header file: // compiled with g++ -I/usr/local/bin/boost_1_43_0 -Wall -std=c++0x…
Max
  • 1,295
  • 6
  • 16
  • 31
1
vote
0 answers

Is there any Memory Align issue on Electric Fence - Cross compiled for MIPS?

I am trying to use Electric Fence on my Embedded box - MIPS based. when I run a simple application - it seems to be good. When I am running on an actual application - a complex application which tries to use everything - right from dbus to sqlite. I…
dexterous
  • 6,422
  • 12
  • 51
  • 99
0
votes
1 answer

Amazon EC2 Electric Fence Exiting: mprotect() failed: Cannot allocate memory

When executing my program inside an Amazon EC2 instance (t2.small, Oregon, Ubuntu 16.04), I get the error ElectricFence Exiting: mprotect() failed: Cannot allocate memory The steps I follow after launching the instance are: Install…
itxp
  • 35
  • 1
  • 4