IBM Support

PI23675: RiCEvent_getMemory may not return correct mem allocation in SMXF

Subscribe

You can track all active APARs for this component.

APAR status

  • Closed as program error.

Error description

  • PROBLEM:
    
    Customer is working with the SMXF and trying to get event
    dispatching working correctly on an Evaluation target, but they
    have discovered a potential bug in a function within RiCEvent.c
    (C:\Program Files
    (x86)\IBM\Rational\Rhapsody\8.0.3\Share\LangC\smxf):
    
    
    01 RiCEvent * RiCEvent_getMemory(void) {
    02    /*#[ operation getMemory() */
    03    /* The initialization is done according to the value of:
    EVENTS_POOL_SIZE (see definition) */
    04    static RiCEvent eventsPool[EVENTS_POOL_SIZE] =
    {{NULL,(RiCEventId)0,NULL,RiCFALSE,NULL}};
    05
    06    RiCEvent* getMemoryRes = NULL;
    07    RhpPositive ind = 0U;
    08    RhpBoolean flag = RiCFALSE;
    09    RiCOSMutex_lock(?eventPoolMutex);
    10
    11
    12    for(; (ind?EVENTS_POOL_SIZE) ?? (flag == RiCFALSE);
    ind++){
    13          if(eventsPool[ind].isAllocated == RiCFALSE){
    14                eventsPool[ind].isAllocated = RiCTRUE;
    15                eventsPool[ind].userData      = NULL;
    16                flag = RiCTRUE;
    17                getMemoryRes = ?(eventsPool[ind]);
    18          }
    19    }
    20    RiCOSMutex_free(?eventPoolMutex);
    21    /*LDRA_INSPECTED 71 S : Pointer is assigned to memory from
    wider scope */
    22    return getMemoryRes;
    23    /*#]*/
    24}
    
    Events in the system are defined in a pool and when one is
    required due to e.g. a Statechart transition, this function
    loops through the pool looking for one in which its flag is set
    to not allocated and returns its address (as well as setting it
    to allocated).
    
    However the Target they are using does not initialise memory to
    0s and line 4 shows that only the first element of the array is
    initialised at runtime.  This means after the first event is
    allocated, the system is unable to allocate any more events.
    This has been verified using Code Composer and a debugger
    attached to the target (TI F28335 DSP) which allows memory
    inspection.
    
    This function will only work if the EVENTS_POOL_SIZE is set to 1
    (though I believe the default is 10), the memory is initialised
    at boot, or potentially if some compilers accept the syntax to
    mean to set all elements of the array to the provided values ?
    though this is only theoretical.
    
    WORKAROUND:
    
    They have patched this in the local install by simply looping
    through the array the first time the code is called and setting
    everything to RiCFalse.  For example:
    
    static RhpBoolean isInitialized = RiCFALSE;
    if (isInitialized == RiCFALSE)
    {
       isInitialized = RiCTRUE;
       for(; ind?EVENTS_POOL_SIZE; ind++){
           eventsPool[ind].isAllocated = RiCFALSE;
       }
    }
    

Local fix

Problem summary

  • ****************************************************************
    * USERS AFFECTED:                                              *
    ****************************************************************
    * PROBLEM DESCRIPTION:                                         *
    ****************************************************************
    * RECOMMENDATION:                                              *
    ****************************************************************
    RiCEvent_getMemory may not return correct mem allocation in
    SMXF
    

Problem conclusion

  • Fixed in 8.1.2.1
    

Temporary fix

Comments

APAR Information

  • APAR number

    PI23675

  • Reported component name

    TLOGIC RHAPSODY

  • Reported component ID

    5724V74RP

  • Reported release

    803

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2014-08-12

  • Closed date

    2015-02-24

  • Last modified date

    2015-02-24

  • APAR is sysrouted FROM one or more of the following:

  • APAR is sysrouted TO one or more of the following:

Fix information

  • Fixed component name

    TLOGIC RHAPSODY

  • Fixed component ID

    5724V74RP

Applicable component levels

  • R803 PSN

       UP



Document information

More support for: Rational Rhapsody

Software version: 8.0.3

Reference #: PI23675

Modified date: 24 February 2015