core on 64bit arch in spirit ... lex_lexertl2-p3 test

Bug #1282140 reported by Tony Reix
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
boost1.55 (Ubuntu)
New
Undecided
Unassigned

Bug Description

Test :
         ./boost1.55-1.55.0/bin.v2/libs/spirit/test/lex_lexertl2-p3.test/gcc-4.8/debug/phoenix_v3-on/lex_lexertl2-p3

SegFaults on 64 bits machines (AMD64 and PPC64).

The issue is that :
           CharT curr_char_ = (std::numeric_limits<CharT>::min)();
returns
           0x80000000
when CharT is wchar_t .

And curr_char (0x80000000) is then used in:
           ptr_[curr_char_]
which cores.

I think that some macros have been defined in /usr/include/c++/4.8.2/limits that work fine for "char" type but not for "wchar_t" type in 64bits world.

 min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min(char); } returns 0 .
 min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min(wchar_t); } returns 0x80000000 .

So, that could be an issue in libC++ . Or not. I'm not an expert and I need someone to look at this.

See PPC64/BE part for more details (values of registers and names of files).

=========================================================

On AMD64 (Ubuntu 14.04):

gdb ./boost1.55-1.55.0/bin.v2/libs/spirit/test/lex_lexertl2-p3.test/gcc-4.8/debug/phoenix_v3-on/lex_lexertl2-p3

(gdb) break generator.hpp:564
Breakpoint 1 at 0x424945: generator.hpp:564. (2 locations)

(gdb) run
Starting program: /home/ubuntu/BOOST/boost1.55/boost1.55-1.55.0/bin.v2/libs/spirit/test/lex_lexertl2-p3.test/gcc-4.8/debug/phoenix_v3-on/lex_lexertl2-p3

Breakpoint 1, boost::lexer::basic_generator<char, boost::lexer::char_traits<char> >::fill_lookup (token_=..., lookup_=0x690030, index_=4) at ../boost/spirit/home/support/detail/lexer/generator.hpp:564
564 ../boost/spirit/home/support/detail/lexer/generator.hpp: No such file or directory.
(gdb) c
Continuing.

Breakpoint 1, boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup (token_=..., lookup_=0x6901b0, index_=4)
    at ../boost/spirit/home/support/detail/lexer/generator.hpp:564
