You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Andrew Black <ab...@roguewave.com> on 2006/02/24 21:41:18 UTC

Testsuite self-test failure on NetBSD 3.0

Greetings all.

While running the different executables in the stdcxx test suite, I 
encountered a segfault executing the printf selftest.  The following is 
the backtrace.

> td143.testdrive.hp.com> gdb 0.printf
> GNU gdb 5.3nb1
> Copyright 2002 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and 
> you are
> welcome to change it and/or distribute copies of it under certain 
> conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for 
> details.
> This GDB was configured as "i386--netbsdelf"...
> (gdb) run
> Starting program: /tmp/ablackrw/stdcxx-11d/tests/0.printf
> "%": percent sign
> "%c": character formatting
> extension: "%{c}": escaped character
> extension: "%{#c}": quoted escaped character
> "%lc": wide character
> extension: "%{lc}": escaped wide character
> extension: "%{#lc}": quoted escaped wide character
> "%s": character string
>
> Program received signal SIGSEGV, Segmentation fault.
> 0xbdab6f2a in memchr () from /usr/lib/libc.so.12
> (gdb) bt
> #0  0xbdab6f2a in memchr () from /usr/lib/libc.so.12
> #1  0x08079164 in __ps_strings ()
> #2  0x0806a154 in _rw_fmtstr(FmtSpec const&, char**, unsigned*, char 
> const*, unsigned) (spec=@0xbfbfe7a0, pbuf=0xbfbfece4, 
> pbufsize=0xbfbfece0,
>     str=0x1 <Error reading address 0x1: Invalid argument>, len=4294967295)
>     at /house/ablackrw/stdcxx/tests/src/printf.cpp:3051
> #3  0x080663b4 in _rw_vasnprintf_c99(FmtSpec*, unsigned, char**, 
> unsigned*, char**) (pspec=0xbfbfe7a0, paramno=0, pbuf=0xbfbfece4, 
> pbufsize=0xbfbfece0,
>     pva=0xbfbfeca8) at /house/ablackrw/stdcxx/tests/src/printf.cpp:681
> #4  0x08066ee9 in rw_vasnprintf(char**, unsigned*, char const*, char*) (
>     pbuf=0xbfbfece4, pbufsize=0xbfbfece0, fmt=0x80728fc "%s",
>     varg=0xbfbfecf4 "\001") at 
> /house/ablackrw/stdcxx/tests/src/printf.cpp:1035
> #5  0x0806c21d in rw_sprintfa(char const*, ...) (fmt=0x80728fc "%s")
>     at /house/ablackrw/stdcxx/tests/src/printf.cpp:4004
> #6  0x0804d9b0 in test_string() ()
>     at /house/ablackrw/stdcxx/tests/self/0.printf.cpp:343
> #7  0x08065763 in main ()
>     at /house/ablackrw/stdcxx/tests/self/0.printf.cpp:2235
> #8  0x08049516 in ___start ()


--Andrew Black

Re: Testsuite self-test failure on NetBSD 3.0

Posted by Martin Sebor <se...@roguewave.com>.
Andrew Black wrote:
> When I build and run the testcase as follows, the assertion fails, 
> seeming to confirm the hypothesis.

Okay, thanks. I'll open an issue for this bug. The next step is to
figure out what call to use on BSD instead of madvise() to detect
invalid pointers. It might also be that the behavior we're seeing
is a BSD bug in which case we should report it to the project
maintainers.

Martin

