The crash seems for exceeded ram usage. So nope...I don't know.
So, you find a way to avoid the crash ?
typedef struct {
uint32_t total;
uint32_t avail;
} sysMemoryInfo_t;
s32 sysMemoryGetUserMemorySize(sysMemoryInfo_t * MemInfo)
{
lv2syscall1(SYSCALL_MEMORY_GET_USER_MEMORY_SIZE, (uint64_t) MemInfo);
return_to_user_prog(s32);
}
int main()
{
FILE *fp;
char str[128];
u64 size = 0;
sysMemoryInfo_t MemInfo;
u8 *test;
fp = fopen("/dev_hdd0/tmp/log.txt", "w");
if(fp==NULL) return 0;
while(1)
{
size += 0x100000;
memset(&MemInfo, 0, sizeof(sysMemoryInfo_t));
sysMemoryGetUserMemorySize(&MemInfo);
sprintf(str, "MEM : %X / %X\n", (unsigned int) MemInfo.avail, (unsigned int) MemInfo.total); fputs(str, fp);
sprintf(str, "Malloc : %lX", (unsigned long int) size); fputs(str, fp); usleep(100);
test = (u8 *) malloc(size);
if(test==NULL) {
strcpy(str, " FAILED \n"); fputs(str, fp);
sysMemoryGetUserMemorySize(&MemInfo);
sprintf(str, "NEW MEM : %X / %X\n", (unsigned int) MemInfo.avail, (unsigned int) MemInfo.total); fputs(str, fp); usleep(100);
fclose(fp);
return 0;
} else {
strcpy(str, " OK \n"); fputs(str, fp);
sysMemoryGetUserMemorySize(&MemInfo);
sprintf(str, "NEW MEM : %X / %X\n", (unsigned int) MemInfo.avail, (unsigned int) MemInfo.total); fputs(str, fp); usleep(100);
}
free(test);
}
}
MEM : EAF0000 / EC00000
Malloc : EA00000 OK
NEW MEM : F0000 / EC00000
MEM : EAF0000 / EC00000
Malloc : EB00000 FAILED
NEW MEM : EAF0000 / EC00000
I did a sample, to test if it crashs if it malloc a too big size of data :
Code:typedef struct { uint32_t total; uint32_t avail; } sysMemoryInfo_t; s32 sysMemoryGetUserMemorySize(sysMemoryInfo_t * MemInfo) { lv2syscall1(SYSCALL_MEMORY_GET_USER_MEMORY_SIZE, (uint64_t) MemInfo); return_to_user_prog(s32); } int main() { FILE *fp; char str[128]; u64 size = 0; sysMemoryInfo_t MemInfo; u8 *test; fp = fopen("/dev_hdd0/tmp/log.txt", "w"); if(fp==NULL) return 0; while(1) { size += 0x100000; memset(&MemInfo, 0, sizeof(sysMemoryInfo_t)); sysMemoryGetUserMemorySize(&MemInfo); sprintf(str, "MEM : %X / %X\n", (unsigned int) MemInfo.avail, (unsigned int) MemInfo.total); fputs(str, fp); sprintf(str, "Malloc : %lX", (unsigned long int) size); fputs(str, fp); usleep(100); test = (u8 *) malloc(size); if(test==NULL) { strcpy(str, " FAILED \n"); fputs(str, fp); sysMemoryGetUserMemorySize(&MemInfo); sprintf(str, "NEW MEM : %X / %X\n", (unsigned int) MemInfo.avail, (unsigned int) MemInfo.total); fputs(str, fp); usleep(100); fclose(fp); return 0; } else { strcpy(str, " OK \n"); fputs(str, fp); sysMemoryGetUserMemorySize(&MemInfo); sprintf(str, "NEW MEM : %X / %X\n", (unsigned int) MemInfo.avail, (unsigned int) MemInfo.total); fputs(str, fp); usleep(100); } free(test); } }
and it works fine... here the last loops logs :
Code:MEM : EAF0000 / EC00000 Malloc : EA00000 OK NEW MEM : F0000 / EC00000 MEM : EAF0000 / EC00000 Malloc : EB00000 FAILED NEW MEM : EAF0000 / EC00000
I don't get it ><
https://stackoverflow.com/questions/2630054/does-c-limit-recursion-depthIs it right if I think that there is some recursion limit or... some root limits?
The link of kozarovv talk about the stacksize, it made me think about SYS_PROCESS_PARAM it allloow you to define the stack sizes maybe if you change these paramaters it will allow you to fix it. hmm, did you define it ?
It's just an idea... https://github.com/Estwald/PSDK3v2/blob/master/psl1ght/ppu/include/sys/process.h
sry.if it's working, just don't change anythingHave you a more elegant method to substitute while(1)?
EUREKAAAAA!!
I substiture all infinite loops with a for with limited loop count definited into a macro + SYS_PROCESS_PARAM(1001, SYS_PROCESS_SPAWN_MALLOC_PAGE_SIZE_1M)!!
Not other configs!
Now it works perfectly!!
many nested while(1) into recursive functions are not accepted by PS3 architecture (or PPU??).
Maybe because the processor can't calculate all potential depth...
What do you think about it?
Now I'm ready to release it!
Have you a more elegant method to substitute while(1)?
Thanks!
I'm glad you found a solution to ur issue. My suggestion ( 'while(1)' ) was a making it worse,sry.
if it's working, just don't change anything
I don't think the spawn_malloc_page value is supposed to be used here. its value is 0x100000
To the staff: please give him then dev status![]()
No PS3 release there?Dev status I think that it is ready.
I made a first build:
https://github.com/whitedragon0000/OpenBOR_PLUS/releases
Have fun!![]()