Skip to contentSkip to conversation

problem with NESTED_FUNC_ATTR : unaligned pointer

DISCUSSION Vincent Guffens 2 participants 2 messages Aug 13, 2005

lore
Share & tools
lore
#0 lore raw

With recent version of GRUB, I have some problem when doing some ls or tab-completion commands.It says unaligned pointer or out of range pointer.

I spent some time on it and I think I found the problem.

In the file config.h, the NESTED_FUNC_ATTR has no value but it should be set to :

#define NESTED_FUNC_ATTR __attribute__ ((__regparm__ (2)))

By comparing a version that work on my pc and the one that doesn't work, I found that that in aclocal.m4, the line return nestedfunc(0,0,0) was now ! nestedfunc(0,0,0).

As a result, the macro NESTED_FUNC_ATTR is not defined anymore and a pointer that was pasted as a third argument of a nested function was corrupted. This appends in grub_ext2_dir() in the nested iterate() function which does a grub_free(node). The pointer node is the one that was corrupted.

Maybe this is also the same problem that the one that has been reported recently for the 1.90 release although the description is quite different.

Signature · 6 lines
				Vincent Guffens
				PhD Student UCL/CESAME
				tel:   +32 10 47 80 30
Value your freedom, or you will lose it, teaches history.
"Don't bother us with politics," respond those who don't want to learn.
	      	-- Richard M. Stallman
#1 lore raw

I investigated this problem. Actually, there were two problems:

- The test didn't detect bugs in gcc-3.4 or gcc-4.0.

- The check was reverse. This is my mistake.

I tried to rewrite the test program, and found a way to detect the bug in gcc-3.4. However, I still do not find a simple way to detect the bug in gcc-4.0. So, for now, the workaround is always enabled, regardless of the result of the test.

The difficulty is that recent GCC is "too clever" in a sense. So it emits code trimmed down very much when a program is simple. But clearly gcc-4.0 has the same bug as older versions with the file ext2.c, so there must be a way to detect the bug in a simple way.

Okuji