 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
foxss
Joined: 07 Dec 2008 Posts: 6
|
Posted: Wed Dec 23, 2009 2:58 am Post subject: [solved]tinyxml bus error |
|
|
Hi,
I tried to parse a utf-8 xml file with tinyxml while get a bus error.
main.cpp
| Code: |
#include "tinyxml.h"
#include <pspkernel.h>
PSP_MODULE_INFO("sample", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
PSP_HEAP_SIZE_KB(20*1024);
TiXmlDocument* doc;
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
return 0;
}
/* Callback thread */
int CallbackThread(SceSize args, void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, PSP_THREAD_ATTR_USER, 0);
if(thid >= 0)
sceKernelStartThread(thid, 0, 0);
return thid;
}
bool LoadMenu(){
doc = new TiXmlDocument("test.xml");
return doc->LoadFile();
}
void GenUI(TiXmlElement *elem){
return;
}
void ParseMenu(TiXmlDocument* doc1){
TiXmlElement* ele = doc1->FirstChildElement("Item");
do{
GenUI(ele);
ele = ele->NextSiblingElement();
}while(ele);
return;
}
int main() {
SetupCallbacks();
if(!LoadMenu()){
//when config file missing, exit program
sceKernelExitGame();
return 0;
}
ParseMenu(doc);
sceKernelExitGame();
return 0;
}
|
| Code: |
host0:/> ./VersiPSP.prx
Load/Start host0:/VersiPSP.prx UID: 0x045EFC39 Name: "s
host0:/> Exception - Bus error (data)
Thread ID - 0x045E7745
Th Name - user_main
Module ID - 0x045EFC39
Mod Name - "sample"
EPC - 0x088047D4
Cause - 0x1000001C
BadVAddr - 0x10500440
Status - 0x40088613
zr:0x00000000 at:0xDEADBEEF v0:0x00000001 v1:0x00000A59
a0:0x00000000 a1:0x00000021 a2:0x00000A58 a3:0x08828984
t0:0x00000020 t1:0x088355A8 t2:0x0882DDF8 t3:0x088355BC
t4:0x00000000 t5:0xDEADBEEF t6:0xDEADBEEF t7:0xDEADBEEF
s0:0x00000000 s1:0x08835330 s2:0x00000001 s3:0x0BBBFEE0
s4:0x00000014 s5:0x00000013 s6:0xDEADBEEF s7:0xDEADBEEF
t8:0xDEADBEEF t9:0xDEADBEEF k0:0x0BBBFF00 k1:0x00000000
gp:0x088364A0 sp:0x0BBBFE08 fp:0x0BBBFEA0 ra:0x08804454
0x088047D4: 0x8C83001C '....' - lw $v1, 28($a0)
|
Is someone know what this about?
I can't get clue over this.
Thanks, _________________ ps2dev.org rocks!
Love eReader/XReader
Last edited by foxss on Mon Dec 28, 2009 12:31 pm; edited 1 time in total |
|
| Back to top |
|
 |
psPea
Joined: 01 Sep 2007 Posts: 64
|
Posted: Wed Dec 23, 2009 5:12 am Post subject: |
|
|
You're trying to derefeence a null pointer at 0x3d4
lw $v1, 28($a0)
a0:0x00000000
EPC:0x088047D4
lw destinationRegister, offset(sourceRegester) # load contents of RAM at offset from sourceRegister into register destinationRegister: destinationRegister = *(destinationRegister+offset)
To calculate where the error occurs type in psplink
calc $epc-$mod
then use that address in psp-address
psp-address2line -fCe your_module.elf address
This will give you the file and the line the error occurs(for this to work need to have -g in CFLAGS in your makefile)
Okay I see 2 places where your crash could have happened
return doc->LoadFile();
ele = ele->NextSiblingElement();
Edit:
I'll go with "return doc->LoadFile();" since LoadFile() is the 8th member of TiXmlDocument. You should make sure you classes are created before you use them. _________________ Click ME! |
|
| Back to top |
|
 |
foxss
Joined: 07 Dec 2008 Posts: 6
|
Posted: Wed Dec 23, 2009 4:37 pm Post subject: |
|
|
Thanks, psPea!
I finally find crash caused as ele is a null pointer. I should be more defensive, check it before using...
| Code: |
ele = ele->NextSiblingElement();
|
| psPea wrote: | You're trying to derefeence a null pointer at 0x3d4
lw $v1, 28($a0)
a0:0x00000000
EPC:0x088047D4
lw destinationRegister, offset(sourceRegester) # load contents of RAM at offset from sourceRegister into register destinationRegister: destinationRegister = *(destinationRegister+offset)
To calculate where the error occurs type in psplink
calc $epc-$mod
then use that address in psp-address
psp-address2line -fCe your_module.elf address
This will give you the file and the line the error occurs(for this to work need to have -g in CFLAGS in your makefile)
Okay I see 2 places where your crash could have happened
return doc->LoadFile();
ele = ele->NextSiblingElement();
Edit:
I'll go with "return doc->LoadFile();" since LoadFile() is the 8th member of TiXmlDocument. You should make sure you classes are created before you use them. |
_________________ ps2dev.org rocks!
Love eReader/XReader |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|