Recent

Author Topic: [LAMW] Setlength causes the app to crash  (Read 6821 times)

Josh

  • Hero Member
  • *****
  • Posts: 1271
Re: [LAMW] Setlength causes the app to crash
« Reply #15 on: December 21, 2021, 10:39:33 pm »
hi

using l:=l*2; to setlength makes for a massive array
with 28bytes per record at step  29 its nearly 4GB in size

« Last Edit: December 21, 2021, 10:41:07 pm by josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: [LAMW] Setlength causes the app to crash
« Reply #16 on: December 21, 2021, 10:42:13 pm »
Do you use pointers in your code?

Run your app
Clear the log with adb logcat -c
Start the log with errors using: adb logcat *:E
Crash your app
Stop the log using CTRL+C
Paste the result here

Like this post if you can.

For more, check: adb logcat --help

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: [LAMW] Setlength causes the app to crash
« Reply #17 on: December 21, 2021, 10:45:07 pm »
hi

using l:=l*2; to setlength makes for a massive array
with 28bytes per record at step  29 its nearly 4GB in size

Yes. Since we don't know why his app crashed, I was hoping for a big value in l. The other possibility, corrupt memory. In both cases SetLength is not the problem. His code has a bug somewhere else.
« Last Edit: December 21, 2021, 10:46:57 pm by engkin »

r.lukasiak

  • Full Member
  • ***
  • Posts: 138
Re: [LAMW] Setlength causes the app to crash
« Reply #18 on: December 21, 2021, 10:52:37 pm »
interestingly, if I change the record fields to
Code: Pascal  [Select][+][-]
  1.     ChatID:  string;
  2.     FromID:  string;
  3.     Msg:     string;
  4.     mtype:   string;
  5.     tstamp:  TDateTime;
  6.     status:  DWORD;
everything is ok. It's exactly like the other variable.

Well, anyway I already did the procedure in a different way, using just array of integer and the rest of data is taken directly from the database but it just makes me wonder what's wrong with that record  :o

Quote
Do you use pointers in your code?
no pointers.

I'm googling for adb logcat but it seems to be for emulators, isn't it? I'm testing on a physical phone

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: [LAMW] Setlength causes the app to crash
« Reply #19 on: December 21, 2021, 10:55:48 pm »
I'm googling for adb logcat but it seems to be for emulators, isn't it? I'm testing on a physical phone

No. It works for the physical device.

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: [LAMW] Setlength causes the app to crash
« Reply #20 on: December 21, 2021, 11:00:33 pm »
Your change does not reveal the bug. It is still there. It might show up again in a different way. Save a copy of your project where it crashes with Setlength.

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: [LAMW] Setlength causes the app to crash
« Reply #21 on: December 21, 2021, 11:10:27 pm »
Just for my curiosity:

What versions of FPC/Lazarus are you using?
Is the cash happening on the first time you call Setlength with this variable?
What optimization level you have for the project?

r.lukasiak

  • Full Member
  • ***
  • Posts: 138
Re: [LAMW] Setlength causes the app to crash
« Reply #22 on: December 21, 2021, 11:34:19 pm »
Quote
What versions of FPC/Lazarus are you using?
version: 2.0.12 r64642 + LAMW + aarch64 (installed using fpcdeluxe)

Quote
Is the cash happening on the first time you call Setlength with this variable?
yes. It's actually the only SetLength on this variable

Quote
What optimization level you have for the project?
-O3

Quote
Your change does not reveal the bug. It is still there. It might show up again in a different way. Save a copy of your project where it crashes with Setlength.
I've just brought back the record fields and it worked... How the heck? :o


r.lukasiak

  • Full Member
  • ***
  • Posts: 138
Re: [LAMW] Setlength causes the app to crash
« Reply #23 on: December 21, 2021, 11:44:42 pm »
Now I even changed the naming to the original Message/Messages and it's still working o.O

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: [LAMW] Setlength causes the app to crash
« Reply #24 on: December 22, 2021, 12:35:20 am »
Message/Messages is not a problem as I showed in my test above.

Make a visual change in your code in the same file where you call Setlength to be certain it is compiled and included in your app.

r.lukasiak

  • Full Member
  • ***
  • Posts: 138
Re: [LAMW] Setlength causes the app to crash
« Reply #25 on: December 22, 2021, 01:18:32 am »
I already added some lines, compiled and tested several times. So far everything seems to be in tact.

Quote
Message/Messages is not a problem as I showed in my test above.
yes, but it was one of ideas so I wanted to check it out, to make sure it's not the culprit.

Thanks everyone for ideas, I'll leave the topic open, in case the problem appears again.

 

TinyPortal © 2005-2018