RISC OS London Show 2014
Steve Fryatt (216) 2105 posts |
what on Earth are alignment exceptions? Er, yes. The way that “unaligned” memory reads and writes (ie. ones to memory addresses which are not multiples of four) happen changed on ARMv7 processors compared to the older chips, resulting in them being unlikely to load or save data in the way that the author of the software making use of them expected. In other words, any software using such “unaligned” transfers is very likely to be corrupting its data in some way when used on modern hardware; in the worst case, this could lead on to other areas of memory (eg. OS workspace, disc maps) being corrupted. Because such corruption is undesirable, the new processors have two ways of handling such loads and stores. They can either carry on and hope for the best (alignment exceptions “off”), or they can raise an “exception” which RISC OS catches as an error, stopping the job completely (alignment exceptions “on”).
Every time an application stops with the exceptions on, it’s tried to do something that would have corrupted memory and the system has caught it. Turning exceptions off may allow it to run, but it won’t stop it executing those “unaligned” loads and stores; this means that each time it would have errored, it’s very likely just corrupted its own data in some way and not told you. This may also lead to corruption of data belonging to the OS as well. I can’t see any scenario where I’d want to run with the exceptions off, to be honest. If software needs them off to run, you probably don’t want to be running it on the machine anyway — unless you have no unsaved work and extensive backups of your disc/SD card contents. |
Tennant Stuart (2505) 122 posts |
Wow, thanks Steve – and now I know what that particular bit of jargon means, I’m almost shocked since it’s like… dirty.
So for my PandaRo Pro it’s irrelevant – I don’t want to turn alignment exceptions off, and there’s no point anyway? |
David Feugey (2125) 2709 posts |
I won’t be so extreme. Lots of software works only with AE off, without any problem. To be honest, most software that was not recompiled for ARMv7. Of course it can crash the system, then stop using the application… My only advice when an application does not work, is to turn AE off and to test it. It’s better to have 2000 software than 400 :) Firefox is a good example of application that works OK with AE off. There are hundreds of other examples. Of course new software should not rely on this feature. |
Rick Murray (539) 13840 posts |
Yes – it seems the older C compiler seemed to have a habit of using unaligned accesses (not sure when or why). Also, be aware that the software is loading data incorrectly. Whether or not this makes a difference is up to you to decide, however since one of my old apps caused the Wimp to give some strange errors, it may be that the application can be doing all sorts of weird things, like passing very invalid data in SWI calls, or corrupted wimp blocks, for example.
As mentioned before, after you have backed up your data and with nothing else running… |
Raik (463) 2061 posts |
I use “AE off” by default in Predesk (Jeffrey posted (?) a short basic tool in the past) since 2010 with my first Beagle C4. No bigger known problems with Beagle, -xM, Pandora, PandaA4 and -ES with the software I use. |
Steve Pampling (1551) 8170 posts |
Hmmm. Do you also like standing on high places, flying kites into thunderstorms? How about “No bigger known problems”… … so far. |
George T. Greenfield (154) 748 posts |
“Firefox is a good example of application that works OK with AE off.” |
Rick Murray (539) 13840 posts |
Utter speculation – but imagine some weird code is performing unaligned loads to determine an address of a buffer (might not be that weird, would “packed” structs behave like this?). The program will be wanting to write to, say, stash its data to a block of memory within its workspace, but thanks to the load behaving in an unexpected manner, the data pointer is somewhere in the dynamic area used by SDFS for the disc map. It is a contrived example, but hopefully you’ll start to understand that the processor isn’t whinging because it is bored or wants fed or a stroking… it is trying to tell you something is amiss. |
Raik (463) 2061 posts |
Any times a program failed but not often and with no known data lost since I use this. |
Steve Pampling (1551) 8170 posts |
There is an English phrase: “You’re pushing your luck” |
Raik (463) 2061 posts |
There is a comparable German phrase. But I think is not the complete truth. |
Paul Sprangers (346) 524 posts |
I’m with Raik. On the other hand, the unpredictable errors and stiffenings that I do encounter from time to time, may very well be attributed to the “AE off” decision after all. However, I never detected any data loss or disc damages. A Control-break or a reset always solves the problem. So, we may still be pushing our luck, but apparently not to an extent that it leaves us. |
Jeffrey Lee (213) 6048 posts |
One thing that’s worth mentioning is that the random crashes, etc. that some people experience when they have alignment exceptions turned off might not be due to software doing unaligned loads. There are plenty of other code sequences which can cause issues on ARMv6+ (more on ARMv7 than ARMv6). Unaligned loads/stores are the only feature we can turn off – other features like interworking on MOV PC,LR can’t be disabled, and you’ll only find out about them causing problems is after the fact. The CPU could switch to Thumb mode due to a dodgy MOV PC,LR and execute any number of garbage instructions (corrupting memory as it goes) before it finally hits an instruction which causes a crash. So I tend to view alignment exceptions as being an “early warning system” – if something crashes when they’re turned on then it indicates that it’s an old piece of software which could suffer from any number of compatibility issues, and it’s probably best to try and avoid using the software where possible. This is also why I abandoned my idea of creating a module which would catch alignment exceptions and emulate the ARMv5 behaviour – a lot of the Iyonix-compatible software I was testing was actually crashing due to encountering other compatibility issues, and creating a piece of software which fixes alignment exceptions would only serve to expose peoples systems to the more serious issues which might happen later on during a program’s execution. |
George T. Greenfield (154) 748 posts |
RISC OS Pi’s !Configure offers 3 CPU configurations: ARMv5 compatibility mode (emulate ‘rotated loads’ to support older software); ARMv7 strict mode (‘alignment exceptions’ on) Older software using ‘rotated loads’ will not run; ARMv7 fast mode (‘alignment exceptions’ off) New software may run faster, older software may crash or corrupt data. ATM I am using the ARMv5 mode, as I have quite a bit of elderly software (Rhapsody, Eureka). You seem to be saying that emulation of ARMv5 behaviour is not desirable – or have I misunderstood? Or is it recommended to run in ARMv7 strict mode at all times, even when using elderly software? |
Jeffrey Lee (213) 6048 posts |
As far as I know, running ARMv5 mode on the Pi is fine – compared to a real ARMv5 there aren’t any prescribed differences that I’m aware of that will cause compatibility issues. The problem however is that there might be some unprescribed differences. E.g. MOVS PC,LR is an instruction which has always been described as being unpredictable if executed in USR32 mode. Some software (I can’t remember what) that I’d been running on my Iyonix used that instruction, and it always ran fine. Chances are it had also been running fine on RiscPCs and other machines running 32bit OS’s (perhaps even the A9, which is also ARMv6). But when I tried running it on my BeagleBoard I found that it crashed horribly due to that instruction. I’m yet to hear of any problems on the Pi caused by instructions like that, but since we’ve already shaken out pretty much all of the ARMv6/v7 compatibility issues from the OS sources the chances of me encountering a problem like that during my day-to-day work are pretty slim. |
Rick Murray (539) 13840 posts |
ARMv5 compatibility is okay, as the quirky older behaviour will behave as would be expected. We’re mainly referring to the likes of the OMAP which do not have a compatibility mode.
Emulating the older way of working is fine – and it is one of the nice things about the Pi that you have this choice. What we are raising eyebrows over is turning off the alignment exceptions (in ARMv7 mode) in the hope that it will magically make the problems go away. It’s a fallacy – the problems are still there, you’re just not being told. That’s all.
I’d say “suck it and see”; but given that elderly software written in C used the older compiler, there’s a good chance that you’ll either get weird errors (I think one of my programs caused the Wimp to say “Not a task” or something like that when it started) or you’ll get the backtrace gibberish. |
Tennant Stuart (2505) 122 posts |
Isn’t that just shrug and admire all the disk errors liberally scattered throughout my SD card? |
jim lesurf (2082) 1438 posts |
FWIW I dislike the way AE are described simply as ‘On/Off’. It keeps confusing me as to what ‘On’ and ‘Off’ actually mean. Is it the exceptions or the errors I’m switching on? Then have to think it though again. I’d prefer terms that explictly warn of which option is safe and which lets software run on risking problems. e.g. Misalignments : ‘Trap and Warn (safe)’ versus ‘Ignore and allow (risky)’ But I agree that’s probably too long. So something like ‘Warn (safe)’ and ‘Ignore (risky)’ might be better. Jim |
patric aristide (434) 418 posts |
Perhaps you shouldn’t use it if you don’t understand it. |
Raik (463) 2061 posts |
Is it possible your card is the problem? |
Tennant Stuart (2505) 122 posts |
At the moment, my SD card doesn’t have a problem; I was referring to this post by George T. Greenfield on November 5th at 6:55pm…
|
jim lesurf (2082) 1438 posts |
Erm, you don’t say who you’re talking to or what “it” you have in mind. For machines like ARMiniX we have to “use” this in the sense that we have to choose to either trap and warn or allow the machine to proceed regardless of risks. The difficulty I was pointing out is actually understanding what choice you’re making by an “On” or “Off” if you’re not already a helicopter-hat programmer. 8-] FWIW I have my ARMiniX set to trap and warn. The problem is that the phrasings used are confusing unless you’ve thought this though. Not helpful for mere users who just want a coconut. The basic problem is what “On” means when you’re offered the choice: Alignment Exceptions On/Off if you have no idea what “Alightment Exceptions” actually means. Particularly as it is easy to think of “Errors” rather than “Exceptions” so miss the point. That’s then aggrivated when someone gets warings without then seeing any consequent problems they can identify. “Oooh! Alignment Exceptions keep popping up! That’s a pest, I don’t think I want any of them. Better turn them off!” Jim |
Rick Murray (539) 13840 posts |
I think what he is saying is if you don’t understand what the setting means, leave it alone. ;-) |