NetBSD-Bugs archive

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

toolchain/53081: __BITMAP_* bitops macros broken with gcc 6.4



>Number:         53081
>Category:       toolchain
>Synopsis:       __BITMAP_* bitops macros broken with gcc 6.4
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Mar 08 09:30:00 +0000 2018
>Originator:     Martin Husemann
>Release:        NetBSD 8.99.12
>Organization:
The NetBSD Foundation, Inc.
>Environment:
System: NetBSD whoever-brings-the-night.aprisoft.de 8.99.12 NetBSD 8.99.12 (WHOEVER) #212: Mon Mar 5 08:13:25 CET 2018 martin%seven-days-to-the-wolves.aprisoft.de@localhost:/work/src/sys/arch/sparc64/compile/WHOEVER sparc64
Architecture: sparc64
Machine: sparc64
>Description:

The example from bitmap(3) is broken when compiled with gcc 6.4. This
also breaks the ASID storage of the common pmap, and makes for example
the evbmips64-eb ERLITE unbootable.

>How-To-Repeat:

Test program:

#include <stdio.h>
#include <sys/types.h>
#include <sys/bitops.h>

int
main(void)
{
	__BITMAP_TYPE(,unsigned long, 256) bitmap;

	// clear the whole bitmap
	__BITMAP_ZERO(&bitmap);

	// set a single bit
	__BITMAP_SET(0, &bitmap);

	// show all bits that are set
	for (size_t i = 0; i < 256; i++) {
		if (!__BITMAP_ISSET(i, &bitmap))
			continue;
		printf("bit %zu is set\n", i);
	}

	// dump whole bitmap for examination
	for (size_t i = 0; i < __arraycount(bitmap._b); i++)
		printf("%zu: %016lx\n", i, bitmap._b[i]);

	return 0;
}

Compile with -Wall -O2 and run:

bit 0 is set
bit 32 is set
0: 0000000000000001
1: 0000000000000000
2: 0000000000000000
3: 0000000000000000

As you can see, the bitmap state itself is correct, but the __BITMAP_ISSET()
macros gives a false postive for bit 32.

This happens at least on mips64eb and sparc64.

>Fix:
n/a



Home | Main Index | Thread Index | Old Index