564 in ../boost/spirit/home/support/detail/lexer/generator.hpp
(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x000000000042907b in boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup (token_=..., lookup_=0x6901b0, index_=4)
    at ../boost/spirit/home/support/detail/lexer/generator.hpp:571
571 in ../boost/spirit/home/support/detail/lexer/generator.hpp

(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y

Starting program: /home/ubuntu/BOOST/boost1.55/boost1.55-1.55.0/bin.v2/libs/spirit/test/lex_lexertl2-p3.test/gcc-4.8/debug/phoenix_v3-on/lex_lexertl2-p3

Breakpoint 1, boost::lexer::basic_generator<char, boost::lexer::char_traits<char> >::fill_lookup (token_=..., lookup_=0x690030, index_=4) at ../boost/spirit/home/support/detail/lexer/generator.hpp:564
564 in ../boost/spirit/home/support/detail/lexer/generator.hpp
(gdb) c
Continuing.

Breakpoint 1, boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup (token_=..., lookup_=0x6901b0, index_=4)
    at ../boost/spirit/home/support/detail/lexer/generator.hpp:564
564 in ../boost/spirit/home/support/detail/lexer/generator.hpp
(gdb) p curr_char_
$1 = 0 L'\000'
(gdb) si
std::numeric_limits<wchar_t>::min () at /usr/include/c++/4.8/limits:655
655 min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (wchar_t); }
(gdb) si
0x0000000000404b47 655 min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (wchar_t); }
(gdb) si
655 min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (wchar_t); }
(gdb) si
0x0000000000404b4f 655 min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (wchar_t); }
(gdb) display/i $pc
1: x/i $pc
=> 0x404b4f <std::numeric_limits<wchar_t>::min()+9>: shl $0x3,%eax
(gdb) si
0x0000000000404b52 655 min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (wchar_t); }
1: x/i $pc
=> 0x404b52 <std::numeric_limits<wchar_t>::min()+12>: sub $0x2,%eax
(gdb) si
0x0000000000404b55 655 min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (wchar_t); }
1: x/i $pc
=> 0x404b55 <std::numeric_limits<wchar_t>::min()+15>: mov $0x1,%edx
(gdb) si
0x0000000000404b5a 655 min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (wchar_t); }
1: x/i $pc
=> 0x404b5a <std::numeric_limits<wchar_t>::min()+20>: mov %eax,%ecx
(gdb) si
0x0000000000404b5c 655 min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (wchar_t); }
1: x/i $pc
=> 0x404b5c <std::numeric_limits<wchar_t>::min()+22>: shl %cl,%edx
(gdb) si
0x0000000000404b5e 655 min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (wchar_t); }
1: x/i $pc
=> 0x404b5e <std::numeric_limits<wchar_t>::min()+24>: mov %edx,%eax
(gdb) si
0x0000000000404b60 655 min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (wchar_t); }
1: x/i $pc
=> 0x404b60 <std::numeric_limits<wchar_t>::min()+26>: sub $0x1,%eax
(gdb) si
0x0000000000404b63 655 min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (wchar_t); }
1: x/i $pc
=> 0x404b63 <std::numeric_limits<wchar_t>::min()+29>: lea (%rax,%rax,1),%edx
(gdb) si
0x0000000000404b66 655 min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (wchar_t); }
1: x/i $pc
=> 0x404b66 <std::numeric_limits<wchar_t>::min()+32>: mov $0xfffffffe,%eax
(gdb) si
0x0000000000404b6b 655 min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (wchar_t); }
1: x/i $pc
=> 0x404b6b <std::numeric_limits<wchar_t>::min()+37>: sub %edx,%eax
(gdb) si
0x0000000000404b6d 655 min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (wchar_t); }
1: x/i $pc
=> 0x404b6d <std::numeric_limits<wchar_t>::min()+39>: pop %rbp
(gdb) si
0x0000000000404b6e 655 min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (wchar_t); }
1: x/i $pc
=> 0x404b6e <std::numeric_limits<wchar_t>::min()+40>: retq
(gdb) si
0x0000000000429050 in boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup (token_=..., lookup_=0x6901b0, index_=4)
    at ../boost/spirit/home/support/detail/lexer/generator.hpp:564
564 ../boost/spirit/home/support/detail/lexer/generator.hpp: No such file or directory.
1: x/i $pc
=> 0x429050 <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+119>: mov %eax,-0x2c(%rbp)
(gdb) info registers
rax 0x80000000 2147483648
rbx 0x690b60 6884192
rcx 0x1e 30
rdx 0x7ffffffe 2147483646
rsi 0x6901b0 6881712
rdi 0x7fffffffdc30 140737488346160
rbp 0x7fffffffdca0 0x7fffffffdca0
rsp 0x7fffffffdc50 0x7fffffffdc50
r8 0x1 1
r9 0x3 3
r10 0x7fffffffd890 140737488345232
r11 0x7ffff7682001 140737344184321
r12 0x692320 6890272
r13 0x1 1
r14 0x0 0
r15 0x6900c8 6881480
rip 0x429050 0x429050 <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+119>
eflags 0x286 [ PF SF IF ]
cs 0x33 51
ss 0x2b 43
ds 0x0 0
es 0x0 0
fs 0x0 0
gs 0x0 0
(gdb) si
565 in ../boost/spirit/home/support/detail/lexer/generator.hpp
1: x/i $pc
=> 0x429053 <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+122>: movq $0x0,-0x20(%rbp)

(gdb) print curr_char_
$2 = -2147483648 L'\x80000000'
(gdb) p/x curr_char_
$3 = 0x80000000
(gdb) si
567 in ../boost/spirit/home/support/detail/lexer/generator.hpp
1: x/i $pc
=> 0x42905b <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+130>:
    jmp 0x4290a0 <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+199>
