You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2015/05/10 14:10:01 UTC

[jira] [Commented] (THRIFT-1248) pointer subtraction in TMemoryBuffer relies on undefined behavior

    [ https://issues.apache.org/jira/browse/THRIFT-1248?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14537156#comment-14537156 ] 

ASF GitHub Bot commented on THRIFT-1248:
----------------------------------------

GitHub user jeking3 opened a pull request:

    https://github.com/apache/thrift/pull/486

    THRIFT-1248 fix TMemoryBuffer pointer arithmetic and add unit test

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/jeking3/thrift bugfix/THRIFT-1248-pointer-arithmetic

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/thrift/pull/486.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #486
    
----
commit 379f6857f087c87a60a933028549534b06a1371b
Author: Jim King <ji...@simplivity.com>
Date:   2015-05-10T12:08:18Z

    THRIFT-1248 fix TMemoryBuffer pointer arithmetic and add unit test

----


> pointer subtraction in TMemoryBuffer relies on undefined behavior
> -----------------------------------------------------------------
>
>                 Key: THRIFT-1248
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1248
>             Project: Thrift
>          Issue Type: Bug
>          Components: C++ - Library
>    Affects Versions: 0.5
>            Reporter: Anatoly Fayngelerin
>            Assignee: James E. King, III
>         Attachments: 0_7_0_ptrdiff.patch
>
>
> The ensureCanWrite function in TMemoryBuffer currently "rebases" the buffer pointers by subtracting the original buffer pointer from the pointer newly returned by realloc. While this seems to work fine on my linux setup(I couldn't force a reproducer), pointer subtraction between pointers that we allocated separately is an undefined operation.
> I have run into problems with this on platforms other than linux.
> I am attaching a patch that removes the undefined operation.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)