Ignore:
Timestamp:
Jun 1, 2017, 1:00:08 PM (2 years ago)
Author:
nmedfort
Message:

Bug fix for memory check and issues found parsing internal 'files'. Added backtrace option from execinfo.h

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/grep_engine.cpp

    r5486 r5489  
    415415    if (grepSource == GrepSource::File) {
    416416        sourceK = mGrepDriver->addKernelInstance(make_unique<kernel::MMapSourceKernel>(idb, segmentSize));
    417         sourceK->setInitialArguments({fileDescriptor});
    418     } else { // if (grepSource == GrepSource::StdIn) {
     417    } else {
    419418        sourceK = mGrepDriver->addKernelInstance(make_unique<kernel::ReadSourceKernel>(idb, segmentSize));
    420         sourceK->setInitialArguments({idb->getInt32(STDIN_FILENO)});
    421     }
     419    }
     420    sourceK->setInitialArguments({fileDescriptor});
    422421
    423422    mGrepDriver->makeKernelCall(sourceK, {}, {ByteStream});
     
    519518    parsedCodePointSet = re::makeCC();       
    520519    const unsigned segmentSize = 8;
    521    
     520
    522521    ParabixDriver pxDriver("codepointEngine");
    523522    auto & idb = pxDriver.getBuilder();
     
    577576
    578577const std::vector<std::string> & grepPropertyValues(const std::string& propertyName, re::RE * propertyValuePattern) {
    579     enum { MaxSupportedVectorWidthInBytes = 32 };
    580     AlignedAllocator<char, MaxSupportedVectorWidthInBytes> alloc;
     578    ParabixDriver pxDriver("propertyValueEngine");
     579    AlignedAllocator<char, 32> alloc;
     580
    581581    parsedPropertyValues.clear();
     582
    582583    const std::string & str = UCD::getPropertyValueGrepString(propertyName);
     584
     585    auto & idb = pxDriver.getBuilder();
     586
     587    const unsigned segmentSize = 8;
    583588    const auto n = str.length();
    584     // NOTE: MaxSupportedVectorWidthInBytes of trailing 0s are needed to prevent the grep function from
    585     // erroneously matching garbage data when loading the final partial block.
    586     char * aligned = alloc.allocate(n + MaxSupportedVectorWidthInBytes, 0);
     589    const auto w = idb->getBitBlockWidth() * segmentSize;
     590    const auto m = w - (n % w);
     591
     592    char * aligned = alloc.allocate(n + m, 0);
    587593    std::memcpy(aligned, str.data(), n);
    588     std::memset(aligned + n, 0, MaxSupportedVectorWidthInBytes);
    589    
    590     const unsigned segmentSize = 8;
    591    
    592     ParabixDriver pxDriver("propertyValueEngine");
    593     auto & idb = pxDriver.getBuilder();
     594    std::memset(aligned + n, 0, m);
     595
    594596    Module * M = idb->getModule();
    595597   
     
    629631    idb->CreateRetVoid();
    630632    pxDriver.finalizeObject();
    631    
     633
    632634    typedef void (*GrepFunctionType)(const char * buffer, const size_t length);
    633635    auto f = reinterpret_cast<GrepFunctionType>(pxDriver.getMain());
Note: See TracChangeset for help on using the changeset viewer.