View Single Post

   
  #1 (permalink)  
Old 04-17-2008, 08:09 PM
Andreas Gustafsson
 
Posts: n/a
Default Segfault in wxMBConvUTF8::MB2WC on startup

I built pgadmin3 1.2.1 with wkGTK-2.6.2 on NetBSD/i386 2.0_BETA by
means of pkgsrc-wip, but the resulting binary segfaults on startup:

Program received signal SIGSEGV, Segmentation fault.
0x48a47178 in wxMBConvUTF8::MB2WC(wchar_t*, char const*, unsigned) const () from /usr/pkg/lib/libwx_base-2.6.so
(gdb) where
#0 0x48a47178 in wxMBConvUTF8::MB2WC(wchar_t*, char const*, unsigned) const () from /usr/pkg/lib/libwx_base-2.6.so
#1 0x0819bb82 in wxUtfFile::Read(wxString&, long long) (this=0xbfbff500, str=@0xbfbff530, nCount=1654) at utils/utffile.cpp:92
#2 0x08194f8a in FileRead(wxString const&, int) (filename=@0xbfbff6e0, format=1) at utils/misc.cpp:482
#3 0x08065a6a in pgAdmin3::OnInit() (this=0x830a980) at pgAdmin3.cpp:228
#4 0x08066ee4 in wxAppConsole::CallOnInit() (this=0x830a980)
at /usr/pkgsrc/wip/pgadmin3/work/.buildlink/include/wx-2.6/wx/app.h:87
#5 0x48a2c13c in wxEntry(int&, char**) () from /usr/pkg/lib/libwx_base-2.6.so
#6 0x080651f1 in main (argc=1, argv=0xbfbff83c) at pgAdmin3.cpp:81
#7 0x08064ef2 in ___start ()

This looks like the same crash as that reported in
<http://lists.freebsd.org/pipermail/freebsd-ports/2005-January/019694.html>
The following patch appears to fix the problem. Is it the correct fix?

--- utffile.cpp.old 2005-10-06 16:49:28.000000000 +0300
+++ utffile.cpp 2005-10-06 16:28:09.000000000 +0300
@@ -89,7 +89,8 @@
if (decr)
Seek(-decr, wxFromCurrent);

- m_conversion->MB2WC((wchar_t*)(wxChar*)wxStringBuffer(str, nLen+1), (const char*)buffer, (size_t)(nLen+1));
+ m_conversion->MB2WC((wchar_t*)(wxChar*)wxStringBuffer(str, (nLen+1) * sizeof(wchar_t)),
+ (const char*)buffer, (size_t)(nLen+1));
}
else
str = (wxChar*)buffer;

--
Andreas Gustafsson, gson@araneus.fi

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Reply With Quote