Sparse infinite loop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
I have been experiencing a situation in which the free use of global
variables has noticeably hindered my experience with Sparse.

The main issue that I wanted to report is that there is no easy way to
"clean up '' sparse in execution, leading to unexpected behaviour if
Sparse is being run multiple times in a row.

Say for instance that I am running automated tests in a given project
that uses Sparse. Each test will call sparse_initialize() in the start
up, making Sparse fill the hash_table "global" variable with the
different identifiers. But I do not have a possibility to clean up
Sparse in the teardown of the tests. While running sparse in the first
run, hash_table is an array of null pointers ( static struct ident
*hash_table[IDENT_HASH_SIZE]; ) so everything will work as expected.
However, if we run Sparse a second time, hash_table will no longer be
an empty array, instead will contain the artifacts of the first run.
This is an issue, since several functions within tokenize.c use
hash_table to check the existence of an identifier in the hash, and
assign it to the "next" ident, opening the door to a cyclic linked
list: ident = ident->next, thus falling in an infinite loop.

The issue can be reproduce just by running:

int main(int argc, char **argv)
{
    struct string_list *filelist = NULL;
    sparse_initialize(argc, argv, &filelist); // (1)
    sparse_initialize(argc, argv, &filelist); // (2)
    return 0;
}

this will never terminate as sparse_initialize (2) will most likely
fall in an infinite loop at some point inside create_hashed_ident.

A possible solution would be to add a "clean_up" function in
tokenize.c to reset the hash_table to null pointers which should be
called in between steps (1) and (2).
It would also make sense to add a security check in insert_hash, to
protect ident->next = ident.



Maybe I am missing something, but I've been stuck here for a while (bad joke).
I look forward to your reply,
best regards,

Vallés Puig, Ramon




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux