google / packetdrill

The official Google release of packetdrill
GNU General Public License v2.0
882 stars 221 forks source link

Compilation failure on i386 #38

Open PinoTsao opened 4 years ago

PinoTsao commented 4 years ago

make in gtests/net/packetdrill complains:

run_system_call.c: In function ‘cmsg_expect_eq’: run_system_call.c:860:38: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘size_t’ {aka ‘unsigned int’} [-Werror=format=] "Bad len in cmsg %d: expected=%lu actual=%lu", ~~^ %u i, ecm->cmsg_len, acm->cmsg_len);

run_system_call.c:860:49: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 5 has type ‘size_t’ {aka ‘unsigned int’} [-Werror=format=]
      "Bad len in cmsg %d: expected=%lu actual=%lu",
                                               ~~^
                                               %u
      i, ecm->cmsg_len, acm->cmsg_len);

run_system_call.c: In function ‘get_epoll_event_from_expr’: run_system_call.c:2924:21: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] event->data.ptr = (void *)epollev_expr->ptr->value.num; ^ run_system_call.c: In function ‘syscall_epoll_wait’: run_system_call.c:3129:6: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=] "epoll_event->data does not match script: " ^~~~~~~~~~~ run_system_call.c:3132:6: event_script.data.u64,

run_system_call.c:3130:19: note: format string is defined here
      "expected: %lu "
                 ~~^
                 %llu
run_system_call.c:3129:6: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
      "epoll_event->data does not match script: "
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
run_system_call.c:3133:6:
      event_live->data.u64);

run_system_call.c:3131:17: note: format string is defined here "actual: %lu\n", ~~^ %llu run_system_call.c: In function ‘syscall_splice’: run_system_call.c:3249:31: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] result = splice(fd_in_live, (loff_t ) off_in, fd_out_live, ^ run_system_call.c:3250:5: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] (loff_t ) off_out, len, flags); ^ cc1: all warnings being treated as errors make: *** [: run_system_call.o] Error 1

nealcardwell commented 4 years ago

Thanks for the report. Can you please provide some more information, so that we can reproduce this issue and verify the fix?

What OS platform, distribution/release, and compiler version is this?

The platform should be accessible with: uname -r

The distribution version you can often get with something like: lsb_release -d or: hostnamectl

The compiler version should be accessible with something like: gcc --version

For example:

Linux, Debian 9, compiler version: $ gcc --version => gcc (Debian 9.2.1-28) 9.2.1 20200203

Thanks!

PinoTsao commented 4 years ago

$ hostnamectl Static hostname: DB10VMi386 Icon name: computer-vm Chassis: vm Machine ID: 889ae9bf38344d3aa6f8359510337dfc Boot ID: 229926988b2f4930b872c1e132422d17 Virtualization: kvm Operating System: Debian GNU/Linux 10 (buster) Kernel: Linux 4.19.0-8-686 Architecture: x86

$ gcc --version gcc (Debian 8.3.0-6) 8.3.0

nealcardwell commented 4 years ago

Hi,

When I use that compiler on Debian 10 to compile the Google packetdrill repo at https://github.com/google/packetdrill at SHA1 a700d17e00b5fc29a0e7ca07ddf1889f0b8c8ff4 I do not see any warnings or errors.

Can you please provide the URL of the packetdrill repo you are using, as well as the SHA1 of the exact commit at which you are compiling?

I will only be able to help if you are using the repo at https://github.com/google/packetdrill at the HEAD for that repo (SHA1 a700d17e00b5fc29a0e7ca07ddf1889f0b8c8ff4). If you are using some other packetdrill fork then you'll need to contact the author of that fork.

Thanks! neal

PinoTsao commented 4 years ago

Hi Neal,

Do you test on i386 Debian 10? I think this issue should be exist in every i386 platform. BTW, I do use the same repo and commit as you mentioned.

PinoTsao commented 4 years ago

some errors are easy for outsider, such as paring "%zu" to size_t variable, like:

run_system_call.c: In function ‘cmsg_expect_eq’:
run_system_call.c:860:38: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘size_t {aka unsigned int}’ [-Werror=format=]
      "Bad len in cmsg %d: expected=%lu actual=%lu",

But,this one:

run_system_call.c: In function ‘get_epoll_event_from_expr’:
run_system_call.c:2924:21: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
   event->data.ptr = (void *)epollev_expr->ptr->value.num;

epollev_expr->ptr->value.num is of type s64, convert to 32-bit pointer make gcc complains, and this is not easy for outsiders