Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752279AbbHTMyb (ORCPT ); Thu, 20 Aug 2015 08:54:31 -0400 Received: from mx2.suse.de ([195.135.220.15]:37515 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751042AbbHTMya (ORCPT ); Thu, 20 Aug 2015 08:54:30 -0400 Subject: Re: [PATCH] genksyms: Duplicate function pointer type definitions segfault To: Richard Yao , linux-kernel@vger.kernel.org References: <1437436369-46257-1-git-send-email-ryao@gentoo.org> Cc: Richard Yao , Madhuri Yechuri From: Michal Marek Message-ID: <55D5CE04.2050705@suse.cz> Date: Thu, 20 Aug 2015 14:54:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1437436369-46257-1-git-send-email-ryao@gentoo.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1978 Lines: 43 On 2015-07-21 01:52, Richard Yao wrote: > From: Richard Yao > > I noticed that genksyms will segfault when it sees duplicate function > pointer type declaration when I placed the same function pointer > definition in two separate headers in a local branch as an intermediate > step of some refactoring. This can be reproduced by piping the following > minimal test case into `genksyms -r /dev/null` or alternatively, putting > it into a C file attempting a build: > > int (*f)(); > int (*f)(); > > Attaching gdb to genksyms to understand this failure is useless without > changing CFLAGS to emit debuginfo. Once you have debuginfo, you will > find that the failure is that `char *s` was NULL and the program > executed `while(*s)`. At which point, further debugging requires > familiarity with compiler front end / parser development. > > What happens is that flex identifies the first instance of the token "f" > as IDENT and the yacc parser adds it to the symbol table. On the second > instance, flex will identify "f" as TYPE, which triggers an error case > in the yacc parser. Given that TYPE would have been IDENT had it not > been in the symbol table, the the segmentaion fault could be avoided by > treating TYPE as IDENT in the affected rule. > > Some might consider placing identical function pointer type declarations > in different headers to be poor style might consider a failure to be > beneficial. However, failing through a segmentation fault makes the > cause non-obvious and can waste the time of anyone who encounters it. > > Signed-off-by: Richard Yao > Acked-by: Madhuri Yechuri Applied to kbuild.git#kbuild. Michal -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/