git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Unexpected pass for t6120-describe.sh on cygwin

From
Jeff King <peff@peff.net>
Date
Sep 11, 2017, 17:47 UTC
Message-ID
<20170911174711.j7ela4feg43gw34b@sigill.intra.peff.net>
In-Reply-To
<947699e6-c206-7818-3780-c4367e0996f0@grubix.eu>
On Sun, Sep 10, 2017 at 02:27:47PM +0200, Michael J Gruber wrote:
Show 15 quoted lines
> This apparantly expects "ulimit -s" to fail on platforms that don't
> support it, so set the prereq accordingly. I moved the following to
> t/test-lib.sh:
> 
> run_with_limited_stack () {
>         (ulimit -s 128 && "$@")
> }
> 
> test_lazy_prereq ULIMIT_STACK_SIZE 'run_with_limited_stack true'
> 
> Same things as above. Two things to note:
> - Those requisites could be the same, also they are used in different ways.
> - "ulimit -s" returning success without doing anything means that, all
> along, we ran the existing tests when we didn't mean to (on Win), and
> they succeeded for the wrong reason, which we did not notice.

Right, if ulimit doesn't actually limit, then the test isn't really accomplishing anything. But we likely have several tests in our suite that do that. As long as they do something on _some_ platforms, they're still useful. And as long as their failure mode is a false-pass, they don't bother people on the other platforms.

So I think one option is to just leave it.
> So, I guess, short of testing the effect of "ulimit -s" with another
> expensive test, it's best to simply set these prerequisites based on
> "uname -s".

You can make a cheap test that uses a lot of stack. E.g., this program runs in about 3ms on my machine, and you can reliably run "ulimit -s 128 && ./a.out >/dev/null" to detect it segfaulting:

-- >8 -- #include <stdio.h>

/*
 * Our goal is to use a lot of stack space relatively cheaply. To do that,
 * allocate a big stack buffer and recurse. But we take a few precautions to
 * avoid a clever compiler optimizing away our stack:
 *
 *   - we need to use the buffer so that it can't be eliminated
 *
 *   - we recurse after touching the buffer but before printing it,
 *     which makes it hard to do tail-recursion.
 */
static void foo(unsigned x)
{
	size_t i;
	unsigned char buf[1024];
	if (!x)
		return;
	for (i = 0; i < sizeof(buf); i++)
		buf[x] = x & 0xff;
	foo(x - 1);
	fwrite(buf, 1, sizeof(buf), stdout);
}
int main(void)
{
	foo(128);
	return 0;
}
-- 8< --

One downside is that it means git's test suite would (on a successful run) stimulate segfaults, which are sometimes tracked and logged by the kernel (or may even generate coredumps outside of the test suite area).

-Peff
Previous: Ramsay JonesNext: Adam Dinwoodie
Message 4 of 9 in “Unexpected pass for t6120-describe.sh on cygwin”
  1. Ramsay JonesSep 9, 2017
  2. Michael J GruberSep 10, 2017
  3. Ramsay JonesSep 10, 2017
  4. Jeff KingSep 11, 2017
  5. Adam DinwoodieSep 11, 2017
  6. Ramsay JonesSep 11, 2017
  7. Johannes SchindelinSep 12, 2017
  8. Michael J GruberSep 13, 2017
  9. Johannes SchindelinSep 13, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.