Pdns: Boost 1.61 hides fcontext

Created on 2 Aug 2016  路  13Comments  路  Source: PowerDNS/pdns

Which means Recursor cannot use Boost Context on 1.61 and up.

defect rec

Most helpful comment

Fixes for this issues are merged in master (#4499) and in the re/rec-4.0.x branch (#4511). The upcoming 4.0.4 release will contains these fixes. @ncopa please try the master branch or the current pre-release tarball: https://downloads.powerdns.com/autobuilt/recursor/dist/pdns-recursor-4.0.3-8-g9e7120f.tar.bz2

All 13 comments

We've worked around this in our build by doing the following hack:

07:41 < ph1> Hey HAbbie, this is all we do to make boost 1.61 work for us: cp ${RPM_BUILD_DIR}/%{name}-%{version}/boost_1_61_0/boost/context/detail/fcontext.hpp 
             ${RPM_BUILD_DIR}/%{name}-%{version}/boost_1_61_0/boost/context/fcontext.hpp
07:41 < ph1> ./configure --with-boost=${RPM_BUILD_DIR}/%{name}-%{version}/boost_1_61_0/ --prefix=/usr --sysconfdir=/etc/powerdns

ph1's hack does not work for me on osx with brew boost 1.61.0:

In file included from mtasker_context.cc:6:
./mtasker_fcontext.cc:8:7: error: no member named 'make_fcontext' in namespace 'boost::context'; did you mean 'boost::context::detail::make_fcontext'?
using boost::context::make_fcontext;
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      boost::context::detail::make_fcontext
/usr/local/include/boost/context/fcontext.hpp:33:12: note: 'boost::context::detail::make_fcontext' declared here
fcontext_t make_fcontext( void * sp, std::size_t size, void (* fn)( transfer_t) );
           ^
In file included from mtasker_context.cc:6:
./mtasker_fcontext.cc:39:7: error: no member named 'fcontext_t' in namespace 'boost::context'; did you mean 'boost::context::detail::fcontext_t'?
using boost::context::fcontext_t;
      ^~~~~~~~~~~~~~~~~~~~~~~~~~
      boost::context::detail::fcontext_t
/usr/local/include/boost/context/fcontext.hpp:23:15: note: 'boost::context::detail::fcontext_t' declared here
typedef void* fcontext_t;
              ^
In file included from mtasker_context.cc:6:
./mtasker_fcontext.cc:40:7: error: no member named 'jump_fcontext' in namespace 'boost::context'; did you mean 'boost::context::detail::jump_fcontext'?
using boost::context::jump_fcontext;
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      boost::context::detail::jump_fcontext
/usr/local/include/boost/context/fcontext.hpp:31:12: note: 'boost::context::detail::jump_fcontext' declared here
transfer_t jump_fcontext( fcontext_t const to, void * vp);
           ^
In file included from mtasker_context.cc:6:
./mtasker_fcontext.cc:71:5: error: no matching function for call to 'jump_fcontext'
    jump_fcontext (reinterpret_cast<fcontext_t*>(&ctx->uc_mcontext),
    ^~~~~~~~~~~~~
/usr/local/include/boost/context/fcontext.hpp:31:12: note: candidate function not viable: requires 2 arguments, but 3 were provided
transfer_t jump_fcontext( fcontext_t const to, void * vp);
           ^
In file included from mtasker_context.cc:6:
./mtasker_fcontext.cc:84:5: error: no matching function for call to 'jump_fcontext'
    jump_fcontext (reinterpret_cast<fcontext_t*>(&ctx->uc_mcontext),
    ^~~~~~~~~~~~~
/usr/local/include/boost/context/fcontext.hpp:31:12: note: candidate function not viable: requires 2 arguments, but 3 were provided
transfer_t jump_fcontext( fcontext_t const to, void * vp);
           ^
In file included from mtasker_context.cc:6:
./mtasker_fcontext.cc:107:9: error: no matching function for call to 'jump_fcontext'
    if (jump_fcontext (reinterpret_cast<fcontext_t*>(&octx.uc_mcontext),
        ^~~~~~~~~~~~~
/usr/local/include/boost/context/fcontext.hpp:31:12: note: candidate function not viable: requires 2 arguments, but 3 were provided
transfer_t jump_fcontext( fcontext_t const to, void * vp);
           ^
In file included from mtasker_context.cc:6:
./mtasker_fcontext.cc:119:23: error: no matching function for call to 'make_fcontext'
    ctx.uc_mcontext = make_fcontext (&ctx.uc_stack[ctx.uc_stack.size()],
                      ^~~~~~~~~~~~~
/usr/local/include/boost/context/fcontext.hpp:33:12: note: candidate function not viable: no known conversion from 'void (*)(const intptr_t)' to 'void (*)(boost::context::detail::transfer_t)' for 3rd argument
fcontext_t make_fcontext( void * sp, std::size_t size, void (* fn)( transfer_t) );
           ^
In file included from mtasker_context.cc:6:
./mtasker_fcontext.cc:124:5: error: no matching function for call to 'jump_fcontext'
    jump_fcontext (reinterpret_cast<fcontext_t*>(&args.prev_ctx),
    ^~~~~~~~~~~~~
/usr/local/include/boost/context/fcontext.hpp:31:12: note: candidate function not viable: requires 2 arguments, but 3 were provided
transfer_t jump_fcontext( fcontext_t const to, void * vp);
           ^
8 errors generated.
make[2]: *** [mtasker_context.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

Yeah - I double checked my config log here. It works enough to find boost using this (which I believe I was having troubles with before), but the actual context ends up linking to system v ucontexts instead because nothing actually works.

Looks like this part was fixed in https://github.com/PowerDNS/pdns/pull/4052

Ah!

duplicate of #4053 ?

ok, if that is duplicate, then this needs to be reopened. It is more than simply namespace changes.
jump_fcontext has different API

I've noticed :crying_cat_face:

The root problem of the include hack mentioned by @phonedph1 is a wrong boost version check, I created a pull request (#4446) to fix the include (the fcontext incompatibility itself is still there)

@anthraxx the boost version header also needs to be included before the check. Also my hack was because the configure script wasn't picking it up properly - this part is indeed fixed now.

@phonedph1 good spot, for me it was already defined but technically you are correct: adjusted the pull request (#4446).
However for such patch related feedback please use the according pull-request next time :yum: I just left this message here to provide a "solution" to your hack and to reference the two issue/pull-request to each other :smile_cat:

Build fails on Alpine Linux (musl libc) too with boost-1.62.0. Since musl does not implement ucontext we can not either fall back to ucontext.

the boost 1.61.0 release notes says that "fcontext_t: no longer part of public API" so fcontext_t can no longer be used.

I don't know what the way forward is.

  CXX      mtasker_context.o
In file included from mtasker_context.cc:27:0:
mtasker_fcontext.cc:33:23: error: 'boost::context::make_fcontext' has not been declared
 using boost::context::make_fcontext;
                       ^~~~~~~~~~~~~
mtasker_fcontext.cc:64:23: error: 'boost::context::fcontext_t' has not been declared
 using boost::context::fcontext_t;
                       ^~~~~~~~~~
mtasker_fcontext.cc:65:23: error: 'boost::context::jump_fcontext' has not been declared
 using boost::context::jump_fcontext;
                       ^~~~~~~~~~~~~
mtasker_fcontext.cc:67:32: error: 'fcontext_t' was not declared in this scope
 static_assert (std::is_pointer<fcontext_t>::value,
                                ^~~~~~~~~~
mtasker_fcontext.cc:67:32: note: suggested alternative:
In file included from mtasker_fcontext.cc:27:0,
                 from mtasker_context.cc:27:
/usr/include/boost/context/detail/fcontext.hpp:23:17: note:   'boost::context::detail::fcontext_t'
 typedef void*   fcontext_t;
                 ^~~~~~~~~~
In file included from mtasker_context.cc:27:0:
mtasker_fcontext.cc:67:42: error: template argument 1 is invalid
 static_assert (std::is_pointer<fcontext_t>::value,
                                          ^
mtasker_fcontext.cc:75:5: error: 'fcontext_t' does not name a type
     fcontext_t prev_ctx = nullptr;
     ^~~~~~~~~~
mtasker_fcontext.cc: In function 'void threadWrapper(intptr_t)':
mtasker_fcontext.cc:96:37: error: 'fcontext_t' does not name a type
     jump_fcontext (reinterpret_cast<fcontext_t*>(&ctx->uc_mcontext),
                                     ^~~~~~~~~~
mtasker_fcontext.cc:96:47: error: expected '>' before '*' token
     jump_fcontext (reinterpret_cast<fcontext_t*>(&ctx->uc_mcontext),
                                               ^
mtasker_fcontext.cc:96:47: error: expected '(' before '*' token
mtasker_fcontext.cc:96:48: error: expected primary-expression before '>' token
     jump_fcontext (reinterpret_cast<fcontext_t*>(&ctx->uc_mcontext),
                                                ^
mtasker_fcontext.cc:97:32: error: 'fcontext_t' does not name a type
                    static_cast<fcontext_t>(args->prev_ctx), 0);
                                ^~~~~~~~~~
mtasker_fcontext.cc:97:50: error: 'struct args_t' has no member named 'prev_ctx'
                    static_cast<fcontext_t>(args->prev_ctx), 0);
                                                  ^~~~~~~~
mtasker_fcontext.cc:109:37: error: 'fcontext_t' does not name a type
     jump_fcontext (reinterpret_cast<fcontext_t*>(&ctx->uc_mcontext),
                                     ^~~~~~~~~~
mtasker_fcontext.cc:109:47: error: expected '>' before '*' token
     jump_fcontext (reinterpret_cast<fcontext_t*>(&ctx->uc_mcontext),
                                               ^
mtasker_fcontext.cc:109:47: error: expected '(' before '*' token
mtasker_fcontext.cc:109:48: error: expected primary-expression before '>' token
     jump_fcontext (reinterpret_cast<fcontext_t*>(&ctx->uc_mcontext),
                                                ^
mtasker_fcontext.cc:110:32: error: 'fcontext_t' does not name a type
                    static_cast<fcontext_t>(next_ctx),
                                ^~~~~~~~~~
mtasker_fcontext.cc: In function 'void pdns_swapcontext(pdns_ucontext_t&, const pdns_ucontext_t&)':
mtasker_fcontext.cc:132:41: error: 'fcontext_t' does not name a type
     if (jump_fcontext (reinterpret_cast<fcontext_t*>(&octx.uc_mcontext),
                                         ^~~~~~~~~~
mtasker_fcontext.cc:132:51: error: expected '>' before '*' token
     if (jump_fcontext (reinterpret_cast<fcontext_t*>(&octx.uc_mcontext),
                                                   ^
mtasker_fcontext.cc:132:51: error: expected '(' before '*' token
mtasker_fcontext.cc:132:52: error: expected primary-expression before '>' token
     if (jump_fcontext (reinterpret_cast<fcontext_t*>(&octx.uc_mcontext),
                                                    ^
mtasker_fcontext.cc:133:36: error: 'fcontext_t' does not name a type
                        static_cast<fcontext_t>(ctx.uc_mcontext), 0)) {
                                    ^~~~~~~~~~
mtasker_fcontext.cc:133:68: error: 'jump_fcontext' was not declared in this scope
                        static_cast<fcontext_t>(ctx.uc_mcontext), 0)) {
                                                                    ^
mtasker_fcontext.cc:133:68: note: suggested alternative:
In file included from mtasker_fcontext.cc:27:0,
                 from mtasker_context.cc:27:
/usr/include/boost/context/detail/fcontext.hpp:31:35: note:   'boost::context::detail::jump_fcontext'
 transfer_t BOOST_CONTEXT_CALLDECL jump_fcontext( fcontext_t const to, void * vp);
                                   ^~~~~~~~~~~~~
In file included from mtasker_context.cc:27:0:
mtasker_fcontext.cc:133:70: error: expected ')' before '{' token
                        static_cast<fcontext_t>(ctx.uc_mcontext), 0)) {
                                                                      ^
mtasker_fcontext.cc:136:1: error: expected primary-expression before '}' token
 }
 ^
mtasker_fcontext.cc: In function 'void pdns_makecontext(pdns_ucontext_t&, boost::function<void()>&)':
mtasker_fcontext.cc:145:73: error: 'make_fcontext' was not declared in this scope
                                      ctx.uc_stack.size(), &threadWrapper);
                                                                         ^
mtasker_fcontext.cc:145:73: note: suggested alternative:
In file included from mtasker_fcontext.cc:27:0,
                 from mtasker_context.cc:27:
/usr/include/boost/context/detail/fcontext.hpp:33:35: note:   'boost::context::detail::make_fcontext'
 fcontext_t BOOST_CONTEXT_CALLDECL make_fcontext( void * sp, std::size_t size, void (* fn)( transfer_t) );
                                   ^~~~~~~~~~~~~
In file included from mtasker_context.cc:27:0:
mtasker_fcontext.cc:149:37: error: 'fcontext_t' does not name a type
     jump_fcontext (reinterpret_cast<fcontext_t*>(&args.prev_ctx),
                                     ^~~~~~~~~~
mtasker_fcontext.cc:149:47: error: expected '>' before '*' token
     jump_fcontext (reinterpret_cast<fcontext_t*>(&args.prev_ctx),
                                               ^
mtasker_fcontext.cc:149:47: error: expected '(' before '*' token
mtasker_fcontext.cc:149:48: error: expected primary-expression before '>' token
     jump_fcontext (reinterpret_cast<fcontext_t*>(&args.prev_ctx),
                                                ^
mtasker_fcontext.cc:149:56: error: 'struct args_t' has no member named 'prev_ctx'
     jump_fcontext (reinterpret_cast<fcontext_t*>(&args.prev_ctx),
                                                        ^~~~~~~~
mtasker_fcontext.cc:150:32: error: 'fcontext_t' does not name a type
                    static_cast<fcontext_t>(ctx.uc_mcontext),
                                ^~~~~~~~~~
make[2]: *** [Makefile:936: mtasker_context.o] Error 1
make[2]: Leaving directory '/home/ncopa/aports/community/pdns-recursor/src/pdns-recursor-4.0.3'
make[1]: *** [Makefile:1060: all-recursive] Error 1
make[1]: Leaving directory '/home/ncopa/aports/community/pdns-recursor/src/pdns-recursor-4.0.3'
make: *** [Makefile:702: all] Error 2

Fixes for this issues are merged in master (#4499) and in the re/rec-4.0.x branch (#4511). The upcoming 4.0.4 release will contains these fixes. @ncopa please try the master branch or the current pre-release tarball: https://downloads.powerdns.com/autobuilt/recursor/dist/pdns-recursor-4.0.3-8-g9e7120f.tar.bz2

indeed. I manually applied the changes to mtasker_fcontext.cc and now it builds. Thanks!

Was this page helpful?
0 / 5 - 0 ratings