Greetings, while regression-testing tcc against a system profile of ~500 ebuilds a potential endless-loop condition was spotted (during one of hundreds of configure checks): - if a library linking option is passed such as -lz - and this library libz.so isn't present in the library search path (i am supporting static linking against libz.a currently) - then tcc option parser got stuck in an endless loop and tcc binary didn't terminate then
The problem got introduced with the following commit February 2024: 42395a19128b7db756721a55e4630ece82cb315b It may not be trivial to re-produce the error-condition, and it is rarely hit, but I could reliably confirm reverting the change made to tcc.c resolved the issue under mentioned circuumstances. The required revert/patch is attached. As a side note, i am not sure if each individual regression that i could reveal with extensive testing if those should be posted to the mailing list (see https://lists.gnu.org/archive/html/tinycc-devel/2024-11/msg00016.html). Temporarily i joined #tcc channel at OFTC, but it seems completely abandoned. Please let me know how efforts could best be coordinated to produce the least amount of noise possible. Regards. aggi --
diff --git a/tcc.c b/tcc.c index 838f41d9..240073fa 100644 --- a/tcc.c +++ b/tcc.c @@ -358,18 +358,20 @@ redo: } /* compile or add each files or library */ - first_file = NULL; + first_file = NULL, ret = 0; do { struct filespec *f = s->files[n]; s->filetype = f->type; if (f->type & AFF_TYPE_LIB) { - ret = tcc_add_library_err(s, f->name); + if (tcc_add_library_err(s, f->name) < 0) + ret = 1; } else { if (1 == s->verbose) printf("-> %s\n", f->name); if (!first_file) first_file = f->name; - ret = tcc_add_file(s, f->name); + if (tcc_add_file(s, f->name) < 0) + ret = 1; } done = ret || ++n >= s->nb_files; } while (!done && (s->output_type != TCC_OUTPUT_OBJ || s->option_r)); @@ -390,24 +392,21 @@ redo: if (!s->outfile) s->outfile = default_outputfile(s, first_file); if (!s->just_deps && tcc_output_file(s, s->outfile)) - ; + ret = 1; else if (s->gen_deps) - gen_makedeps(s, s->outfile, s->deps_outfile); + ret = gen_makedeps(s, s->outfile, s->deps_outfile); } } - done = 1; - if (t) - done = 0; /* run more tests with -dt -run */ - else if (s->nb_errors) - ret = 1; - else if (n < s->nb_files) - done = 0; /* compile more files with -c */ - else if (s->do_bench) + if (done && 0 == t && 0 == ret && s->do_bench) tcc_print_stats(s, end_time - start_time); + tcc_delete(s); if (!done) - goto redo; + goto redo; /* compile more files with -c */ + if (t) + goto redo; /* run more tests with -dt -run */ + if (ppfp && ppfp != stdout) fclose(ppfp); return ret;
signature.asc
Description: Digital signature
_______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel