Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2023-08

rtl_do_close is not called in the embedded and freertos targets

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Kostas Michalopoulos

Hi all,

I was looking at the RTL code to see if the embedded target could be used as a workaround for unsupported OSes (e.g. some custom kernel) and noticed that there are some global function pointers used as callbacks for system-specific functionality - which is neat.

However i also noticed that the do_close procedure in sysfile.inc doesn't do anything (it is empty) and nothing calls the rtl_do_close callback (the other do_xxx procedures do call the equivalent rtl_do_xxx if they are set). I don't have any actual program to test that out, it was just something i noticed by reading the code but it seems like a bug to me as i can't see a way to close a file handle otherwise.

The code can be seen here:

https://gitlab.com/freepascal.org/fpc/source/-/blob/main/rtl/embedded/sysfile.inc?ref_type=heads#L25

My guess is that the code above should call rtl_do_close defined here:

https://gitlab.com/freepascal.org/fpc/source/-/blob/main/rtl/embedded/system.pp?ref_type=heads#L108

...like it is done in the other procedures in the sysfile.inc file.

FWIW the code for freertos seems to be exactly the same - empty do_close despite there being a rtl_do_close callback (which isn't used anywhere).

Kostas

Reply by email

Christo Crause
to Kostas Michalopoulos
Show quoted text 11 lines
I was looking at the RTL code to see if the embedded target could be used as a workaround for unsupported OSes (e.g. some custom kernel) and noticed that there are some global function pointers used as callbacks for system-specific functionality - which is neat. However i also noticed that the do_close procedure in sysfile.inc doesn't do anything (it is empty) and nothing calls the rtl_do_close callback (the other do_xxx procedures do call the equivalent rtl_do_xxx if they are set). I don't have any actual program to test that out, it was just something i noticed by reading the code but it seems like a bug to me as i can't see a way to close a file handle otherwise.

For what it's worth, I agree with your assessment. Obviously file handling is not used or tested much with embedded/freeRTOS targets.

I suggest creating a pull request with your fix.

Best regards,
Christo

Reply by email