appleseedlab / superc

The SuperC Parsing Framework
24 stars 4 forks source link

Preprocessor throws NullPtrException (replaceArgs() <- expandFunction() <- expandAndHoistFunction() ..) #153

Closed necipfazil closed 3 years ago

necipfazil commented 3 years ago

The following error can be reproduced on branch sourceline_pc commit fa9c15c201912e8b734b1ccb4167b21ceff84466.

# get specific linux commit for kernel/trace/bpf_trace.c
cd ~/
git clone https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/
cd linux-next/
git checkout 69c087ba6225

# build kernel/trace/bpf_trace.c
klocalizer -a x86_64 kernel/trace/bpf_trace.c
make olddefconfig && make clean kernel/trace/bpf_trace.o

# create superc config file
SUPERC_DIR = ~/xtc-dev/ # or wherever it is installed
mkdir superc-configs/
bash $SUPERC_DIR/scripts/superc_linux.sh -w -L superc-configs/ kernel/trace/bpf_trace.c

# clear autoconf.h
rm include/generated/autoconf.h
touch include/generated/autoconf.h

# run superc
$SUPERC_DIR/scripts/superc_linux.sh -S"-restrictConfigToPrefix CONFIG_  -sourcelinePC sourceline_pc.txt" -L superc-configs/ kernel/trace/bpf_trace.c > out.txt 2> err.txt

Content of out.txt:

Processing kernel/trace/bpf_trace.c

Content of err.txt:

error: header generated/autoksyms.h not found
warning: #warning inconsistent configuration , CONFIG_CPU_BIG_ENDIAN is set

error: header string.h not found
warning: #warning inconsistent configuration , CONFIG_CPU_BIG_ENDIAN is set

error: header string.h not found
EXPRESSION:1:25: error: ')' expected
( ( cpu_feature_enabled ( ( 16 * 32 + 16 ) ) ? 52 : 46 ) - 27 ) + 2 + CONFIG_NODES_SHIFT <= 64 - 23 
                        ^

EXPRESSION:1:25: error: ')' expected
( ( cpu_feature_enabled ( ( 16 * 32 + 16 ) ) ? 52 : 46 ) - 27 ) + 2 + 0 <= 64 - 23 
                        ^

EXPRESSION:1:25: error: ')' expected
( ( cpu_feature_enabled ( ( 16 * 32 + 16 ) ) ? 52 : 46 ) - 27 ) + 2 + CONFIG_NODES_SHIFT <= 32 - 23 
                        ^

EXPRESSION:1:25: error: ')' expected
( ( cpu_feature_enabled ( ( 16 * 32 + 16 ) ) ? 52 : 46 ) - 27 ) + 2 + 0 <= 32 - 23 
                        ^

error: #error "Vmemmap: No space for nodes field in page flags"

EXPRESSION:1:25: error: ')' expected
( ( cpu_feature_enabled ( ( 16 * 32 + 16 ) ) ? 52 : 46 ) - 27 ) + 2 + CONFIG_NODES_SHIFT + ( 8 + NR_CPUS_BITS ) + 8 <= 64 - 23 
                        ^

EXPRESSION:1:25: error: ')' expected
( ( cpu_feature_enabled ( ( 16 * 32 + 16 ) ) ? 52 : 46 ) - 27 ) + 2 + 0 + ( 8 + NR_CPUS_BITS ) + 8 <= 64 - 23 
                        ^

EXPRESSION:1:25: error: ')' expected
( ( cpu_feature_enabled ( ( 16 * 32 + 16 ) ) ? 52 : 46 ) - 27 ) + 2 + CONFIG_NODES_SHIFT + 0 + 8 <= 64 - 23 
                        ^

EXPRESSION:1:25: error: ')' expected
( ( cpu_feature_enabled ( ( 16 * 32 + 16 ) ) ? 52 : 46 ) - 27 ) + 2 + 0 + 0 + 8 <= 64 - 23 
                        ^

EXPRESSION:1:25: error: ')' expected
( ( cpu_feature_enabled ( ( 16 * 32 + 16 ) ) ? 52 : 46 ) - 27 ) + 2 + CONFIG_NODES_SHIFT + ( 8 + NR_CPUS_BITS ) + 0 <= 64 - 23 
                        ^

EXPRESSION:1:25: error: ')' expected
( ( cpu_feature_enabled ( ( 16 * 32 + 16 ) ) ? 52 : 46 ) - 27 ) + 2 + 0 + ( 8 + NR_CPUS_BITS ) + 0 <= 64 - 23 
                        ^

EXPRESSION:1:25: error: ')' expected
( ( cpu_feature_enabled ( ( 16 * 32 + 16 ) ) ? 52 : 46 ) - 27 ) + 2 + CONFIG_NODES_SHIFT + 0 + 0 <= 64 - 23 
                        ^

EXPRESSION:1:25: error: ')' expected
( ( cpu_feature_enabled ( ( 16 * 32 + 16 ) ) ? 52 : 46 ) - 27 ) + 2 + 0 + 0 + 0 <= 64 - 23 
                        ^

EXPRESSION:1:25: error: ')' expected
( ( cpu_feature_enabled ( ( 16 * 32 + 16 ) ) ? 52 : 46 ) - 27 ) + 2 + CONFIG_NODES_SHIFT + ( 8 + NR_CPUS_BITS ) + 8 <= 32 - 23 
                        ^

