Recent

Author Topic: SIGSEGV on inline method from unit of package  (Read 6552 times)

Okoba

  • Hero Member
  • *****
  • Posts: 528
SIGSEGV on inline method from unit of package
« 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.

Okoba

  • Hero Member
  • *****
  • Posts: 528
Re: SIGSEGV on inline method from unit of package
« Reply #1 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?

Okoba

  • Hero Member
  • *****
  • Posts: 528
Re: SIGSEGV on inline method from unit of package
« Reply #2 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.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
Re: SIGSEGV on inline method from unit of package
« Reply #3 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.

Okoba

  • Hero Member
  • *****
  • Posts: 528
Re: SIGSEGV on inline method from unit of package
« Reply #4 on: July 27, 2021, 01:36:08 pm »
Thanks for the verification. I will.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
Re: SIGSEGV on inline method from unit of package
« Reply #5 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. ::)

Okoba

  • Hero Member
  • *****
  • Posts: 528
Re: SIGSEGV on inline method from unit of package
« Reply #6 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