X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:subject:to:date:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=IFF PaQq3eoabRuyeybgOLVnAlAjhdzNL8GPRD3dRMa1OkEOasFuThwK60UEEHskmMLO SJ4qs4ZYazwkJSmkQWXCwQbaldWMRUefiBYmaAxVa3H3Pgkk1KHejgJmZ6XhQVB6 UPxFuXBL6XmN0JBK9XkoqZW0VVNPeopR8WNEVXZ4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:subject:to:date:message-id:mime-version :content-type:content-transfer-encoding; s=default; bh=IuxO089xa mtBvpzxqP56ujcAcuw=; b=aDmit+0OBBcxt1/SKW3rIuMJ5OeEVQ+PVdIC+8klf 5pk4EiDD9ND+cOCkP/fP+iUr+rLTI68EomQrYuwOxgvovl/ggn/nbzvbCyr7mS/8 xeRIfIBWrz58exgBYfb0x4mYCFDXUPRdB+3BwayGhACq6rQZKTQ4LMyBWrpFKzKL 0A= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=4.1 required=5.0 tests=BAYES_60,CHARSET_FARAWAY_HEADER,RP_MATCHES_RCVD,SPF_PASS autolearn=no version=3.3.2 X-HELO: smtpout.ngs.ru From: "=?KOI8-R?Q?=F2=CF=CD=C1=CE?=" Subject: Errors in handling of boost::asio errors ('boost' was compiled with wrong std::string representation?) To: cygwin AT cygwin DOT com Date: Sat, 21 Nov 2015 11:33:20 +0600 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="KOI8-R"; format="flowed" Content-Transfer-Encoding: 8bit X-KLMS-Rule-ID: 1 X-KLMS-Message-Action: clean X-KLMS-AntiSpam-Lua-Profiles: 75324 [Mar 30 2015] X-KLMS-AntiSpam-Version: 5.5.4 X-KLMS-AntiSpam-Envelope-From: rod1gin AT ngs DOT ru X-KLMS-AntiSpam-Rate: 0 X-KLMS-AntiSpam-Status: not_detected X-KLMS-AntiSpam-Method: none X-KLMS-AntiSpam-Info: LuaCore: 175 2015-03-18_14-10-30 59b0fb5d1fe0bc13ab72a23d6aa445f4185e0a58, Auth:dkim=none X-KLMS-AntiSpam-Interceptor-Info: scan successful X-KLMS-AntiPhishing: Clean, 2015/03/25 07:44:58 X-KLMS-AntiVirus: Kaspersky Security 8.0 for Linux Mail Server, version 8.0.1.705, bases: 2015/03/29 19:07:00 #10436451 X-KLMS-AntiVirus-Status: Clean, skipped Following program: --------------- begin of code #include #include 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 #include 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