Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


wierd stack overflow...

This topic is 5178 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

okay i got this code (please dont ask what for ):
struct CharDataPacket2
	char data[65536]; /* data */

struct CharDataPacket3
	int16 size; /* data */

bool CharHandler(SOCKET sd)
	struct CharDataPacket2 p;
	struct CharDataPacket3 d;

	int nTemp5 = 0;
	int nTemp6 = 0;
	int bytesIn33 = 0;

int peer[] = {
0x22, 0x00, 0xb4, 0x1c, 0xad, 0xa2, 0x17, 0xe8, 
0x81, 0xe9, 0x86, 0xf4, 0x7c, 0xf2, 0xaa, 0x55, 
0x3c, 0x75, 0x2e, 0x7d, 0xb8, 0x00, 0x60, 0xa6, 
0xfc, 0xb8, 0xd7, 0xa4, 0x74, 0xaf, 0xf7, 0x94, 
0x2c, 0x76, 0x2a, 0x00, 0xbb, 0x2b, 0x2f, 0x14, 
0x60, 0x9e, 0x76, 0xf7, 0xa0, 0x1f, 0x71, 0xb8, 
0xa3, 0x5c, 0xb5, 0x0b, 0x6c, 0xf2, 0xb9, 0x42, 
0x6d, 0x92, 0x71, 0xe5, 0xb0, 0x0c, 0x6b, 0xbc, 
0xa7, 0x58, 0xb0, 0x21, 0x71, 0xc0, 0x2b, 0x10, 
0x74, 0x86, 0x6e, 0xc6, 0x22, 0x00, 0x32, 0x9b, 
0xad, 0xa3, 0x90, 0x6e, 0x09, 0xfa, 0x95, 0xe4, 
0x05, 0x8c, 0x52, 0xac, 0xcb, 0x51, 0x0c, 0x4f, 
0x96, 0x3f, 0xc9, 0x06, 0x53, 0xc4, 0xab, 0xdb, 
0x65, 0xec, 0x32, 0xcd, 0xa2, 0x1c, 0x2a, 0x00, 
0x1f, 0x8e, 0x2f, 0x0b, 0xc5, 0x3a, 0xdc, 0x5a, 
0x0d, 0xb3, 0xd7, 0x13, 0xb2, 0x4c, 0xab, 0x66, 
0x01, 0x9e, 0xd5, 0x25, 0x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0x74, 
0x11, 0xe8, 0x38, 0x58, 0x0c, 0xa5, 0xca, 0xc6, 
0x5a, 0x87, 0x62, 0x3a, 0x6e, 0xc7, 0xa8, 0x5a, 
0x39, 0xc0, 0x10, 0x71, 0x25, 0x8c, 0x1c, 0xee, 
0x8f, 0x77, 0xcd, 0x9e, 0x0a, 0x00, 0x34, 0xa0, 
0x50, 0xc3, 0xf5, 0x0d, 0x85, 0x06, 0x0a, 0x00, 
0xe5, 0x46, 0x4f, 0xaa, 0xb7, 0x0f, 0xc1, 0x43, 
0x0a, 0x00, 0xdb, 0x42, 0x35, 0x2f, 0x2c, 0xd4, 
0x1c, 0xc1, 0x0a, 0x00, 0xa4, 0x07, 0x8b, 0x0e, 
0xea, 0x12, 0xd3, 0xfc, 0x0a, 0x00, 0x32, 0xab, 
0x43, 0x21, 0xaa, 0x52, 0x45, 0x4c, 0x0a, 0x00, 
0xa4, 0x08, 0x19, 0x57, 0xc2, 0x35, 0x79, 0x91, 
0x0a, 0x00, 0xb2, 0x24, 0x47, 0x12, 0x12, 0xe5, 
0x63, 0x0d, 0x0a, 0x00, 0x3a, 0x96, 0x0a, 0x80, 
0x2b, 0xdc, 0x68, 0x4e, 0x0a, 0x00, 0xbe, 0x28, 
0xcc, 0x96, 0x64, 0x93, 0xa2, 0x8d, 0x12, 0x00, 
0xb8, 0x65, 0xf8, 0x63, 0xae, 0xbc, 0x05, 0xe8, 
0x09, 0xb3, 0xfd, 0xb0, 0xb1, 0x42, 0x8c, 0x7a


	char buf[sizeof(p.data)+2];
	char* buf_ptr= buf; // done so we can mover buf_ptr to were we need to memcpy
	memcpy(buf_ptr,p.data, d.size); // now you have a buf with size, and data in it no padding and ready to send

	nTemp5 = send(sd, (char*)buf, d.size, 0);

	WriteDataStr(hData, "Send Packet 4");

	if (nTemp5 > 0)
	char buffer3[60];
	bytesIn33 = recv(sd, buffer3, 20, 0);
	WriteDataStr(hData, "Recv Packet 2 - info");
	return false;

	if (bytesIn33 > 0)

	struct ChattestData1 test2;
	struct CharDataPacket p;


	char buf[sizeof(p.size)+sizeof(p.data)];
	char* buf_ptr= buf;
	nTemp6 = send(sd, (char*)buf, p.size, 0);

	WriteDataStr(hData, "Send Packet 4");

	return true;
but it never sends that huge packet, it gives me a stack overflow when it hits that. anyone can spot any problems with this ? i want it to send peer. (i know it aint pretty, sorry for that :D )

Share this post

Link to post
Share on other sites
My rough count has you sticking about 400 kilobytes of data on the stack. This is non-kosher on current operating systems with default link settings. If you want to use that many data structures and buffers of that size, you should allocate them on the heap. Since you seem to be using pure C in your code, try malloc()ing everything bigger than a couple kilobytes. That includes your CharDataPacket2 structures, and most of your buffers. And while you''re at it, since you don''t seem to be modifying the peer array, you might consider making in a static variable.

Share this post

Link to post
Share on other sites
actually i fixed it alot easier


int peer[] = { ............


unsigned char peer[] = { .........

then send it with

send(sd, (char*)&peer, sizeof(peer), 0);

or like that anyways, dont have the sources right here right now, but o well.. it works like this :D

Share this post

Link to post
Share on other sites
You can also use auto_ptr<> and new to create those large arrays and the large packet structs. Or just declare them static. Or instruct your linker to make the stack larger.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!