You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by "Michael Tyler (Created) (JIRA)" <ji...@apache.org> on 2012/02/01 22:48:58 UTC

[jira] [Created] (AXIS2C-1585) Double freeing pointers

Double freeing pointers
-----------------------

                 Key: AXIS2C-1585
                 URL: https://issues.apache.org/jira/browse/AXIS2C-1585
             Project: Axis2-C
          Issue Type: Improvement
          Components: util
            Reporter: Michael Tyler


I believe that most of double freeing of pointer core dump issues can simple by resolved by altering the axutil_allocator_free_impl function

change 

void AXIS2_CALL
axutil_allocator_free_impl(
    axutil_allocator_t * allocator,
    void *ptr)
{
    free(ptr);
}

to 

void AXIS2_CALL
axutil_allocator_free_impl(
    axutil_allocator_t * allocator,
    void *ptr)
{
    free(ptr);
    ptr = NULL;
}


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: c-dev-help@axis.apache.org


Re: [jira] [Commented] (AXIS2C-1585) Double freeing pointers

Posted by Nandika Jayawardana <ja...@gmail.com>.
Your suggestion is good. However, it would require a lot of code changes
and would break all projects that depend on Axis2/C.

Regards
Nandika

On Thu, Feb 2, 2012 at 10:48 PM, Michael Tyler (Commented) (JIRA) <
jira@apache.org> wrote:

>
>    [
> https://issues.apache.org/jira/browse/AXIS2C-1585?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13198995#comment-13198995]
>
> Michael Tyler commented on AXIS2C-1585:
> ---------------------------------------
>
> ok, you are right not sure what I was thinking.
>
> Would have to be
>
> void AXIS2_CALL
> axutil_allocator_free_impl(
>    axutil_allocator_t * allocator,
>     void **ptr)
> {
>    free(*ptr);
>    *ptr = NULL;
> }
>
> and then the address of the address be passed in.
>
> So not sure which is less work, changing all the calls to free or add the
> 'ptr = NULL' after ever call to free.  But I still believe it would reduce
> core dumps, because if you allow access to a 'free' functions most C coders
> are going to try to clean up the memory they allocated, but frees are
> attempted to be recusive at the highest level in Axis2/C.
>
> And the code all over the place is
>
> if( ptr )
>  free(ptr);
>
> and this leads to double freeing rapidly.
>
> > Double freeing pointers
> > -----------------------
> >
> >                 Key: AXIS2C-1585
> >                 URL: https://issues.apache.org/jira/browse/AXIS2C-1585
> >             Project: Axis2-C
> >          Issue Type: Improvement
> >          Components: util
> >            Reporter: Michael Tyler
> >              Labels: api-change, features, patch
> >
> > I believe that most of double freeing of pointer core dump issues can
> simple by resolved by altering the axutil_allocator_free_impl function
> > change
> > void AXIS2_CALL
> > axutil_allocator_free_impl(
> >     axutil_allocator_t * allocator,
> >     void *ptr)
> > {
> >     free(ptr);
> > }
> > to
> > void AXIS2_CALL
> > axutil_allocator_free_impl(
> >     axutil_allocator_t * allocator,
> >     void *ptr)
> > {
> >     free(ptr);
> >     ptr = NULL;
> > }
>
> --
> This message is automatically generated by JIRA.
> If you think it was sent incorrectly, please contact your JIRA
> administrators:
> https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
> For more information on JIRA, see: http://www.atlassian.com/software/jira
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: c-dev-unsubscribe@axis.apache.org
> For additional commands, e-mail: c-dev-help@axis.apache.org
>
>

[jira] [Commented] (AXIS2C-1585) Double freeing pointers

Posted by "nadir amra (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2C-1585?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13198929#comment-13198929 ] 

nadir amra commented on AXIS2C-1585:
------------------------------------

Not sure where the double free'ing of pointers are, but your solution does not solve the problem since the ptr variable is a local variable.   

Unless there is something more to it? 
                
> Double freeing pointers
> -----------------------
>
>                 Key: AXIS2C-1585
>                 URL: https://issues.apache.org/jira/browse/AXIS2C-1585
>             Project: Axis2-C
>          Issue Type: Improvement
>          Components: util
>            Reporter: Michael Tyler
>              Labels: api-change, features, patch
>
> I believe that most of double freeing of pointer core dump issues can simple by resolved by altering the axutil_allocator_free_impl function
> change 
> void AXIS2_CALL
> axutil_allocator_free_impl(
>     axutil_allocator_t * allocator,
>     void *ptr)
> {
>     free(ptr);
> }
> to 
> void AXIS2_CALL
> axutil_allocator_free_impl(
>     axutil_allocator_t * allocator,
>     void *ptr)
> {
>     free(ptr);
>     ptr = NULL;
> }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: c-dev-help@axis.apache.org


[jira] [Commented] (AXIS2C-1585) Double freeing pointers

Posted by "Michael Tyler (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2C-1585?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13198995#comment-13198995 ] 

Michael Tyler commented on AXIS2C-1585:
---------------------------------------

ok, you are right not sure what I was thinking.

Would have to be

void AXIS2_CALL 
axutil_allocator_free_impl( 
    axutil_allocator_t * allocator, 
    void **ptr) 
{ 
    free(*ptr); 
    *ptr = NULL; 
} 

and then the address of the address be passed in.

So not sure which is less work, changing all the calls to free or add the 'ptr = NULL' after ever call to free.  But I still believe it would reduce core dumps, because if you allow access to a 'free' functions most C coders are going to try to clean up the memory they allocated, but frees are attempted to be recusive at the highest level in Axis2/C.  

And the code all over the place is 

if( ptr )
  free(ptr);

and this leads to double freeing rapidly.
                
> Double freeing pointers
> -----------------------
>
>                 Key: AXIS2C-1585
>                 URL: https://issues.apache.org/jira/browse/AXIS2C-1585
>             Project: Axis2-C
>          Issue Type: Improvement
>          Components: util
>            Reporter: Michael Tyler
>              Labels: api-change, features, patch
>
> I believe that most of double freeing of pointer core dump issues can simple by resolved by altering the axutil_allocator_free_impl function
> change 
> void AXIS2_CALL
> axutil_allocator_free_impl(
>     axutil_allocator_t * allocator,
>     void *ptr)
> {
>     free(ptr);
> }
> to 
> void AXIS2_CALL
> axutil_allocator_free_impl(
>     axutil_allocator_t * allocator,
>     void *ptr)
> {
>     free(ptr);
>     ptr = NULL;
> }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: c-dev-help@axis.apache.org