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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:22:30+00:00 2026-05-26T05:22:30+00:00

BAD QUESTION The code suddenly works as it should. I can’t recall having changed

  • 0

BAD QUESTION

The code suddenly works as it should. I can’t recall having changed the code at all from when it crashed to now, other than adding some printfs for debugging. I just removed the comment from free(c); and now it works.

So please remove this question


The free on line 48 is the one in question. Once I remove it, my program runs fine, but with memory leakage of course. The string is malloced, filled by sprintf and attempted freed, but unsuccessfully.

I’ve pastebinned the function by demand
int extcommand(char** param)

The free line causes the following carnage:

*** glibc detected *** ./bin/tomashell: free(): invalid next size (fast): 0x094e7030 ***
======= Backtrace: =========
/lib/i686/cmov/libc.so.6(+0x6b281)[0xb7656281]
/lib/i686/cmov/libc.so.6(+0x6cad8)[0xb7657ad8]
/lib/i686/cmov/libc.so.6(cfree+0x6d)[0xb765abbd]
./bin/tomashell[0x8048ffb]
./bin/tomashell[0x8048e28]
./bin/tomashell[0x8048c37]
/lib/i686/cmov/libc.so.6(__libc_start_main+0xe6)[0xb7601c76]
./bin/tomashell[0x8048751]
======= Memory map: ========
08048000-0804a000 r-xp 00000000 08:01 5578979    /root/Dropbox/UIO/INF1060/hjemmeeksamen-1/tomashell/bin/tomashell
0804a000-0804b000 rw-p 00001000 08:01 5578979    /root/Dropbox/UIO/INF1060/hjemmeeksamen-1/tomashell/bin/tomashell
094e7000-09508000 rw-p 00000000 00:00 0          [heap]
b7400000-b7421000 rw-p 00000000 00:00 0
b7421000-b7500000 ---p 00000000 00:00 0
b75c5000-b75e2000 r-xp 00000000 08:01 1843203    /lib/libgcc_s.so.1
b75e2000-b75e3000 rw-p 0001c000 08:01 1843203    /lib/libgcc_s.so.1
b75ea000-b75eb000 rw-p 00000000 00:00 0
b75eb000-b772b000 r-xp 00000000 08:01 1860235    /lib/i686/cmov/libc-2.11.2.so
b772b000-b772d000 r--p 0013f000 08:01 1860235    /lib/i686/cmov/libc-2.11.2.so
b772d000-b772e000 rw-p 00141000 08:01 1860235    /lib/i686/cmov/libc-2.11.2.so
b772e000-b7731000 rw-p 00000000 00:00 0
b7736000-b773a000 rw-p 00000000 00:00 0
b773a000-b773b000 r-xp 00000000 00:00 0          [vdso]
b773b000-b7756000 r-xp 00000000 08:01 1843225    /lib/ld-2.11.2.so
b7756000-b7757000 r--p 0001a000 08:01 1843225    /lib/ld-2.11.2.so
b7757000-b7758000 rw-p 0001b000 08:01 1843225    /lib/ld-2.11.2.so
bf9f8000-bfa0d000 rw-p 00000000 00:00 0          [stack]
Aborted

Why can’t I free my string?

Here is some extra information

root@chu:~/sc/tomashell# gcc --version
gcc (Debian 4.4.5-8) 4.4.5
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

root@chu:~/sc/tomashell# uname -a
Linux chu 2.6.32-5-686 #1 SMP Mon Jun 13 04:13:06 UTC 2011 i686 GNU/Linux
root@chu:~/sc/tomashell#
  • 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-26T05:22:31+00:00Added an answer on May 26, 2026 at 5:22 am

    Well, the obvious answer is that the sprintf is printing more characters than there is allocated space, so that some info on the end of the block (containing bookkeeping info for the memory manager) is being overwritten. Without examining the whole program, there are too many uncertainties here for us to diagnose it perfectly. For example, we don’t know what param points to, and how you guarantee it’s not too long. You could use snprintf to do this more safely.

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

Sidebar

Related Questions

This question is inspired from Joel's Making Wrong Code Look Wrong http://www.joelonsoftware.com/articles/Wrong.html Sometimes you
I want to use this code (from my last question (thanks Adam)), bool AllDigitsIdentical(int
Edit Downvoter, how is this a bad question? I have provided runnable example code
I don't understand this at all. Here is some Javascript code that works in
sorry for my bad english. I've got such a question: why the first code:
I asked this question a while ago. I now know it is a Bad
(second question today - must be a bad day) I have a dataframe with
Quick question: Would it be a good or a bad idea to implement my
I saw this question asking about whether globals are bad . As I thought
Today I got this question for which I think I answered very bad. 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.