Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect handling of types causes a segfault on armv7l (e.g., Raspberry Pi) #1423

Closed
wbkang opened this issue May 30, 2017 · 1 comment
Closed

Comments

@wbkang
Copy link
Contributor

wbkang commented May 30, 2017

Hello,

I was excited to try out your project on my Raspberry Pi but ctags died with a segfault. After running it through gdb, I found the root cause:

// main/kind.h
#define KIND_GHOST_INDEX -1
#define KIND_FILE_INDEX -2
// main/parse.c
extern kindDefinition* getLanguageKind (const langType language, char kindIndex)
{
	kindDefinition* kdef;

	Assert (0 <= language  &&  language < (int) LanguageCount);

	switch (kindIndex)
	{
	case KIND_FILE_INDEX:
		kdef = LanguageTable [language].fileKind;
		break;
	case KIND_GHOST_INDEX:
		kdef = &kindGhost;
		break;
	default:
		kdef = getKind (LanguageTable [language].kindControlBlock, kindIndex);
	}
	return kdef;
}

On armv7l, char type is actually unsigned. So doing a switch on an unsigned value kindIndex with a negative case value actually does not work. My suggestion is to fix the type of kindIndex specifically to signed char. All unit tests pass if I make that change as well.

wbkang added a commit to wbkang/ctags that referenced this issue May 30, 2017
armv7l (e.g., Raspberry Pi)

universal-ctags#1423

make units is passed.
wbkang added a commit to wbkang/ctags that referenced this issue May 31, 2017
armv7l (e.g., Raspberry Pi)

universal-ctags#1423

make units is passed.
@masatake
Copy link
Member

Thank you for reporting and fixing this.
I will add #1428 , too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants