All of lore.kernel.org
 help / color / mirror / Atom feed
From: Grzegorz Jaskiewicz <gj@pointblue.com.pl>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: attempt to free, allready freed memory .. rfc
Date: 31 Mar 2003 19:07:25 +0100	[thread overview]
Message-ID: <1049134044.945.35.camel@gregs> (raw)

Hello !
As allways, i have a problem. Thus i want ask you for comment.

Today i had a strange problem with my customers program. It is very
fresh soft, and they are still strugling with it (developing i meant :-)
). But they were stucked on very strange problem. 

[explanation of problem in program- ommited]

Problem it self.

this code will be an example.

struct doom{
        int data1;
        int data2;
        void *mydata;
};

doom doomed;

void dosomething_with_data(doom *d)
{       
//      .... doing some fancy operations
//      then..
        if (d->mydata)
        {
                free(d->mydata);
                d->mydata=NULL;
        }
}

void main()
{
        int i,j;
        void *t;

        // this program is just not doing anything important :-)
        
        t=doomed.mydata=malloc(somenumberofbytes);
        if (t==NULL){
                return;
        }
        
        dosomething_with_data(&doomed); 

// plenty of lines and finally ........
        if (doomed.mydata)
        {
                free(doomed.mydata);
                doomed.mydata=NULL;
        }

// now i will get strange behavior in other structures
// seems like it is a memory leak.....
 
}

well, finding this error in somebody software was not easy. 
Finaly i tested simmilar behavior on windows, and... it was not better.
But under compilation with m$ comiler in debug mode gived me assert on
first attempt to free allready freed memory. 
Is this behavior system has to take ? (i mean segfault)
which options for gcc i have to use to get assertion in case of such
error (i guess malloc seats in glibc, thus debug version of this liblary
might have this). But i am not sure. Waiting for comments. 
  

-- 
Grzegorz Jaskiewicz <gj@pointblue.com.pl>
K4 Labs


             reply	other threads:[~2003-03-31 18:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-31 18:07 Grzegorz Jaskiewicz [this message]
2003-03-31 19:29 ` attempt to free, allready freed memory .. rfc Richard B. Johnson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1049134044.945.35.camel@gregs \
    --to=gj@pointblue.com.pl \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.