(gdb) si
567 in ../boost/spirit/home/support/detail/lexer/generator.hpp
1: x/i $pc
=> 0x4290a0 <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+199>: mov -0x28(%rbp),%rax
(gdb) si
0x00000000004290a4 567 in ../boost/spirit/home/support/detail/lexer/generator.hpp
1: x/i $pc
=> 0x4290a4 <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+203>: cmp -0x18(%rbp),%rax
(gdb) si
0x00000000004290a8 567 in ../boost/spirit/home/support/detail/lexer/generator.hpp
1: x/i $pc
=> 0x4290a8 <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+207>:
    jb 0x42905d <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+132>
(gdb) si
569 in ../boost/spirit/home/support/detail/lexer/generator.hpp
1: x/i $pc
=> 0x42905d <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+132>:
    jmp 0x429087 <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+174>
(gdb) si
569 in ../boost/spirit/home/support/detail/lexer/generator.hpp
1: x/i $pc
=> 0x429087 <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+174>: mov -0x28(%rbp),%rax
(gdb) si
0x000000000042908b 569 in ../boost/spirit/home/support/detail/lexer/generator.hpp
1: x/i $pc
=> 0x42908b <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+178>: mov (%rax),%eax
(gdb) si
0x000000000042908d 569 in ../boost/spirit/home/support/detail/lexer/generator.hpp
1: x/i $pc
=> 0x42908d <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+180>: cmp -0x2c(%rbp),%eax
(gdb) si
0x0000000000429090 569 in ../boost/spirit/home/support/detail/lexer/generator.hpp
1: x/i $pc
=> 0x429090 <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+183>:
    jg 0x42905f <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+134>
(gdb) si
571 in ../boost/spirit/home/support/detail/lexer/generator.hpp
1: x/i $pc
=> 0x42905f <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+134>: mov -0x2c(%rbp),%eax
(gdb) si
0x0000000000429062 571 in ../boost/spirit/home/support/detail/lexer/generator.hpp
1: x/i $pc
=> 0x429062 <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+137>: cltq
(gdb) si
0x0000000000429064 571 in ../boost/spirit/home/support/detail/lexer/generator.hpp
1: x/i $pc
=> 0x429064 <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+139>: lea 0x0(,%rax,8),%rdx
(gdb) s

Program received signal SIGSEGV, Segmentation fault.
0x000000000042907b in boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup (token_=..., lookup_=0x6901b0, index_=4)
    at ../boost/spirit/home/support/detail/lexer/generator.hpp:571
571 in ../boost/spirit/home/support/detail/lexer/generator.hpp
1: x/i $pc
=> 0x42907b <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+162>: mov %rdx,(%rax)
(gdb) info registers
rax 0x7ffbf6971010 140720150614032
rbx 0x690b60 6884192
rcx 0x1e 30
rdx 0xb 11
rsi 0x6901b0 6881712
rdi 0x7fffffffdc30 140737488346160
rbp 0x7fffffffdca0 0x7fffffffdca0
rsp 0x7fffffffdc50 0x7fffffffdc50
r8 0x1 1
r9 0x3 3
r10 0x7fffffffd890 140737488345232
r11 0x7ffff7682001 140737344184321
r12 0x692320 6890272
r13 0x1 1
r14 0x0 0
r15 0x6900c8 6881480
rip 0x42907b 0x42907b <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+162>
eflags 0x10202 [ IF RF ]
cs 0x33 51
ss 0x2b 43
ds 0x0 0
es 0x0 0
fs 0x0 0
gs 0x0 0

======================================================================

On PPC64

boost/spirit/home/support/detail/lexer/generator.hpp :

static void fill_lookup (
 const string_token &token_,
 size_t_vector *lookup_,
 const std::size_t index_)
    {
        const CharT *curr_ = token_._charset.c_str ();
        const CharT *chars_end_ = curr_ + token_._charset.size ();
        std::size_t *ptr_ = &lookup_->front ();
        const std::size_t max_ = sizeof (CharT) == 1 ? num_chars : num_wchar_ts;

        if (token_._negated)
        {
===> CharT curr_char_ = (std::numeric_limits<CharT>::min)();
     curr_char_ : 0x80000000

{
CharT :::::::

boost/format/format_class.hpp :
namespace boost {
    template<class Ch, class Tr, class Alloc>
    class basic_format
    {
    public:
        typedef Ch CharT; // borland fails in operator% if we use Ch and Tr directly

boost/property_tree/detail/json_parser_read.hpp :
     struct context { typedef typename Ptree::key_type::value_type Ch;

boost/accumulators/numeric/functional.hpp :
    template<typename T>
    struct default_
    {
        typedef T value_type;
}

            std::size_t i_ = 0;

            while (curr_ < chars_end_)
            {
                while (*curr_ > curr_char_)
                {

===> ptr_[static_cast<typename Traits::index_type> (curr_char_)] = index_ + dfa_offset;
  ptr_[0x80000000] :Core

  ++curr_char_;
                ++i_;
                }

/usr/include/c++/4.8.2/limits :

  template<>
    struct numeric_limits<char>
    {
      static _GLIBCXX_CONSTEXPR char min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min(char); }

  template<>
    struct numeric_limits<wchar_t>
    {
      static _GLIBCXX_CONSTEXPR wchar_t min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (wchar_t); }

#define __glibcxx_signed(T) ((T)(-1) < 0)

#define __glibcxx_min(T) (__glibcxx_signed (T) ? -__glibcxx_max (T) - 1 : (T)0)

#define __glibcxx_max(T) (__glibcxx_signed (T) ? (((((T)1 << (__glibcxx_digits (T) - 1)) - 1) << 1) + 1) : ~(T)0)

#define __glibcxx_digits(T) (sizeof(T) * __CHAR_BIT__ - __glibcxx_signed (T))
    4 * 8 - 2

gdb boost_1_55_0/bin.v2/libs/spirit/test/lex_lexertl2-p3.test/gcc-4.8.2/debug/phoenix_v3-on/lex_lexertl2-p3

break generator.hpp:564

(gdb) run

Breakpoint 5, boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup (token_=..., lookup_=0x100f11b0, index_=4)
    at ../boost/spirit/home/support/detail/lexer/generator.hpp:564
564 CharT curr_char_ = (std::numeric_limits<CharT>::min)();
5: /x curr_char_ = 0x0

(gdb) s
std::numeric_limits<wchar_t>::min () at /usr/include/c++/4.8.2/limits:655
655 min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (wchar_t); }

(gdb) s
boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup (token_=..., lookup_=0x100f11b0, index_=4)
    at ../boost/spirit/home/support/detail/lexer/generator.hpp:565
565 std::size_t i_ = 0;
5: /x curr_char_ = 0x80000000

(gdb) p/t 0x80000000
$15 = 10000000000000000000000000000000

==============================================================

(gdb) run

......................

Breakpoint 5, boost::lexer::basic_generator<char, boost::lexer::char_traits<char> >::fill_lookup (token_=..., lookup_=0x100f1030, index_=4)
    at ../boost/spirit/home/support/detail/lexer/generator.hpp:564
564 CharT curr_char_ = (std::numeric_limits<CharT>::min)();
7: /x curr_char_ = 0x0
3: /x *curr_ = 0xa
2: /x curr_ = 0x100f1f18
1: /x curr_char_ = 0x0

(gdb) c
Continuing.

Breakpoint 5, boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup (token_=..., lookup_=0x100f11b0, index_=4)
    at ../boost/spirit/home/support/detail/lexer/generator.hpp:564
564 CharT curr_char_ = (std::numeric_limits<CharT>::min)();
5: /x curr_char_ = 0x0

(gdb) s
std::numeric_limits<wchar_t>::min () at /usr/include/c++/4.8.2/limits:655
655 min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (wchar_t); }

=> 0x10005600 <std::numeric_limits<wchar_t>::min()+12>: li r9,4
=> 0x10005604 <std::numeric_limits<wchar_t>::min()+16>: rlwinm r9,r9,3,0,28
=> 0x10005608 <std::numeric_limits<wchar_t>::min()+20>: clrldi r9,r9,32
=> 0x1000560c <std::numeric_limits<wchar_t>::min()+24>: addi r9,r9,-2
=> 0x10005610 <std::numeric_limits<wchar_t>::min()+28>: clrldi r9,r9,32
=> 0x10005614 <std::numeric_limits<wchar_t>::min()+32>: extsw r9,r9
=> 0x10005618 <std::numeric_limits<wchar_t>::min()+36>: li r10,1
=> 0x1000561c <std::numeric_limits<wchar_t>::min()+40>: slw r9,r10,r9
=> 0x10005620 <std::numeric_limits<wchar_t>::min()+44>: extsw r9,r9
=> 0x10005624 <std::numeric_limits<wchar_t>::min()+48>: addi r9,r9,-1
=> 0x10005628 <std::numeric_limits<wchar_t>::min()+52>: extsw r9,r9
=> 0x1000562c <std::numeric_limits<wchar_t>::min()+56>: rlwinm r9,r9,1,0,30
=> 0x10005630 <std::numeric_limits<wchar_t>::min()+60>: extsw r9,r9
=> 0x10005634 <std::numeric_limits<wchar_t>::min()+64>: subfic r9,r9,-2
=> 0x10005638 <std::numeric_limits<wchar_t>::min()+68>: extsw r9,r9
=> 0x1000563c <std::numeric_limits<wchar_t>::min()+72>: mr r3,r9
=> 0x10005640 <std::numeric_limits<wchar_t>::min()+76>: addi r1,r31,64
=> 0x10005644 <std::numeric_limits<wchar_t>::min()+80>: ld r31,-8(r1)
=> 0x10005648 <std::numeric_limits<wchar_t>::min()+84>: blr
=> 0x1004097c <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+156>: mr r9,r3
=> 0x10040984 <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+164>: li r9,0

(gdb)
0x0000000010040978 in boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup (token_=..., lookup_=0x100f11b0, index_=4)
    at ../boost/spirit/home/support/detail/lexer/generator.hpp:564
564 CharT curr_char_ = (std::numeric_limits<CharT>::min)();
8: x/i $pc
=> 0x10040978 <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+152>: nop
5: /x curr_char_ = 0x0

(gdb)
0x000000001004097c 564 CharT curr_char_ = (std::numeric_limits<CharT>::min)();
8: x/i $pc
=> 0x1004097c <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+156>: mr r9,r3
5: /x curr_char_ = 0x0

(gdb) n
565 std::size_t i_ = 0;
8: x/i $pc
=> 0x10040984 <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+164>: li r9,0
5: /x curr_char_ = 0x80000000

(gdb) info registers
r3 0xffffffff80000000 18446744071562067968
r9 0xffffffff80000000 18446744071562067968
r10 0x1 1

r9 0x1 1
=> 0x10005600 <std::numeric_limits<wchar_t>::min()+12>: li r9,4
r9 0x4 4
=> 0x10005604 <std::numeric_limits<wchar_t>::min()+16>: rlwinm r9,r9,3,0,28
r9 0x20 32
=> 0x10005608 <std::numeric_limits<wchar_t>::min()+20>: clrldi r9,r9,32
r9 0x20 32
=> 0x1000560c <std::numeric_limits<wchar_t>::min()+24>: addi r9,r9,-2
r9 0x1e 30
=> 0x10005610 <std::numeric_limits<wchar_t>::min()+28>: clrldi r9,r9,32
r9 0x1e 30
=> 0x10005614 <std::numeric_limits<wchar_t>::min()+32>: extsw r9,r9
r9 0x1e 30
r10 0x1fffff750010 35184362979344
=> 0x10005618 <std::numeric_limits<wchar_t>::min()+36>: li r10,1
r9 0x1e 30
r10 0x1 1
=> 0x1000561c <std::numeric_limits<wchar_t>::min()+40>: slw r9,r10,r9
r9 0x40000000 1073741824
r10 0x1 1
=> 0x10005620 <std::numeric_limits<wchar_t>::min()+44>: extsw r9,r9
r9 0x40000000 1073741824
=> 0x10005624 <std::numeric_limits<wchar_t>::min()+48>: addi r9,r9,-1
r9 0x3fffffff 1073741823
=> 0x10005628 <std::numeric_limits<wchar_t>::min()+52>: extsw r9,r9
r9 0x3fffffff 1073741823
=> 0x1000562c <std::numeric_limits<wchar_t>::min()+56>: rlwinm r9,r9,1,0,30
r9 0x7ffffffe 2147483646
=> 0x10005630 <std::numeric_limits<wchar_t>::min()+60>: extsw r9,r9
r9 0x7ffffffe 2147483646
=> 0x10005634 <std::numeric_limits<wchar_t>::min()+64>: subfic r9,r9,-2
r9 0xffffffff80000000 18446744071562067968
=> 0x10005638 <std::numeric_limits<wchar_t>::min()+68>: extsw r9,r9
r3 0x1fffff750010 35184362979344
r9 0xffffffff80000000 18446744071562067968
=> 0x1000563c <std::numeric_limits<wchar_t>::min()+72>: mr r3,r9
r1 0x3fffffffe3f0 70368744170480
r31 0x3fffffffe3f0 70368744170480
=> 0x10005640 <std::numeric_limits<wchar_t>::min()+76>: addi r1,r31,64
r1 0x3fffffffe430 70368744170544
r31 0x3fffffffe3f0 70368744170480
=> 0x10005644 <std::numeric_limits<wchar_t>::min()+80>: ld r31,-8(r1)
=> 0x10005648 <std::numeric_limits<wchar_t>::min()+84>: blr
0x0000000010040978 in boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup (token_=..., lookup_=0x100f11b0, index_=4)
    at ../boost/spirit/home/support/detail/lexer/generator.hpp:564
564 CharT curr_char_ = (std::numeric_limits<CharT>::min)();
=> 0x10040978 <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+152>: nop
5: /x curr_char_ = 0x0
(gdb) info registers
r3 0xffffffff80000000 18446744071562067968
r9 0xffffffff80000000 18446744071562067968
(gdb) p ~0xffffffff80000000
$17 = 2147483647
(gdb) p/x ~0xffffffff80000000
$18 = 0x7fffffff
=> 0x1004097c <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+156>: mr r9,r3
5: /x curr_char_ = 0x0
r3 0xffffffff80000000 18446744071562067968
r9 0xffffffff80000000 18446744071562067968
r31 0x3fffffffe430 70368744170544
=> 0x10040980 <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+160>: stw r9,120(r31)
5: /x curr_char_ = 0x0
(gdb) si
565 std::size_t i_ = 0;
8: x/i $pc
=> 0x10040984 <boost::lexer::basic_generator<wchar_t, boost::lexer::char_traits<wchar_t> >::fill_lookup(boost::lexer::basic_string_token<wchar_t> const&, std::vector<unsigned long, std::allocator<unsigned long> >*, unsigned long)+164>: li r9,0
6: /x curr_char_ = 0x80000000
5: /x curr_char_ = 0x80000000
4: /x curr_char_ = 0x80000000
(gdb) p/x ~0x80000000
$19 = 0x7fffffff

Tony Reix (tony-reix)
affects: boost1.54 (Ubuntu) → boost1.55 (Ubuntu)
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

It is correct for std::numberic_limits<wchar_t>::min() to be -2147483648, as per standard it is not specified if wchar_t is signed or unsigned value. If explicitly unsigned values are desired char16_t or char32_t should be used, as those are unsigned.
Looking at upstream test results http://www.boost.org/development/tests/develop/developer/spirit.html the test only passes on those configurations where wchar_t is unsigned (e.g. android/windows) and not on any other platforms. Thus this is an upstream bug that should be forwarded to boost bug tracker.

Revision history for this message
Tony Reix (tony-reix) wrote :

Hummmm OK. I'll dig that later, and open a defect in Boost world.
Thanks !
Tony

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.