41 lines
1.5 KiB
C
41 lines
1.5 KiB
C
// A1 regression: pre-fix, malloc bumped the bank-0 phantom heap window
|
|
// [__bss_end, 0xBF00) into GNO's kernel heartbeat block (alarmHB ~0xB7xx)
|
|
// -> SysFailMgr $0308 halt. crt0Gno now backs malloc with an MM-owned
|
|
// handle (__heapInitMM), so several KB of allocations survive intact.
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
int main(void) {
|
|
*(volatile uint16_t *)0x025010UL = 0xBEEF; // main entered
|
|
uint16_t ok = 1;
|
|
char *b[8];
|
|
uint8_t i;
|
|
for (i = 0; i < 8; i++) {
|
|
b[i] = (char *)malloc(0x400); // 8 KB total
|
|
if (!b[i]) {
|
|
ok = 0;
|
|
break;
|
|
}
|
|
memset(b[i], (char)(0xA0 + i), 0x400);
|
|
}
|
|
if (ok) {
|
|
for (i = 0; i < 8; i++) {
|
|
if ((uint8_t)b[i][0] != (uint8_t)(0xA0 + i) ||
|
|
(uint8_t)b[i][0x3FF] != (uint8_t)(0xA0 + i)) {
|
|
ok = 0;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
// The observable regression signal is survival: pre-fix, malloc bumped
|
|
// into GNO's kernel heartbeat block and 8 KB of allocations could not
|
|
// complete intact. (A bank read cannot prove MM-ownership -- NewHandle
|
|
// uses attr without attrBank, so the MM may legitimately place the block
|
|
// in bank 0 -- so this probe asserts survival, not the block's bank.)
|
|
*(volatile uint16_t *)0x025012UL = ok ? 0x0001 : 0xDEAD;
|
|
*(volatile uint16_t *)0x025000UL = 0xC0DE; // reached end
|
|
for (volatile unsigned long j = 0; j < 600000UL; j++) {
|
|
}
|
|
return 0;
|
|
}
|