gcc - using memcpy for 64bit linux zeroes out the content -
i stuck unusual issue. have exe created using gyp project , common.gypi supported build exe both 32 , 64 bit linux. however, when build 64 bit linux , memcpy invoked @ point within code, content gets zeroed out. building 32 bit platform using -m32 flag not cause problem. uncertainty there might issue headers since header files project mutual both 32bit , 64bit platform. can please provide pointers how tackle issue? binary dynamically linked , uses glibc lgcc, lc , lm. pointers in area appreciated. happy provide additional info required. thanks.
update : little bit of code snippet: basic snippet of code:
dst->flags = src->flags; src->b = dst->b; , few more assignments memcpy(dst, src, size here 152); size of dst 224 , size of src 496.
the problem value of flags copied dst becomes 0 after memcpy invoked. same logic when built 32bit works fine.
read documentation of memcpy(3). source , destination areas not allowed overlap (otherwise undefined behavior). don't forget enable warnings , debug info while compiling (gcc -wall -wextra -g
)
you might want utilize memmove(3) instead.
to debug such issues, set watchpoint watch
command in gdb
debugger, , recent gcc utilize -fsanitize=address
compilation flag. or valgrind, etc...
linux gcc 64bit memcpy gyp
No comments:
Post a Comment