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

  1. Xref: sparky comp.os.os2.programmer:4391 comp.lang.c:12670
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!mips!mips!btr!car
  3. From: car@btr.BTR.COM (Carlos Rimola-Sarti  car@btr.com)
  4. Newsgroups: comp.os.os2.programmer,comp.lang.c
  5. Subject: Re: malloc causes a segmentation violation!?
  6. Message-ID: <7779@public.BTR.COM>
  7. Date: 22 Aug 92 16:34:28 GMT
  8. References: <1992Aug18.143135.6259@cc.tut.fi> <3dfy6bq@rpi.edu> <1992Aug19.155648.6210@funet.fi> <harris.714243433@garfield.catt.ncsu.edu>
  9. Followup-To: comp.os.os2.programmer
  10. Organization: Connective Strategies, Inc. (CSI).  Mountain View, California
  11. Lines: 33
  12.  
  13. In article <harris.714243433@garfield.catt.ncsu.edu> harris@garfield.catt.ncsu.edu (Michael Harris) writes:
  14. -mn87504@cs.tut.fi (Naatula Mika) writes:
  15. -
  16. ->I thought that OS/2 could detect writes to non-allocated areas and
  17. ->give me a segmentation fault right away.  Like it usually does. 
  18. -
  19. -What you have to understand is that the area IS allocated as far as the
  20. -operating system is concerned.  It is allocated to your process.  Since your
  21. -process owns it, the operating system is very happy to let you write there.
  22. -
  23. -Memory protection in OS/2 protects one process from another... not a process
  24. -from itself.
  25. -______________________________________________________________________________
  26. -     Michael Harris - harris@catt.ncsu.edu or harris@carvm3.vnet.ibm.com
  27. - System Administrator, Computer & Technologies Theme Program, NC State Univ.
  28. -(My opinions are my own and do not represent those of NCSU or IBM Corporation)
  29.  
  30. If I am not mistaken, the MS C version of malloc allocates requested chunks
  31. of memory from a single allocated OS/2 segement (created via DosAllocSeg).
  32. Therefore, as Michael indicates, writes to the non-allocated portions of
  33. this segment are not protected by the OS.
  34.  
  35. I believe that when the mallocs exceed the size of the segment it is either
  36. augmented or a new segment is allocated.
  37.  
  38. Hope that helps!
  39.  
  40. +---------------------------------------+-----------------------------------+
  41. | Carlos Rimola-Sarti                   |         email: rimola@csisdn.com  |
  42. | Connective Strategies Inc.            |                      car@btr.com  |
  43. | ISDN PRI Connectivity Group           |         phone:      415-903-2585  |
  44. +---------------------------------------+-----------------------------------+
  45.  
  46.