You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficserver.apache.org by "Brian Geffon (JIRA)" <ji...@apache.org> on 2015/11/10 07:40:11 UTC

[jira] [Closed] (TS-4007) ClassAllocator: don't attempt to destruct the prototype object when ClassAllocator goes out of scope.

     [ https://issues.apache.org/jira/browse/TS-4007?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Brian Geffon closed TS-4007.
----------------------------
    Resolution: Fixed

> ClassAllocator: don't attempt to destruct the prototype object when ClassAllocator goes out of scope.
> -----------------------------------------------------------------------------------------------------
>
>                 Key: TS-4007
>                 URL: https://issues.apache.org/jira/browse/TS-4007
>             Project: Traffic Server
>          Issue Type: Bug
>          Components: Core
>            Reporter: Brian Geffon
>            Assignee: Brian Geffon
>             Fix For: 6.1.0
>
>
> Today in the ClassAllocator class the prototype object which is used to construct new objects of the same type is allocated within the object when the process ends the destructor for ClassAllocator is called and subsequently the destructor for the prototype object C. In situations where the process is ending as a result of a startup failure this can result in a segfault if the object isn't properly initialized (this happened recently with SPDY), the destructor for the prototype object should never be called. There are two approaches to solving this problem, the first would be to heap allocate the prototype object and never call delete. This isn't ideal because then the prototype object resides in memory that is (presumably) very far away from the ClassAllocator. The other solution and the one that we'll commit is to use a uint8_t array that is large enough to hold an object of type C and do a placement new. This will properly construct the prototype, it will still remain within the ClassAllocator object, and finally it guarantees the destructor won't be called (which is again safe for ClassAllocators).



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