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 8658695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:49:54+00:00 2026-06-12T15:49:54+00:00

I am getting a segmentation fault inside of the malloc() routine. Here is the

  • 0

I am getting a segmentation fault inside of the malloc() routine. Here is the stacktrace from gdb:

#0  0x00007ffff787e882 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007ffff787fec6 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x00007ffff7882a45 in malloc () from /lib/x86_64-linux-gnu/libc.so.6
#3  0x0000000000403ab0 in xmalloc (size=1024) at global.c:14
#4  0x00000000004020fb in processConnectionQueue (arguments=0x60a4e0)
    at connection.c:117
#5  0x00007ffff7bc4e9a in start_thread ()
   from /lib/x86_64-linux-gnu/libpthread.so.0
#6  0x00007ffff78f24bd in clone () from /lib/x86_64-linux-gnu/libc.so.6
#7  0x0000000000000000 in ?? ()

What’s going on? What could cause malloc() to segfault?

EDIT: Here is the code from xmalloc(). It’s pretty standard, and as you can see from the stacktrace it’s calling malloc with a size of 1024.

void* xmalloc(size_t size)
{
    void* result = malloc(size);
    if(!result)
    {
        if(!size)
        {
            result = malloc(1);
        }
        if(!result)
        {
            fprintf(stderr, "Error allocating memory of size %zu\n", size);
            exit(-1);
        }
    }
    return result;
}

And line 117 in connection.c:

        item->readBuffer = xmalloc(kInitialPacketBufferSize);
  • 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-06-12T15:49:55+00:00Added an answer on June 12, 2026 at 3:49 pm

    You are most likely seeing the effect of an error elsewhere in your code, that access memory outside an allocation. If you are lucky enough, your code can touch some of the internal values malloc uses to track allocations.

    If you have the possibility, try linking your code with an allocation checker like libefence or similar, and use this to locate the real problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting a segmentation fault from SDL_BlitSurface in C++. here's the code mainScreen->draw( 0,
Why am I getting segmentation fault? I ran it with gdb and it crashing
I'm getting a segmentation fault the first time I call malloc() after I protect
I am getting a segmentation fault from bash when I try to SSH to
I'm getting a segmentation fault everytime i want to run this code : from
Possible Duplicate: getting segmentation fault in a small c program Here's my code: char
Im getting segmentation fault from pthread_mutex_lock, heres my backtrace: Program received signal SIGSEGV, Segmentation
I saw many questions about getting segmentation fault in C program here in SO,
When I am running the devicequey from CUDA SDK I'm getting segmentation fault error:
I have a process in Linux that's getting a segmentation fault. How can I

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.