Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build errors on 32-bit architectures [-Werror=format=] #501

Open
vt-alt opened this issue Sep 22, 2023 · 2 comments
Open

Build errors on 32-bit architectures [-Werror=format=] #501

vt-alt opened this issue Sep 22, 2023 · 2 comments

Comments

@vt-alt
Copy link

vt-alt commented Sep 22, 2023

For 2.6 there are build errors on x86 (i586) and arm32 (armv7hf):

fuzz.c:258:30: error: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
fuzz.c:258:35: error: format '%lu' expects argument of type 'long unsigned int', but argument 6 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
fuzz.c:258:17: error: format '%llu' expects argument of type 'long long unsigned int', but argument 7 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
fuzz.c:258:17: error: format '%llu' expects argument of type 'long long unsigned int', but argument 8 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
fuzz.c:258:17: error: format '%llu' expects argument of type 'long long unsigned int', but argument 9 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
input.c:663:15: error: format '%lu' expects argument of type 'long unsigned int', but argument 7 has type 'size_t' {aka 'unsigned in '} [-Werror=format=]

Perhaps %zu should be used? Or you should not have used size_t for counters in the first place, as size_t is intended for maximum object (array) sizes (i.e. maximum sizeof value), and obviously this on 32-platforms is 32-bit number.

@vt-alt
Copy link
Author

vt-alt commented Sep 23, 2023

Possible solution:

diff --git a/fuzz.c b/fuzz.c
index 398cae34..0e6919f9 100644
--- a/fuzz.c
+++ b/fuzz.c
@@ -255,8 +255,7 @@ static void fuzz_perfFeedback(run_t* run) {
             size_t tot_exec_per_sec = elapsed_sec ? (curr_exec_cnt / elapsed_sec) : 0;

             dprintf(run->global->io.statsFileFd,
-                "%lu, %lu, %lu, %lu, "
-                "%" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 "\n",
+                "%lu, %lu, %zu, %zu, %zu, %zu, %zu, %ju, %ju\n",
                 curr_sec,                                 /* unix_time */
                 run->global->timing.lastCovUpdate,        /* last_cov_update */
                 curr_exec_cnt,                            /* total_exec */
diff --git a/input.c b/input.c
index a03b6674..e056d3a5 100644
--- a/input.c
+++ b/input.c
@@ -660,7 +660,7 @@ void input_enqueueDynamicInputs(honggfuzz_t* hfuzz) {
             continue;
         }

-        LOG_I("Loading dynamic input file: %s (%lu)", dynamicInputFileName, dynamicFileSz);
+        LOG_I("Loading dynamic input file: %s (%zu)", dynamicInputFileName, dynamicFileSz);

         run_t tmp_run;
         tmp_run.global        = hfuzz;

@robertswiecki
Copy link
Collaborator

Looks good, would it be possible to send a PR with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants