[ wxwindows-Bugs-1519710 ] wxMac unicode crash in strconv.cpp
SourceForge.net
noreply at sourceforge.net
Sun Jul 9 15:23:14 PDT 2006
Bugs item #1519710, was opened at 2006-07-09 22:23
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1519710&group_id=9863
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Pecan (pecan2)
Assigned to: Nobody/Anonymous (nobody)
Summary: wxMac unicode crash in strconv.cpp
Initial Comment:
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_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);
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
r0,0(r2)
is incorrect. But since the assem is about to do a
bctrl using the value loaded off r2, 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
_GLOBAL__I__ZN18wxSTEditorPrefBase12ms_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
__dyld__dyld_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 __dyld__dyld_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
_GLOBAL__I__ZN18wxSTEditorPrefBase12ms_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
__dyld__dyld_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: {
<wxStringBase> = {
static npos = 4294967295,
m_pchData = 0x63103ac
}, <No data fields>}
(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 r0
0x000e4298 <_ZNK8wxMBConv6cMB2WCEPKc+4>: stmw
r29,-12(r1)
0x000e429c <_ZNK8wxMBConv6cMB2WCEPKc+8>: stw
r0,8(r1)
0x000e42a0 <_ZNK8wxMBConv6cMB2WCEPKc+12>: stwu
r1,-128(r1)
0x000e42a4 <_ZNK8wxMBConv6cMB2WCEPKc+16>: mr
r30,r1
0x000e42a8 <_ZNK8wxMBConv6cMB2WCEPKc+20>: stw
r3,152(r30)
0x000e42ac <_ZNK8wxMBConv6cMB2WCEPKc+24>: stw
r4,156(r30)
0x000e42b0 <_ZNK8wxMBConv6cMB2WCEPKc+28>: stw
r5,160(r30)
0x000e42b4 <_ZNK8wxMBConv6cMB2WCEPKc+32>: lwz
r0,160(r30)
0x000e42b8 <_ZNK8wxMBConv6cMB2WCEPKc+36>: cmpwi
cr7,r0,0
0x000e42bc <_ZNK8wxMBConv6cMB2WCEPKc+40>: beq-
cr7,0xe43bc <_ZNK8wxMBConv6cMB2WCEPKc+296>
0x000e42c0 <_ZNK8wxMBConv6cMB2WCEPKc+44>: lwz
r2,156(r30)
0x000e42c4 <_ZNK8wxMBConv6cMB2WCEPKc+48>: lwz
r2,0(r2)
0x000e42c8 <_ZNK8wxMBConv6cMB2WCEPKc+52>: lwz
r0,0(r2)
0x000e42cc <_ZNK8wxMBConv6cMB2WCEPKc+56>: lwz
r3,156(r30)
0x000e42d0 <_ZNK8wxMBConv6cMB2WCEPKc+60>: li
r4,0
0x000e42d4 <_ZNK8wxMBConv6cMB2WCEPKc+64>: lwz
r5,160(r30)
0x000e42d8 <_ZNK8wxMBConv6cMB2WCEPKc+68>: li
r6,0
0x000e42dc <_ZNK8wxMBConv6cMB2WCEPKc+72>: mr
r12,r0
0x000e42e0 <_ZNK8wxMBConv6cMB2WCEPKc+76>: mtctr r12
0x000e42e4 <_ZNK8wxMBConv6cMB2WCEPKc+80>: bctrl
0x000e42e8 <_ZNK8wxMBConv6cMB2WCEPKc+84>: mr
r0,r3
0x000e42ec <_ZNK8wxMBConv6cMB2WCEPKc+88>: stw
r0,64(r30)
0x000e42f0 <_ZNK8wxMBConv6cMB2WCEPKc+92>: lwz
r2,64(r30)
0x000e42f4 <_ZNK8wxMBConv6cMB2WCEPKc+96>: li
r0,-1
0x000e42f8 <_ZNK8wxMBConv6cMB2WCEPKc+100>: cmpw
cr7,r2,r0
0x000e42fc <_ZNK8wxMBConv6cMB2WCEPKc+104>: beq-
cr7,0xe43bc <_ZNK8wxMBConv6cMB2WCEPKc+296>
0x000e4300 <_ZNK8wxMBConv6cMB2WCEPKc+108>: addi
r0,r30,80
0x000e4304 <_ZNK8wxMBConv6cMB2WCEPKc+112>: mr
r3,r0
0x000e4308 <_ZNK8wxMBConv6cMB2WCEPKc+116>: lwz
r4,64(r30)
0x000e430c <_ZNK8wxMBConv6cMB2WCEPKc+120>: bl
0x3e1bd4 <_ZN13wxWCharBufferC1Em>
0x000e4310 <_ZNK8wxMBConv6cMB2WCEPKc+124>: lwz
r2,156(r30)
0x000e4314 <_ZNK8wxMBConv6cMB2WCEPKc+128>: lwz
r2,0(r2)
0x000e4318 <_ZNK8wxMBConv6cMB2WCEPKc+132>: stw
r2,96(r30)
0x000e431c <_ZNK8wxMBConv6cMB2WCEPKc+136>: addi
r0,r30,80
0x000e4320 <_ZNK8wxMBConv6cMB2WCEPKc+140>: mr
r3,r0
0x000e4324 <_ZNK8wxMBConv6cMB2WCEPKc+144>: bl
0x3d7f0c <_ZN13wxWCharBuffer4dataEv>
0x000e4328 <_ZNK8wxMBConv6cMB2WCEPKc+148>: mr
r0,r3
0x000e432c <_ZNK8wxMBConv6cMB2WCEPKc+152>: lwz
r2,64(r30)
0x000e4330 <_ZNK8wxMBConv6cMB2WCEPKc+156>: addi
r2,r2,1
0x000e4334 <_ZNK8wxMBConv6cMB2WCEPKc+160>: lwz
r11,96(r30)
0x000e4338 <_ZNK8wxMBConv6cMB2WCEPKc+164>: lwz
r9,0(r11)
0x000e433c <_ZNK8wxMBConv6cMB2WCEPKc+168>: lwz
r3,156(r30)
0x000e4340 <_ZNK8wxMBConv6cMB2WCEPKc+172>: mr
r4,r0
0x000e4344 <_ZNK8wxMBConv6cMB2WCEPKc+176>: lwz
r5,160(r30)
0x000e4348 <_ZNK8wxMBConv6cMB2WCEPKc+180>: mr
r6,r2
0x000e434c <_ZNK8wxMBConv6cMB2WCEPKc+184>: mr
r12,r9
0x000e4350 <_ZNK8wxMBConv6cMB2WCEPKc+188>: mtctr r12
0x000e4354 <_ZNK8wxMBConv6cMB2WCEPKc+192>: bctrl
0x000e4358 <_ZNK8wxMBConv6cMB2WCEPKc+196>: mr
r0,r3
0x000e435c <_ZNK8wxMBConv6cMB2WCEPKc+200>: stw
r0,64(r30)
0x000e4360 <_ZNK8wxMBConv6cMB2WCEPKc+204>: lwz
r2,64(r30)
0x000e4364 <_ZNK8wxMBConv6cMB2WCEPKc+208>: li
r0,-1
0x000e4368 <_ZNK8wxMBConv6cMB2WCEPKc+212>: cmpw
cr7,r2,r0
0x000e436c <_ZNK8wxMBConv6cMB2WCEPKc+216>: beq-
cr7,0xe43b0 <_ZNK8wxMBConv6cMB2WCEPKc+284>
0x000e4370 <_ZNK8wxMBConv6cMB2WCEPKc+220>: addi
r0,r30,80
0x000e4374 <_ZNK8wxMBConv6cMB2WCEPKc+224>: lwz
r3,152(r30)
0x000e4378 <_ZNK8wxMBConv6cMB2WCEPKc+228>: mr
r4,r0
0x000e437c <_ZNK8wxMBConv6cMB2WCEPKc+232>: bl
0x3e1c10 <_ZN13wxWCharBufferC1ERKS_>
0x000e4380 <_ZNK8wxMBConv6cMB2WCEPKc+236>: addi
r0,r30,80
0x000e4384 <_ZNK8wxMBConv6cMB2WCEPKc+240>: mr
r3,r0
0x000e4388 <_ZNK8wxMBConv6cMB2WCEPKc+244>: bl
0x3c84d8 <_ZN13wxWCharBufferD1Ev>
0x000e438c <_ZNK8wxMBConv6cMB2WCEPKc+248>: b
0xe440c <_ZNK8wxMBConv6cMB2WCEPKc+376>
0x000e4390 <_ZNK8wxMBConv6cMB2WCEPKc+252>: stw
r3,100(r30)
0x000e4394 <_ZNK8wxMBConv6cMB2WCEPKc+256>: lwz
r29,100(r30)
0x000e4398 <_ZNK8wxMBConv6cMB2WCEPKc+260>: addi
r0,r30,80
0x000e439c <_ZNK8wxMBConv6cMB2WCEPKc+264>: mr
r3,r0
0x000e43a0 <_ZNK8wxMBConv6cMB2WCEPKc+268>: bl
0x3c84d8 <_ZN13wxWCharBufferD1Ev>
0x000e43a4 <_ZNK8wxMBConv6cMB2WCEPKc+272>: stw
r29,100(r30)
0x000e43a8 <_ZNK8wxMBConv6cMB2WCEPKc+276>: lwz
r3,100(r30)
0x000e43ac <_ZNK8wxMBConv6cMB2WCEPKc+280>: bl
0x81b10 <_Unwind_Resume>
0x000e43b0 <_ZNK8wxMBConv6cMB2WCEPKc+284>: addi
r0,r30,80
0x000e43b4 <_ZNK8wxMBConv6cMB2WCEPKc+288>: mr
r3,r0
0x000e43b8 <_ZNK8wxMBConv6cMB2WCEPKc+292>: bl
0x3c84d8 <_ZN13wxWCharBufferD1Ev>
0x000e43bc <_ZNK8wxMBConv6cMB2WCEPKc+296>: addi
r0,r30,80
0x000e43c0 <_ZNK8wxMBConv6cMB2WCEPKc+300>: mr
r3,r0
0x000e43c4 <_ZNK8wxMBConv6cMB2WCEPKc+304>: li
r4,0
0x000e43c8 <_ZNK8wxMBConv6cMB2WCEPKc+308>: bl
0x3e1b98 <_ZN13wxWCharBufferC1EPKw>
0x000e43cc <_ZNK8wxMBConv6cMB2WCEPKc+312>: addi
r0,r30,80
0x000e43d0 <_ZNK8wxMBConv6cMB2WCEPKc+316>: lwz
r3,152(r30)
0x000e43d4 <_ZNK8wxMBConv6cMB2WCEPKc+320>: mr
r4,r0
0x000e43d8 <_ZNK8wxMBConv6cMB2WCEPKc+324>: bl
0x3e1c10 <_ZN13wxWCharBufferC1ERKS_>
0x000e43dc <_ZNK8wxMBConv6cMB2WCEPKc+328>: addi
r0,r30,80
0x000e43e0 <_ZNK8wxMBConv6cMB2WCEPKc+332>: mr
r3,r0
0x000e43e4 <_ZNK8wxMBConv6cMB2WCEPKc+336>: bl
0x3c84d8 <_ZN13wxWCharBufferD1Ev>
0x000e43e8 <_ZNK8wxMBConv6cMB2WCEPKc+340>: b
0xe440c <_ZNK8wxMBConv6cMB2WCEPKc+376>
0x000e43ec <_ZNK8wxMBConv6cMB2WCEPKc+344>: stw
r3,100(r30)
0x000e43f0 <_ZNK8wxMBConv6cMB2WCEPKc+348>: lwz
r29,100(r30)
0x000e43f4 <_ZNK8wxMBConv6cMB2WCEPKc+352>: addi
r0,r30,80
0x000e43f8 <_ZNK8wxMBConv6cMB2WCEPKc+356>: mr
r3,r0
0x000e43fc <_ZNK8wxMBConv6cMB2WCEPKc+360>: bl
0x3c84d8 <_ZN13wxWCharBufferD1Ev>
0x000e4400 <_ZNK8wxMBConv6cMB2WCEPKc+364>: stw
r29,100(r30)
0x000e4404 <_ZNK8wxMBConv6cMB2WCEPKc+368>: lwz
r3,100(r30)
0x000e4408 <_ZNK8wxMBConv6cMB2WCEPKc+372>: bl
0x81b10 <_Unwind_Resume>
0x000e440c <_ZNK8wxMBConv6cMB2WCEPKc+376>: lwz
r3,152(r30)
0x000e4410 <_ZNK8wxMBConv6cMB2WCEPKc+380>: lwz
r1,0(r1)
0x000e4414 <_ZNK8wxMBConv6cMB2WCEPKc+384>: lwz
r0,8(r1)
0x000e4418 <_ZNK8wxMBConv6cMB2WCEPKc+388>: mtlr r0
0x000e441c <_ZNK8wxMBConv6cMB2WCEPKc+392>: lmw
r29,-12(r1)
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
r0 0xbffff1c0 3221221824
r1 0xbffff0b0 3221221552
r2 0x532f60 5451616
r3 0xbffff600 3221222912
r4 0x56b9f0 5683696
r5 0xbffff1c0 3221221824
r6 0x6a5 1701
r7 0x0 0
r8 0x6e 110
r9 0x0 0
r10 0x4d652e 5072174
r11 0x44424248 1145193032
r12 0xbffff1c0 3221221824
r13 0x0 0
r14 0x0 0
r15 0x0 0
r16 0x0 0
r17 0x0 0
r18 0x8fe50504 2414150916
r19 0x1 1
r20 0x20000000 536870912
r21 0x8fe507d4 2414151636
r22 0x8fe507d4 2414151636
r23 0x0 0
r24 0x8fe57250 2414178896
r25 0xc4 196
r26 0x8fe50504 2414150916
r27 0x3 3
r28 0x8fe57250 2414178896
r29 0xbffff600 3221222912
r30 0xbffff0b0 3221221552
r31 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
r0 0xbffff1c0 3221221824
r1 0xbffff0b0 3221221552
r2 0x56b9f0 5683696
r3 0xbffff600 3221222912
r4 0x56b9f0 5683696
r5 0xbffff1c0 3221221824
r6 0x6a5 1701
r7 0x0 0
r8 0x6e 110
r9 0x0 0
r10 0x4d652e 5072174
r11 0x44424248 1145193032
r12 0xbffff1c0 3221221824
r13 0x0 0
r14 0x0 0
r15 0x0 0
r16 0x0 0
r17 0x0 0
r18 0x8fe50504 2414150916
r19 0x1 1
r20 0x20000000 536870912
r21 0x8fe507d4 2414151636
r22 0x8fe507d4 2414151636
r23 0x0 0
r24 0x8fe57250 2414178896
r25 0xc4 196
r26 0x8fe50504 2414150916
r27 0x3 3
r28 0x8fe57250 2414178896
r29 0xbffff600 3221222912
r30 0xbffff0b0 3221221552
r31 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
r0 0xbffff1c0 3221221824
r1 0xbffff0b0 3221221552
r2 0x0 0
r3 0xbffff600 3221222912
r4 0x56b9f0 5683696
r5 0xbffff1c0 3221221824
r6 0x6a5 1701
r7 0x0 0
r8 0x6e 110
r9 0x0 0
r10 0x4d652e 5072174
r11 0x44424248 1145193032
r12 0xbffff1c0 3221221824
r13 0x0 0
r14 0x0 0
r15 0x0 0
r16 0x0 0
r17 0x0 0
r18 0x8fe50504 2414150916
r19 0x1 1
r20 0x20000000 536870912
r21 0x8fe507d4 2414151636
r22 0x8fe507d4 2414151636
r23 0x0 0
r24 0x8fe57250 2414178896
r25 0xc4 196
r26 0x8fe50504 2414150916
r27 0x3 3
r28 0x8fe57250 2414178896
r29 0xbffff600 3221222912
r30 0xbffff0b0 3221221552
r31 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
r0 0xbffff1c0 3221221824
r1 0xbffff0b0 3221221552
r2 0x0 0
r3 0xbffff600 3221222912
r4 0x56b9f0 5683696
r5 0xbffff1c0 3221221824
r6 0x6a5 1701
r7 0x0 0
r8 0x6e 110
r9 0x0 0
r10 0x4d652e 5072174
r11 0x44424248 1145193032
r12 0xbffff1c0 3221221824
r13 0x0 0
r14 0x0 0
r15 0x0 0
r16 0x0 0
r17 0x0 0
r18 0x8fe50504 2414150916
r19 0x1 1
r20 0x20000000 536870912
r21 0x8fe507d4 2414151636
r22 0x8fe507d4 2414151636
r23 0x0 0
r24 0x8fe57250 2414178896
r25 0xc4 196
r26 0x8fe50504 2414150916
r27 0x3 3
r28 0x8fe57250 2414178896
r29 0xbffff600 3221222912
r30 0xbffff0b0 3221221552
r31 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 $r30
$18 = 3221221552
(gdb) p *$r30
$19 = -1073745616
(gdb) p $r4
$20 = 5683696
(gdb) info args
this = (const wxMBConv * const) 0x56b9f0
psz = 0xbffff1c0 "1"
(gdb) p /x $r4
$21 = 0x56b9f0
(gdb) p /x *($r4+156)
$22 = 0x0
(gdb) p /x $r30
$23 = 0xbffff0b0
(gdb) p /x *($r30+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 $r0
$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 *$r0
$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;
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1519710&group_id=9863
More information about the wx-dev
mailing list