Page 1 of 1

issue-#149 bug in Kernel.Upper/Lower

Posted: Thu Mar 09, 2017 11:56 am
by Josef Templ
I found and fixed a severe bug in Kernel.Upper/Lower.

For the issue see https://redmine.blackboxframework.org/issues/149.

For the diffs see https://redmine.blackboxframework.org/p ... 09ddc6ad20.

I found this bug when I tried out a trivial optimization in DevSearch.Find that
crashed BlackBox in a random way because memory was overwritten at a random location.
It was just pure luck so far that it did not occur earlier.

- Josef

Re: issue-#149 bug in Kernel.Upper/Lower

Posted: Fri Mar 10, 2017 8:53 am
by Josef Templ
This issue is ready for voting, I think.

- Josef

Re: issue-#149 bug in Kernel.Upper/Lower

Posted: Fri Mar 10, 2017 10:01 am
by Ivan Denisov
The only question. Why ORD(ch), but not S.ADR(ch) ?

Re: issue-#149 bug in Kernel.Upper/Lower

Posted: Fri Mar 10, 2017 12:10 pm
by Josef Templ
Ivan Denisov wrote:The only question. Why ORD(ch), but not S.ADR(ch) ?
WinApi.CharUpperW can be used for two purposes:
1. for converting a single wide character, passed as a zero extended 32 bit value
2. for converting a wide string in place, passed as its start address.

We use it for converting a single wide character but if the high bits are not zero
it is treated as a string address and then the memory is corrupted.

The msdn docu has all the details.
See https://msdn.microsoft.com/en-us/librar ... s.85).aspx.

- Josef

Re: issue-#149 bug in Kernel.Upper/Lower

Posted: Fri Mar 10, 2017 12:25 pm
by Ivan Denisov
Thank you Josef, now I understand better. I also think, that this issue is ready for voting.