Author Topic: unknown exception  (Read 39721 times)

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: unknown exception
« Reply #45 on: December 16, 2005, 09:26:06 pm »
There is no 0x00 in a bin64 encoded string :)  Luckily, or we couldn't do that :)

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+   <---  these are all.


However the base64 decode algorithm builds up a return string starting with ' ', followed by 0x0, etc.  This is not OK for a string value.  i.e. The returned string is 0x15,0x0, "wxDocking-Stream-v1.0"
Right, but the data really looks like this. This is correct. And wxString is meant to hold 0x00 values. This certainly works.
« Last Edit: December 16, 2005, 09:28:40 pm by thomas »
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline grv575

  • Official tester
  • Regular
  • ***
  • Posts: 381
Re: unknown exception
« Reply #46 on: December 16, 2005, 09:29:06 pm »
See message one up.  I just upped the screenshot.  I'm not sure how that <bin></bin> string got calculated, but it looks incorrect in Unicode mode.  The first two boxes in the screenshot are 0x15,0x0.  These should all be spaces I would think.

Offline grv575

  • Official tester
  • Regular
  • ***
  • Posts: 381
Re: unknown exception
« Reply #47 on: December 16, 2005, 09:32:41 pm »
Well, even if 0x0 nulls are OK in wxStrings, when we build a memory stream from the c_string version of the wxString, doesn't this chop off at the first 0x0?

Code: [Select]
    buf = Manager::Get()->GetConfigManager(_T("app"))->ReadBinary(_T("/main_frame/layout"));
    wxMemoryInputStream ms(buf.c_str(), buf.Length());

And then the ms memorystream wouldn't hold all it should, so it crashes a few lines below.

Edit:

When I put a watch on ms after those two lines, gdb gives <incomplete type>.  Tracing into the wxSlideBar::LoadFromStream -> wxUtil::ReadString() call,

wxDockit/src/generic/util.cpp:34
Code: [Select]
    stream.Read( &size, sizeof( size ) );

sets size to 1392520448.  We then allocate a buffer:
Code: [Select]
    char* psz = new char[size + 1];
whoops.
« Last Edit: December 16, 2005, 09:38:41 pm by grv575 »

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: unknown exception
« Reply #48 on: December 16, 2005, 09:37:57 pm »
Well, even if 0x0 nulls are OK in wxStrings, when we build a memory stream from the c_string version of the wxString, doesn't this chop off at the first 0x0?
No. wxMemoryInputStream comes in two flavours.

Code: [Select]
    wxMemoryInputStream ms(buf.c_str(), buf.Length());
                                        ^^^^^^^^^^^^

This one is safe to be used with 0x0, the other is not.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline grv575

  • Official tester
  • Regular
  • ***
  • Posts: 381
Re: unknown exception
« Reply #49 on: December 16, 2005, 09:44:35 pm »
Look at the screenshot.  Specifically the size variable value after reading the stream.  Also at where the gdb -> arrow is.  I trace one more line, (allocate that huge char buffer) and it gives the exception.  See it's heap corruption after all.  Malloc() == :)

Something wrong with the stream encode or decode or... at least with a unicode build.


[attachment deleted by admin]

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5193
Re: unknown exception
« Reply #50 on: December 16, 2005, 11:05:05 pm »
no idea if this might give any hints or not, but tiwag and I suffered also from a problem tht our debug toolbar was gone. The only way to get it back was deleting the <LAYOUT>  ... crc ... thingy. This was on a windows NON unicode build.

Hope this is usefull information.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: unknown exception
« Reply #51 on: December 17, 2005, 12:56:17 am »
Oh Yes!! And I think I know what is wrong. Look:

http://www.wxwidgets.org/manuals/2.6.2/wx_wxmeminputstream.html#wxmemoryinputstreamctor

It takes len chars, but wxString has len wchars in Unicode!

