MoarVM / MoarVM

A VM with adaptive optimization and JIT compilation, built for Rakudo
https://moarvm.org/
Other
697 stars 172 forks source link

build on x32 has "pointer cast size mismatch" #444

Closed dod38fr closed 5 years ago

dod38fr commented 7 years ago

Hello

x32 build log of Debian moarvm build show some pointer-cast-size-mismatch warnings. This may hint at bugs in some corner case.

Can you fix this ?

All the best

samcv commented 5 years ago

Closing this since i'm assuming it's been fixed. Please reopen if this is actually still an issue.

dod38fr commented 5 years ago

@samcv Build logs shows that this issue still occurs on armel, armhf, i386, kfreebsd-i386, mips, mipsel, powerpc architectures.

E.g. on armhf:

gcc -c -Werror=declaration-after-statement -Werror=pointer-arith -O3 -DNDEBUG -g3  -D_REENTRANT -D_FILE_OFFSET_BITS=64 -DHAVE_LIBFFI -fPIC -DDEBUG_HELPERS -g -O2 -fdebug-prefix-map=/<<BUILDDIR>>/moarvm-2018.09+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -DMVM_TRACING=0 -DMVM_CGOTO=1 -DMVM_RDTSCP=0 -DMVM_BUILD_SHARED -fPIC -I3rdparty/sha1 -I3rdparty/tinymt -I3rdparty/dynasm -I3rdparty/cmp -I3rdparty -Isrc -o src/core/exceptions.o src/core/exceptions.c
src/core/exceptions.c: In function 'handler_can_handle':
src/core/exceptions.c:85:57: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     MVMuint64           block_label = block_has_label ? (MVMuint64)(f->work[fh->label_reg].o) : 0;
                                                         ^
src/core/exceptions.c:86:49: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     MVMuint64          thrown_label = payload ? (MVMuint64)payload : 0;
                                                 ^
gcc -c -Werror=declaration-after-statement -Werror=pointer-arith -O3 -DNDEBUG -g3  -D_REENTRANT -D_FILE_OFFSET_BITS=64 -DHAVE_LIBFFI -fPIC -DDEBUG_HELPERS -g -O2 -fdebug-prefix-map=/<<BUILDDIR>>/moarvm-2018.09+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -DMVM_TRACING=0 -DMVM_CGOTO=1 -DMVM_RDTSCP=0 -DMVM_BUILD_SHARED -fPIC -I3rdparty/sha1 -I3rdparty/tinymt -I3rdparty/dynasm -I3rdparty/cmp -I3rdparty -Isrc -o src/core/interp.o src/core/interp.c
src/core/interp.c: In function 'MVM_interp_run':
src/core/interp.c:1906:42: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
                 GET_REG(cur_op, 0).i64 = (MVMint64)GET_REG(cur_op, 2).o;
                                          ^
src/core/interp.c:6022:39: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
                 char      *cache    = (char *)MVM_BC_get_I64(cur_op, 12);
                                       ^
samcv commented 5 years ago

Ok thanks. I'm going to reopen this.

samcv commented 5 years ago

@dod38fr looks like github closed automatically.. Regardless it is hopefully fixed with https://github.com/MoarVM/MoarVM/commit/6ff60a3bc2a296bff664866da9bd6240c66cb8f5

Let me know if it isn't.

dod38fr commented 5 years ago

@samcv the issue was automatically closed by GitHub because the commit message of 6ff60a3 contain "resolve #". See https://help.github.com/articles/closing-issues-using-keywords/ for other ways to resolve an issue with a commit message.

The warnings mentioned in this bug are gone. However, build log of 2018.11 on x32 has other similar warnings:

gcc -c -Werror=declaration-after-statement -Werror=pointer-arith -O3 -DNDEBUG -g3  -D_REENTRANT -D_FILE_OFFSET_BITS=64 -DHAVE_LIBFFI -fPIC -DDEBUG_HELPERS -g -O2 -fdebug-prefix-map=/<<BUILDDIR>>/moarvm-2018.11+dfsg=. -specs=/usr/share/dpkg/pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -DMVM_TRACING=0 -DMVM_CGOTO=1 -DMVM_RDTSCP=1 -DMVM_BUILD_SHARED -fPIC -I/usr/local/include -I3rdparty/sha1 -I3rdparty/tinymt -I3rdparty/dynasm -I3rdparty/cmp -I3rdparty -Isrc -o src/core/nativecall_libffi.o src/core/nativecall_libffi.c
In file included from src/moar.h:140,
                 from src/core/nativecall_libffi.c:1:
src/core/nativecall_libffi.c: In function 'MVM_nativecall_invoke':
src/core/nativecall_libffi.c:474:41: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
         result = make_fun(tc, res_type, (c_type)ret); \
                                         ^
src/gc/roots.h:76:5: note: in definition of macro 'MVMROOT2'
     block \
     ^~~~~
src/core/nativecall_libffi.c:674:21: note: in expansion of macro 'handle_ret'
                     handle_ret(tc, void *, ffi_arg, MVM_nativecall_make_cstruct);
                     ^~~~~~~~~~
