Skip to Content.
Sympa Menu

svadev - Re: [svadev] BBC test issue

svadev AT lists.siebelschool.illinois.edu

Subject: Svadev mailing list

List archive

Re: [svadev] BBC test issue


Chronological Thread 
  • From: John Criswell <criswell AT illinois.edu>
  • To: Baozeng <sploving1 AT gmail.com>
  • Cc: svadev AT cs.illinois.edu
  • Subject: Re: [svadev] BBC test issue
  • Date: Thu, 14 Jun 2012 12:47:21 -0500
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/svadev>
  • List-id: <svadev.cs.uiuc.edu>

On 6/14/12 3:06 AM, Baozeng wrote:
2012/6/14 John
Criswell<criswell AT illinois.edu>:
On 6/13/12 8:37 AM, Baozeng wrote:
Hello,
I use current BBC implementation to test an example (buffer.c):

#include<stdio.h>
#include<stdlib.h>

int main (int argc, char ** argv) {
char array[17];
return array[17];
}

$ clang -g -fmemsafety -bbc buffer.c -o mytest
-L/home/sploving/llvm/projects/safecode/Debug/lib
$ ./mytest

It output this:
0xbfd00b9b, 0xbfd00b80, 17 Not aligned

This related code is in the function __internal_register in
BaggyBoundsCheck.cpp:

if(Source1 != Source) {
printf("%p, %p, %u Not aligned\n", (void*)Source, (void*)Source1,
NumBytes);
assert(0&& "Memory objects not aligned");
}

I think the problem is that the stack object being registered isn't aligned
on a power-of-two boundary like it should be.

yep.
I debugged and found that the function adjustAlloca is not called.
I inserted some printf statement in the following function:

void
InsertBaggyBoundsChecks::adjustAllocasFor (Function * F) {
//
// If there is no such function, do nothing.
//
if (!F) return;
printf("test1\n"); // It output!
//
// Scan through all uses of the function and process any allocas used by
it.
//
for (Value::use_iterator FU = F->use_begin(); FU != F->use_end(); ++FU) {
printf("test2\n"); // It does not ouput!
if (CallInst * CI = dyn_cast<CallInst>(*FU)) {
printf("test3\n"); // It does not ouput!
Value * Ptr = CI->getArgOperand(2)->stripPointerCasts();
if (AllocaInst * AI = dyn_cast<AllocaInst>(Ptr)){
adjustAlloca (AI);
printf("test4\n"); // It does not ouput!
}
}
}

return;
}

Only test1 was printed out. So the statements in the for loop are not
executed. why?

I'm not sure, but it looks like a bug in the code. You should add more debugging to see what Ptr is (you can use CI->dump() and Ptr->dump() to print them to stderr). It's possible that the code is looking at the wrong argument of the call to pool_register_stack().

-- John T.





Archive powered by MHonArc 2.6.16.

Top of Page