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

Zoltán Borók-Nagy resolved ORC-586.
-----------------------------------
    Fix Version/s: 1.7.0
                   1.6.3
       Resolution: Fixed

> [C++] Memory leak in StructColumnReader
> ---------------------------------------
>
>                 Key: ORC-586
>                 URL: https://issues.apache.org/jira/browse/ORC-586
>             Project: ORC
>          Issue Type: Bug
>            Reporter: Zoltán Borók-Nagy
>            Assignee: Zoltán Borók-Nagy
>            Priority: Major
>             Fix For: 1.6.3, 1.7.0
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> StructColumnReader can leak memory if its constructor throws an exception.
> StructColumnReader has a member vector<ColumnReader*> called 'children' which 
> is filled in the constructor:
> [https://github.com/apache/orc/blob/c26ff4c351d7c34c4272442a6874703f510282a8/c%2B%2B/src/ColumnReader.cc#L874]
> {noformat}
>   for(unsigned int i=0; i < type.getSubtypeCount(); ++i) {
>     const Type& child = *type.getSubtype(i);
>     if (selectedColumns[static_cast<uint64_t>(child.getColumnId())]) {
>       children.push_back(buildReader(child, stripe).release());
>     }
>   }
> {noformat}
> buildReader() returns a unique_ptr, but the constructor calls release() on it 
> which returns the underlying raw pointer and in the meantime the unique_ptr 
> releases the ownership.
> StructColumnReader's destructor is supposed to invoke delete on these raw 
> pointers, but if an exception is thrown during the construction of a 
> StructColumnReader, then only the destructors of the member variables are 
> called. Therefore the vector gets destroyed, but the ColumnReader objects are 
> leaked.
> The solution is to store unique_ptrs in the vector instead of raw pointers.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to