A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2000-August/008937.html below:

[Python-Dev] stack check on Unix: any suggestions?

[Python-Dev] stack check on Unix: any suggestions? [Python-Dev] stack check on Unix: any suggestions?Barry Scott barry@scottb.demon.co.uk
Tue, 29 Aug 2000 22:21:04 +0100
Use the problem as the solution.

The problem is that you get a SIGSEGV after you fall off the end of the stack.
(I'm assuming you always have guard pages between the stack end and other memory
zones. Otherwise you will not get the SEGV).

If you probe ahead of the stack to trigger the SIGSEGV you can use the signal
handler to trap the probe and recover gracefully. Use posix signal handling
everywhere for portability (don't mix posix and not and expect signals to work
BTW).

jmp_buf probe_env;

int CheckStack()	/* untested */
	{
	if( setjmp( &probe_env ) == 0 )
		{
		char buf[32];
		/* need code to deal with direction of stack */
		if( grow_down )
			buf[-65536] = 1;
		else
			buf[65536] = 1;
		return 1; /* stack is fine of 64k */
		}
	else
		{
		return 0; /* will run out of stack soon */
		}
	}

void sigsegv_handler( int )
	{
	longjmp( &probe_env );
	}

			Barry (not just a Windows devo <wink>)





RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4