Menu

#256 JWASMD: padding bytes between segments are uninitialized

open
nobody
None
2
2013-03-28
2013-03-27
dosfan01
No

In JWASMD (not JWASM) padding bytes between segments are uninitialized. This is very likely due to memory not being initialized in the DOS version as JWASM does not have this problem. This problem is easily seen with your DEBUG as it uses multiple segments.

Discussion

  • dosfan01

    dosfan01 - 2013-03-27
    • priority: 5 --> 2
     
  • japheth

    japheth - 2013-03-28

    IIRC this happens with certain OSes only ( FreeDOS? )

     
  • dosfan01

    dosfan01 - 2013-03-28

    I run PC DOS 7.0. I do have other versions of MS-DOS/PC DOS but I only have PC DOS 7.0 installed on my system. FreeDOS doesn't really count as it's not real DOS.

     
  • dosfan01

    dosfan01 - 2013-03-28

    This seems like it would be more of a C library issue with malloc than any version of DOS. If allocated memory isn't initialized then of course whatever happened to be there which wasn't overwritten (in this case padding between segments) would be used.

     
  • japheth

    japheth - 2013-03-28

    > This seems like it would be more of a C library issue with malloc than any
    > version of DOS.

    IIRC it's not a memory allocation issue, but an issue related to file positioning (in a "new" file ). And AFAIR it works well in MS-DOS ( including NTVDM ), but fails in FreeDOS ( and apparently DR-DOS ).

     
  • dosfan01

    dosfan01 - 2013-03-28

    File positioning (INT 21h function 42h) has nothing to do with memory allocation. When memory is allocated in DOS via INT 21h function 48h, DOS only writes the MCB header, it doesn't clear memory. The issue doesn't always appear for me either, it only happens when something else happened to be in memory so the unwritten bytes between segments get written out because they were skipped.

    I did say I was running PC DOS 7.0. You do know that MS-DOS and PC DOS were derived from the codebase with IBM essentially being the first OEM of MS-DOS which is why they have OEM ID 00h.

     
  • japheth

    japheth - 2013-03-28

    > File positioning (INT 21h function 42h) has nothing to do with memory allocation.

    And who did claim otherwise?

    > When memory is allocated in DOS via INT 21h function 48h, DOS
    > only writes the MCB header, it doesn't clear memory.

    Well, yes, I guess that's right. However, please be aware the jwasmd's memory allocation is done via the DOS extender, using extended memory - this means, DOS is not involved at all here.

     
  • japheth

    japheth - 2013-03-28
    • status: open --> pending
     
  • dosfan01

    dosfan01 - 2013-03-28
    • status: pending --> open
     
  • dosfan01

    dosfan01 - 2013-03-28

    Issue also occurs with JWASMR.

     
  • dosfan01

    dosfan01 - 2013-03-28

    Issue also happens with MS-DOS 6.22 though that was to be expected since MS-DOS and PC DOS originated from the same codebase. They only started to diverge after DOS 5 though even then there were no API functionality differences to maintain compatibility since both were retail products at that point.

     
  • dosfan01

    dosfan01 - 2013-03-29

    I looked at the source code and I see why it isn't due to uninitialized memory as fseek and fwrite are being used to write a buffer for each segment. Unfortunately this should always be an issue in DOS since the file pointer is being advanced to skip bytes via fseek for segment alignment so the skipped bytes are indeterminate. Even the documentation for the Win32 SetFilePointer function says that when it is used to write beyond EOF to increase the file size the intervening bytes are uninitialized though Windows always seems to zero them which is why the problem isn't seen with JWASM or JWASMD/JWASMR in a NTVDM.

     

Log in to post a comment.