Welcome! Log In Create A New Profile

Advanced

DSI error with stl

Posted by arasium 
DSI error with stl
June 20, 2009 11:56PM
When i use a vector, i've a dsi exception. Is there a bug on the stl?

Here is my code:

int main(int argc, char **argv) {
//---------------------------------------------------------------------------------

	// Initialise the video system
	VIDEO_Init();

	vmode = VIDEO_GetPreferredMode(NULL);
	xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode));

	VIDEO_Configure(vmode);
	VIDEO_SetNextFramebuffer(xfb);
	VIDEO_SetBlack(false);
	VIDEO_Flush();

	VIDEO_WaitVSync();
	if (vmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();

	int x = 20, y = 20, w, h;
	w = vmode->fbWidth - (x * 2);
	h = vmode->xfbHeight - (y + 20);

	// Initialize the console
	CON_InitEx(vmode, x, y, w, h);

	VIDEO_ClearFrameBuffer(vmode, xfb, COLOR_BLACK);

	// This function initialises the attached controllers
	WPAD_Init();

	// To see the first phrase :)
	printf("\x1b[2;0H");

	// comment to disable the debugger
	DEBUG_Init(GDBSTUB_DEVICE_WIFI, 8000);
	_break();


	vector vec;
	vec.push_back("tt"); //DSI Exception here
	while(1) 
	{

		// Call WPAD_ScanPads each loop, this reads the latest controller states
		WPAD_ScanPads();

		// WPAD_ButtonsDown tells us which buttons were pressed in this loop
		// this is a "one shot" state which will not fire again until the button has been released
		u32 pressed = WPAD_ButtonsDown(0);

		// We return to the launcher application via exit
		if ( pressed & WPAD_BUTTON_HOME ) exit(0);

		// Wait for the next frame
		VIDEO_WaitVSync();
	}

	return 0;
}

Edit: it works now!!! So my problem is solved.



Edited 1 time(s). Last edit at 06/21/2009 12:46AM by arasium.
Re: DSI error with stl
June 21, 2009 01:18AM
Could you tell us what you did to solve your problem for the benefit of others interested in this as well?
Re: DSI error with stl
June 21, 2009 04:14PM
I don't know, because i haven't change anything (i've just swith off my wii, removing the power cable).

But, it seems that i've e real problems with the vector class because today i've an other error. It occurs in the push_back method of the vector class.

Here is my source code:

[www.mediafire.com]



Edited 2 time(s). Last edit at 06/21/2009 04:29PM by arasium.
Re: DSI error with stl
June 21, 2009 07:27PM
The heap got corrupted, it's not stl's fault. It's just a heavy heap user and thus a likely victim.
Re: DSI error with stl
June 21, 2009 08:27PM
I don't understand what you mean. The heap isn't enough large to allow the use of vectors?
Re: DSI error with stl
June 22, 2009 02:09AM
No, that is not the issue at all. What I said is that something corrupted the heap. Corrupted as in, overwrote the internal management data that the heap manager needs in order to manage the memory the heap has allocated.
If you corrupt the memory management data, you get random crashes like this.
Re: DSI error with stl
June 22, 2009 07:05AM
ok, so i've made a coding error! If someone can help me to find it, because i don' see where the error is!
I will try with a dinamic vector (with new) of pointers instead of objects.
Re: DSI error with stl
June 22, 2009 12:54PM
Yeah, allocate even more memory, that's definitely going to fix the issue.
I am sorry, but I can't find the issue.
Re: DSI error with stl
June 23, 2009 09:52AM
you mean that i need to use vector::reserve before including an element?
or do I need to construct the vector like this "vector vect(15);"?
Re: DSI error with stl
June 23, 2009 02:26PM
No, that was not what I was saying. I used an advanced form of communication called "sarcasm".
Re: DSI error with stl
June 24, 2009 12:12AM
!kickhenke

Going through step by step with a debugger is my only suggestion, arasium. Not knowledgeable enough to find the issue, myself.
Re: DSI error with stl
June 24, 2009 12:06PM
Ok, i've used the debuuger and the bug occured when we call the push_back function.

It seems that the programme bug at this point in stl_vector.h:

void
      push_back(const value_type& __x)
      {
	if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage) // it loops on this line!!!
	  {
	    this->_M_impl.construct(this->_M_impl._M_finish, __x);
	    ++this->_M_impl._M_finish;
	  }
	else
	  _M_insert_aux(end(), __x);
      }

I will try with a list object, but i'm pessimistic.
Re: DSI error with stl
June 24, 2009 01:28PM
Again, it's not the fault of stl. It just happened to be the victim. Something else set it up by corrupting the heap. Run the application in some memory manangerment checking environment and catch the real error. You are either freeing memory when you should not or overflowing a buffer.
Re: DSI error with stl
June 24, 2009 02:33PM
ok. So i will make simple tests and i will give you my results :)

thank you.
Re: DSI error with stl
June 29, 2009 01:36PM
I've made some others tests, and i think that problem comes from libfat.

You can see my explanation here.

Thank you for your helps.
Sorry, only registered users may post in this forum.

Click here to login