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

memcpy can fail with rewriter tests #355

Closed
stanfordcox opened this issue Mar 21, 2017 · 3 comments
Closed

memcpy can fail with rewriter tests #355

stanfordcox opened this issue Mar 21, 2017 · 3 comments
Labels

Comments

@stanfordcox
Copy link
Contributor

The rewriter tests can fail with dyninst 9.3.1 on
ppc linux. For example: with test5_1 at the point of failure I see:

(gdb) bt
#0 .__memcpy_power7 () at ../sysdeps/powerpc/powerpc64/power7/memcpy.S:101
#1 0x00003fffb74f4ecc in memcpy (__len=1080, __src=0x0,
__dest=) at /usr/include/bits/string3.h:51
#2 memoryTracker (b=0x0, s=1080, a=268569680, this=0x12ee5fa0)
at
/usr/src/debug/dyninst-9.3.1/dyninst-9.3.1/dyninstAPI/src/binaryEdit.h:262
#3 BinaryEdit::createMemoryBackingStore (this=this@entry=0x15b73b00,
obj=)
at
/usr/src/debug/dyninst-9.3.1/dyninst-9.3.1/dyninstAPI/src/binaryEdit.C:768
#4 0x00003fffb74f569c in BinaryEdit::openFile
(file="dyninst_cxx_group_test.dyn_g++_64_none_none", mgr=...,
patch=, member=...) at
/usr/src/debug/dyninst-9.3.1/dyninst-9.3.1/dyninstAPI/src/binaryEdit.C:381
#5 0x00003fffb74a5da8 in BPatch_binaryEdit::BPatch_binaryEdit
(this=0x15b70640,
path=0x10197480 "dyninst_cxx_group_test.dyn_g++_64_none_none",
openDependencies=)
at
/usr/src/debug/dyninst-9.3.1/dyninst-9.3.1/dyninstAPI/src/BPatch_binaryEdit.C:90
#6 0x00003fffb7453d58 in BPatch::openBinary (this=,
path=, openDependencies=)
at
/usr/src/debug/dyninst-9.3.1/dyninst-9.3.1/dyninstAPI/src/BPatch.C:1886
#7 0x00003fffb769fb3c in DyninstComponent::group_setup
(this=0x10497650, group=0x1038e710,
params=std::map with 35 elements = {...}) at
/builddir/build/BUILD/dyninst-9.3.1/testsuite-9.3.0/src/dyninst/dyninst_comp.C:216
#8 0x0000000010015298 in executeGroup (group=0x1038e710,
groups=std::vector of length 1717, capacity 2048 = {...},
param=std::map with 35 elements = {...}) at
/builddir/build/BUILD/dyninst-9.3.1/testsuite-9.3.0/src/test_driver.C:486
#9 0x0000000010016b80 in startAllTests (groups=std::vector of length
1717, capacity 2048 = {...},
param=std::map with 35 elements = {...}) at
/builddir/build/BUILD/dyninst-9.3.1/testsuite-9.3.0/src/test_driver.C:666
#10 0x0000000010017d74 in main (argc=5, argv=0x3ffffffff468)
at
/builddir/build/BUILD/dyninst-9.3.1/testsuite-9.3.0/src/test_driver.C:877

(gdb) fra 3
#3 BinaryEdit::createMemoryBackingStore (this=this@entry=0x15b73b00, obj=)
at /usr/src/debug/dyninst-9.3.1/dyninst-9.3.1/dyninstAPI/src/binaryEdit.C:768
768 regs[i]->getPtrToRawData());
(gdb) list
763 continue;
764 }
765 else {
766 newTracker = new memoryTracker(regs[i]->getMemOffset(),
767 regs[i]->getMemSize(),
768 regs[i]->getPtrToRawData());
769
770 }
771 newTracker->alloced = false;
772 if (!memoryTracker_)

@wrwilliams
Copy link
Member

In frame 2 (the memoryTracker constructor, in binaryEdit.h), this:

            b_ = malloc(s_);
            memcpy(b_, b, s_);

should become this:

            if(b) {
                b_ = malloc(s_);
                memcpy(b_, b, s_);
            } else {
                b_ = calloc(1, s_);
            }

Have a local patch in testing, but if you can cross-check on ppc64 while I test, that would be handy.

@stanfordcox
Copy link
Contributor Author

The above binaryEdit.h patch fixes the case I was seeing.

@wrwilliams
Copy link
Member

Fixed by #346.

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

No branches or pull requests

2 participants