You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Anatoly Fayngelerin (JIRA)" <ji...@apache.org> on 2011/07/29 15:41:24 UTC

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

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: Anatoly Fayngelerin
             Fix For: 0.7
         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 is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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

Posted by "Anatoly Fayngelerin (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-1248?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Anatoly Fayngelerin updated THRIFT-1248:
----------------------------------------

    Attachment: 0_7_0_ptrdiff.patch

> 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: Anatoly Fayngelerin
>             Fix For: 0.7
>
>         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 is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira