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

Re: [MiNT] gcc 4.2.2 compile error



MiKRO wrote :
/* make sure there's enough room for the stack */
	if (((long)bp + m) > ((long)bp->p_hitpa - MINFREE))
	    goto notenough;

and this test fails for default/undefined TPA in mint.cnf and 2 MB
stack. This TPA is calculated by Freemint kernel just according to
that TPA value in mint.cnf. When I set TPA to 4096 KB, I'll get around
0.5 MB gap here so test pass  then.

No problem, we agree.
I added the initial TPA size in prstack.
Here the stack of prstack is set to 3M.
In mint.cnf, I set TPA_INITIALMEM=5120

       basepage = 0x02612000
     minimal sp = 0x0262b3ee  end of the .bss segment
     current sp = 0x0292b404  3145750 bytes free
     maximal sp = 0x0292b470  end of the Mshrinked TPA
initial TPA end = 0x02b2c000  size = 5224 Ko
       _stksize = 0x00300000  3145728 bytes total
      _heapbase = 0x00000000

We can see that the initial TPA size = 5224 Ko, more or less the same size of the TPA_INITIALMEM value.

If a program size (text+data+bss+stack) is greater than TPA_INITIALMEM, we get "Fatal Error: Insufficient memory", because of the test you show, in the MiNTLib sources.

> One thing is still mystery for me -- why under aranym with JIT and
> without mmu mintlib says (right) message "Fatal error: insufficient
> memory" (with default TPA in mint.cnf) but under falcon+mmu it says
> "bus error" (or memory violation, I don't remember now).

You're right, the only mystery is here.

Tonight libgcc will be for you !

--
Vincent Rivière
/* prstack.c
 * By Vincent Riviere, 2007
 * Display the current stack values
 */

#include <stdio.h>
#include <mint/basepage.h>

extern long _stksize;
extern void *_heapbase;
extern unsigned long _PgmSize;

int main(int argc, char* argv[])
{
    unsigned long cursp;
    unsigned long minsp;
    unsigned long maxsp;

    /* Get current stack address. */
    asm ("move.l %%sp,%0"
	:"=g"(cursp)	/* outputs */
    );

    /* The minimum stack address is the end of the .bss segment. */
    minsp = (unsigned long)(_base->p_bbase + _base->p_blen);

    /* The maximum stack address is the end of the shrinked TPA. */
    maxsp = (unsigned long)_base + _PgmSize;

    printf ("       basepage = 0x%08lx\n", (unsigned long)_base);
    printf ("     minimal sp = 0x%08lx  end of the .bss segment\n", minsp);
    printf ("     current sp = 0x%08lx  %ld bytes free\n", cursp, (long)(cursp - minsp));
    printf ("     maximal sp = 0x%08lx  end of the Mshrinked TPA\n", maxsp);
    printf ("initial TPA end = 0x%08lx  size = %lu Ko\n", (unsigned long)_base->p_hitpa, ((unsigned long)_base->p_hitpa - (unsigned long)_base) / 1024);
    printf ("       _stksize = 0x%08lx  %ld bytes total\n", (unsigned long)_stksize, _stksize);
    printf ("      _heapbase = 0x%08lx\n", (unsigned long)_heapbase);

    return 0;
}