Languages

Menu
Sites
Language
runtime error on boost asio example

I try to build native app with libboost 1.51.0 
 

I add some missing boost library files to tizen-sdk\platforms\tizen2.2\rootstraps\tizen-device-2.2.native\usr\include\boost and ..\..\..\libs,
from 
http://download.tizen.org/releases/2.2/tizen-2.2/repos/tizen-main/armv7l/packages/armv7l/libboost*.rpm (that extract .hpp and .so, .a with 7zip)

 

Anyway, I can build with `native-make.bat`. 

and I use 'http://www.boost.org/doc/libs/1_51_0/doc/html/boost_asio/example/chat/chat_client.cpp' source code. 
It compiled and link well : )

 

But, when I sdb push output to device, and chmod, launch with root permission,
It seems run well, but if I type something It crashed with following error.

sh-4.1# ./chat_client 54321
./chat_client 54321
54321
54321
crashed [1390706381] processname=chat_client, pid=8574, tid=8575, signal=4[sys-assert]dladdr returnes error!
Illegal instruction (core dumped)
sh-4.1# 

 

I dig some more, and I know that following line is the issue point. (without post, It doesn't crashed.)

io_service_.post(boost::bind(&chat_client::do_write, this, msg));

 

Is it a my fault? or what? I dont know what to do...
Anybody knows simillar issue?

 

PS. Sorry for my bad english. ; )

Responses

1 Replies
승례 안

I figure this out.

I guess, It is the differences of llvm compiler (clang++) 's behavior and gcc's .
(I use llvm's)

Just change following lines

void write(const chat_message& msg)
  {
    io_service_.post(boost::bind(&chat_client::do_write, this, msg));
  }

to

void write(const chat_message& msg)
  {
    io_service_.post(boost::bind(&chat_client::do_write, this, &msg));
  }

 

and

  void do_write(chat_message msg)
  {
    bool write_in_progress = !write_msgs_.empty();
    write_msgs_.push_back(msg);
    if (!write_in_progress)
    {
      boost::asio::async_write(socket_,
          boost::asio::buffer(write_msgs_.front().data(),
            write_msgs_.front().length()),
          boost::bind(&chat_client::handle_write, this,
            boost::asio::placeholders::error));
    }
  }

to 

  void do_write(chat_message *msg)
  {
    bool write_in_progress = !write_msgs_.empty();
    write_msgs_.push_back(*msg);
    if (!write_in_progress)
    {
      boost::asio::async_write(socket_,
          boost::asio::buffer(write_msgs_.front().data(),
            write_msgs_.front().length()),
          boost::bind(&chat_client::handle_write, this,
            boost::asio::placeholders::error));
    }
  }

 

plz. Somebody let me know the exact reason.