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

[c] Lexical header in C-header file from Linux #4217

Open
stevenKlusener opened this issue Nov 17, 2022 · 0 comments
Open

[c] Lexical header in C-header file from Linux #4217

stevenKlusener opened this issue Nov 17, 2022 · 0 comments
Labels
a:bug PMD crashes or fails to analyse a file. needs:pmd7-revalidation The issue hasn't yet been retested vs PMD 7 and may be stale

Comments

@stevenKlusener
Copy link

stevenKlusener commented Nov 17, 2022

Language: C
PMD Version: 6.51.0

Description:

When running CPD (with --language c) PMD raises a lexical error.

The input file can be retrieved from:
https://github.com/torvalds/linux/blob/master/arch/arc/include/asm/entry-arcv2.h

Exception Stacktrace:

net.sourceforge.pmd.lang.ast.TokenMgrError: Lexical error in file .../linux/arch/arc/include/asm/entry-arcv2.h at line 184, column 37.  Encountered: Lexical error at line 184, column 37.  Encountered: "\n" (10), after : "\'t really matter" (in lexical state 0)
	at net.sourceforge.pmd.lang.ast.TokenMgrError.withFileName(TokenMgrError.java:124)
	at net.sourceforge.pmd.cpd.internal.JavaCCTokenizer.tokenize(JavaCCTokenizer.java:44)
	at net.sourceforge.pmd.cpd.CPD.addAndThrowLexicalError(CPD.java:154)
	at net.sourceforge.pmd.cpd.CPD.add(CPD.java:148)
	at net.sourceforge.pmd.cpd.CPD.add(CPD.java:117)
	at net.sourceforge.pmd.cpd.CPD.add(CPD.java:79)
	at net.sourceforge.pmd.cpd.CPD.addDirectory(CPD.java:90)
	at net.sourceforge.pmd.cpd.CPD.addRecursively(CPD.java:74)
	at net.sourceforge.pmd.cpd.CPDCommandLineInterface.addSourcesFilesToCPD(CPDCommandLineInterface.java:162)
	at net.sourceforge.pmd.cpd.CPDCommandLineInterface.addSourceFilesToCPD(CPDCommandLineInterface.java:142)
	at net.sourceforge.pmd.cpd.CPD.runCpd(CPD.java:225)
	at net.sourceforge.pmd.cpd.CPD.main(CPD.java:196)

Problem:

The tokenizer fails on the single quote in the following fragment (see doesn't really matter):

.macro __RESTORE_REGFILE_SOFT

	LD2	gp, fp, PT_r26		; gp (r26), fp (r27)

	ld	r12, [sp, PT_r12]
	ld	r30, [sp, PT_r30]

	; Restore SP (into AUX_USER_SP) only if returning to U mode
	;  - for K mode, it will be implicitly restored as stack is unwound
	;  - Z flag set on K is inverse of what hardware does on interrupt entry
	;    but that doesn't really matter
	bz	1f
	ld	r10, [sp, PT_sp]	; SP (pt_regs->sp)
	sr	r10, [AUX_USER_SP]
1:

Steps to reproduce:

  1. Clone the repo 'https://github.com/torvalds/linux/' to your machine, say into ~/tmp/linux
  2. Run CPD from the command line: .../pmd-bin-6.51.0/bin/run.sh cpd --minimum-tokens 100 --files ~/tmp/linux --language c
@stevenKlusener stevenKlusener added the a:bug PMD crashes or fails to analyse a file. label Nov 17, 2022
@adangel adangel changed the title Lexical header in C-header file from Linux [c] Lexical header in C-header file from Linux Nov 18, 2022
@jsotuyod jsotuyod added the needs:pmd7-revalidation The issue hasn't yet been retested vs PMD 7 and may be stale label Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug PMD crashes or fails to analyse a file. needs:pmd7-revalidation The issue hasn't yet been retested vs PMD 7 and may be stale
Projects
None yet
Development

No branches or pull requests

2 participants