23

The question Why does invalid memset() after malloc() lead to free() invalid next size (fast) error has just been closed as a duplicate of:

But there are multiple other bugs in the related lists of the various questions that should probably also be closed as duplicates of this issue. This question is primarily to document the set and get approval before using Mjölnir to close them as duplicates. The list is in sorted order of increasing SO question number (sort -u -t/ -k5n on the list with the * at the front). Thus, the canonical question is nominally the first of those listed, 'Facing an error …'.

Designated canonical question

Closed as duplicates

A few were already closed; they've been annotated with the alternative.

Not duplicated (already closed)

OK; that's at least 61. It avoids 'old size' problems, double free, invalid pointer, and C++ questions.

14
  • 4
    Yes, you have my support. Thanks for taking the time to hunt these down. :) Is there a good canonical somewhere in there that we can use as the target?
    – Mysticial
    May 14, 2014 at 5:36
  • I've nominated the lowest numbered one (Facing an error — glibc detected free invalid next size (fast)); we can request any better answers to be migrated. May 14, 2014 at 6:19
  • @Mysticial: Can I persuade you to close the last 7 ones which I couldn't close? Then update the question with the information. If you do it — or someone else does it — thanks! May 14, 2014 at 6:26
  • 3
    I was hoping for a better canonical than that first one. One where the question is short and clear. And the answer explains everything in detail. In the C++ tag we have a lot of self-answers that do this, but there doesn't seem to be much of an effort in C.
    – Mysticial
    May 14, 2014 at 6:36
  • Fair enough. Choose your preferred alternative and tell me. If it's already closed by me, I'll cancel that. You can then make it the canonical for the remaining few, and for 'Facing an error'. I am just about to update 'Facing an error' with a pointer to this question. (I'm also headed for bed; it should be 6+ hours before I get around to doing anything more.) May 14, 2014 at 6:38
  • 2
    Running down that list, it looks like the one you sent me earlier is the best. It's still not great, but better than all the other ones. The error is in the title and the question is pretty short. Unwind's answer is straight to the point with "overwriting your allocated space". So I'll the dupe the rest of them to that one. If anyone does come along with a good canonical later on, we can dupe the head of the chain to that instead.
    – Mysticial
    May 14, 2014 at 6:48
  • @Mysticial: Works for me. We can clean up more tomorrow. Thanks for your help. May 14, 2014 at 6:55
  • I updated the progress. I stopped short of repointing the head of the chain to the canonical you sent me earlier. We can decide on that later.
    – Mysticial
    May 14, 2014 at 6:59
  • I can't believe I hadn't thought of using Mjölnir for this! Thanks for the idea, and good on you for putting all this research in!
    – jscs
    May 14, 2014 at 8:35
  • Should the canonical answer also be extended to discuss the symptoms/fixes on Windows with the MS toolchain? The error message is of course different but the coding errors are the same. Or should it be a separate (but very similar) question and answer?
    – nobody
    May 15, 2014 at 16:34
  • @AndrewMedico: If you have the expertise to do so -- and the solutions for the problem in glibc on Windows are different from on Unix -- then yes, please (but that should probably be the canonical created by PlasmaHH. At the moment, this is not a generic 'all memory allocation errors' Q&A; it is tied to the glibc implementation specifically. I'd like to get the glibc version fixed before we go further and generalize it too much. May 15, 2014 at 16:43
  • @JonathanLeffler Please undo this! The 'master' question is tagged 'linux', 'jni' and 'centos', yet many of the duplcates are 'c', 'malloc', and 'realloc'. Totally different topics!
    – kingledion
    May 2, 2018 at 16:08
  • What does "fast" mean?
    – S.S. Anne
    Aug 27, 2019 at 1:39
  • @JL2210 — dunno; it’s part of the error message and presumably means something to the authors of the malloc() package and contrasts with slow or thorough or some other word. Aug 27, 2019 at 7:21

2 Answers 2

40

(Correct me if I'm wrong and the causes of all the problems are listed in that tiny little answer, but...)

A canonical question + answer should contain everything (all causes of and solutions to a problem) prior to having everything closed as a duplicate of it. And that just seems like a randomly nominated candidate as opposed to an especially constructed one (its question number isn't a good selection criteria).

The motivation should not be:

Let's get all these questions closed.

But rather:

Let's make one super awesome post containing all this information ... and then get rid of all the redundant questions.

6
  • Unfortunately it looks like people are doing it already anyways... stackoverflow.com/questions/10469886
    – PlasmaHH
    May 14, 2014 at 15:58
  • 2
    I think the list collection work was done reasonably well and thoroughly. I think the duplicate chosen was (fairly badly) mis-chosen. I will work on rectifying that, but it will take time. I wish I'd waited rather than trying to get it all done last night; it is easy to be wise after the event. One good thing: the list above identifies the afflicted questions, so it makes chasing what needs repairing that much easier. (So, in case it isn't clear, I agree with the criticism. And yes, the intention was to get to a super-awesome post, but there was a big gap between intention and achievement). May 14, 2014 at 17:39
  • @JonathanLeffler: Is -- to your knowledge -- anyone working on that super awesome post? When not swamped with more stuff I could try doing something tomorrow. We should probably collect topics that we want to have in there. imho we should point out that: this is not a good type of question for SO but the answer is there so we can link duplicates to it. it should emphasize that there is no single reason and people need to debug, and then list a bunch of helpful things to start debugging.
    – PlasmaHH
    May 14, 2014 at 18:40
  • @PlasmaHH: As of 'right now', I don't know of anyone working on it. Mysticial has looked at the issue and likes one item as the canonical. I will look at it later -- this evening, after work and a school concert. I also plan to look at some of the other related items (notably 'old size' error messages; that's a dozen or so questions), to see if they should be added to the list. To the extent there's a plan, I will look at the accepted answer in the proposed canonical. I want to make sure valgrind is mentioned somewhere. Otherwise, it shouldn't need much touching up. May 14, 2014 at 18:44
  • @PlasmaHH: If it seems best, I'll add a CW answer that covers points not already made by the accepted answer. It might also point to some of the related issues. If someone else gets in and fixes up the mess before I get to it, that'll be fine with me (as long as the mess afterwards is less of a mess than it is now). May 14, 2014 at 18:46
  • 1
    @JonathanLeffler: For the canonical q/a pair I would prefer a "fresh" one because then we could make the question itself already list all kinds of typical error message for this kind of issue. It shouldn't be a big deal to move/copy the answer to that new fresh question should we find resources to create and re-duplicate-link it.
    – PlasmaHH
    May 14, 2014 at 18:49
3

Since the initial choice of "canonical" Q/A was rather suboptimal, I have just created a Q/A pair, which I think should quite a good starting point: What is a glibc free/malloc/realloc invalid next size/invalid pointer error and how to fix it?

Maybe someone else can make it "super awesome" as requested by Dukeling

We should re-duplicate-close with targeting this.

2
  • I've done some work on both question and answer. There's a lot more to do. Amongst other things still to do: (1) Add credit for example question (I added the link and the question body); (2) Add answer to the example question and credit for it; (3) Convert to Community Wiki, please; (4) Update this question with links to the other error types than 'invalid next size' (since most of them occur somewhere in SO, but I deliberately excluded them originally); (5) Make a note that this problem can happen in C++ programs that are using the C memory allocation facilities (and add to the list here). May 15, 2014 at 16:39
  • @JonathanLeffler: Thanks a lot. regarding (5): It can happen in C++ programs too, since normally their memory allocation facilities will just use those of C. I will have a look at things tomorrow, now I need to try getting a certain kid to stay in her bed...
    – PlasmaHH
    May 15, 2014 at 18:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .