Recent

Author Topic: Random crashes on Mac Studio with ARM64 target using FPC 3.2.2  (Read 514 times)

tygraphics

  • New Member
  • *
  • Posts: 15
Hello, I'm experiencing random crashes when running my FPC-compiled application (version 3.2.2 for aarch64) on a Mac Studio with ARM64 architecture. The crashes occur 25% of the time at the same point in the program, while the other 75% of the time, the program runs without any issue.

My application involves parsing an input file and managing complex data structures using dynamic arrays of record pointers. I have carefully implemented memory allocation and deallocation, and I have tested my cleanup procedures thoroughly. I have also verified that there are no concurrency issues, external factors, or random elements causing the crashes.

I suspect the issue might be related to the ARM64 target or the Mac Studio architecture. Are there any known issues or quirks specific to compiling for ARM64 on Mac Studio using FPC 3.2.2? If so, could you provide any recommendations, workarounds, or fixes that could help resolve this issue?

Thank you for your assistance.

jamie

  • Hero Member
  • *****
  • Posts: 5359
Re: Random crashes on Mac Studio with ARM64 target using FPC 3.2.2
« Reply #1 on: March 30, 2023, 03:32:23 am »
Have you run your app with HeapTrc on?

Turn it on, build the app, run a few examples in your, even those that do not crash and exist the program and observe if you have memory leaks.

 Also, move some code blocks around so that the compiler places them in different places when building and then see if the crash still happens in the same code frag!
    if you find that the crash moves around then you have a memory overwrite taking place.

 I am not discounting a problem with the compiler but other steps that I know of should be looked at first. also experiment with the optimizer levels.
The only true wisdom is knowing you know nothing

tygraphics

  • New Member
  • *
  • Posts: 15
Re: Random crashes on Mac Studio with ARM64 target using FPC 3.2.2
« Reply #2 on: March 30, 2023, 04:10:42 am »
Thank you for the suggestion to change the order.
I had three procedures running sequentially.
The third one crashed randomly, on average, one out of four.
I commented out all but the third and resolved the issue; 20 for 20, with no crashes.
Since this procedure will eventually be run first to parse the input file and then pass the collected data to the subsequent procedures, the code may all play well together.
I have no idea why I placed it last. As an independent procedure, it runs smooth as silk in microseconds.

As for the HeapTrc, I'm trying to figure out how to invoke that. I added {$H+} to the main, but I see no difference. I'm sorry for my ignorance. I've only had one CS11 intro to programming back in 1986 that covered all basics through pointers and records. By the way, I love the dynamic arrays!

jamie

  • Hero Member
  • *****
  • Posts: 5359
Re: Random crashes on Mac Studio with ARM64 target using FPC 3.2.2
« Reply #3 on: March 31, 2023, 02:18:19 am »
You may need to show the partial code snippet that is generating your issue.
The only true wisdom is knowing you know nothing

tygraphics

  • New Member
  • *
  • Posts: 15
Re: Random crashes on Mac Studio with ARM64 target using FPC 3.2.2
« Reply #4 on: April 02, 2023, 01:42:32 am »
Hello everyone,

I wanted to take a moment to express my gratitude to Jamie for his valuable suggestions. He helped me identify and resolve the issue causing my program to crash 25% of the time.

After parsing and collecting a series of line coordinates, I realized I had forgotten to zero out my counters once the path was complete. It's surprising that the program even ran, given that the counters were beyond their bounds. A small oversight, but it cost me hours of troubleshooting. Thankfully, the program now runs without any problems.

Thank you so much, Jamie!

Best regards,
Thomas
« Last Edit: April 02, 2023, 01:44:12 am by tygraphics »

jamie

  • Hero Member
  • *****
  • Posts: 5359
Re: Random crashes on Mac Studio with ARM64 target using FPC 3.2.2
« Reply #5 on: April 02, 2023, 03:03:21 pm »
I am glad you found your problem.

Some call that a memory Leak, but that really isn't what you had.

You had what I call is jumping in the wrong swimming pool!  :D

have fun.
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018