home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / unix / wizards / 5317 < prev    next >
Encoding:
Internet Message Format  |  1992-12-22  |  1.9 KB

  1. Xref: sparky comp.unix.wizards:5317 comp.unix.programmer:5768 comp.unix.questions:14902
  2. Newsgroups: comp.unix.wizards,comp.unix.programmer,comp.unix.questions
  3. Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!spool.mu.edu!darwin.sura.net!convex!news.oc.com!utacfd.uta.edu!rwsys!sneaky!gordon
  4. From: gordon@sneaky.lonestar.org (Gordon Burditt)
  5. Subject: Re: Portability issues in using a memory dump
  6. Message-ID: <BzoHJ9.798@sneaky.lonestar.org>
  7. Organization: Gordon Burditt
  8. References: <1992Dec17.222402.18347@sj.ate.slb.com> <1992Dec21.165835.17205@thunder.mcrcim.mcgill.edu>
  9. Date: Tue, 22 Dec 1992 20:42:38 GMT
  10. Lines: 26
  11.  
  12. >Yes.  The difference is usually fairly minor; most UNIXish systems just
  13. >give you text/data/stack at runtime, so if you dump out the data
  14. >segment you should be OK, even though the data segment may begin at a
  15. >different address and be a different size from system to system.  If
  16.  
  17. One of the biggest ugly problems with this technique is saving 
  18. and later restoring data that you don't know exists.  Some of 
  19. the things you might end up restoring are:
  20.  
  21. - Your terminal type, and internal curses/termcap/terminfo variables
  22. related to it.  Bad news if you restart on a different terminal type.
  23. - Stdio information about open files that aren't open in the restoring
  24. process.  This often includes the FILE * stream used to save the data.
  25. - On fixed-stack machines, your stack and all auto variables may be
  26. included in what you are restoring.  KABOOM!
  27. - Environment variables, or copies made of them by library routines.
  28. - Malloc and sbrk's records of memory allocation.
  29.  
  30. At least one version of the game rogue used this technique, although
  31. it tried saving data AND bss AND malloc space.  I rapidly learned to 
  32. hate it.  Save/restore cycles ended up leaking memory, FILE * descriptors, 
  33. and after a couple dozen cycles, the game generally fell apart with 
  34. SIGSEGV's.
  35.  
  36.                     Gordon L. Burditt
  37.                     sneaky.lonestar.org!gordon
  38.