Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#2720 closed defect (fixed)

Ordering of ExternalObject constructors is reversed

Reported by: federico.terraneo@… Owned by: Per Östlund
Priority: high Milestone: 1.9.1
Component: Code Generation Version: trunk
Keywords: ExternalObject constructor order Cc:

Description

This is a simple example that tries to instantiate two ExternalObject clasees, passing one object as a parameter to the other.

Running this simple example with omc nightly builds results in the following error:

Bar ctor called (param=(nil))
Test: ./ExtObj.h:28: void *barCtor(void *): Assertion `param==(void*)0x11111111' failed.
Aborted (core dumped)

It looks like the order in which constructors are called is reversed. A look at the C sources generated by omc resulted in this (Test_01exo.c):

/* Has to be performed after _init.xml file has been read */

void Test_callExternalObjectConstructors(DATA *data)
{
  /* data->simulationInfo.extObjs = NULL; */
  infoStreamPrint(LOG_DEBUG, 0, "call external Object Constructors");
  $Pbar = omc_P_Bar_constructor(threadData, $Pfoo);
  $Pfoo = omc_P_Foo_constructor(threadData);
  infoStreamPrint(LOG_DEBUG, 0, "call external Object Constructors finished");
}

So the constructors are called in reverse order.

Note: the following was built using

omc +s ExtObj.mo
make -f Test.makefile
./Test

Attachments (1)

ExtObj.zip (873 bytes ) - added by federico.terraneo@… 11 years ago.
Simplified example that triggers the bug

Download all attachments as: .zip

Change History (4)

by federico.terraneo@…, 11 years ago

Attachment: ExtObj.zip added

Simplified example that triggers the bug

comment:1 by Per Östlund, 11 years ago

Owner: changed from Lennart Ochel to Per Östlund
Status: newaccepted

comment:2 by Per Östlund, 11 years ago

Resolution: fixed
Status: acceptedclosed

Fixed in r21020, the list of external objects was indeed mistakenly reversed. I also added your example as a test case in our test suite.

comment:3 by federico.terraneo@…, 11 years ago

Thanks for the quick response.

Note: See TracTickets for help on using tickets.