EXPRESSION:1:25: error: ')' expected
( ( cpu_feature_enabled ( ( 16 * 32 + 16 ) ) ? 52 : 46 ) - 27 ) + 2 + 0 + ( 8 + NR_CPUS_BITS ) + 8 <= 32 - 23 
                        ^

EXPRESSION:1:25: error: ')' expected
( ( cpu_feature_enabled ( ( 16 * 32 + 16 ) ) ? 52 : 46 ) - 27 ) + 2 + CONFIG_NODES_SHIFT + 0 + 8 <= 32 - 23 
                        ^

EXPRESSION:1:25: error: ')' expected
( ( cpu_feature_enabled ( ( 16 * 32 + 16 ) ) ? 52 : 46 ) - 27 ) + 2 + 0 + 0 + 8 <= 32 - 23 
                        ^

EXPRESSION:1:25: error: ')' expected
( ( cpu_feature_enabled ( ( 16 * 32 + 16 ) ) ? 52 : 46 ) - 27 ) + 2 + CONFIG_NODES_SHIFT + ( 8 + NR_CPUS_BITS ) + 0 <= 32 - 23 
                        ^

EXPRESSION:1:25: error: ')' expected
( ( cpu_feature_enabled ( ( 16 * 32 + 16 ) ) ? 52 : 46 ) - 27 ) + 2 + 0 + ( 8 + NR_CPUS_BITS ) + 0 <= 32 - 23 
                        ^

EXPRESSION:1:25: error: ')' expected
( ( cpu_feature_enabled ( ( 16 * 32 + 16 ) ) ? 52 : 46 ) - 27 ) + 2 + CONFIG_NODES_SHIFT + 0 + 0 <= 32 - 23 
                        ^

EXPRESSION:1:25: error: ')' expected
( ( cpu_feature_enabled ( ( 16 * 32 + 16 ) ) ? 52 : 46 ) - 27 ) + 2 + 0 + 0 + 0 <= 32 - 23 
                        ^

EXPRESSION:1:25: error: ')' expected
( ( cpu_feature_enabled ( ( 16 * 32 + 16 ) ) ? 52 : 46 ) - 27 ) + 0 + 2 + 0 + 8 > 64 - 23 
                        ^

EXPRESSION:1:25: error: ')' expected
( ( cpu_feature_enabled ( ( 16 * 32 + 16 ) ) ? 52 : 46 ) - 27 ) + 0 + 2 + 0 + 0 > 64 - 23 
                        ^

EXPRESSION:1:25: error: ')' expected
( ( cpu_feature_enabled ( ( 16 * 32 + 16 ) ) ? 52 : 46 ) - 27 ) + 0 + 2 + 0 + 8 > 32 - 23 
                        ^

EXPRESSION:1:25: error: ')' expected
( ( cpu_feature_enabled ( ( 16 * 32 + 16 ) ) ? 52 : 46 ) - 27 ) + 0 + 2 + 0 + 0 > 32 - 23 
                        ^

error: #error "Not enough bits in page flags"

error: #error "Unknown RCU implementation specified to kernel configuration"

error: #error "include/generated/timeconst.h has the wrong HZ value!"

error: #error Invalid value of HZ .

error: #error "CONFIG_RCU_FANOUT insufficient for NR_CPUS"

error: #error "Unknown SRCU implementation specified to kernel configuration"

error: #error "include/generated/timeconst.h has the wrong HZ value!"

error: #error Invalid value of HZ .

error: #error "CONFIG_RCU_FANOUT insufficient for NR_CPUS"

error: #error "Unknown SRCU implementation specified to kernel configuration"

error: #error Allocator MAX_ORDER exceeds SECTION_SIZE

error: header unistd.h not found
error: #error CONFIG_PGTABLE_LEVELS is not consistent with __PAGETABLE_ { P4D , PUD , PMD } _FOLDED

error: #error Missing MAX_POSSIBLE_PHYSMEM_BITS definition

error: header unistd.h not found
error: header asm/membarrier.h not found
error: header sys/socket.h not found
error: header asm/hash.h not found
error: header asm/vtime.h not found
error: header asm/bitrev.h not found
error: #error Compiler does not support fentry ?

error: #error tlb_needs_table_invalidate ( ) requires MMU_GATHER_RCU_TABLE_FREE

error: #error MMU_GATHER_NO_RANGE relies on default tlb_flush ( ) , tlb_start_vma ( ) and tlb_end_vma ( )

java.lang.NullPointerException
    at superc.core.Preprocessor.replaceArgs(Preprocessor.java:4110)
    at superc.core.Preprocessor.expandFunction(Preprocessor.java:3028)
    at superc.core.Preprocessor.expandAndHoistFunction(Preprocessor.java:3266)
    at superc.core.Preprocessor.processToken(Preprocessor.java:2410)
    at superc.core.Preprocessor.__next(Preprocessor.java:409)
    at superc.core.Preprocessor.next(Preprocessor.java:371)
    at superc.SuperC$ConditionalBlock.readConditionalBlockGroups(SuperC.java:312)
    at superc.SuperC$ConditionalBlock.getConditionalBlockGroups(SuperC.java:176)
    at superc.SuperC.parse(SuperC.java:935)
    at xtc.util.Tool.run(Tool.java:502)
    at superc.SuperC.main(SuperC.java:2004)
1 error