Recent

Author Topic: No debug - no errors, debug - Error 201.  (Read 533 times)

Seenkao

  • Full Member
  • ***
  • Posts: 115
No debug - no errors, debug - Error 201.
« on: November 27, 2020, 01:39:10 pm »
День добрый!
Я зачастую использую Byte, Word, LongWord в качестве флагов.
Прилагаю снимок экрана. И я хотел бы узнать, тот код, что выделен, в таком варианте и попадает в программу?

Если да, то по какой причине, проверка осуществляется в процессе исполнения программы? Почему эта проверка не происходит на этапе компоновки, когда ещё программа не скомпилирована.

Я специально проверил, да, программа вылетает по ошибке, сообщая, что было переполнение. Но не было ни какого предупреждения, что число взято больше чем возможно взять.

В данном случае, я думаю, изначально должно идти предупреждение и, если программист (человек создающий программу) не хочет обращать внимания на то что ему сообщил компилятор, то просто "обрезать" ему это число.

Данная проверка, ни как не поможет ни разработке программы, ни её работе, ни поиску произошедших ошибок. Но может добавить ошибку при отладке!

google translate:
Good afternoon!
I often use Byte, Word, LongWord as flags.
Attached is a screenshot. And I would like to know the code that is highlighted, in this variant and gets into the program?

If so, for what reason, the check is carried out during the execution of the program? Why does this check not occur at the link stage, when the program has not yet been compiled.

I specifically checked, yes, the program crashes by mistake, reporting that there was an overflow. But there was no warning that the number was taken more than it was possible to take.

In this case, I think, initially there should be a warning, and if the programmer (the person creating the program) does not want to pay attention to what the compiler told him, then simply "cut off" this number for him.

This check will neither help the development of the program, nor its work, nor the search for errors that have occurred. But may add an error when debugging!

Sorry! Error = 201.
« Last Edit: November 27, 2020, 03:44:49 pm by Seenkao »

jamie

  • Hero Member
  • *****
  • Posts: 4055
Re: No debug - no errors, debug - Error 211.
« Reply #1 on: November 27, 2020, 02:01:19 pm »
There must be an array of some data type that is  indexing outside the range of the array ?

You need to show that part of the program where it is doing the indexing..

The reason why you don't see this at compile time is because you are using a variable instead of a constant and the compiler will not know until runtime what the value will be.

 If warnings were issued for every possible situation like this at compile time the window would be filled with them.  ;)

The only true wisdom is knowing you know nothing

Seenkao

  • Full Member
  • ***
  • Posts: 115
Re: No debug - no errors, debug - Error 211.
« Reply #2 on: November 27, 2020, 02:07:57 pm »
If warnings were issued for every possible situation like this at compile time the window would be filled with them.  ;)
Для этого существует фильтрация.

Ни кто не должен получать ошибку в работе программы, в следствии опечатки - которая приведёт к критической ошибке во время отладки!

google translate:
There is filtering for this.

No one should receive an error in the program, as a result of a typo - leading to a critical error during debugging!

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6823
  • Debugger - SynEdit - and more
    • wiki
Re: No debug - no errors, debug - Error 211.
« Reply #3 on: November 27, 2020, 02:41:56 pm »
What is the declaration of "newEdit" and "EditOne" in
Code: Pascal  [Select][+][-]
  1. newEdit[EditOne].Flags .....

?

Your question makes me guess:

Code: Pascal  [Select][+][-]
  1.   newEdit: array [byte] of ....;
  2.   EditOne: Integer;

If it is like that: then that does compile because "EditOne" can be between 0 and 255 (it has the possibility).

If EditOne is between 0 and 255 all will work. If EditOne is greater than 255 then you get the error. (But at runtime, because at compile-time it is not known)



Actually it seems that
Code: Pascal  [Select][+][-]
  1. Flags or Active
gives the error.

So what are they declared to be.
What are there values, just before the error?

At least that is the assemble you highlight.
A bit strange so that a logical "or" gives an out of range
« Last Edit: November 27, 2020, 02:56:24 pm by Martin_fr »

Seenkao

  • Full Member
  • ***
  • Posts: 115
Re: No debug - no errors, debug - Error 211.
« Reply #4 on: November 27, 2020, 03:43:00 pm »
В данном случае flags - LongWord, но вообще, без разницы какая размерность, боюсь выдаст ошибку в любом случае. Вы можете сами удостоверится, взяв число и использовать or с числом больше заданного значения. (в отладчике включить проверку переполнения).

Логическое or, вышло из диапазона, потому что я специально это сделал, для проверки.
И как проверка показала, число не "обрезается", а идёт целиком. Что, видимо, включает флаг переполнения и код проверки этого переполнения выдаст ошибку.

