Zap Block edit, tabs, not a heap block
David J. Ruck (33) 1635 posts |
One cause of the many many many Not a Heap Block errors Zap 1.47 rick-07 throws on my 5.27rc16 ARMx6 mini.m is attempting to block edit some text which contains tabs. Reproducable every time. |
David J. Ruck (33) 1635 posts |
Another similar cause is a search and replace into a line which contains tabs. So it looks like tab handling is completely fscked. |
Rick Murray (539) 13840 posts |
Ah, so that why I never see these problems. I hate tabs. Files with tabs are completely fscked. Is a tab 3? 4? 8? Line-up-with-what’s-above? I’ve seen it all. And in one sorry case, a file where the interpretation differed depending, I guess, upon when that bit of it was edited. Anybody smarter than me (and with more time) willing to fiddle around inside Zap’s dark dusty corners to see what’s blowing up? |
Clive Semmens (2335) 3276 posts |
Hear, hear! Tabs belong in tables in WP or DTP or in spreadsheet files (if anywhere), not plain text and certainly not code. |
David J. Ruck (33) 1635 posts |
I’ve been eliminating tabs everywhere since I first started using Python, because mixing tabs and spaces there leads to a special type of hell. All my C and C++ is now tab free too, which includes the old 8 indent with tabs, the horrendous 4 indent with half tabs half with spaces, and the recent 4 tab stuff. However tabs still persist in makefiles for some platforms for historical reasons. I was using tabs temporarily when I reported this. I was creating obey files with multiple lines of “copy sourcefile destfile” and I wanted the columns of filenames to line up, so used tabs intending to convert to spaces at the end. During this I need to block edit and use search and replace, which Zap threw a wobbly at, so had to untabify immediately. |
Julie Stamp (8365) 474 posts |
I can’t replicate this. I copied Can you see if this still happens |
David J. Ruck (33) 1635 posts |
I am using 1.49 rick-07 from the store. On the ARMx6 the block edit bug is reproducible, just select a few lines and try to delete the D of DestFile to trigger it, in either obey or text mode. I get not a heap blocks, or various exceptions. Trying the same thing on the Pi 3B, I don’t get heap blocks or aborts, but block editing anything around the tab is completely weird, the two characters after cant be deleted and editing anything else on the rest of the line is as if the cursor is two characters to the left of where it is shown. I can’t reproduce search and replace with tabs now, either replacing after the tab or spanning the tab. But I’ll let you know if it happens again. Incidentally I’d saved a search and replace in a text file, and when I came to use it again by selecting and using ctrl+P in to the dialog, all the backslashes in the search string had become prefixed with backquotes. |
Julie Stamp (8365) 474 posts |
I still can’t get anything weird to happen unfortunately :-( Just to clarify, by block edit you mean literally just selecting text and pressing the backspace key? If you are able to trigger an exception, then
might help us figure it out. |
Fred Graute (114) 645 posts |
I can confirm the block edit bug, and when it happens it’s very reproducible. It’s caused by an unaligned memory access so will only show when address exceptions are on. Below is the debug output I collected. The sequence This is with Zap 1.49 (rick-07) on a mini.m running RO 5.27 (09-Jun-2020).
|
David J. Ruck (33) 1635 posts |
That would make sense, the minim crashes on unaligned access, where the Pi is accessing the wrong location, hence editing two characters away from where the cursor is. What I don’t understand is I get exceptions on the mini.m with alignment exceptions on or off, and I get funny behavior but no exceptions on the Pi 3B with alignment exceptions on or off. It would be good to get the Pi crashing in the same way, so it can be reproduced without have to have the far less common mini.m |
Julie Stamp (8365) 474 posts |
Thanks! That’s at the end of |
Julie Stamp (8365) 474 posts |
From
Could we change it to
? |
David J. Ruck (33) 1635 posts |
The code as it stands doesn’t look correct to me, its loading from either +0 or +2 addresses then using the top 16 bits shifted down in the next instruction. i.e with rotated loads for +0 it getting bits 16-32, and for +2 getting bits 0-15. Where as if you used LDRH you would get for +0 bits 0-15 and for +2 bits 16-31. Is it some hack to avoid using a 16 bit mask by storing the column numbers in the order 1,0,3,2,5,4 ? My brain might just be too melted to understand this anymore. |
Fred Graute (114) 645 posts |
Has a fix for this been found yet? I ask because I came across some scraps with possible solutions – that I drew up after reporting the above debug info – and I’m wondering if they might still be of interest or that they can be tossed. |
Julie Stamp (8365) 474 posts |
I haven’t done it myself.
Yes please :-)
If you are unable to run Rick’s version on v5 or v6 can you let us know what the issue is? |
Fred Graute (114) 645 posts |
Below are my brief notes. The top section describes what happens on a CPU that supports unaligned loads, followed by the original code. The middle section shows a potential solution using LDRH. This has the drawback of losing RiscPC compatibility as its memory bus doesn’t support halfword transfers. The final section has a slightly more elaborate solution but it should work on any machine. A quick test showed that the abort is gone but the result of a block edit can be weird, and by weird I mean that the result wasn’t the same as my yardstick (i.e. StrongED ;-). It happens when you have a file where some lines are indented with spaces and others with visible tabs. The code in
|
Chris Hall (132) 3554 posts |
Block edits in !Zap that span a single short line, in BASIC mode, fail already anyway. |