home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / os2 / programm / 4362 < prev    next >
Encoding:
Internet Message Format  |  1992-08-21  |  1.9 KB

  1. Xref: sparky comp.os.os2.programmer:4362 comp.lang.c:12610
  2. Newsgroups: comp.os.os2.programmer,comp.lang.c
  3. Path: sparky!uunet!ferkel.ucsb.edu!taco!garfield.catt.ncsu.edu!harris
  4. From: harris@garfield.catt.ncsu.edu (Michael Harris)
  5. Subject: Re: malloc causes a segmentation violation!?
  6. Message-ID: <harris.714400169@garfield.catt.ncsu.edu>
  7. Sender: news@ncsu.edu (USENET News System)
  8. Organization: North Carolina State University
  9. References: <harris.714243433@garfield.catt.ncsu.edu> <1992Aug20.092700.8373@wsl.ie>
  10. Date: Fri, 21 Aug 1992 12:29:29 GMT
  11. Lines: 27
  12.  
  13. jja@wsl.ie (John J. Allen) writes:
  14.  
  15. >harris@garfield.catt.ncsu.edu (Michael Harris) writes:
  16. >: mn87504@cs.tut.fi (Naatula Mika) writes:
  17. >: 
  18. >: >I thought that OS/2 could detect writes to non-allocated areas and
  19. >: >give me a segmentation fault right away.  Like it usually does. 
  20. >: 
  21.  
  22. >OS/2 2.0 = Flat memory model
  23. >OS/2 1.x = Segmented memory model.
  24. >
  25. >The segmented memory model had some advantages over the flat model. If I
  26. >used DosAllocSeg() to create a 20k block and then ran off the end of
  27. >it I'd get a segmentation violation as soon as I did that. (As in Win 3.x)
  28.  
  29. This discussion has nothing to do with Flat vs Segmented memory model.  What
  30. it deals with is WHERE some housekeeping info for your process is kept.  True,
  31. if you used DosAllocSeg() only, you wouldn't experience this particular
  32. problem.  HOWEVER, if you then used DosSubAlloc() you might experience the
  33. same problem.  And then there is the other highly unlikely situation (yet
  34. still possible) where your pointer is so screwed up that it points back to
  35. your application stack space.
  36. ______________________________________________________________________________
  37.      Michael Harris - harris@catt.ncsu.edu or harris@carvm3.vnet.ibm.com
  38.  System Administrator, Computer & Technologies Theme Program, NC State Univ.
  39. (My opinions are my own and do not represent those of NCSU or IBM Corporation)
  40.