Author Topic: MOD crashed my program!!!  (Read 7385 times)

0 Members and 1 Guest are viewing this topic.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
MOD crashed my program!!!
« on: February 04, 2020, 11:20:55 am »
I made a typo in a sub call parameter, which resulted in the variable I intended to use in a mod statement being zero. This should have triggered some kind of error, similar to division by zero, but instead, it just crashed the program after a couple of second delay. You know, the kind of delay where the Windows mouse goes into a flat spin. Hey, maybe some day they'll come up with a Windows Maverick. That system could find it's way out of a flat spin, but I digress. Anyway, something like...

myvariable = 10
PRINT 7 MOD myvariable

That works as intended, but if...

myvariable = 0
PRINT 7 MOD myvariable

... That would probably crash. This line is similar to the line in my code, without going through the sub argument passes, etc. I'd like to test this simplified code line, but I've got too many windows and projects open at the moment.

Maybe this was addressed in a later version. I'm still using 1.3.

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

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: MOD crashed my program!!!
« Reply #1 on: February 04, 2020, 11:30:53 am »
No crash, it is division by 0

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: MOD crashed my program!!!
« Reply #2 on: February 04, 2020, 12:21:10 pm »
That's what it should be, but in my 1.3 version, my more complicated routine just crashes. When I get some windows closed and work finished today, I'll try the code I posted, vs. the actual code in my program. Maybe the example I posted won't crash, and something else in my code is preventing the error message from being activated.

Are you using v 1.3, or a later developer build or the new version?

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

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: MOD crashed my program!!!
« Reply #3 on: February 04, 2020, 12:35:04 pm »
Hi Pete,

1.3 except to test new commands I find might come in handy, copying Fellippe's examples to a folder for reminders but I don't have any new stuff tested in dev's of 1.3 because some might be rejected or improved for standard issue. Steve's colors and console stuff is all going in?

Did you use 7 mod 0 as argument to parameter, I can see how that would be disastrous! Do I want to test? No, why go looking for trouble? :)
« Last Edit: February 04, 2020, 12:44:04 pm by bplus »

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: MOD crashed my program!!!
« Reply #4 on: February 04, 2020, 02:25:17 pm »
Hi Mark,

I just used the 7 MOD 0 as an example. In my routine, the MOD statement is involved in a loop, but the myvariable is always 10 so something like:

CALL example(myvariable)
myvariable = 10

SUB example(myvvvvvariable) ' Oops, this typo will make myvariable an undefined zero value in this sub!
FOR i = 1 to 10
x = i MOD myvariable
NEXT
END SUB

So when I goofed on the typo, not a bad as the example I put up here, I actually just missed a letter in mine, but anyway, same results, a zero division with MOD. It should have thrown a division by zero error, but it didn't. It just crashed the program.

Oh, I should mention that I'm NOT using $CHECKING_OFF or whatever it's called. So that isn't the issue.

I get the "Why go looking for trouble?" 100%. I'll fiddle with this more when I don't have stuff to lose, which just isn't happening anytime soon. I'm in the middle of a 8000 line program, among other website things. I just figured if I posted something now, I wouldn't forget what happened at a later date.

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

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: MOD crashed my program!!!
« Reply #5 on: February 04, 2020, 02:30:17 pm »
mine throws a Division By Zero error at run time. using v1.1 for kicks.
does your program just flat out terminate with no Div by 0 popup?
Granted after becoming radioactive I only have a half-life!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: MOD crashed my program!!!
« Reply #6 on: February 04, 2020, 03:50:24 pm »
Yep, it just spins for two seconds, and then crashes. No error message.

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

Offline Bert22306

  • Forum Regular
  • Posts: 206
    • View Profile
Re: MOD crashed my program!!!
« Reply #7 on: February 04, 2020, 04:13:47 pm »
I tried the first test program your posted, and the one with the subroutine, and with QB64 v1.4, they both flag this division by 0 error.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: MOD crashed my program!!!
« Reply #8 on: February 04, 2020, 04:29:23 pm »
Well it looks like I'll have to take a closer look at this when I close out my projects tonight. I didn't save that code, but I think I can get back to it, give it another try, and see what's up. Maybe I discovered a bug but if so, it's apparently not as straight-forward as the examples I posted.

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

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: MOD crashed my program!!!
« Reply #9 on: February 04, 2020, 04:31:40 pm »
Hey Pete, the way you have it listed, you don't need the typeo because you set the variable after you call the sub.

OK I looked:
Code: QB64: [Select]
  1. example 7 MOD var
  2.  
  3.  
  4. SUB example (myvariable) ' Oops, this typo will make myvariable an undefined zero value in this sub!
  5.     FOR i = 1 TO 10
  6.         x = i MOD myvariable
  7.     NEXT
  8.  

no crash, just division by 0

I looked some more and can't get it to crash.
« Last Edit: February 04, 2020, 04:44:45 pm by bplus »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: MOD crashed my program!!!
« Reply #10 on: February 04, 2020, 04:41:22 pm »
Yep, it just spins for two seconds, and then crashes. No error message.

Pete

I've tested this with every odd combination I can think of, and I can't reproduce the problem.

Code: [Select]
$CHECKING:OFF
$CONSOLE:ONLY
_DEST _CONSOLE
PRINT 1 MOD 0

Checking on, checking off, print to the console, a file, a normal text screen....  They all toss a "Division by 0" error for me.  DEFINT, DEFLNG, _DEFINE A-Z AS _FLOAT -- none of these make any difference.

Are you certain the MOD statement is causing the issue?  Did your typo change or interact with a different line inside the sub?  When a program just crashes on you, it can be hard sometimes to pinpoint the exact spot where it crashed as you don't have any error reports or line numbers to refer back to. 

If all else fails, share the whole code which glitches out with you and then we'll work on removing sections until we get to the smallest possible batch to try and reproduce the result.  As it is, I don't have a clue what the problem might be.  At this point, my only suggestion would be: Download the 1.4 candidate and see if the problem still persists for you.

It may be that whatever the glitch is, is one that we've already addressed in the last year and fixed, and that's why it's proving impossible for me to replicate it.  I don't know who fixed it, or how it got fixed, but if it is, you're welcome in advance.  ;D
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

FellippeHeitor

  • Guest
Re: MOD crashed my program!!!
« Reply #11 on: February 04, 2020, 04:57:31 pm »
What OS version again? (If it's been mentioned above I missed it, sorry)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: MOD crashed my program!!!
« Reply #12 on: February 04, 2020, 05:26:09 pm »
What OS version again? (If it's been mentioned above I missed it, sorry)

reply #2 v 1.3

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: MOD crashed my program!!!
« Reply #13 on: February 04, 2020, 05:59:59 pm »
Yep 1.3. To be even more specific...

V 1.3 [Revision] Stable from git: 96937f0

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

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: MOD crashed my program!!!
« Reply #14 on: February 04, 2020, 06:14:59 pm »
Yep 1.3. To be even more specific...

V 1.3 [Revision] Stable from git: 96937f0

Pete

Same as mine, Steve might be right, something else is causing the crash.