rakshasa/rtorrent — Issue #9: About crash on CentOS
Author: Novik
Created: 2011-11-30 10:26:29+00:00
State: open

See http://libtorrent.rakshasa.no/ticket/2115 for details.

In gdb wee may to see:

```
(gdb) s
rak::cacheline_allocator::alloc_size (size=8)
at ../rak/allocators.h:79
79 pointer ptr = NULL;
(gdb) n
80 int __UNUSED result = posix_memalign((void**)&ptr, LT_SMP_CACHE_BYTES, size);
(gdb) n
82 return ptr;
(gdb) p result
$6 = 22
(gdb) p ptr
$7 = (rak::priority_item **) 0x0
(gdb) p size
$8 = 8
(gdb) p LT_SMP_CACHE_BYTES
$9 = 1
(gdb) bt
#0 rak::cacheline_allocator::alloc_size (size=8)
at ../rak/allocators.h:82
#1 0x00002aaaaaf6c5e7 in rak::cacheline_allocator::allocate (this=0x2aaaab2ca680, num=1, hint=0x0) at ../rak/allocators.h:76
#2 0x00002aaaaaf6c60f in std::_Vector_base >::_M_allocate (this=0x2aaaab2ca680, __n=1)
at /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:127
#3 0x00002aaaaaf6c79c in std::vector >::_M_insert_aux (this=0x2aaaab2ca680, __position=Cannot access memory at address 0x0
)
at /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/vector.tcc:275
#4 0x00002aaaaaf6c9f0 in std::vector >::push_back (this=0x2aaaab2ca680,
__x=@0x7fffffffe290)
at /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:610
#5 0x00002aaaaaf6ca10 in rak::priority_queue, rak::cacheline_allocator >::push (this=0x2aaaab2ca680, value=@0x7fffffffe290)
at ../rak/priority_queue.h:77
#6 0x00002aaaaaf6cf8e in rak::priority_queue_insert (queue=0x2aaaab2ca680,
item=0x820d98, t=...) at ../rak/priority_queue_default.h:116
#7 0x00002aaaaaf69571 in torrent::Manager::Manager (this=0x820d20)
at manager.cc:89
#8 0x00002aaaaaf8aa54 in torrent::initialize (poll=0x8124b0) at torrent.cc:104
#9 0x0000000000412aab in main (argc=1, argv=0x7fffffffe998) at main.cc:198
```

e.q. LT_SMP_CACHE_BYTES is setted to 1, this is a invalid value.

And yes, in config.h (after configure) we may to see:

```
#define LT_SMP_CACHE_BYTES 1
```

For avoid this you must remove the superfluous comma in files libtorrent/scripts/common.m4 and rtorrent/scripts/common.m4, e.q. replace lines

AC_DEFINE(LT_SMP_CACHE_BYTES, 128, Largest L1 cache size we know of, should work on all archs.)

to

AC_DEFINE(LT_SMP_CACHE_BYTES, 128, Largest L1 cache size we know of)

and all will be OK.