Boost logo

Boost :

Subject: Re: [boost] [Stacktrace] Second review begins today 17th Mar ends 26th Mar
From: Peter Dimov (lists_at_[hidden])
Date: 2017-03-17 17:30:22


> You can find the documentation at
> http://apolukhin.github.io/stacktrace/index.html and the github repo
> at https://github.com/apolukhin/stacktrace.

The heuristic that skips 3 frames (under Windows) doesn't quite work. It
seems that MSVC in whole program optimization mode ignores BOOST_NOINLINE
directives and makes inline decisions that differ in unpredictable ways
between compiles. This program, for instance:

#include <boost/stacktrace.hpp>
#include <iostream>
#include <algorithm>
#include <functional>

void g( int x )
{
    boost::stacktrace::stacktrace st( -3, -1 );
    std::cout << st << std::endl;
}

void f( int x )
{
    std::function<void(int)> h( g );
    std::for_each( &x, &x + 1, g );
}

int main()
{
    f( 1 );
}

gives this trace:

0# boost::stacktrace::detail::this_thread_frames::collect at
c:\projects\boost-git\boost\boost\stacktrace\detail\frame_msvc.ipp:48
1# g at c:\projects\testbed2017\testbed2017.cpp:9
2# main at c:\projects\testbed2017\testbed2017.cpp:20
3# __scrt_common_main_seh at
f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:259
4# BaseThreadInitThunk in kernel32
5# RtlInitializeExceptionChain in ntdll
6# RtlInitializeExceptionChain in ntdll

With the default constructor, #0, #1 and #2 disappear and nothing useful
remains.

There should probably be a way to optionally remove the +1 and +2 hardcoded
skips because passing a nonportable -3 to a size_t is not exactly a best
practice.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk