Port-arm archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: can not download IMAP messages with isync/mbsync



On Mon, 14 Nov 2022, RVP wrote:

On Mon, 14 Nov 2022, Mouse wrote:

My guess is that the buffer you're testing with is near the top of the
address space, within ~1GB of address 0xffffffff, and what you're
seeing is due to wraparound.


Thanks for that analysis--address-wrapping was my first guess too, but,
I didn't have the time to confirm it: the 1GB was with a standalone
program; in mbsync itself, the range was much smaller--less than 1MB even.


Well, that 1GB vs 1MB difference is easily explained. In my test code,
below, I originally had `const char* const s = "hello"'. So, `s' pointed
to a data segment address instead of the stack.

And, the wraparound seems to happen at 0x7fffffff instead of 0xffffffff.
Don't know ARM well enough to explain why.

---START---
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>

static void
f2(const char* fmt, va_list ap)
{
	size_t max, l = 0, n;
	const char* s;

	if (*fmt != 's')
		return;
	s = va_arg(ap, const char *);
	n = strlen(s);
	for (max = ULONG_MAX; max != 0; max /= 2)
		if ((l = strnlen(s, max)) == n)
			break;
	printf("s @ %p, got len=%zu when max=%zu\n", s, l, max);
}

static void
f1(const char* fmt, ...)
{
	va_list ap;

	va_start(ap, fmt);
	f2(fmt, ap);
	va_end(ap);
}

int
main(void)
{
	const char s[] = "hello";

	f1("s", s);
	return 0;
}
---END---

-RVP


Home | Main Index | Thread Index | Old Index