Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6210583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:11:08+00:00 2026-05-24T06:11:08+00:00

I am facing SIGEV with this malloc wrapper code, can anybody please help me?

  • 0

I am facing SIGEV with this malloc wrapper code, can anybody please help me?

enter code here
#include <stdio.h>
#include <dlfcn.h>
#include <stdlib.h>
#include <string.h>

void *handle;
static void* (*ef_libc_malloc) (size_t);
static void* (*ef_libc_calloc) (size_t, size_t);
static void init1() __attribute__ ((constructor));

void *malloc(size_t size)
{
 return (*ef_libc_malloc)(size);
}

void *calloc(size_t nmemb, size_t size)
{
 return (*ef_libc_calloc)(nmemb, size);
}

void init1()
{

 //handle=dlopen("/devel/lib/libc.so.6",RTLD_LAZY);
 handle=dlopen("libc.so.6",RTLD_LAZY);
 if(!handle) {
 printf("dlopen failed\n");
exit(1);    
  }
 ef_libc_malloc = dlsym(handle, "malloc"); 
 if(!ef_libc_malloc) {
 printf("Could not resolve malloc in libc.so\n");
  }

  ef_libc_calloc = dlsym(handle, "calloc"); 
  if(!ef_libc_calloc) {
 printf("Could not resolve calloc in libc.so\n");
  }
 }

  int main()
  {
   char *ptr;

   ptr=(char*)malloc(20);
   strcpy(ptr,"jghjghbj");
   puts(ptr);
  }

Here is the GDB backtrace:

enter code here
(gdb) r
 Starting program: /usr/local/arm-sony-linux-gnueabi/target/arm/tmp/efence/a.out 

 Program received signal SIGSEGV, Segmentation fault.

 0x00000000 in ?? ()
 (gdb) bt 
 #0  0x00000000 in ?? ()
 #1  0x080484c8 in malloc (size=20) at dlopen10.c:13
 #2  0x0067cb42 in _dl_map_object_deps () from /lib/ld-linux.so.2
 #3  0x00681aed in dl_open_worker () from /lib/ld-linux.so.2
 #4  0x0067de26 in _dl_catch_error () from /lib/ld-linux.so.2
 #5  0x00681472 in _dl_open () from /lib/ld-linux.so.2
 #6  0x00803c4d in dlopen_doit () from /lib/libdl.so.2
 #7  0x0067de26 in _dl_catch_error () from /lib/ld-linux.so.2
 #8  0x008042cc in _dlerror_run () from /lib/libdl.so.2
 #9  0x00803b84 in dlopen@@GLIBC_2.1 () from /lib/libdl.so.2
 #10 0x08048501 in init1 () at dlopen10.c:25
 #11 0x0804866b in __do_global_ctors_aux ()
 #12 0x0804836d in _init ()
 #13 0x080485f9 in __libc_csu_init ()
 #14 0x006a8e41 in __libc_start_main () from /lib/libc.so.6
 #15 0x08048401 in _start ()
 (gdb) q
 The program is running.  Exit anyway? (y or n) y

I am not able to find the root cause. Please help me to fix this issue.
Please help me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:11:09+00:00Added an answer on May 24, 2026 at 6:11 am

    Looks like loading libc.so at the wrong time is causing the problem. Try without loading it:

    dlsym(RTLD_NEXT, "malloc");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm facing a problem with IE6. I took the toggle function from this website
Facing a need for a single CMS we can use for rapid deployment of
I am facing an issue with my code . the thing is i want
When you are facing with this kind of dilemma, what do you usually do,
I am facing problem with an Oracle Query in a .net 2.0 based windows
I am facing a problem with .NET generics. The thing I want to do
I have a public facing website that has been receiving a number of SQL
I am facing strange issue on Windows CE: Running 3 EXEs 1)First exe doing
I am facing a problem. I would like to localize my action names in
I'm facing a real problem in understanding how to draw a variable diagram to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.