> 
> --Andrew Black
> 
> td143.testdrive.hp.com> cat > testcase.cpp
>  #include <cassert>
>  #include <sys/types.h>
> 
>  namespace __rw {
>      ssize_t __rw_memattr (const void*, size_t, int);
>  }
> 
>  int main () {
>      assert (-1 == __rw::__rw_memattr ((void*)1, 1, -1));
>  }
> td143.testdrive.hp.com> gcc -c -I/house/ablackrw/stdcxx/include/ansi 
> -D_RWSTDDEBUG    -D_RWSTD_USE_CONFIG -I/tmp/ablackrw/stdcxx-11d/include 
> -I/house/ablackrw/stdcxx/include -pedantic -nostdinc++ -g  -W -Wall 
> -Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long 
> -Wcast-align testcase.cpp
> td143.testdrive.hp.com> gcc testcase.o -o testcase 
> -L/tmp/ablackrw/stdcxx-11d/lib -lstd11d  -lsupc++ -lm
> td143.testdrive.hp.com> ./testcase
> assertion "-1 == __rw::__rw_memattr ((void*)1, 1, -1)" failed: file 
> "testcase.cpp", line 9, function "int main()"
> Abort trap (core dumped)
> 
> 
> Martin Sebor wrote:
> 
>> Andrew Black wrote:
>>
>>> Greetings all.
>>>
>>> While running the different executables in the stdcxx test suite, I 
>>> encountered a segfault executing the printf selftest.  The following 
>>> is the backtrace.
>>
>>
>>
>> This might be caused by __rw::__rw_memattr() not detecting that
>> (char*)1 is not a valid pointer to a character string. A simple
>> test case to confirm this hypothesis would go something like
>> this:
>>
>>   #include <cassert>
>>   #include <sys/types.h>
>>
>>   namespace __rw {
>>       ssize_t __rw_memattr (const void*, size_t, int);
>>   }
>>
>>   int main () {
>>       assert (-1 == __rw::__rw_memattr ((void*)1, 1, -1));
>>   }
>>
>> Martin
> 
> 


Re: Testsuite self-test failure on NetBSD 3.0

Posted by Andrew Black <ab...@roguewave.com>.
When I build and run the testcase as follows, the assertion fails, 
seeming to confirm the hypothesis.

--Andrew Black

td143.testdrive.hp.com> cat > testcase.cpp
  #include <cassert>
  #include <sys/types.h>

  namespace __rw {
      ssize_t __rw_memattr (const void*, size_t, int);
  }

  int main () {
      assert (-1 == __rw::__rw_memattr ((void*)1, 1, -1));
  }
td143.testdrive.hp.com> gcc -c -I/house/ablackrw/stdcxx/include/ansi 
-D_RWSTDDEBUG    -D_RWSTD_USE_CONFIG -I/tmp/ablackrw/stdcxx-11d/include 
-I/house/ablackrw/stdcxx/include -pedantic -nostdinc++ -g  -W -Wall 
-Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long 
-Wcast-align testcase.cpp
td143.testdrive.hp.com> gcc testcase.o -o testcase 
-L/tmp/ablackrw/stdcxx-11d/lib -lstd11d  -lsupc++ -lm
td143.testdrive.hp.com> ./testcase
assertion "-1 == __rw::__rw_memattr ((void*)1, 1, -1)" failed: file 
"testcase.cpp", line 9, function "int main()"
Abort trap (core dumped)


Martin Sebor wrote:

> Andrew Black wrote:
>
>> Greetings all.
>>
>> While running the different executables in the stdcxx test suite, I 
>> encountered a segfault executing the printf selftest.  The following 
>> is the backtrace.
>
>
> This might be caused by __rw::__rw_memattr() not detecting that
> (char*)1 is not a valid pointer to a character string. A simple
> test case to confirm this hypothesis would go something like
> this:
>
>   #include <cassert>
>   #include <sys/types.h>
>
>   namespace __rw {
>       ssize_t __rw_memattr (const void*, size_t, int);
>   }
>
>   int main () {
>       assert (-1 == __rw::__rw_memattr ((void*)1, 1, -1));
>   }
>
> Martin



Re: Testsuite self-test failure on NetBSD 3.0

Posted by Martin Sebor <se...@roguewave.com>.
Andrew Black wrote:
> Greetings all.
> 
> While running the different executables in the stdcxx test suite, I 
> encountered a segfault executing the printf selftest.  The following is 
> the backtrace.

This might be caused by __rw::__rw_memattr() not detecting that
(char*)1 is not a valid pointer to a character string. A simple
test case to confirm this hypothesis would go something like
this:

   #include <cassert>
   #include <sys/types.h>

   namespace __rw {
       ssize_t __rw_memattr (const void*, size_t, int);
   }

   int main () {
       assert (-1 == __rw::__rw_memattr ((void*)1, 1, -1));
   }

Martin