Skip to content
  • David Griffith's avatar
    d9676545
    Fatal error instead of segfault when writing a string that crosses the 64k mark. · d9676545
    David Griffith authored
    Static and dynamic memory is restricted to below $0ffff (64k).  Past
    this mark is high memory.  Frotz previously stored the address for
    printing a string in a zword variable (unsigned short).  An unsigned
    short is two bytes and therefore loops back to zero after passing
    0xffff.  When decode_text() was given a string that straddles the 64k
    boundary, the address variable looped back to zero, which then provoked
    a segfault.
    
    Per the Z-machine Standard, the proper action to take when crossing that
    boundary is undefined.  If the value in the address variable is copied
    to a zlong variable (unsigned long) before proceeding, printing one of
    these naughty strings will succeed without complaint.  Allowing that to
    happen is in direct opposition to why segfaults happen in the first
    place: when a program starts writing outside your allocated memory,
    that's a clear indication that the program has aquired a faulty picture
    of what should be happening. Therefore I have Frotz throw a fatal error
    when encountering such a print attempt.
    d9676545
    Fatal error instead of segfault when writing a string that crosses the 64k mark.
    David Griffith authored
    Static and dynamic memory is restricted to below $0ffff (64k).  Past
    this mark is high memory.  Frotz previously stored the address for
    printing a string in a zword variable (unsigned short).  An unsigned
    short is two bytes and therefore loops back to zero after passing
    0xffff.  When decode_text() was given a string that straddles the 64k
    boundary, the address variable looped back to zero, which then provoked
    a segfault.
    
    Per the Z-machine Standard, the proper action to take when crossing that
    boundary is undefined.  If the value in the address variable is copied
    to a zlong variable (unsigned long) before proceeding, printing one of
    these naughty strings will succeed without complaint.  Allowing that to
    happen is in direct opposition to why segfaults happen in the first
    place: when a program starts writing outside your allocated memory,
    that's a clear indication that the program has aquired a faulty picture
    of what should be happening. Therefore I have Frotz throw a fatal error
    when encountering such a print attempt.
To find the state of this project's repository at the time of any of these versions, check out the tags.
Loading