Opened 9 years ago

Closed 8 years ago

Last modified 7 years ago

#9207 closed Bugs (invalid)

different sizeof atomic_count (boost/asio/detail/atomic_count.hpp) type after comilation with --std=c++11 than after comilation without --std=c++11 (gcc, x86_64).

Reported by: Karol Nowacki <karol.nowacki@…> Owned by: chris_kohlhoff
Milestone: To Be Determined Component: asio
Version: Boost 1.54.0 Severity: Problem
Keywords: Cc:

Description

atomic_count has different size when compiling with --std==c++11 (sizeof(long)) than compiling without --std=c++11 (sizof(int)). Hence classes which use atomic_count have different memory layout of members depending on --std compilation option. This leads to troubles when program is built from object files compiled with --std=c++11 and files compiled without --std=c++11.

This phenomena is not visible for clang (clang std lib contains std::atomic) Problem is also not visible on i386 (sizeof(long) == sizeof(int))

Problem exists in 1.54 and on the trunk.

In attached example task_io_service has different size in two compilation units. This leads to segmentation fault.

Attachments (1)

test.tar.gz (494 bytes ) - added by Karol Nowacki <karol.nowacki@…> 9 years ago.
program with segmentation fault due to different size of atomic_count in task_io_service class

Download all attachments as: .zip

Change History (3)

by Karol Nowacki <karol.nowacki@…>, 9 years ago

Attachment: test.tar.gz added

program with segmentation fault due to different size of atomic_count in task_io_service class

comment:1 by chris_kohlhoff, 8 years ago

Resolution: invalid
Status: newclosed

Don't mix and match language versions. Or if you really really must, define BOOST_ASIO_DISABLE_STD_ATOMIC.

comment:2 by leon@…, 7 years ago

The assertion that the phenomena is not visible if using clang is incorrect. The test program would crash on OS/X (10.10.4) with brew installed Boost 1.58.0, too.

Clang version:

mac: clang --version
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.4.0
Thread model: posix

Note: See TracTickets for help on using tickets.