Boost function "boost::property_tree::ini_parser::read_ini" causing "EXC_BAD_ACCESS (code=EXC_I386_GPFLT)"
<p>I have a simple source like this that build and executes correctly under Windows 10 with Visual Studio 2015 but throws "EXC_BAD_ACCESS (code=EXC_I386_GPFLT)" under OsX 10.11.3 with Xcode 7.2.1:</p>

<pre><code>#include &lt;boost/property_tree/ini_parser.hpp&gt;
#include &lt;boost/property_tree/ptree.hpp&gt;
#include &lt;boost/property_tree/json_parser.hpp&gt;
#include &lt;iostream&gt;
using namespace std;

int main(int argc, char* argv[])
{    
    if (argc != 3)
    {
        std::cerr &lt;&lt; "Usage: program rootPath iniFileName" &lt;&lt; std::endl ;
        return 1;
    }        

    string mainPath(argv[1]) ;
    string iniFileName(argv[2])  ;

    boost::property_tree::ptree pt;
    try
    {
        boost::property_tree::ini_parser::read_ini(mainPath + iniFileName, pt);
    }
    catch(const boost::property_tree::ptree_error &amp;e)
    {
        cout &lt;&lt; e.what() &lt;&lt; endl;
    }

     return 0;
}
</code></pre>

<p>This is the stack trace: </p>

<pre><code>Thread 1Queue : com.apple.main-thread (serial) #0 0x00000001000a10c0 in std::1::basic_streambuf&lt;char, std::1::char_traits&lt;char&gt; &gt;::pubimbue(std::1::locale const&amp;) [inlined] at /Applications/Xcode?.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/streambuf:227 #1 0x00000001000a10c0 in std::1::basic_ios&lt;char, std::1::char_traits&lt;char&gt; &gt;::imbue(std::1::locale const&amp;) [inlined] at /Applications/Xcode?.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ios:717 #2 0x00000001000a100b in void boost::property_tree::ini_parser::read_ini&lt;boost::property_tree::basic_ptree&lt;std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::1::allocator&lt;char&gt; &gt;, std::1::basic_string&lt;char, std::1::char_traits&lt;char&gt;, std::1::allocator&lt;char&gt; &gt;, std::1::less&lt;std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::1::allocator&lt;char&gt; &gt; &gt; &gt; &gt;(std::1::basic_string&lt;char, std::1::char_traits&lt;char&gt;, std::1::allocator&lt;char&gt; &gt; const&amp;, boost::property_tree::basic_ptree&lt;std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::1::allocator&lt;char&gt; &gt;, std::1::basic_string&lt;char, std::1::char_traits&lt;char&gt;, std::1::allocator&lt;char&gt; &gt;, std::1::less&lt;std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::1::allocator&lt;char&gt; &gt; &gt; &gt;&amp;, std::1::locale const&amp;) at /Users/andreagiovacchini/Documents/Sviluppo/boost_1_60_0/boost/property_tree/ini_parser.hpp:167 #3 0x0000000100124a36 in main at /Users/andreagiovacchini/Documents/Sviluppo/Test/Test/main.cpp:21 #4 0x00007fff857245ad in start () 
</code></pre>

<p>Problem comes from "stream.imbue(loc);" line in ini_parser.php from this function: </p>

<pre><code>template&lt;class Ptree&gt;
    void read_ini(const std::string &amp;filename, 
                  Ptree &amp;pt,
                  const std::locale &amp;loc = std::locale())
    {
        std::basic_ifstream&lt;typename Ptree::key_type::value_type&gt;
            stream(filename.c_str());
        if (!stream)
            BOOST_PROPERTY_TREE_THROW(ini_parser_error(
                "cannot open file", filename, 0));
        stream.imbue(loc);
        try {
            read_ini(stream, pt);
        }
        catch (ini_parser_error &amp;e) {
            BOOST_PROPERTY_TREE_THROW(ini_parser_error(
                e.message(), filename, e.line()));
        }
    }
</code></pre>

<p>Since I can't see how my code can generate this kind of problem I think it is a Boost bug.</p>

<p>I've tryed filing a bug on Boost (<a href="https://svn.boost.org/trac/boost/ticket/11963" rel="nofollow">https://svn.boost.org/trac/boost/ticket/11963</a>) but looks like the property_tree bugs are not taken care a lot</p>