[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Memory violation: free



I've been having a lot of problems with some apps with the above memory
violation. I finally got around to tracking it down today & it happens
with apps which call the OS with less than 1K of supervisor stack free
in the current page. 64 bytes seems a lot more reasonable than 1K to
me since 64 bytes is around the size of the largest stack frame which
the processor can generate. Whilst I was about it I fixed up a couple
of other new problems I'd never encountered, but obviously could happen
(wrong number of loop iterations).

*** m:/context.spp  Tue Jul 27 19:44:42 1993
--- context.spp Wed Sep 29 14:50:38 1993
***************
*** 104,109 ****
--- 104,110 ----
    lea _framesizes,a3
    move.b  0(a3,d1.w),d1
    beq.s   short1      ; if no data to save, skip this
+   subq.w  #1,d1       ; correct for first time through loop
  bcint:    move.w  (a1)+,(a2)+ ; copy CPU internal state
  bcover:   dbf d1,bcint
  short1:
***************
*** 174,180 ****
  
    move.l  C_SSP(a0),a1    ; get supervisor stack pointer
    tst.b   (a1)        ; touch the page for virtual memory programs
!   tst.b   -1023(a1)   ; make sure stack can grow
    move.l  a1,sp
    move.l  C_USP(a0),a1
    move.l  a1,usp      ; set user stack pointer
--- 175,181 ----
  
    move.l  C_SSP(a0),a1    ; get supervisor stack pointer
    tst.b   (a1)        ; touch the page for virtual memory programs
!   tst.b   -63(a1)     ; make sure stack can grow
    move.l  a1,sp
    move.l  C_USP(a0),a1
    move.l  a1,usp      ; set user stack pointer
***************
*** 206,212 ****
    sub.w   d1,sp
    sub.w   d1,sp
    move.l  sp,a2
!   bra.s   rcover
  rcint:    move.w  (a1)+,(a2)+
  rcover:   dbf d1,rcint
  rcovernc:
--- 207,213 ----
    sub.w   d1,sp
    sub.w   d1,sp
    move.l  sp,a2
!   subq.w  #1,d1       ; correct for first time through loop
  rcint:    move.w  (a1)+,(a2)+
  rcover:   dbf d1,rcint
  rcovernc:
***************
*** 241,247 ****
  
    move.l  C_SSP(a0),a1    ; get supervisor stack pointer
    tst.b   (a1)        ; touch the page for virtual memory programs
!   tst.b   -1023(a1)   ; make sure stack can grow
    move.l  a1,sp
    move.l  C_USP(a0),a1
    move.l  a1,usp      ; set user stack pointer
--- 242,248 ----
  
    move.l  C_SSP(a0),a1    ; get supervisor stack pointer
    tst.b   (a1)        ; touch the page for virtual memory programs
!   tst.b   -63(a1)     ; make sure stack can grow
    move.l  a1,sp
    move.l  C_USP(a0),a1
    move.l  a1,usp      ; set user stack pointer
***************
*** 270,275 ****
--- 271,277 ----
    sub.w   d1,sp
    sub.w   d1,sp
    move.l  sp,a2
+   subq.w  #1,d1       ; correct for first time through loop
  rcint2:   move.w  (a1)+,(a2)+
  rcover2: dbf  d1,rcint2
  rcover2nc:
--
Alex Kiernan.
alex@falcon.demon.co.uk