src/core/nativecall_libffi.c:474:41: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
         result = make_fun(tc, res_type, (c_type)ret); \
                                         ^
src/gc/roots.h:76:5: note: in definition of macro 'MVMROOT2'
     block \
     ^~~~~
src/core/nativecall_libffi.c:677:21: note: in expansion of macro 'handle_ret'
                     handle_ret(tc, void *, ffi_arg, MVM_nativecall_make_cppstruct);
                     ^~~~~~~~~~
src/core/nativecall_libffi.c:474:41: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
         result = make_fun(tc, res_type, (c_type)ret); \
                                         ^
src/gc/roots.h:76:5: note: in definition of macro 'MVMROOT2'
     block \
     ^~~~~
src/core/nativecall_libffi.c:680:21: note: in expansion of macro 'handle_ret'
                     handle_ret(tc, void *, ffi_arg, MVM_nativecall_make_cpointer);
                     ^~~~~~~~~~
src/core/nativecall_libffi.c:474:41: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
         result = make_fun(tc, res_type, (c_type)ret); \
                                         ^
src/gc/roots.h:76:5: note: in definition of macro 'MVMROOT2'
     block \
     ^~~~~
src/core/nativecall_libffi.c:683:21: note: in expansion of macro 'handle_ret'
                     handle_ret(tc, void *, ffi_arg, MVM_nativecall_make_carray);
                     ^~~~~~~~~~
src/core/nativecall_libffi.c:474:41: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
         result = make_fun(tc, res_type, (c_type)ret); \
                                         ^
src/gc/roots.h:76:5: note: in definition of macro 'MVMROOT2'
     block \
     ^~~~~
src/core/nativecall_libffi.c:686:21: note: in expansion of macro 'handle_ret'
                     handle_ret(tc, void *, ffi_arg, MVM_nativecall_make_cunion);
                     ^~~~~~~~~~
[snip]
gcc -c -Werror=declaration-after-statement -Werror=pointer-arith -O3 -DNDEBUG -g3  -D_REENTRANT -D_FILE_OFFSET_BITS=64 -DHAVE_LIBFFI -fPIC -DDEBUG_HELPERS -g -O2 -fdebug-prefix-map=/<<BUILDDIR>>/moarvm-2018.11+dfsg=. -specs=/usr/share/dpkg/pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -DMVM_TRACING=0 -DMVM_CGOTO=1 -DMVM_RDTSCP=1 -DMVM_BUILD_SHARED -fPIC -I/usr/local/include -I3rdparty/sha1 -I3rdparty/tinymt -I3rdparty/dynasm -I3rdparty/cmp -I3rdparty -Isrc -o src/6model/reprs/VMArray.o src/6model/reprs/VMArray.c
src/6model/reprs/VMArray.c: In function 'read_buf':
src/6model/reprs/VMArray.c:900:82: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'MVMint64' {aka 'long long int'} [-Wformat=]
         MVM_exception_throw_adhoc(tc, "MVMArray: read_buf out of bounds offset %ld start %ld elems %lu count %lu", offset, start, body->elems, count);
                                                                                ~~^                                 ~~~~~~
                                                                                %lld
src/6model/reprs/VMArray.c:900:92: warning: format '%ld' expects argument of type 'long int', but argument 4 has type 'MVMint64' {aka 'long long int'} [-Wformat=]
         MVM_exception_throw_adhoc(tc, "MVMArray: read_buf out of bounds offset %ld start %ld elems %lu count %lu", offset, start, body->elems, count);
                                                                                          ~~^                               ~~~~~
                                                                                          %lld
src/6model/reprs/VMArray.c:900:102: warning: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'MVMuint64' {aka 'long long unsigned int'} [-Wformat=]
         MVM_exception_throw_adhoc(tc, "MVMArray: read_buf out of bounds offset %ld start %ld elems %lu count %lu", offset, start, body->elems, count);
                                                                                                    ~~^                            ~~~~~~~~~~~
                                                                                                    %llu
src/6model/reprs/VMArray.c:900:112: warning: format '%lu' expects argument of type 'long unsigned int', but argument 6 has type 'MVMuint64' {aka 'long long unsigned int'} [-Wformat=]
         MVM_exception_throw_adhoc(tc, "MVMArray: read_buf out of bounds offset %ld start %ld elems %lu count %lu", offset, start, body->elems, count);
                                                                                                              ~~^                               ~~~~~
                                                                                                              %llu

and fails with:

src/math/bigintops.c: In function 'MVM_bigint_rand':
src/math/bigintops.c:1166:13: error: 'MP_GEN_RANDOM_MAX' undeclared (first use in this function); did you mean 'MP_GEN_RANDOM'?
         if (MP_GEN_RANDOM_MAX >= abs(smallint_max)) {
             ^~~~~~~~~~~~~~~~~
             MP_GEN_RANDOM
src/math/bigintops.c:1166:13: note: each undeclared identifier is reported only once for each function it appears in

On the other hand, the build failure may be due to the fact that Debian compile moar with the last released version of libtommath, not from a later git commit as done by moar. I've asked libtommath for a new release

All the best

cc @robertlemmen