Если есть возможность, то надо исключить данный код из программы, и для отладчика сделать всё через эмуляцию.

google translate:
In this case flags is LongWord, but in general, no matter what dimension, I'm afraid it will give an error in any case. You can check for yourself by taking a number and using OR with a number greater than the given value. (enable overflow checking in the debugger).

The boolean OR is out of range because I did it on purpose to test it.
And as the test showed, the number is not "cut off", but goes entirely. Which apparently turns on the overflow flag and the code for checking this overflow will throw an error.

If possible, then you need to exclude this code from the program, and for the debugger to do everything through emulation.

Sorry! Error = 201.
« Last Edit: November 27, 2020, 03:45:01 pm by Seenkao »

jamie

  • Hero Member
  • *****
  • Posts: 4055
Re: No debug - no errors, debug - Error 201.
« Reply #5 on: November 27, 2020, 03:52:16 pm »
I think I see the error..

there is a movzbl to a EBX which zero extends the remainder of the 32 bit register, not the 64 bit one..

Then it is ORed with the 64 bit version of the register and then moved to another 64 bit register

basically the upper 32 bits of the R register is uninitialized and a cmp is being done against it for a BYTE range.

I would say that is a compiler bug!

I bet that code works in 32 bit mode just fine so it's looking like a 64 bit bug.
The only true wisdom is knowing you know nothing

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 818
Re: No debug - no errors, debug - Error 201.
« Reply #6 on: November 27, 2020, 05:32:53 pm »
I think I see the error..

there is a movzbl to a EBX which zero extends the remainder of the 32 bit register, not the 64 bit one..
All instructions that write to 32 bit registers on x86-64 automatically zero the upper 32 bits.

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 818
Re: No debug - no errors, debug - Error 201.
« Reply #7 on: November 27, 2020, 07:48:47 pm »
Attached is a screenshot. And I would like to know the code that is highlighted, in this variant and gets into the program?

If so, for what reason, the check is carried out during the execution of the program? Why does this check not occur at the link stage, when the program has not yet been compiled.
That check will indeed never trigger. It gets inserted because when evaluating expressions, all values get converted to the native integer type by default. When assigning the result to a byte, a range check is inserted because there is no logic that reasons about the expression to determine that this value will always fit in a byte.

If you nevertheless get a run time error 201, it will come from somewhere else.

Seenkao

  • Full Member
  • ***
  • Posts: 115
Re: No debug - no errors, debug - Error 201.
« Reply #8 on: November 28, 2020, 11:17:38 am »
That check will indeed never trigger. It gets inserted because when evaluating expressions, all values get converted to the native integer type by default. When assigning the result to a byte, a range check is inserted because there is no logic that reasons about the expression to determine that this value will always fit in a byte.

If you nevertheless get a run time error 201, it will come from somewhere else.
Хотелось бы знать, что означает нет ни какой логики? Ведь вполне логично, если константы известны изначально, если известны переменные (на которых наверняка будет выдавать ошибку), входят эти данные в диапазон или нет.
Достаточно проверить на моменте компоновки программы, совпадения диапазона и данных, которые сверяются. И данный код, в случаях "AND", "OR", "XOR" и подобных, вставлять не надо будет. Что позволит избежать множества случаев выхода из диапазона.

google translate:
I would like to know what does not mean any logic? After all, it is quite logical if the constants are known initially, if the variables are known (on which it will most likely give an error), whether these data are included in the range or not.
It is enough to check at the moment of the program linking, the coincidence of the range and the data that are being checked. And this code, in the cases of "AND", "OR", "XOR" and the like, will not need to be inserted. This will avoid many cases of out of range.

Seenkao

  • Full Member
  • ***
  • Posts: 115
Re: No debug - no errors, debug - Error 201.
« Reply #9 on: November 28, 2020, 11:45:02 am »
Попытался переполнить флаг для QWORD... = $FFFF FFFF FFFF FFFF + F
даже не дали заполнить его полностью ($FFFF FFFF FFFF FFFF):
Edit.lpr(172,63) Error: range check error while evaluating constants (-1 must be between 0 and 18446744073709551615)

Int64 не даёт переполнить в любом случае:
Edit.lpr(172,63) Error: Invalid integer expression  - что достаточно верно!

google translate:
Tried to overflow flag for QWORD ... = $ FFFF FFFF FFFF FFFF + F
they weren't even allowed to fill it completely ($ FFFF FFFF FFFF FFFF):
Edit.lpr(172,63) Error: range check error while evaluating constants (-1 must be between 0 and 18446744073709551615)

Int64 does not allow overflow anyway:
Edit.lpr(172,63) Error: Invalid integer expression  - which is true enough!

 

TinyPortal © 2005-2018