Article View: comp.os.os2.programmer
Article #1210Re: malloc causes a segmentation violation!?
From: Carlos Rimola-Sarti car
Date: Sat, 22 Aug 1992 16:34
Date: Sat, 22 Aug 1992 16:34
32 lines
2318 bytes
2318 bytes
In article <harris.714243433@garfield.catt.ncsu.edu> harris@garfield.catt.ncsu.edu (Michael Harris) writes: -mn87504@cs.tut.fi (Naatula Mika) writes: - ->I thought that OS/2 could detect writes to non-allocated areas and ->give me a segmentation fault right away. Like it usually does. - -What you have to understand is that the area IS allocated as far as the -operating system is concerned. It is allocated to your process. Since your -process owns it, the operating system is very happy to let you write there. - -Memory protection in OS/2 protects one process from another... not a process -from itself. -______________________________________________________________________________ - Michael Harris - harris@catt.ncsu.edu or harris@carvm3.vnet.ibm.com - System Administrator, Computer & Technologies Theme Program, NC State Univ. -(My opinions are my own and do not represent those of NCSU or IBM Corporation) If I am not mistaken, the MS C version of malloc allocates requested chunks of memory from a single allocated OS/2 segement (created via DosAllocSeg). Therefore, as Michael indicates, writes to the non-allocated portions of this segment are not protected by the OS. I believe that when the mallocs exceed the size of the segment it is either augmented or a new segment is allocated. Hope that helps! +---------------------------------------+-----------------------------------+ | Carlos Rimola-Sarti | email: rimola@csisdn.com | | Connective Strategies Inc. | car@btr.com | | ISDN PRI Connectivity Group | phone: 415-903-2585 | +---------------------------------------+-----------------------------------+
Technical Details
Message-ID:
<7779@public.BTR.COM>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!mips!mips!btr!carReferences:
<1992Aug18.143135.6259@cc.tut.fi> <3dfy6bq@rpi.edu> <1992Aug19.155648.6210@funet.fi> <harris.714243433@garfield.catt.ncsu.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!mips!mips!btr!car From: car@btr.BTR.COM (Carlos Rimola-Sarti car@btr.com) Newsgroups: comp.os.os2.programmer,comp.lang.c Subject: Re: malloc causes a segmentation violation!? Message-ID: <7779@public.BTR.COM> Date: 22 Aug 92 16:34:28 GMT References: <1992Aug18.143135.6259@cc.tut.fi> <3dfy6bq@rpi.edu> <1992Aug19.155648.6210@funet.fi> <harris.714243433@garfield.catt.ncsu.edu> Followup-To: comp.os.os2.programmer Organization: Connective Strategies, Inc. (CSI). Mountain View, California Lines: 33