From: richterm Date: Fri, 12 Oct 2007 11:13:34 +0000 (+0000) Subject: bugfix AliHLTDataBuffer: correct handling of pointer and offset in block descriptor... X-Git-Url: http://git.uio.no/git/?a=commitdiff_plain;h=3294f81a7ce76a686d6d9e42419135ad12d36b7d;p=u%2Fmrichter%2FAliRoot.git bugfix AliHLTDataBuffer: correct handling of pointer and offset in block descriptor, fixes bug #29974 AliHLTComponent: reverting previous changes which were supposed to fix the mentioned bug minor argument check in external interface and correction in documentation --- diff --git a/HLT/BASE/AliHLTComponent.cxx b/HLT/BASE/AliHLTComponent.cxx index 45eb482a6b5..8917bda3e50 100644 --- a/HLT/BASE/AliHLTComponent.cxx +++ b/HLT/BASE/AliHLTComponent.cxx @@ -502,9 +502,8 @@ int AliHLTComponent::FindInputBlock(const AliHLTComponentDataType& dt, int start for ( ; (UInt_t)idx(fpInputBlocks[idx].fPtr); - pSrc+=fpInputBlocks[idx].fOffset; - if (*reinterpret_cast(pSrc)!=fpInputBlocks[idx].fSize-sizeof(AliHLTUInt32_t)) continue; + AliHLTUInt32_t firstWord=*((AliHLTUInt32_t*)fpInputBlocks[idx].fPtr); + if (firstWord!=fpInputBlocks[idx].fSize-sizeof(AliHLTUInt32_t)) continue; } if (dt == kAliHLTAnyDataType || fpInputBlocks[idx].fDataType == dt) { iResult=idx; @@ -521,12 +520,10 @@ TObject* AliHLTComponent::CreateInputObject(int idx, int bForce) if (fpInputBlocks!=NULL) { if ((UInt_t)idx(fpInputBlocks[idx].fPtr); - pSrc+=fpInputBlocks[idx].fOffset; - AliHLTUInt32_t firstWord=*((AliHLTUInt32_t*)pSrc); + AliHLTUInt32_t firstWord=*((AliHLTUInt32_t*)fpInputBlocks[idx].fPtr); if (firstWord==fpInputBlocks[idx].fSize-sizeof(AliHLTUInt32_t)) { HLTDebug("create object from block %d size %d", idx, fpInputBlocks[idx].fSize); - AliHLTMessage msg((void*)pSrc, fpInputBlocks[idx].fSize); + AliHLTMessage msg(fpInputBlocks[idx].fPtr, fpInputBlocks[idx].fSize); TClass* objclass=msg.GetClass(); pObj=msg.ReadObject(objclass); if (pObj && objclass) { @@ -782,7 +779,6 @@ int AliHLTComponent::InsertOutputBlock(void* pBuffer, int iBufferSize, const Ali AliHLTComponentBlockData bd; FillBlockData( bd ); bd.fOffset = fOutputBufferFilled; - bd.fPtr = fpOutputBuffer; bd.fSize = iBlkSize; bd.fDataType = dt; bd.fSpecification = spec; @@ -855,7 +851,6 @@ AliHLTMemoryFile* AliHLTComponent::CreateMemoryFile(int capacity, AliHLTComponentBlockData bd; FillBlockData( bd ); bd.fOffset = fOutputBufferFilled; - bd.fPtr = fpOutputBuffer; bd.fSize = capacity; bd.fDataType = dt; bd.fSpecification = spec; @@ -1212,8 +1207,7 @@ int AliHLTComponent::CopyStruct(void* pStruct, unsigned int iStructSize, unsigne if (fpInputBlocks!=NULL && iBlockNofpInputBlocks[iBlockNo].fSize) copy=fpInputBlocks[iBlockNo].fSize; @@ -1226,7 +1220,7 @@ int AliHLTComponent::CopyStruct(void* pStruct, unsigned int iStructSize, unsigne memset(pTgt, 0, iStructSize); } } - memcpy(pTgt, pSrc, copy); + memcpy(pTgt, fpInputBlocks[iBlockNo].fPtr, copy); *pTgt=iStructSize; iResult=copy; } else { diff --git a/HLT/BASE/AliHLTDataBuffer.cxx b/HLT/BASE/AliHLTDataBuffer.cxx index 67437a25eec..f85a7609f60 100644 --- a/HLT/BASE/AliHLTDataBuffer.cxx +++ b/HLT/BASE/AliHLTDataBuffer.cxx @@ -182,8 +182,14 @@ int AliHLTDataBuffer::Subscribe(const AliHLTComponent* pConsumer, AliHLTComponen arrayBlockDesc[i].fShmKey.fStructSize=sizeof(AliHLTComponentShmData); arrayBlockDesc[i].fShmKey.fShmType=gkAliHLTComponentInvalidShmType; arrayBlockDesc[i].fShmKey.fShmID=gkAliHLTComponentInvalidShmID; + // This models the behavior of PubSub. + // For incoming data blocks, fOffset must be ignored by the + // processing component. It is set for bookkeeping in the framework. + // fPtr always points to the beginning of the data. arrayBlockDesc[i].fOffset=(*segment).fSegmentOffset; - arrayBlockDesc[i].fPtr=*fpBuffer; + AliHLTUInt8_t* pTgt=*fpBuffer; + pTgt+=(*segment).fSegmentOffset; + arrayBlockDesc[i].fPtr=reinterpret_cast(pTgt); arrayBlockDesc[i].fSize=(*segment).fSegmentSize; arrayBlockDesc[i].fDataType=(*segment).fDataType; arrayBlockDesc[i].fSpecification=(*segment).fSpecification; @@ -296,17 +302,14 @@ int AliHLTDataBuffer::SetSegments(AliHLTUInt8_t* pTgt, AliHLTComponentBlockData* if (*fpBuffer==pTgt) { AliHLTDataBuffer::AliHLTDataSegment segment; for (int i=0; i' includes the size of the buffer + // This function has to model the behavior of PubSub + // For output blocks only the fOffset value is used, this must be the offset + // relative to the output pointer. fPtr must be either NULL or the output + // pointer if (arrayBlockData[i].fPtr==NULL || - ((*fpBuffer)<=arrayBlockData[i].fPtr && (*fpBuffer)>arrayBlockData[i].fPtr)) { - int ptrOffset=0; - if (arrayBlockData[i].fPtr!=NULL) { - ptrOffset=(*fpBuffer)-arrayBlockData[i].fPtr; - } - if (arrayBlockData[i].fOffset+ptrOffset+arrayBlockData[i].fSize<=fpBuffer->fSize) { - segment.fSegmentOffset=arrayBlockData[i].fOffset+ptrOffset; + arrayBlockData[i].fPtr==*fpBuffer) { + if (arrayBlockData[i].fOffset+arrayBlockData[i].fSize<=fpBuffer->fSize) { + segment.fSegmentOffset=arrayBlockData[i].fOffset; segment.fSegmentSize=arrayBlockData[i].fSize; segment.fDataType=arrayBlockData[i].fDataType; segment.fSpecification=arrayBlockData[i].fSpecification; @@ -318,7 +321,9 @@ int AliHLTDataBuffer::SetSegments(AliHLTUInt8_t* pTgt, AliHLTComponentBlockData* iResult=-E2BIG; } } else { - HLTError("invalid pointer (%p) in block data specification (buffer %p size %d)", arrayBlockData[i].fPtr, fpBuffer->fPtr, fpBuffer->fSize); + HLTError("invalid pointer (%p) in block data specification (buffer %p size %d)." + "please note: for output blocks only the fOffset value is valid and must " + "be relative to the output buffer", arrayBlockData[i].fPtr, fpBuffer->fPtr, fpBuffer->fSize); iResult=-ERANGE; } } diff --git a/HLT/BASE/AliHLTDataTypes.h b/HLT/BASE/AliHLTDataTypes.h index 776cf032f4d..2f68d14f5ee 100644 --- a/HLT/BASE/AliHLTDataTypes.h +++ b/HLT/BASE/AliHLTDataTypes.h @@ -182,16 +182,31 @@ extern "C" { /** * @struct AliHLTComponentBlockData - * Descriptor for data blocks. + * This is the decription of data blocks exchanged between components. + * \b IMPORTANT: The validity of fPtr and fOffset is different for input and + * output blocks: + * - input blocks: The \em fPtr member always points to the beginning of the data + * of size \em fSize. fOffset is ignored and should be in most + * case 0. + * - output blocks: The \em fPtr member is ignored by the framework. \em fOffset + * must specify the start of the data relative to the output + * buffer. The data block has size \em fSize. */ struct AliHLTComponentBlockData { + /* size and version of the struct */ AliHLTUInt32_t fStructSize; + /* shared memory key, ignored by processing components */ AliHLTComponentShmData fShmKey; + /* offset of output data relative to the output buffer */ AliHLTUInt32_t fOffset; + /* start of the data for input data blocks, fOffset to be ignored*/ void* fPtr; + /* size of the data block */ AliHLTUInt32_t fSize; + /* data type of the data block */ AliHLTComponentDataType fDataType; + /* data specification of the data block */ AliHLTUInt32_t fSpecification; }; diff --git a/HLT/BASE/AliHLTModuleAgent.h b/HLT/BASE/AliHLTModuleAgent.h index fb0bb11554d..d9dda5b6771 100644 --- a/HLT/BASE/AliHLTModuleAgent.h +++ b/HLT/BASE/AliHLTModuleAgent.h @@ -51,7 +51,7 @@ class AliRawReader; * can be queried when required. * * This is usually done during running the AliRoot reconstruction (see AliRoot - * documentation on AliSimulation and AliReconstruction ). + * documentation on AliSimulation and AliReconstruction ). * The HLT implemets the @ref AliHLTSimulation and @ref * AliHLTReconstructor which hold the HLT steering object. Several flags can * be specified as options via the SetRunHLT method of diff --git a/HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx b/HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx index 8e096074528..7de5185c2f1 100644 --- a/HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx +++ b/HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx @@ -77,9 +77,11 @@ int AliHLT_C_CreateComponent( const char* componentType, void* environ_param, in { if ( !gComponentHandler_C ) return ENXIO; + if ( !handle ) return EINVAL; AliHLTComponent* comp; int ret = gComponentHandler_C->CreateComponent( componentType, environ_param, argc, argv, comp ); *handle = reinterpret_cast( comp ); + return ret; }