Application crashes in unit CRT when executing a writeln
Original Reporter info from Mantis: Theo van Oosten
-
Reporter name: Theo van Oosten
Original Reporter info from Mantis: Theo van Oosten
- Reporter name: Theo van Oosten
Description:
To investigate why text is always wrapped at 80 char's, I copied the file CRT.PP (including CRTH.INC) to my local folder. From that moment my application crashed at the very first writeln. I traced the problem to the procedure CRTWRITE at line 1266 in the unit CRT. There a memory copy is performed (MOVE), followed by SETLENGTH to adjust the size of the receiving string; This should be reversed. SETLENGTH allocates the memory needed for the larger string; MOVE does not look if the memory is allocated, so if not: SIGSEGV!
Steps to reproduce:
Copy CRT.PP and CRTH.INC to a local folder. Create a new project, console application, and put crt in the uses clause. In project options, add this local folder (where you copied CRT.PP to) to compilation paths. Put a writeln in your project and press F9.
Additional information:
To confirm and solve the problem, I renamed CRT.PP to MYCRT (also the unit clause inside the file and the uses clause in the project file). When the crash was confirmed, I put the setlength statement on line 1267 one line higher (before the move statement). No more crashes... I just wonder why there are no crashes when using CRT on its original location??
I did all this because a max line length of 80 is not suitable for me. The fpIOCtl call in GetConsoleBuf returns a width and height of 0 (only in Linux?). So the actual console size is not reported and set to 80 x 25. Can you please add a procedure "set_screen_size", or something like that? I will add that to MYCRT because I really need it.