From d3156bf6fb7b4bd1e70dfff438b494cc0f978136 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 11 Jun 2024 17:35:33 +0300 Subject: [PATCH] db: don't load silly amounts of caller info The issue here was is_inode_flag_set(). We say functions which are called over 200 times as too common. Don't save anything about them. But is_inode_flag_set() was called 166 times. Apparently, there is no limit to the amount of caller info per call which gets saved in the database. This is hard to limit in a sensible ways as well. So is_inode_flag_set() was loading 28k entries of caller_info. Which is too much. Cap it at 5000. (This number is picked by guessing what an appropriate number is). Signed-off-by: Dan Carpenter --- smatch_db.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/smatch_db.c b/smatch_db.c index ef5146ab..ec37ee16 100644 --- a/smatch_db.c +++ b/smatch_db.c @@ -722,6 +722,18 @@ struct select_caller_info_data { static int caller_info_callback(void *_data, int argc, char **argv, char **azColName); +static bool too_much_caller_info_data(struct symbol *sym) +{ + int count = 0; + + run_sql(get_row_count, &count, + "select count(*) from caller_info where %s;", + get_static_filter(sym)); + if (count > 5000) + return true; + return false; +} + static void sql_select_caller_info(struct select_caller_info_data *data, const char *cols, struct symbol *sym) { @@ -740,6 +752,9 @@ static void sql_select_caller_info(struct select_caller_info_data *data, if (data->results) return; + if (too_much_caller_info_data(sym)) + return; + run_sql(caller_info_callback, data, "select %s from caller_info where %s order by call_id;", cols, get_static_filter(sym)); -- 2.11.4.GIT