Boost::coroutine2 and compiling for ASAN problems

tjisana (泰志) via Boost-users <[email protected]>
Newsgroups gmane.comp.lib.boost.user
Message-ID <CAGXaPtBT1G2wv9aNmaO-m6AiKyNUwdFuuexrhKgHV5LqBCkOMw@mail.gmail.com>
Team,

I'm trying to get a simple coroutine2 program to work with address
sanitizer and I'm running into a block.  I'm building boost_1_78_0 as
follows: ./b2 context-impl=ucontext and compiling with -DBOOST_USE_ASAN and
-DBOOST_USE_CONTEXT.  I've built and rebuilt the library thinking I've made
an error somewhere and it boils down to jump_fcontext and make_fcontext.
What am I doing wrong/missing?

Cheers,

TJ


g++ -DBOOST_USE_ASAN -DBOOST_USE_UCONTEXT
-I/home/tjisana/Downloads/boost_1_78_0 -O0 -g3 -fsanitize=address -pedantic
-Wall -c -fmessage-length=0 -o src/Testbed II.o ../src/Testbed II.cpp
g++ -L/home/tjisana/Downloads/boost_1_78_0/stage/lib -fsanitize=address -o
Testbed II src/Testbed II.o -lboost_context -lboost_coroutine
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld:
/home/tjisana/Downloads/boost_1_78_0/stage/lib/libboost_coroutine.so:
undefined reference to `jump_fcontext'
/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld:
/home/tjisana/Downloads/boost_1_78_0/stage/lib/libboost_coroutine.so:
undefined reference to `make_fcontext'
collect2: error: ld returned 1 exit status


#include <queue>

#include <memory>

#include "boost/coroutine2/coroutine.hpp"


typedef boost::coroutines2::coroutine<int> coro_t;



int main() {

                int l = 0;

                std::queue<int> y({1,2,3,4});

                std::queue<std::unique_ptr<int>> w;



                coro_t::push_type sink([&](coro_t::pull_type& source) {

                                for (const auto& i : source) {

                                                while (!w.empty()) {

                                                                auto ptr =
std::move(w.front());

                                                                w.pop();

                                                                 if (*ptr
== 1) {


std::cout << "first: " << i << std::endl;




auto item = 21;


w.push(std::move(std::make_unique<int>(item)));

                                                                }

                                                                else if
(*ptr == 21) {


std::cout << "second: " << i+2*i << std::endl;




auto item = 32;


w.push(std::move(std::make_unique<int>(item)));

                                                                }

                                                                else if
(*ptr == 32) {


std::cout << "third: " << i*i << std::endl;

                                                                }

                                                }

                                }

                                source();

                });



                while (!y.empty()) {

                                if (!y.empty()) {

                                                l = y.front();

                                                y.pop();




w.push(std::move(std::make_unique<int>(1)));

                                                sink(l);

                                }

                }



                return 0;

}

_______________________________________________
Boost-users mailing list
[email protected]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.