Menu

#666 Script integer overflow causes server to crash

None
open
5
2014-04-13
2009-05-14
Alestan
No

In line 81, newcheck.Value = int((number)*(conversionfactor)) When the value exceeds 10000, it gives OverflowError: long int too large to convert to int as an error, and then crashes the server. Python is supposed to handle big integers natively, and items can be set with a higher value with the map editor without error. If someone can either fix whatever is causing this issue, or give advice on another way to write the script to achieve the same effect, I would appreciate it.

Discussion

  • Alestan

    Alestan - 2009-05-14

    The offending script

     
  • AnMaster

    AnMaster - 2009-10-15

    First: While python can certainly handle arbitrary precision integers, crossfire can not.

    Looking at the attached file (haven't tested it, see reason at end of comment), it seems that newcheck is a crossfire object (which is a python "wrapper" representation for an object in crossfire). The "Value" member maps to a long in Object_SetValue() in plugins/cfpython/cfpython_object.c

    In include/object.h value is declared as a sint32.

    Thus this means that on 32-bit x86 at least, the range is and should be the same as of a signed int (sizeof(int) == sizeof(long) on that platform).

    However, at least on AMD64 long is 64-bit and int is 32-bit, thus that line wouldn't throw overflow error when it should. This sounds like a separate bug.

    Second: The bug report says that the value 10000 gives an OverflowError. This seems strange. It should be well within the range of a 32-bit signed integer.

    I'm not able to easily debug this due to only having 64-bit systems available. Would have to set up a 32-bit chroot first.

     
  • Kevin Zheng

    Kevin Zheng - 2013-08-30

    In the current version of "checks.py", the offending lines were commented out by Alestan. I haven't tried to reproduce the problem, though.

     
  • Kevin Zheng

    Kevin Zheng - 2013-08-30
    • labels: object scripts --> object scripts, server
    • summary: Python script makes server crash --> Script integer overflow causes server to crash
    • Group: --> 1.11
     

Log in to post a comment.