Lazarus

Free Pascal => General => Topic started by: Okoba on July 26, 2021, 02:58:12 pm

Title: SIGSEGV on inline method from unit of package
Post by: Okoba on July 26, 2021, 02:58:12 pm
I was working on a code and found a sudden crash, in trying to find the problem, I made a project I hope someone can check and help me find the reason.
Requirements for the crash:
- A project calling an inline method from another unit that is in a package.
- The project has a static array and the method too needs assigning an array.
I copied the exact code for the unit in the project and everything is working fine. Removing inline works fine, removing one of the arrays works fine.
I checked the assembly code and there is only one line difference if I use the unit from the project:
Code: Pascal  [Select][+][-]
  1. movq    $1,-40(%rbp)
Tested with Trunk FPC and Lazarus on Win X64.
Title: Re: SIGSEGV on inline method from unit of package
Post by: Okoba on July 27, 2021, 08:17:26 am
I know a fix for it. I like to know the reason and find out if it is a bug so I can report it.
Can you check and see if it happens for you or not?
Title: Re: SIGSEGV on inline method from unit of package
Post by: Okoba on July 27, 2021, 12:48:54 pm
FPC supports assigning an array, no need for SetLength. And the problem disappear when I use the project unit. Please recheck the first post.
Title: Re: SIGSEGV on inline method from unit of package
Post by: PascalDragon on July 27, 2021, 01:33:31 pm
I was working on a code and found a sudden crash, in trying to find the problem, I made a project I hope someone can check and help me find the reason.
Requirements for the crash:
- A project calling an inline method from another unit that is in a package.
- The project has a static array and the method too needs assigning an array.
I copied the exact code for the unit in the project and everything is working fine. Removing inline works fine, removing one of the arrays works fine.
I checked the assembly code and there is only one line difference if I use the unit from the project:
Code: Pascal  [Select][+][-]
  1. movq    $1,-40(%rbp)
Tested with Trunk FPC and Lazarus on Win X64.

Please report a bug (once the Git conversion is done and the repository on GitLab becomes available).

Though the important part is not whether the unit is from a package or not, but whether the used unit is compiled during the same compilation. If you'd do a recompile with the UnitFromProject then it would fail as well.
Title: Re: SIGSEGV on inline method from unit of package
Post by: Okoba on July 27, 2021, 01:36:08 pm
Thanks for the verification. I will.
Title: Re: SIGSEGV on inline method from unit of package
Post by: PascalDragon on July 28, 2021, 09:19:28 am
FPC supports assigning an array, no need for SetLength. And the problem disappear when I use the project unit. Please recheck the first post.

Really?

I can see where this is leading.

This was added because Delphi supports it as well since XE4. ::)
Title: Re: SIGSEGV on inline method from unit of package
Post by: Okoba on July 28, 2021, 10:11:09 am
This was added because Delphi supports it as well since XE4. ::)
And it is a nice feature.
TinyPortal © 2005-2018