So we have to... umm... do without a wxString outside wxDockit. The base64 data is byte data, by definition. But... if we put it into a wxString, it is transformed to double-byte nevertheless. It does not matter normally, but here it does, because wxMemoryInputStream apparently does not understand Unicode...
So we have to allocate a char[] and copy the characters from the string in there.... or rewrite both Base64Decode and ConfigManager. I guess copying the characters to a char[] will be easier.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline takeshi miya

  • Lives here!
  • ****
  • Posts: 1487
Re: unknown exception
« Reply #52 on: December 17, 2005, 01:35:25 am »
I don't understand this, in wx/mstream.h the ctor is defined as

Code: [Select]
wxMemoryInputStream(const void *data, size_t length);and not as
Code: [Select]
wxMemoryInputStream(const char *data, size_t length);

Offline 280Z28

  • Regular
  • ***
  • Posts: 397
  • *insert unicode here*
Re: unknown exception
« Reply #53 on: December 17, 2005, 01:48:16 am »
If this builds, I have a patch for you. What. A.Pain. That. Was.  :shock:

All the other patches I already posted on SF.

I keep switching between unicode and non to make sure both are working... not just one.
« Last Edit: December 17, 2005, 01:50:58 am by 280Z28 »
78 280Z, "a few bolt-ons" - [email protected]
99 Trans Am, "Daily Driver" - 525rwhp/475rwtq
 Check out The Sam Zone :cool:

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: unknown exception
« Reply #54 on: December 17, 2005, 01:52:57 am »
I don't understand this, in wx/mstream.h the ctor is defined as
Code: [Select]
wxMemoryInputStream(const void *data, size_t length);and not as
Code: [Select]
wxMemoryInputStream(const char *data, size_t length);
No...?
Quote from: http://www.wxwidgets.org/manuals/2.6.2/wx_wxmeminputstream.html#wxmeminputstream
wxMemoryInputStream::wxMemoryInputStream

wxMemoryInputStream(const char * data, size_t len)

Apart from that, sizeof(void) == sizeof(char) so it would not matter anyway.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: unknown exception
« Reply #55 on: December 17, 2005, 02:09:59 am »
Try if this works in Unicode, please. It might just do fine (it works in ANSI, and it is a lot easier).

[attachment deleted by admin]
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline 280Z28

  • Regular
  • ***
  • Posts: 397
  • *insert unicode here*
Re: unknown exception
« Reply #56 on: December 17, 2005, 02:26:15 am »
Try if this works in Unicode, please. It might just do fine (it works in ANSI, and it is a lot easier).

It's building  :)
78 280Z, "a few bolt-ons" - [email protected]
99 Trans Am, "Daily Driver" - 525rwhp/475rwtq
 Check out The Sam Zone :cool:

Offline 280Z28

  • Regular
  • ***
  • Posts: 397
  • *insert unicode here*
Re: unknown exception
« Reply #57 on: December 17, 2005, 02:31:42 am »
It'll work if you change everything in appglobals.h back to #define statements



[attachment deleted by admin]
78 280Z, "a few bolt-ons" - [email protected]
99 Trans Am, "Daily Driver" - 525rwhp/475rwtq
 Check out The Sam Zone :cool:

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: unknown exception
« Reply #58 on: December 17, 2005, 02:46:10 am »
No, I'll rather change the about box... but that can wait until tomorrow morning.

The important thing is whether this patch fixes the crash. Because if it does, then we can stop looking now, and I'll commit it after sleeping for 5 hours...
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline 280Z28

  • Regular
  • ***
  • Posts: 397
  • *insert unicode here*
Re: unknown exception
« Reply #59 on: December 17, 2005, 02:49:26 am »
No, I'll rather change the about box... but that can wait until tomorrow morning.

The important thing is whether this patch fixes the crash. Because if it does, then we can stop looking now, and I'll commit it after sleeping for 5 hours...

The about box.. the title bar.. the status bar..

It wasn't crashing on me
78 280Z, "a few bolt-ons" - [email protected]
99 Trans Am, "Daily Driver" - 525rwhp/475rwtq
 Check out The Sam Zone :cool: