Test stack_test is LittleEndian dependant
- Dominant language
- C++
- Stars
- 160
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
Running the test **stack_test** on AIX, which is BigEndian, I see that it fails while running the test **fixed_size_stack_test_exhausted** .
```
../libs/lockfree/test/stack_test.cpp :
85 BOOST_AUTO_TEST_CASE( fixed_size_stack_test_exhausted )
86 {
87 boost::lockfree::stack > stk;
88
89 stk.push(1);
90 stk.push(2);
....
```
The first stk.push(1) seems OK, but not really, since:
```
../boost/lockfree/detail/freelist.hpp:552
552 tagged_index new_pool(next_index->get_index(), old_pool.get_next_tag());
(gdb) whatis next_index
type = boost::lockfree::detail::tagged_index *
AIX:
(gdb) p * next_index
$12 = {index = 0, tag = 1}
Linux:
(gdb) p * next_index
$14 = {index = 0, tag = 65535}
```
Then, stk.push(2) does not put correct values in stk.
Main differences between Fedora/x86_64 and AIX after line stk.push(2) are:
- padding is 60 on Fedora and 124 on AIX (compiled in 64bit too)
- stk.pool.pool_._M_i = {index = 2, tag = 2} On Fedora but : {index = 0, tag = 0} on AIX.
On **Fedora/x86_64**:
```
stk = {static has_capacity = true, static capacity = 2, static fixed_sized = false, static node_based = false, static compile_time_sized = true,
tos = { static _S_min_alignment = 4, static _S_alignment = 4, _M_i = {index = 0, tag = 0}},
static padding_size = 60,
padding = ...........,
pool = { >::node, 2>>
= {data = {
elems = .......}},
pool_ = {static _S_min_alignment = 4, static _S_alignment = 4, _M_i = {index = 2, tag = 2}}}}
```
On **AIX**:
```
stk = {static has_capacity = true, static capacity = 2, static fixed_sized = false, static node_based = false, static compile_time_sized = true,
tos = { static _S_min_alignment = 4, static _S_alignment = 4, _M_i = {index = 0, tag = 0}},
static padding_size = 124,
padding = ........,
pool = { >::node, 2>>
= {data = { elems = ..........}},
pool_ = {static_S_min_alignment = 4, static _S_alignment = 4, _M_i = {index = 0, tag = 0}}}}
```
However, looking at details with gdb:
**Fedora/x86_64**:
```
(gdb) p & stk.pool.pool_._M_i
$54 = (boost::lockfree::detail::tagged_index *) 0x7fffffffc1c0
(gdb) x/2x 0x7fffffffc1c0
0x7fffffffc1c0: 0x00020002 0x00000000
```
**AIX**:
```
(gdb) p & stk.pool.pool_._M_i
$12 = (boost::lockfree::detail::tagged_index *) 0xfffffffffffdb08
(gdb) x/4x 0xfffffffffffdb08
0xfffffffffffdb08: 0x00000000 0x00000002 0x00020001 0x001baca8
```
So, it seems that the code does not write the 0x00020002 value at the right place on AIX.
This is probably due to the following code:
```
boost/lockfree/detail/freelist.hpp :
class
BOOST_ALIGNMENT( 4 ) // workaround for bugs in MSVC
tagged_index
{
public:
typedef boost::uint16_t tag_t;
typedef boost::uint16_t index_t;
...
protected:
index_t index;
tag_t tag;
};
```
since using 16bit has already shown within another library of Boost that it does not work fine in BigEndian.
Note: On Fedora/PPC64LE (PowerPC LittleEndian), this works fine.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with boost/lockfree/test/stack_test.cpp, especially fixed_size_stack_test_exhausted, and inspect tagged_index and its updates in boost/lockfree/detail/freelist.hpp. Compare the AIX big-endian layout and values with Fedora/x86_64, then run the stack test on a big-endian system. Done means the test passes without incorrect stack values on AIX or another big-endian target.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100