From c140103a707dc5a68175cf2591120c603c6db28c Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 12 Jun 2023 15:49:56 +0300 Subject: [PATCH] db/fill_db_caller_info.pl: fix "too common function" code The code here is supposed to record when a function is too common to the point where it's not useful to record all the caller data. For example, trying to make sense out of all the places which call kmalloc() would does not scale. Unfortunately this code was broken when I converted smatch to use hashes of the file names instead of actual filenames so it no longer recorded any functions as being too common. What that ended up doing is that when we were parsing the caller_data we would quickly run out of resources. Then we would fake a "I don't know anything" return. This code has been broken for a while. How I noticed the bug is that mutex_lock() is a sleeping function but the SLEEP wasn't being recorded in the database so it was not warning about functions that sleep while holding a spinlock. Update the sample output to show how hashed filenames look like as well. Signed-off-by: Dan Carpenter --- smatch_data/db/fill_db_caller_info.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/smatch_data/db/fill_db_caller_info.pl b/smatch_data/db/fill_db_caller_info.pl index a363d4ff..e29f4abd 100755 --- a/smatch_data/db/fill_db_caller_info.pl +++ b/smatch_data/db/fill_db_caller_info.pl @@ -17,7 +17,7 @@ sub get_too_common_functions($$$) my $project = shift; my $warns = shift; - open(FUNCS, "grep 'SQL_caller_info: ' $warns | grep '%call_marker%' | cut -d \"'\" -f 6 | sort | uniq -c | "); + open(FUNCS, "grep 'SQL_caller_info: ' $warns | grep '%call_marker%' | cut -d \"'\" -f 4 | sort | uniq -c | "); while () { if ($_ =~ /(\d+) (.*)/) { @@ -68,7 +68,7 @@ my ($fn, $dummy, $sql); open(WARNS, "<$warns"); while () { - # test.c:11 frob() SQL_caller_info: insert into caller_info values ('test.c', 'frob', '__smatch_buf_size', %CALL_ID%, 1, 0, -1, '', '); + # net/mac80211/util.c:1857 ieee80211_send_auth() SQL_caller_info: insert into caller_info values (0x1e4debd9f09b1007, 'ieee80211_send_auth', 'fortify_memcpy_chk', %CALL_ID%, 0, 0, -1, '%call_marker%', 'bool(*)(ulong, ulong, ulong, ulong, ulong, char*)'); if (!($_ =~ /^.*? \w+\(\) SQL_caller_info: /)) { next; -- 2.11.4.GIT