[Boost-bugs] [Boost C++ Libraries] #11918: access violation when using string literals with lambda style formatting expressions

Subject: [Boost-bugs] [Boost C++ Libraries] #11918: access violation when using string literals with lambda style formatting expressions
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-01-17 14:44:24


#11918: access violation when using string literals with lambda style formatting
expressions
-----------------------------------------+------------------------
 Reporter: Stefan Mianome <smianome@…> | Owner: andysem
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: log
  Version: Boost 1.60.0 | Severity: Regression
 Keywords: formatting |
-----------------------------------------+------------------------
 The code below crashes with an access violation when using the
 BOOST_LOG_SEV macro. I'm using boost 1.60 compiled with msvc-10.0.
 {{{#!c++
     #include <boost/log/trivial.hpp>
     #include <boost/log/sinks.hpp>
     #include <boost/log/expressions.hpp>
     #include <boost/log/expressions/formatters.hpp>
     #include <boost/log/attributes.hpp>
     #include <boost/core/null_deleter.hpp>
     #include <iostream>

     #define BOOST_TEST_MODULE TestsLogging
     #include <boost/test/unit_test.hpp>
         BOOST_AUTO_TEST_SUITE(example_lib_log)

         BOOST_AUTO_TEST_CASE(severity_logging_min) {

                 namespace src = ::boost::log::sources;
                 namespace keywords = ::boost::log::keywords;
                 namespace expr = boost::log::expressions;
                 namespace attributes = boost::log::attributes;

                 //sink backend setup
                 typedef boost::log::sinks::text_ostream_backend
 text_ostream_backend;

                 boost::shared_ptr<text_ostream_backend> backend =
                         boost::make_shared<text_ostream_backend>();

 backend->add_stream(boost::shared_ptr<std::ostream>(&std::cerr,
 boost::null_deleter()));
                 backend->auto_flush(true);

                 //sink frontend setup
                 typedef
 boost::log::sinks::synchronous_sink<text_ostream_backend>
 synchronous_sink_text_ostream_backend;

                 boost::shared_ptr<synchronous_sink_text_ostream_backend>
 sink(new synchronous_sink_text_ostream_backend(backend));

                 sink->set_formatter(expr::stream << "[" << expr::message);
 //problem is here

                 boost::log::core::get()->add_sink(sink);

                 //logger setup
                 typedef
 src::severity_logger<boost::log::trivial::severity_level> severity_logger;

                 severity_logger lg;

                 //logging function
                 BOOST_LOG_SEV(lg, boost::log::trivial::debug) << "First
 entry."; //exception happens here

                 boost::log::core::get()->remove_sink(sink);
         }
     BOOST_AUTO_TEST_SUITE_END()
 }}}
  - When I remove the line where the formatter for the sink is set, the
 code works fine.
  - When I remove the string literal "[" from the stream (expr::stream <<
 expr::message), the code works fine.
  - When i move the string literal to the end (expr::stream <<
 expr::message << "[") the code also works.
  - The code works with boost 1.57.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11918>
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 : 2017-02-16 18:50:19 UTC