From: Роман <rod1gin@ngs.ru>
To: cygwin@cygwin.com
Subject: Errors in handling of boost::asio errors ('boost' was compiled with wrong std::string representation?)
Date: Sat, 21 Nov 2015 05:33:00 -0000 [thread overview]
Message-ID: <web-32611685@mx27.intranet.ru> (raw)
Following program:
--------------- begin of code
#include <stdio.h>
#include <boost/system/error_code.hpp>
int main()
{
std::string s =
boost::system::generic_category().message(22);
printf("size=%lu, c_str=\"%s\".\n",
s.size(),
s.c_str());
return 0;
}
--------------- end of code
Give out following output:
--------------- begin of output
size=1628781863, c_str="Invalid argument".
--------------- end of output
If I try to use such string, for example:
std::string a("");
a += s;
program crashes.
The program was compiled from cygwin command line by
following commands:
--------------- begin of commands
g++ -c test.cpp
gcc -s test.o -lstdc++ -lboost_system
--------------- end of commands
I used fresh installed cygwin with following additional
packages:
Devel / gcc-core 5.2.0-1
Devel / gcc-g++ 5.2.0-1
Libs / libgcc1 5.2.0-1
Libs / libstdc++6 5.2.0-1
Devel / make 4.1-1
Libs / libboost-devel 1.58.0-1
Operating system: Windows XP, 32 bits, russian language
Processor: Intel Pentium 4 (3 GHz)
Version of installator: setup-x86.exe, 2.873
With libboost-devel 1.57.0-1 effect is the same.
With Windows 7, 64 bit, russian language, effect is the
same (with 32-bit and with 64-bit cygwin), with the
exception that another wrong values are exposed for
'size'.
When I compile boost from sources ('boost_1_59_0.7z' from
boost org), the same program is running as proper:
--------------- begin of correct output
size=16, c_str="Invalid argument".
--------------- end of correct output
Constant '22' corresponds to
'boost::asio::error::invalid_argument'. Some other ASIO
error codes also brings to the same effect. Aforementioned
code is used in handling of exceptions from ASIO functions
and brings to crashes in various unpredictable situations.
There is more real-life piece of code that produce same
error:
--------------- begin of example #2
#include <stdio.h>
#include <boost/asio.hpp>
int main()
{
boost::asio::ip::address_v4 a;
boost::system::error_code ec;
a.from_string("127.0.0.1111", ec);
std::string s = ec.message();
printf("size=%lu, c_str=\"%s\".\n",
s.size(),
s.c_str());
return 0;
}
--------------- end of example #2
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
next reply other threads:[~2015-11-21 5:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-21 5:33 Роман [this message]
2015-11-22 17:22 ` John Hein
2015-11-23 16:32 Роман
2015-11-24 8:18 Роман
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=web-32611685@mx27.intranet.ru \
--to=rod1gin@ngs.ru \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).