weggli-rs / weggli

weggli is a fast and robust semantic search tool for C and C++ codebases. It is designed to help security researchers identify interesting functionality in large codebases.
Apache License 2.0
2.34k stars 130 forks source link

my weggli got hang while parsing a simple c source code. #84

Open 0xLucifer opened 1 year ago

0xLucifer commented 1 year ago

I install weggli use this command : cargo install weggli and finally i can run weggli success.

this is the simple c code which i want to analyse with weggli

include

include

int main() { char array_1[16]; char array_2[16]; memcpy(array_1,array_2,16); printf("Hello World!\n"); return 0; }

and when I ran this command: $ strace weggli '{printf(_);}' ./weggli.test.code -vvvvv

the strace command output last 10 lines here:

mmap(NULL, 2101248, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7fb564dff000

mprotect(0x7fb564e00000, 2097152, PROT_READ|PROT_WRITE) = 0

rt_sigprocmask(SIG_BLOCK, ~[], [], 8) = 0

clone3({flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, child_tid=0x7fb564fff910, parent_tid=0x7fb564fff910, exit_signal=0, stack=0x7fb564dff000, stack_size=0x1ffd80, tls=0x7fb564fff640} => {parent_tid=[11021]}, 88) = 11021

rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0

futex(0x7fb56565e834, FUTEX_WAIT_BITSET_PRIVATE, 0, NULL, FUTEX_BITSET_MATCH_ANY^C) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)

you can see it's stuck on the futex function.

when i run command : weggli '{printf(_);}' ./weggli.test.code -vvvvv

it's stuck here:

04:46:21 [INFO] query sexp: (translation_unit (compound_statement (expression_statement (call_expression function: (identifier) arguments: (argument_list (identifier)))))) 04:46:21 [DEBUG] (1) weggli::builder: query needs anchor: true 04:46:21 [DEBUG] (1) weggli::builder: generated query: (argumentlist () 04:46:21 [DEBUG] (1) weggli::builder: tree_sitter query 1: ((call_expression function: [(field_expression field: (field_identifier)@0)(identifier) @0] arguments: (argumentlist ())) (#eq? @0 "printf")) 04:46:21 [DEBUG] (1) weggli::builder: tree_sitter query 0: (function_definition body: (compound_statement) @0) @1 04:46:21 [INFO] parsing 1 files

please help. thanks.