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

Hudson commented on HDFS-9265:
------------------------------

SUCCESS: Integrated in Jenkins build Hadoop-trunk-Commit #13869 (See 
[https://builds.apache.org/job/Hadoop-trunk-Commit/13869/])
HDFS-9265. InputStreamImpl should hold a shared_ptr of the BlockReader. 
(james.clampffer: rev a14d1f741ff7c83bd80aa73ce95a82e6c3032e96)
* (edit) 
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/inputstream_impl.h


> InputStreamImpl should hold a shared_ptr of the BlockReader
> -----------------------------------------------------------
>
>                 Key: HDFS-9265
>                 URL: https://issues.apache.org/jira/browse/HDFS-9265
>             Project: Hadoop HDFS
>          Issue Type: Sub-task
>          Components: hdfs-client
>            Reporter: James Clampffer
>            Assignee: James Clampffer
>            Priority: Blocker
>             Fix For: HDFS-8707
>
>         Attachments: HDFS-9265.HDFS-8707.000.patch
>
>
> The remote block reader relies on undefined behavior in how it uses 
> enable_shared_from_this.
> http://en.cppreference.com/w/cpp/memory/enable_shared_from_this
> The spec states a shared_ptr to an object inheriting from 
> enable_shared_from_this must be live before calling make_shared_from_this.  
> Calling make_shared_from_this without an existing shared_ptr is undefined 
> behavior and causes deterministic crashes when the code is built with GCC.
> example:
> class foo : public enable_shared_from_this {/*bar*/};
> safe:
> auto ptr1 = std::make_shared<foo>();
> auto ptr2 = foo->make_shared_from_this();
> broken:
> foo *ptr = new foo();
> auto ptr2 = foo->make_shared_from_this(); //no existing live shared_ptr
> In order to fix the input stream should call std::make_shared and hang onto a 
> shared_ptr to the block reader.  The block reader will then be free to call 
> make_shared_from this as much as it wants without issue.  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to