[Boost-bugs] [Boost C++ Libraries] #13585: Undefined Behavior results in optimizer removing critical check

Subject: [Boost-bugs] [Boost C++ Libraries] #13585: Undefined Behavior results in optimizer removing critical check
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2018-05-31 21:16:23


#13585: Undefined Behavior results in optimizer removing critical check
------------------------------+-------------------------
 Reporter: bart.wyatt@… | Owner: Beman Dawes
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: filesystem
  Version: Boost 1.67.0 | Severity: Problem
 Keywords: |
------------------------------+-------------------------
 We have been experiencing an odd BAD_ACCESS when calling
 boost::filesystem::copy(const path& from, const path& to)

 the symptom is a null pointer dereference when converting *ec to a bool at
 operations.cpp:894. However, this is preceeded by a check to ensure the
 ec != 0 which is being subverted.

 The working theory is that on operations.cpp:893 a potentially null
 pointer to a boost::system::error_code is dereferenced and assigned to a
 reference as part of symlink_status(from, *ec) which is *undefined
 behavior*.

 As a result, the optimizer seems to be removing the "ec != 0" check from
 the next line based on the knowledge that if ec had been null it would
 have resulted in undefined behavior already. This of course leads to the
 null ec being dereferenced and having its bool conversion called. In
 turn, this creates a bad access and abort.

-- 
Ticket URL: <https://svn.boost.org/trac10/ticket/13585>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2018-05-31 21:22:19 UTC