* * *

Author Topic: Same code works on x86, crashes on ARM  (Read 1378 times)

Thaddy

  • Hero Member
  • *****
  • Posts: 6560
Re: Same code works on x86, crashes on ARM
« Reply #15 on: August 09, 2018, 08:16:12 pm »
When I run the program compiled with FPC trunk and Lazarus trunk as sudo, at least my Raspberry Pi 3 shows up correct.
I made two small changes:
- I call Form1.BeginFormUpdate/Form1.EndFormUpdate in the init button to speed up painting.
- I changed the ridiculous try except to set the timer interval to
Code: Pascal  [Select]
  1.   i := strtointdef(Edit1.Text,10);
 

So the program works OK. See screenshot.
I saw more coding and layout issues, but those are for later. It works.
Can be that you need to upgrade to trunk versions.
« Last Edit: August 09, 2018, 08:24:00 pm by Thaddy »
Ada's daddy wrote this:"Fools are my theme, let satire be my song."

TCH

  • Jr. Member
  • **
  • Posts: 91
Re: Same code works on x86, crashes on ARM
« Reply #16 on: August 09, 2018, 09:08:43 pm »
No, you got it all wrong. As i told, the program crashes when you enter into the boxes and hit 1 or 0. Your changes are totally irrelevant to that. The program still crashes when editing the fields. And the problem is, that it works for the first N time, then suddenly it crashesh. If i change which TEdit i edit, then it crashes more easily.

Still, thanks for the strtointdef function, i wasn't aware of that function.

Thaddy

  • Hero Member
  • *****
  • Posts: 6560
Re: Same code works on x86, crashes on ARM
« Reply #17 on: August 09, 2018, 09:36:58 pm »
As long as I run as sudo I can also repeatedly edit the edit boxes and it does not crash.(yet) but I use fpc3.1.1 + Lazarus 1.9.
What are you using? fpc version? Laz version?
I forgot that I also added cthreads, btw.
« Last Edit: August 09, 2018, 09:40:39 pm by Thaddy »
Ada's daddy wrote this:"Fools are my theme, let satire be my song."

Thaddy

  • Hero Member
  • *****
  • Posts: 6560
Re: Same code works on x86, crashes on ARM
« Reply #18 on: August 10, 2018, 06:30:38 am »
It still doesn't crash.... :D
Ada's daddy wrote this:"Fools are my theme, let satire be my song."

TCH

  • Jr. Member
  • **
  • Posts: 91
Re: Same code works on x86, crashes on ARM
« Reply #19 on: August 10, 2018, 02:43:54 pm »
I am running it as a root. FPC is 3.0.2 and Lazarus is 1.6.4.
It already had CThreads, as the relevant conditional macro has been commented out.

Please send me the binary you built and let me try it. If it does not crash, then the problem is inside the version of Lazarus/FPC i use. If it crash, then it's in my system.

Thaddy

  • Hero Member
  • *****
  • Posts: 6560
Re: Same code works on x86, crashes on ARM
« Reply #20 on: August 10, 2018, 03:33:22 pm »
I am running it as a root. FPC is 3.0.2 and Lazarus is 1.6.4.
It already had CThreads, as the relevant conditional macro has been commented out.

Please send me the binary you built and let me try it. If it does not crash, then the problem is inside the version of Lazarus/FPC i use. If it crash, then it's in my system.
Ok. But you are using OLD versions and that's the cause!
I will put it on my website, too large to attach.

Link to binary is: http://thaddy.org/el_gpiot.zip compiled on RPi3 Rasbian-stretch. -O2 optimization.
It works. But note it is compiled with trunk. I suppose 3.0.4 and 1.8.4 will also do (but not old crap)
« Last Edit: August 10, 2018, 03:49:06 pm by Thaddy »
Ada's daddy wrote this:"Fools are my theme, let satire be my song."

TCH

  • Jr. Member
  • **
  • Posts: 91
Re: Same code works on x86, crashes on ARM
« Reply #21 on: August 13, 2018, 01:36:50 pm »
I have downloaded your binary and it crashes when i click on the Init button. It does not even get that far to show up the textfields...

Is there any repository for Debian armv7l with Lazarus 1.8 and FPC 3.0.4? Debian repo contains only old ones and Lazarus download page does not have any ARM download.

Thaddy

  • Hero Member
  • *****
  • Posts: 6560
Re: Same code works on x86, crashes on ARM
« Reply #22 on: August 13, 2018, 02:12:11 pm »
Well. I thoroughly tested it and here it does not crash. It only crashes if you are not running as root or sudo. Maybe a dependency is missing on your computer? Or a raspi-config setting?
To obtain version 3.0.4 there are three options:
1. add stretch-backports to /etc/apt/sources.list. FPC 3.0.4 and Lazarus 1.8.4. are both in stretch-backports. You can subsequently install them with apt or apt-get
    You need to install with the -t option. See https://backports.debian.org/Instructions/
2. use fpcdeluxe
3. build from source. Here's how I do that.
step 0. sudo apt-get update && sudo apt-get dist-upgrade -y If you haven't done that for a long time.
step 1. check out the sources for fixes-3.0.4 or 3.1.1 trunk for fpc from svn
step 2. rename or copy the executable (not the symlink ) ppcarm to fpcstart and move it to your home directory.
           If /usr/local/bin/ppcarm is a symlink, the binary is here: /usr/local/lib/fpc/3.0.2/ppcarm or here /usr/lib/fpc/3.0.2/ppcarm
step 3. sudo apt-get remove fpc
step 4. change to the directory where you checked out the sources, probably /home/pi/fpc
step 5. sudo make clean all install  PP=/home/pi/fpcstart
step 6. sudo cp /usr/local/lib/fpc/3.0.4/ppcarm /usr/local/bin. use 3.1.1 instead of 3.0.4. if you use trunk.
step 7. type fpc -v in a terminal window. It should give you the new version.
step 8. sudo apt-get remove lazarus
step 9. check out the lazarus sources from git either 1.8.4 or trunk
step 10. goto the lazarus source directory
step 11. make clean all install
step 12. type ./startlazarus
« Last Edit: August 13, 2018, 02:26:41 pm by Thaddy »
Ada's daddy wrote this:"Fools are my theme, let satire be my song."

Thaddy

  • Hero Member
  • *****
  • Posts: 6560
Re: Same code works on x86, crashes on ARM
« Reply #23 on: August 13, 2018, 03:55:46 pm »
@TCH
I reworked the code a bit and it seems a bit more stable (I could intermittently get an error, seldom, but still...After all...). I suspect that the runtime control creation had issues.
I will attach the code here later.
[edit]
Attached.
« Last Edit: August 13, 2018, 04:25:11 pm by Thaddy »
Ada's daddy wrote this:"Fools are my theme, let satire be my song."

Thaddy

  • Hero Member
  • *****
  • Posts: 6560
Re: Same code works on x86, crashes on ARM
« Reply #24 on: August 13, 2018, 09:54:17 pm »
@TCH
Currently solving some issues regarding you not testing fpopen, fpclose, fpmmap and fpmunmap results.
I have introduced a EGpioException to handle those and made the procedures in el_gpiot into boolean functions.
Will attach code tomorrow. We're getting there. I also made everything range safe: it wasn't.
Ada's daddy wrote this:"Fools are my theme, let satire be my song."

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus