Author Topic: FPC 3.2.4-rc2 published  (Read 3501 times)

jamie

  • Hero Member
  • *****
  • Posts: 8071
Re: FPC 3.2.4-rc2 published
« Reply #15 on: September 11, 2026, 01:40:06 am »
For anyone interested, Windows SNAPSHOT of 3.2.4RC2 with Lazarus 4.9 (NOT 4.99, but 4.9 aka 4.8 + fixes)
https://sourceforge.net/projects/lazarus-snapshots/files/Window%2064/2026-09-09-Lazarus-4.9-fixes-Fpc-3.2.4RC2/
https://sourceforge.net/projects/lazarus-snapshots/files/Window%2032/2026-09-09-Lazarus-4.9-fixes-Fpc-3.2.4RC2/

I installed both of them over my existing 32- and 64-bit installs.

Everything seems to be working well.

Also, I did have a problem with the Indy TidSimpleServer before where if you dropped it on the form it would error with a stream writing error.

Now it seems to work, not sure if it's the compiler or the IDE?

Jamie
The only true wisdom is knowing you know nothing

lscoughlin

  • Newbie
  • Posts: 2
Re: FPC 3.2.4-rc2 published - managment operators
« Reply #16 on: October 16, 2026, 08:11:14 am »
I tried to speed up an arbitrary-precision decimal record by replacing its dynamic-array field with a pointer to a reference-counted block, managed through Initialize, Finalize, AddRef and Copy. A micro-benchmark showed 8 ns per operation against 39 ns for the dynamic-array record, because the RTTI-driven fpc_initialize, fpc_finalize and fpc_copy calls disappear. The change compiled, but the test suite hung and returned wrong numbers. The cause is that the compiler does not call the operators as the wiki describes.

Environment: FPC 3.2.4 (rc2 build), aarch64, macOS. The results are the same at -O- and -O3. I have not tried other targets or trunk.

Faults (I counted references in a global array, so nothing touches freed memory):

1. Record without Copy: B := A does not call AddRef. The count stays at 1 and reaches -1 after both variables are finalized (a double free). The wiki says AddRef is called after the bitwise copy on assignment.
2. Record without Copy: A := Default(T) does not call Finalize on the old value of A (leak).
3. Record without Copy: B := A does not call Finalize on the old value of B (leak).
4. Record with all four operators: GA := MakeC(6), where GA is a variable of the main program block and MakeC returns a record through Result, leaves the count at 2 instead of 1. The temporary is not finalized after Copy. The same statement with a local variable in a procedure is correct.

Without Copy you get faults 1 to 3, and with Copy you get fault 4, so I found no operator set that works correctly.

Cases that work as documented: variable-to-variable assignment with Copy, a function that does Result := X, by-value parameters without Copy, and release at scope exit.

The test case is one stand-alone file using only the RTL. It prints ok or FAIL for each case, and on my machine it prints eight FAIL lines and exits with code 1. A fixed compiler should print ok on every line.

The full write-up, with the code and its output, is at https://github.com/lscoughlin/TBigDecimal/blob/main/doc/management-operators.md. The test case file is https://github.com/lscoughlin/TBigDecimal/blob/main/tests/fpcbugs/ManagementOperators.lpr.

I also found the open report https://gitlab.com/freepascal.org/fpc/source/-/issues/40392 (double Finalize with nested functions, FPC 3.3.1). The symptom is different, and I do not know whether it shares a cause with these four.

Questions:
- Has anyone seen the same on other targets or on trunk?
- Is fault 1 (no AddRef on assignment without Copy) intended behavior?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 13052
  • FPC developer.
Re: FPC 3.2.4-rc2 published
« Reply #17 on: October 16, 2026, 10:41:46 am »
3.3.1 results (build a few days old:)

Quote
ok    1 TWithCopy: A := MakeC(1) (count while owned): count 1
ok    1 TWithCopy: after the procedure returned: count 0
ok    2 TWithCopy: B := A (count while shared): count 2
ok    2 TWithCopy: after the procedure returned: count 0
ok    3 TWithCopy: B := IdentC(A) (count while shared): count 2
ok    3 TWithCopy: after the procedure returned: count 0
FAIL  4 TNoCopy: B := A (count while shared): expected count 2, got 1
FAIL  4 TNoCopy: after the procedure returned: expected count 0, got -1
ok    5 TNoCopy: ByValueN(A) (count after the call): count 1
ok    5 TNoCopy: after the procedure returned: count 0
FAIL  8 TNoCopy: A := Default(TNoCopy) (count after the assignment): expected count 0, got 1
FAIL  9 TNoCopy: B := A (count of the old value of B): expected count 0, got 1
ok    6 TWithCopy global: GA := MakeC(6) (count while owned): count 1
ok    6 TWithCopy global: GB := GA (count while shared): count 2
ok    6 TWithCopy global: both set to Default: count 0
ok    7 TNoCopy global: GN := MakeN(7) (count while owned): count 1
FAIL  7 TNoCopy global: GN set to Default: expected count 0, got 1
result: the compiler fails at least one reference counting case

So all withcopy cases seem fixed.

lscoughlin

  • Newbie
  • Posts: 2
Re: FPC 3.2.4-rc2 published
« Reply #18 on: October 17, 2026, 05:47:27 am »
That's really good to know.  I had not tested on 3.3.1 one because there's no target date for 3.4.0 release as far as I am aware and the next stable release is going to be a 3.2.4.

Any target dates at all at all for 3.4?

AlexTP

  • Hero Member
  • *****
  • Posts: 2770
    • UVviewsoft
Re: FPC 3.2.4-rc2 published
« Reply #19 on: November 05, 2026, 11:21:54 am »
Can you merge to 3.2.4-RC the fix of this bug, pls?
https://gitlab.com/freepascal.org/fpc/source/-/work_items/40495

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 13052
  • FPC developer.
Re: FPC 3.2.4-rc2 published
« Reply #20 on: November 05, 2026, 11:29:55 am »

 

TinyPortal © 2005-2018