Recent

Author Topic: Unknown SIGSEGV error  (Read 1505 times)

Weeb mindset

  • New Member
  • *
  • Posts: 10
Unknown SIGSEGV error
« on: August 13, 2020, 05:11:20 pm »
Lazarus
version :2.0.8
FPC version : 3.0.4
SVN revision : 62994
x86_64_win64-win32/win64
OS : win 10 pro 1909 64 bit

Well, i have no idea how this will have exception. HELLp >:D .
here is PART of the program
I did test my code, when the declarations is not equal to M5 and M6, the program works fine. Do i violate some hidden rules ?
THANKS ! :D
Code: Pascal  [Select][+][-]
  1. type
  2. rule_t         = (CE_M3,c42x,M5,M6);
  3. basic_info_t   =  record
  4.                         rule   : rule_t;
  5.                   end;
  6. programme_t = record
  7.                     basic_info : array [1..500]  of basic_info_t;
  8.              end;
  9. const
  10. p_s_t_x = 20;
  11. p_s_t_y = 501;
  12. progDB.prog_c = 53;
  13. var
  14.     progDB   : programme_t;
  15.     j,i      : integer;
  16.     p_s_t    : array [1..p_s_t_y,1..p_s_t_x] of string;
  17. begin
  18.         J := 2;
  19.         repeat
  20.                               i := 0;
  21.                               repeat
  22.                                     inc(i);
  23.                                     case p_s_t[j,i] of
  24.                                                     'Chi&Eng + Best 3' : progDB.basic_info[j-1].rule := CE_M3;
  25.                                                     '4C + 2X'          : progDB.basic_info[j-1].rule := c42x;
  26.                                                     'Best 5'           : progDB.basic_info[j-1].rule := M5;
  27.                                                     'Best 6'           : progDB.basic_info[j-1].rule := M6;
  28.                                     end;
  29.                               until i = p_s_t_x;
  30.                               inc(j);
  31.           until (p_s_t[j,i] = '') or (j = p_s_t_y);
  32.  end.                      
  33.  
« Last Edit: August 13, 2020, 06:01:25 pm by Weeb mindset »

ASBzone

  • Hero Member
  • *****
  • Posts: 678
  • Automation leads to relaxation...
    • Free Console Utilities for Windows (and a few for Linux) from BrainWaveCC
-ASB: https://www.BrainWaveCC.com/

Lazarus v2.2.7-ada7a90186 / FPC v3.2.3-706-gaadb53e72c
(Windows 64-bit install w/Win32 and Linux/Arm cross-compiles via FpcUpDeluxe on both instances)

My Systems: Windows 10/11 Pro x64 (Current)

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: Unknown SIGSEGV error
« Reply #2 on: August 13, 2020, 05:45:08 pm »
I guess you have wrong index somewhere (you try to write out of array). Just switch on all debugging options - range checks etc. Do you use Lazarus?
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Handoko

  • Hero Member
  • *****
  • Posts: 5130
  • My goal: build my own game engine using Lazarus
Re: Unknown SIGSEGV error
« Reply #3 on: August 13, 2020, 05:53:16 pm »
I eye-inspected the code. Although not properly written but all the things in the array. I believe the bug is in elsewhere.

Weeb mindset

  • New Member
  • *
  • Posts: 10
Re: Unknown SIGSEGV error
« Reply #4 on: August 13, 2020, 06:09:01 pm »
I guess you have wrong index somewhere (you try to write out of array). Just switch on all debugging options - range checks etc. Do you use Lazarus?

i updated the post and put the info.
about range check, i just figured how to open it and digging with it.
Once i got a problem i will update.
Anyway, thanks for your help!
« Last Edit: August 13, 2020, 06:20:13 pm by Weeb mindset »

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: Unknown SIGSEGV error
« Reply #5 on: August 13, 2020, 08:00:39 pm »
I don't understand what you are doing here, but there are some things which look strange to me:

The outer j loop begins with j=2, you access p_s_t[2, i] -- the first value of p_s_t (j=1) is never used.

The j loop is exited when j = p_s_t_y = 501. The last statement in the loop is inc(j), i.e. the last j value used is p_s_t_y-1 = 500. But the first index of the array p_s_t is dimensioned to run up to p_s_t_y = 501. So, the last value of p_s_t (j=501) is never used either.

Is this intended?

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: Unknown SIGSEGV error
« Reply #6 on: August 13, 2020, 11:40:53 pm »
Lazarus
version :2.0.8
FPC version : 3.0.4
SVN revision : 62994
x86_64_win64-win32/win64
OS : win 10 pro 1909 64 bit

Well, i have no idea how this will have exception. HELLp >:D .
here is PART of the program
I did test my code, when the declarations is not equal to M5 and M6, the program works fine. Do i violate some hidden rules ?
THANKS ! :D
Code: Pascal  [Select][+][-]
  1. type
  2. rule_t         = (CE_M3,c42x,M5,M6);
  3. basic_info_t   =  record
  4.                         rule   : rule_t;
  5.                   end;
  6. programme_t = record
  7.                     basic_info : array [1..500]  of basic_info_t;
  8.              end;
  9. const
  10. p_s_t_x = 20;
  11. p_s_t_y = 501;
  12. progDB.prog_c = 53;
  13. var
  14.     progDB   : programme_t;
  15.     j,i      : integer;
  16.     p_s_t    : array [1..p_s_t_y,1..p_s_t_x] of string;
  17. begin
  18.         J := 2;
  19.         repeat
  20.                               i := 0;
  21.                               repeat
  22.                                     inc(i);
  23.                                     case p_s_t[j,i] of
  24.                                                     'Chi&Eng + Best 3' : progDB.basic_info[j-1].rule := CE_M3;
  25.                                                     '4C + 2X'          : progDB.basic_info[j-1].rule := c42x;
  26.                                                     'Best 5'           : progDB.basic_info[j-1].rule := M5;
  27.                                                     'Best 6'           : progDB.basic_info[j-1].rule := M6;
  28.                                     end;
  29.                               until i = p_s_t_x;
  30.                               inc(j);
  31.           until (p_s_t[j,i] = '') { this will Fail if all elements are full } or (j = p_s_t_y);
  32.  end.                      
  33.  

 You should be checking for the size of J before using it..
The only true wisdom is knowing you know nothing

furious programming

  • Hero Member
  • *****
  • Posts: 853
Re: Unknown SIGSEGV error
« Reply #7 on: August 14, 2020, 12:37:25 am »
Change the loops to the two for loops and try again.

And correct the code formatting — indentations first of all, because they are monstrously large. Besides, stick to the adopted naming convention — PascalCase for variables and data types (plus the T prefix), and the UPPER_SNAKE_CASE for the constants.
Lazarus 3.2 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on an acrade, action/adventure game in retro style (pixelart), programming the engine and shell from scratch, using Free Pascal and SDL. Release planned in 2026.

 

TinyPortal © 2005-2018