RISC OS Open
Safeguarding the past, present and future of RISC OS for everyone
ROOL
Home | News | Downloads | Bugs | Bounties | Forum | Documents | Photos | Contact us
Account
Forums → General →

Toolbox/Wimp error on the OMAP

Subscribe to Toolbox/Wimp error on the OMAP 12 posts, 4 voices

 
Nov 28, 2010 9:28pm
Avatar Tank (53) 357 posts

I have been writing a program that uses the Toolbox, and have been developing it on the Iyonix. When testing on the OMAP port, a simple window open from the icon bar icon locks the machine up. If address exeptions are off, the open works fine.

The problem seems to be connected to checkhandle in Wimp04 of the WindowManager source.

The offending code uses R10 as a pointer with a fixed offset (LDR R0,[R10,#w_guardword]).

when entering this instruction, R10 is equal to 3.

 
Nov 28, 2010 9:40pm
Avatar Jeffrey Lee (213) 5984 posts

The bit in checkhandle, at line 5840? That should be easy enough to fix:

TST handle,#3
BNE errhandle

Of course, the real question is why are you (or the toolbox!) passing a window handle of 3 to the wimp…

 
Nov 28, 2010 9:44pm
Avatar Jeffrey Lee (213) 5984 posts

a window handle of 3

Although looking at what the ‘Abs’ macro does, it looks like it must be a window handle of 4 (which the Abs macro translates to a window pointer of 3, via the incredibly high-tech hashing/obfuscation method of substracting 1)

 
Nov 28, 2010 9:49pm
Avatar Tank (53) 357 posts

Yes, thats the bit. In the compiled code, the Abs handle,handle at line 5830 compiles to SUB R10,R10,#-1 ?

As to why the handle is only 3 thats a mistery to me as when execptions are off, both wimp and toolbox handles are normal looking.

Also, this is 100% repeatable with the program in question, but not with a different program … The open window request is generated by the icon bar gadget in both cases.

Oops, posts crossed in writing !!!

 
Nov 29, 2010 6:51pm
Avatar Tank (53) 357 posts

OK, I seem to have cured it by changing the Show default to Show centred option in the Iconbar setup. Changing it back after saving, all seems well.

Some stray bit in the flag word must have been at fault, but I am suprised this didn’t cause a reserved flags error to show.

 
Nov 29, 2010 7:02pm
Avatar Tank (53) 357 posts

On another note, the ROL toolbox modules (the ones I have are dated in 2008) work with the OMAP port….

 
Nov 29, 2010 10:20pm
Avatar Tank (53) 357 posts

Another thought , is it worth changing the Abs macro to-

MACRO

Abs $to,$from,$cc

MOV$cc $to,$from,LSR #2

MOV$cc $to,$to,LSL #2

MEND

I have tried this on my BBxM and no problems seem evident.

 
Dec 1, 2010 2:27pm
Avatar Steve Revill (20) 1361 posts

Wouldn’t the single instruction:

BIC$cc $to,$from,#3

do the same thing as your two MOV instructions?

 
Dec 1, 2010 3:44pm
Avatar Tank (53) 357 posts

Ah.. yes.

Does anyone actually know the effect this macro is tying to achieve, is it just to align the address used, or is there a darker objective..

Also, the Rel macro below it in the source just adds 1 as its result, and then is used as a window pointer from where it is called.

 
Dec 1, 2010 4:44pm
Avatar Jeffrey Lee (213) 5984 posts

Does anyone actually know the effect this macro is tying to achieve, is it just to align the address used, or is there a darker objective..

To me it looks like it’s a primitive method of obfuscating the pointer so that it looks more like an arbitrary ID rather than a pointer which nosey programmers will poke around in.

Plus the act of obfuscating it may help to reveal errors (e.g. if you pass a null pointer to the wimp, the Abs macro would turn it into -1, which would then – at least on machines with a 26 bit address bus – result in a nice data abort). But since the wimp also seems to range check the pointers, and checks for a guard word at a certain position inside each window structure, it’s questionable whether the Abs/Rel macros were designed to help with error checking or not.

It’s probably best to just leave the Abs/Rel code as it is, since it’s not doing any harm and could be rather tricky to remove without introducing lots of hidden bugs.

 
Dec 4, 2010 5:51pm
Avatar Jeffrey Lee (213) 5984 posts

I’ve now checked in a change so that checkhandle checks that pointers are word aligned.

 
Dec 27, 2010 3:15am
Avatar Ben Avison (25) 445 posts

My suspicion was always that the requirement that the public Wimp API expects window handles to have bit 0 set comes from the menu item structure. Once upon a time (RISC OS 2 I think) there could only be 256 windows open at a time, and window handles happened to use an index number, so submenus could be either dialogue boxes (identified by window handles less than 256) or other menu structures (identified by addresses in the application slot or higher). When this limit was lifted, window handles would still needed to be easily convertible to RMA addresses, yet using an RMA address directly would have made this ambiguous. Older Wimps already assumed menu structure pointers were at least word aligned, so using bit 0 in this way is an obvious choice for expanding the handle pool without breaking compatibility.

Of course, it’s also true that it’s a valuable way to dissuade people from fiddling in internal Wimp data structures – you should always treat all handles as opaque data.

Using ADD/SUB in Abs/Rel rather than BIC/ORR may have been a deliberate attempt to be sensitive to uninitialised or corrupted handles.

Reply

To post replies, please first log in.

Forums → General →

Search forums

Social

Follow us on and

ROOL Store

Buy RISC OS Open merchandise here, including SD cards for Raspberry Pi and more.

Donate! Why?

Help ROOL make things happen – please consider donating!

RISC OS IPR

RISC OS is an Open Source operating system owned by RISC OS Developments Ltd and licensed primarily under the Apache 2.0 license.

Description

General discussions.

Voices

  • Tank (53)
  • Jeffrey Lee (213)
  • Steve Revill (20)
  • Ben Avison (25)

Options

  • Forums
  • Login
Site design © RISC OS Open Limited 2018 except where indicated
The RISC OS Open Beast theme is based on Beast's default layout

Valid XHTML 1.0  |  Valid CSS

Powered by Beast © 2006 Josh Goebel and Rick Olson
This site runs on Rails

Hosted by Arachsys