Author Topic: Port old program qbasic 1.1 to QB64 throws segmentation fault  (Read 5815 times)

0 Members and 1 Guest are viewing this topic.

Offline deniscassiano

  • Newbie
  • Posts: 3
    • View Profile
Port old program qbasic 1.1 to QB64 throws segmentation fault
« on: February 23, 2018, 07:42:27 am »
Hi Guys,

I need convert a old qb 1.1 program to QB64. I change a bit from code to can compile and run, but when i attempt run the program in QB64 editor or in command line i get random segmentation fault: 11 error. The program is simple: read some random files, perform some calcs to volumetric measures and write to random and text files.
I attempt run int in MACOS High Sierra and Ubuntu Mate 17.10.1 and both get this issue. How i can debug this? No errors in Editor output or c++ dump. only segmentation fault: 11

FellippeHeitor

  • Guest
Re: Port old program qbasic 1.1 to QB64 throws segmentation fault
« Reply #1 on: February 23, 2018, 07:48:24 am »
You can paste your code here (or attach it if it's too long) so we can have a look and try to help you.

Welcome to the forum.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Port old program qbasic 1.1 to QB64 throws segmentation fault
« Reply #2 on: February 23, 2018, 12:09:51 pm »
Yes, please post the code. Happy to run it and see what's up, although I run Windows.

Question on posting code. I tried to put a prog in a code box, not that big either, and I had to end up attaching  it. Can that limit be upped? Frankly it is easier to paste code and read code in a code box, rather than upload/download it.

Pete :)
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline odin

  • Administrator
  • Newbie
  • Posts: 92
  • I am.
    • View Profile
Re: Port old program qbasic 1.1 to QB64 throws segmentation fault
« Reply #3 on: February 23, 2018, 12:30:51 pm »
Question on posting code. I tried to put a prog in a code box, not that big either, and I had to end up attaching  it. Can that limit be upped? Frankly it is easier to paste code and read code in a code box, rather than upload/download it.

Pete :)

Noted.

Offline deniscassiano

  • Newbie
  • Posts: 3
    • View Profile
Re: Port old program qbasic 1.1 to QB64 throws segmentation fault
« Reply #4 on: March 01, 2018, 09:59:07 am »
Hi Guys,

I can't send all code because my client want confidentiality, but a bit of code that throws segmentation fault is:

OPEN "S32342323.DAT" FOR RANDOM AS #21 LEN = 58
FIELD #21, 4 AS I1$, 4 AS I2$, 21 AS I3$, 21 AS I4$, 1 AS I5$, 3 AS I6$, 4 AS I7$
FIELD #21, 2 AS J1$, 4 AS J2$, 2 AS J3$, 4 AS J4$, 4 AS J5$, 2 AS J6$, 2 AS J7$, 2 AS J8$, 2 AS J9$, 4 AS J10$, 4 AS J11$, 4 AS J12$, 4 AS J13$, 4 AS J14$, 4 AS J15$, 2 AS J16$, 4 AS J17$, 4 AS J18$

1210 KK = 0: I = 0: QTOT = 0
1220 FOR I = 1 TO NT
    PRINT "ACESSANDO LINHA-> " + STR$(I):
    1230 GET #21, I + 1: SINIC = J2$: IFIM = CVI(J3$): VAZAO1 = CVS(J4$): C1 = CVS(J5$)
    'NUM30 = CVI(J6$)
    'NUM45 = CVI(J7$): NUM60 = CVI(J8$): NUM90 = CVI(J9$)
    PRINT "DADOS: ["; SINIC; " - "; IFIM; " - "; VAZAO1; " - "; C1; " - "; NUM30; " - "; NUM45; " - "; NUM60; " - "; NUM90; "]";
    PRINT "DADOS"
    1240 IF C1 = 0 THEN 1400
    1250 COIFA = CVS(J10$): COTU30 = CVS(J11$): COTU45 = CVS(J12$): COTU60 = CVS(J13$): COTU90 = CVS(J14$): ENTRA = CVS(J15$): KSOMA = CVI(J16$): TEMP = CVS(J17$)
    PRINT "DADOS: ["; COIFA; " - "; CUTU30; " - "; COTU45; " - "; COTU60; " - "; COTU90; " - "; ENTRA; " - "; KSOMA; " - "; TEMP; "]";
    1260 IF COIFA <> 0 THEN ACEL = 1 ELSE ACEL = 0

NEXT I


This issue is random. The code runs fine in first run, but in next attempts i get segmentation fault: 11 our bus error: 10

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Port old program qbasic 1.1 to QB64 throws segmentation fault
« Reply #5 on: March 01, 2018, 10:07:36 am »
Please add here a complete code. This is uncomplete. What is SINIC? Is declared as number in this program, next - line 1400 miss, as i look at, so if this FOR NEXT I loop is run, then file is read in one direction. If is read  next time, reading start on last position - not in file begin. In this program is none CLOSE or SEEK.

FellippeHeitor

  • Guest
Re: Port old program qbasic 1.1 to QB64 throws segmentation fault
« Reply #6 on: March 01, 2018, 10:17:44 am »
Denis, how did you pinpoint this bit as the faulty bit?