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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:56:34+00:00 2026-06-14T11:56:34+00:00

So on a project I’m working on I’m getting the following error: *** glibc

  • 0

So on a project I’m working on I’m getting the following error:

*** glibc detected *** ./social_network: munmap_chunk(): invalid pointer: 0x09a913b0 ***

A few printf statements revealed the the struct I’m freeing that causes this error has a memory address of….17. So how is this possible? What could have happened to make this appear…?

Here’s some output right before the crash:

temp is: 162075592
temp user is  162075408
After free of temp
inside while loop, first line
before free of temp
temp is: 162075760
temp user is  162075480
After free of temp
inside while loop, first line
before free of temp
temp is: 162075568
temp user is  17

And here’s the code that outputs the output

 21 void destroy() {
 22 
 23     struct user_node *node;
 24 
 25     struct friend_node *temp;
 26     struct friend_node *next_temp;
 27     
 28     //iterate over the list of users
 29     while (*head != NULL) {
 30         printf("before a_friend\n");
 31         temp = (*head)->a_friend;
 32         
 33         //Iterate over friends of users, free friend nodes
 34         while (temp != NULL) {
 35             printf("inside while loop, first line\n");
 36             next_temp = temp->next_friend;
 37             printf("before free of temp\n");
 38             printf("temp is: %d\n", (int) temp);
 39             printf("temp user is  %d\n", (int)temp->user);
 40             free(temp); <==================================SEGFAULT IS HERE!!!!!!!!!!!!!
 41             printf("After free of temp\n");
 42             temp = next_temp;
 43             next_temp = NULL;
 44         }
 45 
 46         node = (*head)->next_user;
 47         printf("before free of: %s\n", (*head)->name);
 48         free(*head);
 49         printf("after free of that person...\n");
 50         *head = node;
 51         printf("*head = node afterwards\n");
 52         node = NULL;
 53     }
 54     printf("before final free...\n");
 55     free(head);
 56 }

EDIT:

struct friend_node

 23 //node used to store a pointer to a user_node and next friend
 24 struct friend_node {
 25     struct friend_node *next_friend;
 26     struct user_node *user;
 27 }; 

struct user_node

 12 //Struct definitions
 13 //node used to store information about a user
 14 struct user_node {
 15     char name[21];
 16     int age;
 17     int gender;
 18     char location[21];
 19     struct friend_node *a_friend;
 20     struct user_node *next_user;
 21 };
 22    
  • 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-14T11:56:35+00:00Added an answer on June 14, 2026 at 11:56 am

    I don’t see anything in your code that would suggest that you are freeing a struct at address 17, as you seem to incorrectly believe.

    Both the crash message and your dump clearly show that you are attempting to free pointer temp that points to address 162075568 (0x09a913b0). That pointer points to invalid memory, which is why free crashes. This is also why you might see 17 stored inside that memory. That memory is invalid, so there’s nothing surprising in the fact that it stores random garbage.

    Forget about that 17. It has nothing to do with anything. You problem is 162075568 (0x09a913b0). This value is invalid and that is the source of the problem.

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

Sidebar

Related Questions

The project that I am working on (Node.js) implies lots of operations with the
My project have no visible error but when i try to run it gives
Project CompetitionServer.exe raised exception class ESQLiteException with message 'Error executing SQL. Error [1]: SQL
Project I'm working on uses jQuery. I have a series of Ajax calls being
Project file here if you want to download: http://files.me.com/knyck2/918odc So I am working on
Project was working on PC number 1. Copied project to external drive and trying
My project has the following scenario: [Preview View Controller] --(Modal)--> Navigation Controller --(Top)--> [Photo
Current project is an Mvc4 application, I had Ioc working and recently it just
The project i am working at right now requires some declarative way of defining
A project I'm working on at the moment involves refactoring a C# Com Object

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.