Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 09 Jun 2005 12:54:08 -0700
From:      "Keyser" <keyser456@verizon.net>
To:        <freebsd-questions@freebsd.org>
Subject:   g++ successfully compiled "Hello World" program causes segfault at runtime
Message-ID:  <002001c56d2c$fffd5bf0$5b01a8c0@mdis>

next in thread | raw e-mail | index | archive | help
I posted this topic a few days ago but still haven't found a solution =
yet.  However, I believe I'm able to provide more information now.  Here =
is a log showing what I'm up against:

vitoc# pwd
/usr/temp/cpp
vitoc# ls
test.cpp
vitoc# cat test.cpp
#include <iostream>
using namespace std;

int main()
{
cout << "Hello world!";
return 0;
}
vitoc# g++ -g -o test test.cpp
vitoc# ls
test            test.cpp
vitoc# gdb test
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 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-marcel-freebsd"...
(gdb) run
Starting program: /usr/temp/cpp/test

Program received signal SIGSEGV, Segmentation fault.
0x2819d7de in wctype () from /lib/libc.so.5
(gdb) bt
#0  0x2819d7de in wctype () from /lib/libc.so.5
#1  0x28119002 in std::ctype<wchar_t>::_M_convert_to_wmask ()
   from /usr/lib/libstdc++.so.4
#2  0x28119453 in std::ctype<wchar_t>::_M_initialize_ctype ()
   from /usr/lib/libstdc++.so.4
#3  0x28119b08 in std::ctype<wchar_t>::ctype () from =
/usr/lib/libstdc++.so.4
#4  0x28112a69 in std::locale::_Impl::_Impl () from =
/usr/lib/libstdc++.so.4
#5  0x281120ba in std::locale::_S_initialize_once ()
   from /usr/lib/libstdc++.so.4
#6  0x28112128 in std::locale::_S_initialize () from =
/usr/lib/libstdc++.so.4
#7  0x28111e9b in std::locale::locale () from /usr/lib/libstdc++.so.4
#8  0x280e3531 in __gnu_cxx::stdio_sync_filebuf<char, =
std::char_traits<char> >::stdio_sync_filebuf () from =
/usr/lib/libstdc++.so.4
#9  0x2810c0e2 in std::ios_base::Init::Init () from =
/usr/lib/libstdc++.so.4
#10 0x0804888e in __static_initialization_and_destruction_0 =
(__initialize_p=3D1,
    __priority=3D65535) at iostream:77
#11 0x080488d9 in global constructors keyed to main () at test.cpp:9
#12 0x08048922 in __do_global_ctors_aux ()
#13 0x08048536 in _init ()
#14 0x08048682 in _start ()
#15 0x00000001 in ?? ()
(gdb) kill
Kill the program being debugged? (y or n) y
(gdb) quit
vitoc# ldd test
test:
        libstdc++.so.4 =3D> /usr/lib/libstdc++.so.4 (0x28076000)
        libm.so.3 =3D> /lib/libm.so.3 (0x28148000)
        libc.so.5 =3D> /lib/libc.so.5 (0x28163000)
vitoc# g++ -v
Using built-in specs.
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 3.4.2 [FreeBSD] 20040728
vitoc#

This is on FreeBSD 5.4 obtained from a freebsd.org mirror.  Any ideas?  =
Thanks!



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?002001c56d2c$fffd5bf0$5b01a8c0>