It appears that the code generated is attempting to
access location 0x0. Here is the gdb tracing. I'm not
very good at ppc assembler, and dont understand why the
code
wxwidgets:
is incorrect. But since the assem is about to do a
bctrl using the value loaded off 2, it might be a
missing "this" pointer.
Should the code actually be" ??
size_t nLen = psz->MB2WC(NULL, psz, 0);
since MB2WC is pure virtual, should this call acturally
be the global wxMB2WC ??
Any help will be appreciated.
Thanks in advance,
pecan
-------------------------------------------------
gdb info
//-------------------------------------------------
wxwidgets:
(gdb) run
Starting program:
/Volumes/Seagate/MAC/proj/wxstedit/samples/stedit/wxstedit
Reading symbols for shared libraries
..........................................................
done
Program received signal EXC_BAD_ACCESS, Could not
access memory.
0x000e42c8 in wxMBConv::cMB2WC(char const) const
(this=0x56b9f0, psz=0xbffff1c0 "1") at
/users/pecan/devel/wxMac263/src/common/strconv.cpp:184
184 size_t nLen = MB2WC(NULL, psz, 0);
(gdb) l
179 const wxWCharBuffer wxMBConv::cMB2WC(const char
psz) const
180 {
181 if ( psz )
182 {
183 // calculate the length of the buffer
needed first
184 size_t nLen = MB2WC(NULL, psz, 0);
185 if ( nLen != (size_t)-1 )
186 {
187 // now do the actual conversion
188 wxWCharBuffer buf(nLen);
(gdb)
(gdb) bt
0 0x000e42c8 in wxMBConv::cMB2WC(char const*) const
(this=0x56b9f0, psz=0xbffff1c0 "1") at
/users/pecan/devel/wxMac263/src/common/strconv.cpp:184
1 0x003cace8 in wxMBConv::cMB2WX(char const*) const
(this=0x56b9f0, psz=0xbffff1c0 "1") at
/users/pecan/devel/wxMac263/include/wx/strconv.h:62
2 0x000e9828 in wxVsnprintf_(wchar_t*, unsigned long,
wchar_t const, char) (buf=0x680360c, lenMax=1024,
format=0x30dfe8, argptr=0xbffff764 "") at
/users/pecan/devel/wxMac263/src/common/wxchar.cpp:372
3 0x000b15d8 in wxString::PrintfV(wchar_t const*,
char*) (this=0xbffff780, pszFormat=0x30dfe8,
argptr=0xbffff760 "") at
/users/pecan/devel/wxMac263/src/common/string.cpp:1828
4 0x000b1428 in wxString::Format(wchar_t const*, ...)
(pszFormat=0x30dfe8) at
/users/pecan/devel/wxMac263/src/common/string.cpp:1782
5 0x0001db34 in wxSTEditorPrefs::AddInitPref(wxString
const&, int, int) const (this=0x5566d8,
prefName=@0xbffff7f0, value=1, flags=2) at
src/steprefs.cpp:275
6 0x0001c0bc in wxSTEditorPrefs::Init()
(this=0x5566d8) at src/steprefs.cpp:135
7 0x003afba8 in
wxSTEditorPrefs::wxSTEditorPrefs(bool) (this=0x5566d8,
create=true) at include/wx/stedit/steprefs.h:97
8 0x003aebb8 in
wxSTEditorPrefs::wxSTEditorPrefs(bool) (this=0x5566d8,
create=true) at include/wx/stedit/steprefs.h:97
9 0x0038b804 in
static_initialization_and_destruction_0(int, int)
(initialize_p=1, __priority=65535) at
src/steprefs.cpp:688
10 0x0038b944 in
_GLOBALIZN18wxSTEditorPrefBase12ms_classInfoE () at
src/steprefs.cpp:966
11 0x8fe176b0 in
__dyld_call_module_initializers_for_objects ()
12 0x8fe17178 in __dyld_call_module_initializers ()
13 0x8fe142a4 in
dylddyld_make_delayed_module_initializer_calls ()
14 0x0000271c in _call_mod_init_funcs () at
/SourceCache/Csu/Csu-47/crt.c:299
15 0x00002518 in _start (argc=1, argv=0xbffffd7c,
envp=0xbffffd84) at /SourceCache/Csu/Csu-47/crt.c:217
16 0x8fe1a278 in dylddyld_start ()
(gdb)
(gdb) bt full
0 0x000e42c8 in wxMBConv::cMB2WC(char const*) const
2008-05-27 18:47:49: @wojdyr changed component from * to wxMac*
2008-05-27 18:47:49: @wojdyr commented
Please don't copy&paste your complete debugging session into the description of bug - include only relevant parts or attach it as a file.
If you want to show changes you made to the code, please don't copy the modified file into the description field! See HowToSubmitPatches to learn how to prepare a patch.
Issue migrated from trac ticket # 3368
component: old wxOSX/Carbon port | priority: normal | resolution: outdated
2006-07-10 00:23:14: pecan2 created the issue
Summary: MB2WC is a pure virtual in strconv.h and should not be being called in strconv.cpp
I get crashes using wxMac263, gcc3.3, OS X 10.3. wxMac263,static,unicode,monolithic
It occurs in strconv.cpp at line 184 wxwidgets:
179 const wxWCharBuffer wxMBConv::cMB2WC(const char *psz) const 180 { 181 if ( psz ) 182 { 183 // calculate the length of the buffer needed first 184 size_t nLen = MB2WC(NULL, psz, 0); 185 if ( nLen != (size_t)-1 ) 186 { 187 // now do the actual conversion 188 wxWCharBuffer buf(nLen);
from a call in wxStEdit line 135 wxwidgets:
6 0x0001c0bc in wxSTEditorPrefs::Init()
(this=0x5566d8) at src/steprefs.cpp:135 135 AddInitPref(wxT("Highlight Syntax"), 1, STE_PREF_FLAG_BOOL); (gdb) l 130 131 s_STE_PrefNames.Alloc(STE_PREFMAX); 132 s_STE_PrefValues.Alloc(STE_PREF__MAX); 133 s_STE_PrefFlags.Alloc(STE_PREFMAX); 134 135 AddInitPref(wxT("Highlight Syntax"), 1, STE_PREF_FLAG_BOOL); 136 AddInitPref(wxT("Highlight Preprocessor"), 1, STE_PREF_FLAG_BOOL); 137 AddInitPref(wxT("Highlight Braces"), 1, STE_PREF_FLAG_BOOL); 138 AddInitPref(wxT("Load Init Language"), 1, STE_PREF_FLAG_BOOL); 139 AddInitPref(wxT("Load Unicode"),
STE_LOAD_DEFAULT, STE_PREF_FLAG_INT);
It appears that the code generated is attempting to access location 0x0. Here is the gdb tracing. I'm not very good at ppc assembler, and dont understand why the code wxwidgets:
0x000e42c8 <_ZNK8wxMBConv6cMB2WCEPKc+52>: lwz
0,0(2)
is incorrect. But since the assem is about to do a bctrl using the value loaded off 2, it might be a missing "this" pointer.
Should the code actually be" ?? size_t nLen = psz->MB2WC(NULL, psz, 0);
since MB2WC is pure virtual, should this call acturally be the global wxMB2WC ??
Any help will be appreciated. Thanks in advance, pecan ------------------------------------------------- gdb info //------------------------------------------------- wxwidgets:
(gdb) run Starting program: /Volumes/Seagate/MAC/proj/wxstedit/samples/stedit/wxstedit Reading symbols for shared libraries .......................................................... done
Program received signal EXC_BAD_ACCESS, Could not access memory. 0x000e42c8 in wxMBConv::cMB2WC(char const) const (this=0x56b9f0, psz=0xbffff1c0 "1") at /users/pecan/devel/wxMac263/src/common/strconv.cpp:184 184 size_t nLen = MB2WC(NULL, psz, 0); (gdb) l 179 const wxWCharBuffer wxMBConv::cMB2WC(const char psz) const 180 { 181 if ( psz ) 182 { 183 // calculate the length of the buffer needed first 184 size_t nLen = MB2WC(NULL, psz, 0); 185 if ( nLen != (size_t)-1 ) 186 { 187 // now do the actual conversion 188 wxWCharBuffer buf(nLen); (gdb) (gdb) bt
0 0x000e42c8 in wxMBConv::cMB2WC(char const*) const
(this=0x56b9f0, psz=0xbffff1c0 "1") at /users/pecan/devel/wxMac263/src/common/strconv.cpp:184
1 0x003cace8 in wxMBConv::cMB2WX(char const*) const
(this=0x56b9f0, psz=0xbffff1c0 "1") at /users/pecan/devel/wxMac263/include/wx/strconv.h:62
2 0x000e9828 in wxVsnprintf_(wchar_t*, unsigned long,
wchar_t const, char) (buf=0x680360c, lenMax=1024, format=0x30dfe8, argptr=0xbffff764 "") at /users/pecan/devel/wxMac263/src/common/wxchar.cpp:372
3 0x000b15d8 in wxString::PrintfV(wchar_t const*,
char*) (this=0xbffff780, pszFormat=0x30dfe8, argptr=0xbffff760 "") at /users/pecan/devel/wxMac263/src/common/string.cpp:1828
4 0x000b1428 in wxString::Format(wchar_t const*, ...)
(pszFormat=0x30dfe8) at /users/pecan/devel/wxMac263/src/common/string.cpp:1782
5 0x0001db34 in wxSTEditorPrefs::AddInitPref(wxString
const&, int, int) const (this=0x5566d8, prefName=@0xbffff7f0, value=1, flags=2) at src/steprefs.cpp:275
6 0x0001c0bc in wxSTEditorPrefs::Init()
(this=0x5566d8) at src/steprefs.cpp:135
7 0x003afba8 in
wxSTEditorPrefs::wxSTEditorPrefs(bool) (this=0x5566d8, create=true) at include/wx/stedit/steprefs.h:97
8 0x003aebb8 in
wxSTEditorPrefs::wxSTEditorPrefs(bool) (this=0x5566d8, create=true) at include/wx/stedit/steprefs.h:97
9 0x0038b804 in
static_initialization_and_destruction_0(int, int) (initialize_p=1, __priority=65535) at src/steprefs.cpp:688
10 0x0038b944 in
_GLOBALIZN18wxSTEditorPrefBase12ms_classInfoE () at src/steprefs.cpp:966
11 0x8fe176b0 in
__dyld_call_module_initializers_for_objects ()
12 0x8fe17178 in __dyld_call_module_initializers ()
13 0x8fe142a4 in
dylddyld_make_delayed_module_initializer_calls ()
14 0x0000271c in _call_mod_init_funcs () at
/SourceCache/Csu/Csu-47/crt.c:299
15 0x00002518 in _start (argc=1, argv=0xbffffd7c,
envp=0xbffffd84) at /SourceCache/Csu/Csu-47/crt.c:217
16 0x8fe1a278 in dylddyld_start ()
(gdb) (gdb) bt full
0 0x000e42c8 in wxMBConv::cMB2WC(char const*) const
(this=0x56b9f0, psz=0xbffff1c0 "1") at /users/pecan/devel/wxMac263/src/common/strconv.cpp:184 nLen = 0 buf = { m_str = 0x0 }
1 0x003cace8 in wxMBConv::cMB2WX(char const*) const
(this=0x56b9f0, psz=0xbffff1c0 "1") at /users/pecan/devel/wxMac263/include/wx/strconv.h:62 No locals.
2 0x000e9828 in wxVsnprintf_(wchar_t*, unsigned long,
wchar_t const, char) (buf=0x680360c, lenMax=1024, format=0x30dfe8, argptr=0xbffff764 "") at /users/pecan/devel/wxMac263/src/common/wxchar.cpp:372 tmp = { m_str = 0xbffff650 } ch = 100 prec_dot = false done = false ilen = 0 min_width = 0 max_width = 4294967295 s_szFlags = "%d", '\0' <repeats 253 times> flagofs = 2 adj_left = false in_prec = false chCur = 37 n = 1 szScratch = "1\000?\020\000\000\000\000\000:??\000\000\000\002\000\000\005\017???????\220\000\000\000\002???@\000\000\000\000????\000\016\215P????Syst???\000\000\016\215P????\000\000\000\000???\020\000\016\215P????\000\000\000\v\000\016??\000\000\000\000?\e?4?\e?4???\220?\e?4\000\000\000\000\000\000\000\000\217?rP\217?&\???\220\000\000\004\002\217?&??\034-\200\000\000\000\v\b\000\001\000?\034\r?\220\035?d????D\000B\210\220\035?P\220\000\v?????\000\000\000\000\220\000\f,\000\000\000\000????????"... lenCur = 0
3 0x000b15d8 in wxString::PrintfV(wchar_t const*,
char) (this=0xbffff780, pszFormat=0x30dfe8, argptr=0xbffff760 "") at /users/pecan/devel/wxMac263/src/common/string.cpp:1828 tmp = { m_str = @0xbffff780, m_buf = 0x680360c } buf = (wxChar ) 0x680360c argptrcopy = 0xbffff760 "" len = 3866984 size = 1024
4 0x000b1428 in wxString::Format(wchar_t const*, ...)
(pszFormat=0x30dfe8) at /users/pecan/devel/wxMac263/src/common/string.cpp:1782 argptr = 0xbffff760 "" s = (wxString *) 0xbffff780
5 0x0001db34 in wxSTEditorPrefs::AddInitPref(wxString
const&, int, int) const (this=0x5566d8, prefName=@0xbffff7f0, value=1, flags=2) at src/steprefs.cpp:275 No locals.
6 0x0001c0bc in wxSTEditorPrefs::Init()
(this=0x5566d8) at src/steprefs.cpp:135 No locals.
7 0x003afba8 in
wxSTEditorPrefs::wxSTEditorPrefs(bool) (this=0x5566d8, create=true) at include/wx/stedit/steprefs.h:97 No locals.
8 0x003aebb8 in
wxSTEditorPrefs::wxSTEditorPrefs(bool) (this=0x5566d8, create=true) at include/wx/stedit/steprefs.h:97 No locals.
9 0x0038b804 in
static_initialization_and_destruction_0(int, int) (initialize_p=1, __priority=65535) at src/steprefs.cpp:688 No locals.
10 0x0038b944 in
_GLOBALIZN18wxSTEditorPrefBase12ms_classInfoE () at src/steprefs.cpp:966 No locals.
11 0x8fe176b0 in
__dyld_call_module_initializers_for_objects () No symbol table info available.
12 0x8fe17178 in __dyld_call_module_initializers ()
No symbol table info available.
13 0x8fe142a4 in
dylddyld_make_delayed_module_initializer_calls () No symbol table info available.
14 0x0000271c in _call_mod_init_funcs () at
/SourceCache/Csu/Csu-47/crt.c:299 p = (void (*)(void)) 0x8fe14238
<__dyld__dyld_make_delayed_module_initializer_calls> #15 0x00002518 in _start (argc=1, argv=0xbffffd7c, envp=0xbffffd84) at /SourceCache/Csu/Csu-47/crt.c:217 i = 1145193032 p = 0x4d652e "" q = (char **) 0x6a5 term = (void (*)(void)) 0 #16 0x8fe1a278 in __dyld__dyld_start () No symbol table info available. (gdb) (gdb) f 0 #0 0x000e42c8 in wxMBConv::cMB2WC(char const*) const (this=0x56b9f0, psz=0xbffff1c0 "1") at /users/pecan/devel/wxMac263/src/common/strconv.cpp:184 184 size_t nLen = MB2WC(NULL, psz, 0); (gdb) l 179 const wxWCharBuffer wxMBConv::cMB2WC(const char *psz) const 180 { 181 if ( psz ) 182 { 183 // calculate the length of the buffer needed first 184 size_t nLen = MB2WC(NULL, psz, 0); 185 if ( nLen != (size_t)-1 ) 186 { 187 // now do the actual conversion 188 wxWCharBuffer buf(nLen); (gdb) Quit (gdb) (gdb) p psz $1 = 0xbffff1c0 "1" (gdb) Quit (gdb) (gdb) f 1 #1 0x003cace8 in wxMBConv::cMB2WX(char const*) const (this=0x56b9f0, psz=0xbffff1c0 "1") at /users/pecan/devel/wxMac263/include/wx/strconv.h:62 62 const wxWCharBuffer cMB2WX(const char *psz) const { return cMB2WC(psz); } (gdb) l 57 const wxWCharBuffer cMB2WC(const char *psz, size_t pszLen, size_t* pOutSize) const; 58 const wxCharBuffer cWC2MB(const wchar_t *psz, size_t pszLen, size_t* pOutSize) const; 59 60 // convenience functions for converting MB or WC to/from wxWin default 61 #if wxUSE_UNICODE 62 const wxWCharBuffer cMB2WX(const char *psz) const { return cMB2WC(psz); } 63 const wxCharBuffer cWX2MB(const wchar_t *psz) const { return cWC2MB(psz); } 64 const wchar_t* cWC2WX(const wchar_t *psz) const { return psz; } 65 const wchar_t* cWX2WC(const wchar_t *psz) const { return psz; } 66 #else // ANSI (gdb) p psz $3 = 0xbffff1c0 "1" (gdb) p *psz $4 = 49 '1' (gdb) (gdb) f 2 #2 0x000e9828 in wxVsnprintf_(wchar_t*, unsigned long, wchar_t const*, char*) (buf=0x680360c, lenMax=1024, format=0x30dfe8, argptr=0xbffff764 "") at /users/pecan/devel/wxMac263/src/common/wxchar.cpp:372 372 wxConvLibc.cMB2WX(szScratch); (gdb) l 367 ::sprintf(szScratch, s_szFlags, val); 368 } 369 370 { 371 const wxMB2WXbuf tmp = 372 wxConvLibc.cMB2WX(szScratch); 373 APPEND_STR(tmp); 374 } 375 376 done = true; (gdb) p szScratch $2 = "1\000?\020\000\000\000\000\000:??\000\000\000\002\000\000\005\017???????\220\000\000\000\002???@\000\000\000\000????\000\016\215P????Syst???\000\000\016\215P????\000\000\000\000???\020\000\016\215P????\000\000\000\v\000\016??\000\000\000\000?\e?4?\e?4???\220?\e?4\000\000\000\000\000\000\000\000\217?rP\217?&\\???\220\000\000\004\002\217?&??\034-\200\000\000\000\v\b\000\001\000?\034\r?\220\035?d????D\000B\210\220\035?P\220\000\v?????\000\000\000\000\220\000\f,\000\000\000\000????????"... (gdb) (gdb) f 3 #3 0x000b15d8 in wxString::PrintfV(wchar_t const*, char*) (this=0xbffff780, pszFormat=0x30dfe8, argptr=0xbffff760 "") at /users/pecan/devel/wxMac263/src/common/string.cpp:1828 1828 int len = wxVsnprintf(buf, size, pszFormat, argptrcopy); (gdb) l 1823 1824 // wxVsnprintf() may modify the original arg pointer, so pass it 1825 // only a copy 1826 va_list argptrcopy; 1827 wxVaCopy(argptrcopy, argptr); 1828 int len = wxVsnprintf(buf, size, pszFormat, argptrcopy); 1829 va_end(argptrcopy); 1830 1831 // some implementations of vsnprintf() don't NUL terminate 1832 // the string if there is not enough space for it so (gdb) p buf $5 = (wxChar *) 0x680360c (gdb) p size $6 = 1024 (gdb) p pszFormat $7 = (const wxChar *) 0x30dfe8 (gdb) p argptrcopy $8 = 0xbffff760 "" (gdb) p *pszFormat $9 = 37 (gdb) (gdb) f 4 #4 0x000b1428 in wxString::Format(wchar_t const*, ...) (pszFormat=0x30dfe8) at /users/pecan/devel/wxMac263/src/common/string.cpp:1782 1782 s.PrintfV(pszFormat, argptr); (gdb) l 1777 { 1778 va_list argptr; 1779 va_start(argptr, pszFormat); 1780 1781 wxString s; 1782 s.PrintfV(pszFormat, argptr); 1783 1784 va_end(argptr); 1785 1786 return s; (gdb) p pszFormat $10 = (const wxChar *) 0x30dfe8 (gdb) p argptr $11 = 0xbffff760 "" (gdb) p *pszFormat $12 = 37 (gdb) (gdb) f 5 #5 0x0001db34 in wxSTEditorPrefs::AddInitPref(wxString const&, int, int) const (this=0x5566d8, prefName=@0xbffff7f0, value=1, flags=2) at src/steprefs.cpp:275 275 return AddInitPref(prefName, wxString::Format(wxT("%d"), value), flags); (gdb) l 270 s_STE_PrefFlags.Add(flags); 271 return s_STE_PrefValues.GetCount() - 1; 272 } 273 size_t wxSTEditorPrefs::AddInitPref(const wxString& prefName, int value, int flags) const 274 { 275 return AddInitPref(prefName, wxString::Format(wxT("%d"), value), flags); 276 } 277 size_t wxSTEditorPrefs::GetInitPrefCount() const 278 { 279 return s_STE_PrefValues.GetCount(); (gdb) p prefName $13 = (const wxString &) @0xbffff7f0: {