You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-dev@hadoop.apache.org by "James Clampffer (JIRA)" <ji...@apache.org> on 2015/10/19 18:04:05 UTC

[jira] [Created] (HDFS-9265) Use of undefined behavior in remote_block_reader causing deterministic crashes.

James Clampffer created HDFS-9265:
-------------------------------------

             Summary: Use of undefined behavior in remote_block_reader causing deterministic crashes.
                 Key: HDFS-9265
                 URL: https://issues.apache.org/jira/browse/HDFS-9265
             Project: Hadoop HDFS
          Issue Type: Sub-task
            Reporter: James Clampffer
            Priority: Blocker


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






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