wxWidgets / wxWidgets

Cross-Platform C++ GUI Library
https://www.wxwidgets.org/
6.15k stars 1.77k forks source link

wxMac unicode crash in strconv.cpp #3368

Closed wxtrac closed 14 years ago

wxtrac commented 18 years ago

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: { = { static npos = 4294967295, m_pchData = 0x63103ac }, } (gdb) p prefName.m_pchData $14 = (wxChar *) 0x63103ac (gdb) p *prefName.m_pchData $15 = 72 (gdb) p value $16 = 1 (gdb) p flags $17 = 2 (gdb) (gdb) f 6 #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_PREF__MAX); 132 s_STE_PrefValues.Alloc(STE_PREF__MAX); 133 s_STE_PrefFlags.Alloc(STE_PREF__MAX); 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); (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) b 184 Breakpoint 1 at 0xe42c0: file /users/pecan/devel/wxMac263/src/common/strconv.cpp, line 184. (gdb) disassem Dump of assembler code for function _ZNK8wxMBConv6cMB2WCEPKc: 0x000e4294 <_ZNK8wxMBConv6cMB2WCEPKc+0>: mflr 0 0x000e4298 <_ZNK8wxMBConv6cMB2WCEPKc+4>: stmw 29,-12(1) 0x000e429c <_ZNK8wxMBConv6cMB2WCEPKc+8>: stw 0,8(1) 0x000e42a0 <_ZNK8wxMBConv6cMB2WCEPKc+12>: stwu 1,-128(1) 0x000e42a4 <_ZNK8wxMBConv6cMB2WCEPKc+16>: mr 30,1 0x000e42a8 <_ZNK8wxMBConv6cMB2WCEPKc+20>: stw 3,152(30) 0x000e42ac <_ZNK8wxMBConv6cMB2WCEPKc+24>: stw 4,156(30) 0x000e42b0 <_ZNK8wxMBConv6cMB2WCEPKc+28>: stw 5,160(30) 0x000e42b4 <_ZNK8wxMBConv6cMB2WCEPKc+32>: lwz 0,160(30) 0x000e42b8 <_ZNK8wxMBConv6cMB2WCEPKc+36>: cmpwi cr7,0,0 0x000e42bc <_ZNK8wxMBConv6cMB2WCEPKc+40>: beq- cr7,0xe43bc <_ZNK8wxMBConv6cMB2WCEPKc+296> 0x000e42c0 <_ZNK8wxMBConv6cMB2WCEPKc+44>: lwz 2,156(30) 0x000e42c4 <_ZNK8wxMBConv6cMB2WCEPKc+48>: lwz 2,0(2) 0x000e42c8 <_ZNK8wxMBConv6cMB2WCEPKc+52>: lwz 0,0(2) 0x000e42cc <_ZNK8wxMBConv6cMB2WCEPKc+56>: lwz 3,156(30) 0x000e42d0 <_ZNK8wxMBConv6cMB2WCEPKc+60>: li 4,0 0x000e42d4 <_ZNK8wxMBConv6cMB2WCEPKc+64>: lwz 5,160(30) 0x000e42d8 <_ZNK8wxMBConv6cMB2WCEPKc+68>: li 6,0 0x000e42dc <_ZNK8wxMBConv6cMB2WCEPKc+72>: mr 12,0 0x000e42e0 <_ZNK8wxMBConv6cMB2WCEPKc+76>: mtctr 12 0x000e42e4 <_ZNK8wxMBConv6cMB2WCEPKc+80>: bctrl 0x000e42e8 <_ZNK8wxMBConv6cMB2WCEPKc+84>: mr 0,3 0x000e42ec <_ZNK8wxMBConv6cMB2WCEPKc+88>: stw 0,64(30) 0x000e42f0 <_ZNK8wxMBConv6cMB2WCEPKc+92>: lwz 2,64(30) 0x000e42f4 <_ZNK8wxMBConv6cMB2WCEPKc+96>: li 0,-1 0x000e42f8 <_ZNK8wxMBConv6cMB2WCEPKc+100>: cmpw cr7,2,0 0x000e42fc <_ZNK8wxMBConv6cMB2WCEPKc+104>: beq- cr7,0xe43bc <_ZNK8wxMBConv6cMB2WCEPKc+296> 0x000e4300 <_ZNK8wxMBConv6cMB2WCEPKc+108>: addi 0,30,80 0x000e4304 <_ZNK8wxMBConv6cMB2WCEPKc+112>: mr 3,0 0x000e4308 <_ZNK8wxMBConv6cMB2WCEPKc+116>: lwz 4,64(30) 0x000e430c <_ZNK8wxMBConv6cMB2WCEPKc+120>: bl 0x3e1bd4 <_ZN13wxWCharBufferC1Em> 0x000e4310 <_ZNK8wxMBConv6cMB2WCEPKc+124>: lwz 2,156(30) 0x000e4314 <_ZNK8wxMBConv6cMB2WCEPKc+128>: lwz 2,0(2) 0x000e4318 <_ZNK8wxMBConv6cMB2WCEPKc+132>: stw 2,96(30) 0x000e431c <_ZNK8wxMBConv6cMB2WCEPKc+136>: addi 0,30,80 0x000e4320 <_ZNK8wxMBConv6cMB2WCEPKc+140>: mr 3,0 0x000e4324 <_ZNK8wxMBConv6cMB2WCEPKc+144>: bl 0x3d7f0c <_ZN13wxWCharBuffer4dataEv> 0x000e4328 <_ZNK8wxMBConv6cMB2WCEPKc+148>: mr 0,3 0x000e432c <_ZNK8wxMBConv6cMB2WCEPKc+152>: lwz 2,64(30) 0x000e4330 <_ZNK8wxMBConv6cMB2WCEPKc+156>: addi 2,2,1 0x000e4334 <_ZNK8wxMBConv6cMB2WCEPKc+160>: lwz 11,96(30) 0x000e4338 <_ZNK8wxMBConv6cMB2WCEPKc+164>: lwz 9,0(11) 0x000e433c <_ZNK8wxMBConv6cMB2WCEPKc+168>: lwz 3,156(30) 0x000e4340 <_ZNK8wxMBConv6cMB2WCEPKc+172>: mr 4,0 0x000e4344 <_ZNK8wxMBConv6cMB2WCEPKc+176>: lwz 5,160(30) 0x000e4348 <_ZNK8wxMBConv6cMB2WCEPKc+180>: mr 6,2 0x000e434c <_ZNK8wxMBConv6cMB2WCEPKc+184>: mr 12,9 0x000e4350 <_ZNK8wxMBConv6cMB2WCEPKc+188>: mtctr 12 0x000e4354 <_ZNK8wxMBConv6cMB2WCEPKc+192>: bctrl 0x000e4358 <_ZNK8wxMBConv6cMB2WCEPKc+196>: mr 0,3 0x000e435c <_ZNK8wxMBConv6cMB2WCEPKc+200>: stw 0,64(30) 0x000e4360 <_ZNK8wxMBConv6cMB2WCEPKc+204>: lwz 2,64(30) 0x000e4364 <_ZNK8wxMBConv6cMB2WCEPKc+208>: li 0,-1 0x000e4368 <_ZNK8wxMBConv6cMB2WCEPKc+212>: cmpw cr7,2,0 0x000e436c <_ZNK8wxMBConv6cMB2WCEPKc+216>: beq- cr7,0xe43b0 <_ZNK8wxMBConv6cMB2WCEPKc+284> 0x000e4370 <_ZNK8wxMBConv6cMB2WCEPKc+220>: addi 0,30,80 0x000e4374 <_ZNK8wxMBConv6cMB2WCEPKc+224>: lwz 3,152(30) 0x000e4378 <_ZNK8wxMBConv6cMB2WCEPKc+228>: mr 4,0 0x000e437c <_ZNK8wxMBConv6cMB2WCEPKc+232>: bl 0x3e1c10 <_ZN13wxWCharBufferC1ERKS_> 0x000e4380 <_ZNK8wxMBConv6cMB2WCEPKc+236>: addi 0,30,80 0x000e4384 <_ZNK8wxMBConv6cMB2WCEPKc+240>: mr 3,0 0x000e4388 <_ZNK8wxMBConv6cMB2WCEPKc+244>: bl 0x3c84d8 <_ZN13wxWCharBufferD1Ev> 0x000e438c <_ZNK8wxMBConv6cMB2WCEPKc+248>: b 0xe440c <_ZNK8wxMBConv6cMB2WCEPKc+376> 0x000e4390 <_ZNK8wxMBConv6cMB2WCEPKc+252>: stw 3,100(30) 0x000e4394 <_ZNK8wxMBConv6cMB2WCEPKc+256>: lwz 29,100(30) 0x000e4398 <_ZNK8wxMBConv6cMB2WCEPKc+260>: addi 0,30,80 0x000e439c <_ZNK8wxMBConv6cMB2WCEPKc+264>: mr 3,0 0x000e43a0 <_ZNK8wxMBConv6cMB2WCEPKc+268>: bl 0x3c84d8 <_ZN13wxWCharBufferD1Ev> 0x000e43a4 <_ZNK8wxMBConv6cMB2WCEPKc+272>: stw 29,100(30) 0x000e43a8 <_ZNK8wxMBConv6cMB2WCEPKc+276>: lwz 3,100(30) 0x000e43ac <_ZNK8wxMBConv6cMB2WCEPKc+280>: bl 0x81b10 <_Unwind_Resume> 0x000e43b0 <_ZNK8wxMBConv6cMB2WCEPKc+284>: addi 0,30,80 0x000e43b4 <_ZNK8wxMBConv6cMB2WCEPKc+288>: mr 3,0 0x000e43b8 <_ZNK8wxMBConv6cMB2WCEPKc+292>: bl 0x3c84d8 <_ZN13wxWCharBufferD1Ev> 0x000e43bc <_ZNK8wxMBConv6cMB2WCEPKc+296>: addi 0,30,80 0x000e43c0 <_ZNK8wxMBConv6cMB2WCEPKc+300>: mr 3,0 0x000e43c4 <_ZNK8wxMBConv6cMB2WCEPKc+304>: li 4,0 0x000e43c8 <_ZNK8wxMBConv6cMB2WCEPKc+308>: bl 0x3e1b98 <_ZN13wxWCharBufferC1EPKw> 0x000e43cc <_ZNK8wxMBConv6cMB2WCEPKc+312>: addi 0,30,80 0x000e43d0 <_ZNK8wxMBConv6cMB2WCEPKc+316>: lwz 3,152(30) 0x000e43d4 <_ZNK8wxMBConv6cMB2WCEPKc+320>: mr 4,0 0x000e43d8 <_ZNK8wxMBConv6cMB2WCEPKc+324>: bl 0x3e1c10 <_ZN13wxWCharBufferC1ERKS_> 0x000e43dc <_ZNK8wxMBConv6cMB2WCEPKc+328>: addi 0,30,80 0x000e43e0 <_ZNK8wxMBConv6cMB2WCEPKc+332>: mr 3,0 0x000e43e4 <_ZNK8wxMBConv6cMB2WCEPKc+336>: bl 0x3c84d8 <_ZN13wxWCharBufferD1Ev> 0x000e43e8 <_ZNK8wxMBConv6cMB2WCEPKc+340>: b 0xe440c <_ZNK8wxMBConv6cMB2WCEPKc+376> 0x000e43ec <_ZNK8wxMBConv6cMB2WCEPKc+344>: stw 3,100(30) 0x000e43f0 <_ZNK8wxMBConv6cMB2WCEPKc+348>: lwz 29,100(30) 0x000e43f4 <_ZNK8wxMBConv6cMB2WCEPKc+352>: addi 0,30,80 0x000e43f8 <_ZNK8wxMBConv6cMB2WCEPKc+356>: mr 3,0 0x000e43fc <_ZNK8wxMBConv6cMB2WCEPKc+360>: bl 0x3c84d8 <_ZN13wxWCharBufferD1Ev> 0x000e4400 <_ZNK8wxMBConv6cMB2WCEPKc+364>: stw 29,100(30) 0x000e4404 <_ZNK8wxMBConv6cMB2WCEPKc+368>: lwz 3,100(30) 0x000e4408 <_ZNK8wxMBConv6cMB2WCEPKc+372>: bl 0x81b10 <_Unwind_Resume> 0x000e440c <_ZNK8wxMBConv6cMB2WCEPKc+376>: lwz 3,152(30) 0x000e4410 <_ZNK8wxMBConv6cMB2WCEPKc+380>: lwz 1,0(1) 0x000e4414 <_ZNK8wxMBConv6cMB2WCEPKc+384>: lwz 0,8(1) 0x000e4418 <_ZNK8wxMBConv6cMB2WCEPKc+388>: mtlr 0 0x000e441c <_ZNK8wxMBConv6cMB2WCEPKc+392>: lmw 29,-12(1) 0x000e4420 <_ZNK8wxMBConv6cMB2WCEPKc+396>: blr End of assembler dump. (gdb) (gdb) r The program being debugged has been started already. Start it from the beginning? (y or n) y Starting program: /Volumes/Seagate/MAC/proj/wxstedit/samples/stedit/wxstedit Breakpoint 1, 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) info registers 0 0xbffff1c0 3221221824 1 0xbffff0b0 3221221552 2 0x532f60 5451616 3 0xbffff600 3221222912 4 0x56b9f0 5683696 5 0xbffff1c0 3221221824 6 0x6a5 1701 7 0x0 0 8 0x6e 110 9 0x0 0 10 0x4d652e 5072174 11 0x44424248 1145193032 12 0xbffff1c0 3221221824 13 0x0 0 14 0x0 0 15 0x0 0 16 0x0 0 17 0x0 0 18 0x8fe50504 2414150916 19 0x1 1 20 0x20000000 536870912 21 0x8fe507d4 2414151636 22 0x8fe507d4 2414151636 23 0x0 0 24 0x8fe57250 2414178896 25 0xc4 196 26 0x8fe50504 2414150916 27 0x3 3 28 0x8fe57250 2414178896 29 0xbffff600 3221222912 30 0xbffff0b0 3221221552 31 0xe8d50 953680 pc 0xe42c0 934592 ps 0x2f030 192560 cr 0x24424288 608322184 lr 0x3cace8 3976424 ctr 0x9011c160 2417082720 xer 0x1 1 mq 0x0 0 fpscr 0x82004000 2181054464 vscr 0x0 0 vrsave 0x0 0 (gdb) stepi 0x000e42c4 184 size_t nLen = MB2WC(NULL, psz, 0); (gdb) (gdb) info registers 0 0xbffff1c0 3221221824 1 0xbffff0b0 3221221552 2 0x56b9f0 5683696 3 0xbffff600 3221222912 4 0x56b9f0 5683696 5 0xbffff1c0 3221221824 6 0x6a5 1701 7 0x0 0 8 0x6e 110 9 0x0 0 10 0x4d652e 5072174 11 0x44424248 1145193032 12 0xbffff1c0 3221221824 13 0x0 0 14 0x0 0 15 0x0 0 16 0x0 0 17 0x0 0 18 0x8fe50504 2414150916 19 0x1 1 20 0x20000000 536870912 21 0x8fe507d4 2414151636 22 0x8fe507d4 2414151636 23 0x0 0 24 0x8fe57250 2414178896 25 0xc4 196 26 0x8fe50504 2414150916 27 0x3 3 28 0x8fe57250 2414178896 29 0xbffff600 3221222912 30 0xbffff0b0 3221221552 31 0xe8d50 953680 pc 0xe42c4 934596 ps 0xd030 53296 cr 0x24424288 608322184 lr 0x3cace8 3976424 ctr 0x9011c160 2417082720 xer 0x1 1 mq 0x0 0 fpscr 0x82004000 2181054464 vscr 0x0 0 vrsave 0x0 0 (gdb) (gdb) stepi 0x000e42c8 184 size_t nLen = MB2WC(NULL, psz, 0); (gdb) info registers 0 0xbffff1c0 3221221824 1 0xbffff0b0 3221221552 2 0x0 0 3 0xbffff600 3221222912 4 0x56b9f0 5683696 5 0xbffff1c0 3221221824 6 0x6a5 1701 7 0x0 0 8 0x6e 110 9 0x0 0 10 0x4d652e 5072174 11 0x44424248 1145193032 12 0xbffff1c0 3221221824 13 0x0 0 14 0x0 0 15 0x0 0 16 0x0 0 17 0x0 0 18 0x8fe50504 2414150916 19 0x1 1 20 0x20000000 536870912 21 0x8fe507d4 2414151636 22 0x8fe507d4 2414151636 23 0x0 0 24 0x8fe57250 2414178896 25 0xc4 196 26 0x8fe50504 2414150916 27 0x3 3 28 0x8fe57250 2414178896 29 0xbffff600 3221222912 30 0xbffff0b0 3221221552 31 0xe8d50 953680 pc 0xe42c8 934600 ps 0xd030 53296 cr 0x24424288 608322184 lr 0x3cace8 3976424 ctr 0x9011c160 2417082720 xer 0x1 1 mq 0x0 0 fpscr 0x82004000 2181054464 vscr 0x0 0 vrsave 0x0 0 (gdb) (gdb) stepi 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) info registers 0 0xbffff1c0 3221221824 1 0xbffff0b0 3221221552 2 0x0 0 3 0xbffff600 3221222912 4 0x56b9f0 5683696 5 0xbffff1c0 3221221824 6 0x6a5 1701 7 0x0 0 8 0x6e 110 9 0x0 0 10 0x4d652e 5072174 11 0x44424248 1145193032 12 0xbffff1c0 3221221824 13 0x0 0 14 0x0 0 15 0x0 0 16 0x0 0 17 0x0 0 18 0x8fe50504 2414150916 19 0x1 1 20 0x20000000 536870912 21 0x8fe507d4 2414151636 22 0x8fe507d4 2414151636 23 0x0 0 24 0x8fe57250 2414178896 25 0xc4 196 26 0x8fe50504 2414150916 27 0x3 3 28 0x8fe57250 2414178896 29 0xbffff600 3221222912 30 0xbffff0b0 3221221552 31 0xe8d50 953680 pc 0xe42c8 934600 ps 0xd030 53296 cr 0x24424288 608322184 lr 0x3cace8 3976424 ctr 0x9011c160 2417082720 xer 0x1 1 mq 0x0 0 fpscr 0x82004000 2181054464 vscr 0x0 0 vrsave 0x0 0 (gdb) (gdb) p $30 $18 = 3221221552 (gdb) p *$30 $19 = -1073745616 (gdb) p $4 $20 = 5683696 (gdb) info args this = (const wxMBConv * const) 0x56b9f0 psz = 0xbffff1c0 "1" (gdb) p /x $4 $21 = 0x56b9f0 (gdb) p /x *($4+156) $22 = 0x0 (gdb) p /x $30 $23 = 0xbffff0b0 (gdb) p /x *($30+156) $24 = 0x56b9f0 (gdb) (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) p /x $0 $25 = 0xbffff1c0 (gdb) p /x $cr7 $26 = Value can't be converted to integer. (gdb) info reg $cr7 Invalid register `cr7' (gdb) info reg cr7 Invalid register `cr7' (gdb) p /x *$0 $27 = 0x3100f210 (gdb) Since MB2WC and WC2MB in src/common/strconv.h/cpp are pure virtual, I changed them to wxMB2WC and wxWX2MB. Now wxStEdit with wxMac263 unicode works fine. Is this the appropriated fix? thanks pecan Please see lines marked (pecan 2006... wxwidgets: // ----------------------------------------------------------------------------_ wxMBConv _ ---------------------------------------------------------------------------- wxMBConv::~wxMBConv() { // nothing to do here (necessary for Darwin linking probably) } const wxWCharBuffer wxMBConv::cMB2WC(const char *psz) const { if ( psz ) { // calculate the length of the buffer needed first //-(pecan 2006.08.06) //-size_t nLen = MB2WC(NULL, psz, 0); size_t nLen = wxMB2WC(NULL, psz, 0); if ( nLen != (size_t)-1 ) { // now do the actual conversion wxWCharBuffer buf(nLen); //-(pecan 2006.08.06) _-nLen = MB2WC(buf.data(), psz, nLen + 1); _ with the trailing NULL nLen = wxMB2WC(buf.data(), psz, nLen + 1); // with the trailing NULL if ( nLen != (size_t)-1 ) { return buf; } } } wxWCharBuffer buf((wchar_t *)NULL); return buf; } const wxCharBuffer wxMBConv::cWC2MB(const wchar_t *pwz) const { if ( pwz ) { //-(pecan 2006.08.06) //-size_t nLen = WC2MB(NULL, pwz, 0); size_t nLen = wxWC2MB(NULL, pwz, 0); if ( nLen != (size_t)-1 ) { wxCharBuffer buf(nLen+3); // space for a wxUint32 trailing zero //-(pecan 2006.08.06 ) //-nLen = WC2MB(buf.data(), pwz, nLen + 4); nLen = wxWC2MB(buf.data(), pwz, nLen + 4); if ( nLen != (size_t)-1 ) { return buf; } } } wxCharBuffer buf((char *)NULL); return buf; } const wxWCharBuffer wxMBConv::cMB2WC(const char *szString, size_t nStringLen, size_t* pOutSize) const { wxASSERT(pOutSize != NULL); const char* szEnd = szString + nStringLen + 1; const char* szPos = szString; const char* szStart = szPos; size_t nActualLength = 0; size_t nCurrentSize = nStringLen; //try normal size first (should never resize?) wxWCharBuffer theBuffer(nCurrentSize); //Convert the string until the length() is reached, continuing the //loop every time a null character is reached while(szPos != szEnd) { wxASSERT(szPos < szEnd); //something is _really_ screwed up if this rings true //Get the length of the current (sub)string _- size_t nLen = MB2WC(NULL, szPos, 0); _(pecan 2006.07.0Cool size_t nLen = wxMB2WC(NULL, szPos, 0); //Invalid conversion? if( nLen == (size_t)-1 ) { -pOutSize = 0; theBuffer.data()[0u] = wxT('\0'); return theBuffer; } //Increase the actual length (+1 for current null character) nActualLength += nLen + 1; //if buffer too big, realloc the buffer if (nActualLength > (nCurrentSize+1)) { wxWCharBuffer theNewBuffer(nCurrentSize << 1); memcpy(theNewBuffer.data(), theBuffer.data(), nCurrentSize * sizeof(wchar_t)); theBuffer = theNewBuffer; nCurrentSize <<= 1; } //Convert the current (sub)string //-(pecan 2006.07.0Cool if ( MB2WC(&theBuffer.data()[szPos - szStart], szPos, nLen + 1) == (size_t)-1 ) if ( wxMB2WC(&theBuffer.data()[szPos - szStart], szPos, nLen + 1) == (size_t)-1 ) { -pOutSize = 0; theBuffer.data()[0u] = wxT('\0'); return theBuffer; } //Increment to next (sub)string //Note that we have to use strlen instead of nLen here //because XX2XX gives us the size of the output buffer, //which is not necessarily the length of the string szPos += strlen(szPos) + 1; } //success - return actual length and the buffer -pOutSize = nActualLength; return theBuffer; } const wxCharBuffer wxMBConv::cWC2MB(const wchar_t *szString, size_t nStringLen, size_t* pOutSize) const { wxASSERT(pOutSize != NULL); const wchar_t* szEnd = szString + nStringLen + 1; const wchar_t* szPos = szString; const wchar_t* szStart = szPos; size_t nActualLength = 0; size_t nCurrentSize = nStringLen << 2; //try * 4 first wxCharBuffer theBuffer(nCurrentSize); //Convert the string until the length() is reached, continuing the //loop every time a null character is reached while(szPos != szEnd) { wxASSERT(szPos < szEnd); //something is _really_ screwed up if this rings true //Get the length of the current (sub)string //-(pecan 2006.08.06 ) //-size_t nLen = WC2MB(NULL, szPos, 0); size_t nLen = wxWC2MB(NULL, szPos, 0); //Invalid conversion? if( nLen == (size_t)-1 ) { -pOutSize = 0; theBuffer.data()[0u] = wxT('\0'); return theBuffer; } //Increase the actual length (+1 for current null character) nActualLength += nLen + 1; //if buffer too big, realloc the buffer if (nActualLength > (nCurrentSize+1)) { wxCharBuffer theNewBuffer(nCurrentSize << 1); memcpy(theNewBuffer.data(), theBuffer.data(), nCurrentSize); theBuffer = theNewBuffer; nCurrentSize <<= 1; } //Convert the current (sub)string //-(pecan 2006.08.06 ) //-if(WC2MB(&theBuffer.data()[szPos - szStart], szPos, nLen + 1) == (size_t)-1 ) if(wxWC2MB(&theBuffer.data()[szPos - szStart], szPos, nLen + 1) == (size_t)-1 ) { -pOutSize = 0; theBuffer.data()[0u] = wxT('\0'); return theBuffer; } //Increment to next (sub)string //Note that we have to use wxWcslen instead of nLen here //because XX2XX gives us the size of the output buffer, //which is not necessarily the length of the string szPos += wxWcslen(szPos) + 1; } //success - return actual length and the buffer -pOutSize = nActualLength; return theBuffer;
wxtrac commented 16 years ago

2008-05-27 18:47:49: @wojdyr changed component from * to wxMac*

2008-05-27 18:47:49: @wojdyr commented

  1. Please don't copy&paste your complete debugging session into the description of bug - include only relevant parts or attach it as a file.
  2. 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.
wxtrac commented 14 years ago

2010-06-03 11:51:50: @vadz changed status from new to closed

2010-06-03 11:51:50: @vadz changed resolution from * to outdated*

2010-06-03 11:51:50: @vadz commented

This is almost certainly out of date by now but if you still have the problem it's probably the same one as in #11094.