ETSI's Bug Tracker - Ext Pack: Object-oriented features (ES 203 790)
View Issue Details

ID | Project | Category | View Status | Date Submitted | Last Update
0007692 | Ext Pack: Object-oriented features (ES 203 790) | [All Projects] General | public | 09-07-2017 12:18 | 18-04-2018 09:51

Reporter | KristÃ³f Szabados |
Assigned To | KristÃ³f Szabados |
Priority | normal | Severity | minor | Reproducibility | have not tried
Status | closed | Resolution | fixed |
Platform |  | OS |  | OS Version |
Product Version |  |
Target Version |  | Fixed in Version |  |

Summary | 0007692: Exception handling with less code and less performance overhead

Description

There are many kinds of testing scenarios, where a few issues are to be expected because of the purpose of the test.
For example when we need to check what happens if the SUT is driven to very high loads for several hours/days, or when the upper limit of stable parallel connections/bandwith is tested.
In these cases the SUT not being able to handle a few messages in a large timeframe can be expected and should not stop the test from execution.
In TTCN-3 it is already possible to use exception handling to write the needed safe code.
The code parts in question need to be executed on parallel components, and exception handling done via ports.
But this has a high overhead in performance and in code size.
It would be better if the try-catch style mechanism of other languages would be available.
TTCN-3 already has the raise and catch keywords, that could be used.
Lets see a trivial example to demonstrate the idea: We wish to divide 2 numbers safely.
Right now one can do this by:
- Defining a signature for the function that will do the safe division.
signature MySafeDivision(in integer Par1,in integer Par2)
return integer
exception(charstring);
- defining some templates:
template MySafeDivision MySafeDivisionTemplate1 := {
Par1 := ?,
Par2 := 0
}
template MySafeDivision MySafeDivisionTemplate2 := {
Par1 := ?,
Par2 := ?
}
- the function that will do the safe division:
function getSafeDivisionCall() runs on MyComponent {
while (true) {
alt {
[] Port0.getCall(MySafeDivisionTemplate1) {
Port0.raise(MySafeDivision, "Error: division by zero");
}
[] Port0.getCall(MySafeDivisionTemplate2) { ... }
...
}
}
}
- At the location where we wish to do the safe division:
myComponentVar := MyComponent.create;
myComponentVar.start(getSafeDivisionCall());
connect(self:Port0, myComponentVar:Port1);
Port0.call(/*actual template to be used*/);
alt{
[] Port0.catch(MySafeDivision, charstring:"Error: division by zero") {
// some sort of error handling
}
[] Port0.getReplay(...) {
// handling for the good case
}
[] Port0.catch(timeout) {
// handle running out of time
}
}
---
The above example solves the task at hand and as a pattern it could be used for more complex situations.
But it involves lots of code and communication between parallel components.
If TTCN-3 would support exception handling the same could be solved like this:
- the safe division function:
function MySafeDivision(in integer Par1,in integer Par2) return integer exception(charstring) {
if (Par2 == 0) {
raise(charstring:"Error: division by zero");
}
return Par1 / Par2;
}
- At the location where we wish to do the safe division:
...
try {
result := MySafeDivision(x, y);
} catch (charstring v_exception) {
log("There was an exception:", v_exception, ", but execution can continue safely");
}
...
This solution has the same safety and granularity.
Using much less code ... that also makes it much easier to see what is happening in the code.
Using much less resources ... there is no need for a parallel component and remote procedure calls, etc...

Steps To Reproduce |
Additional Information |
Tags | No tags attached.

Relationships

related to | 0007731 | closed | Jens Grabowski | Draft document for Object-oriented Extension
related to | 0007561 | closed | KristÃ³f Szabados | Allow finally block or shutdown hook

Attached Files

CR7692.docx (279,126) 28-07-2017 14:11
http://oldforge.etsi.org/mantis/file_download.php?file_id=3672&type=bug
CR7692_v2.docx (281,583) 05-09-2017 11:38
http://oldforge.etsi.org/mantis/file_download.php?file_id=3677&type=bug
CR7692_v3.docx (288,770) 08-09-2017 09:48
http://oldforge.etsi.org/mantis/file_download.php?file_id=3684&type=bug
MTS-203790-00F_ed111v001_with_exceptions_v2.docx (180,702) 26-10-2017 08:48
http://oldforge.etsi.org/mantis/file_download.php?file_id=3704&type=bug
MTS-203790-00F_ed111v001_with_exceptions_v4.docx (182,754) 31-03-2018 09:11
http://oldforge.etsi.org/mantis/file_download.php?file_id=3735&type=bug

Issue History
Date Modified | Username | Field | Change
09-07-2017 12:18 | KristÃ³f Szabados | New Issue |
10-07-2017 09:57 | Jacob Wieland - Spirent | Note Added: 0014729 |
24-07-2017 14:15 | Jens Grabowski | Assigned To | => Jacob Wieland - Spirent
24-07-2017 14:15 | Jens Grabowski | Status | new => assigned
24-07-2017 14:15 | Jens Grabowski | Note Added: 0014737 |
28-07-2017 12:29 | Jens Grabowski | Relationship added | related to 0007561
28-07-2017 12:41 | Jens Grabowski | Project | TTCN-3 Change Requests => Ext Pack: Object-oriented features (ES 203 790)
28-07-2017 12:41 | Jens Grabowski | Category | New Feature => General
28-07-2017 14:11 | KristÃ³f Szabados | File Added: CR7692.docx |
28-07-2017 14:13 | KristÃ³f Szabados | Note Added: 0014796 |
05-09-2017 11:38 | KristÃ³f Szabados | File Added: CR7692_v2.docx |
05-09-2017 11:38 | KristÃ³f Szabados | Note Added: 0014814 |
08-09-2017 07:45 | Jens Grabowski | Assigned To | Jacob Wieland - Spirent => KristÃ³f Szabados
08-09-2017 09:48 | KristÃ³f Szabados | File Added: CR7692_v3.docx |
08-09-2017 09:58 | KristÃ³f Szabados | Note Added: 0014824 |
26-10-2017 08:48 | KristÃ³f Szabados | File Added: MTS-203790-00F_ed111v001_with_exceptions_v2.docx |
26-10-2017 08:48 | KristÃ³f Szabados | Note Added: 0014878 |
26-10-2017 14:41 | KristÃ³f Szabados | Note Added: 0014896 |
26-10-2017 14:41 | KristÃ³f Szabados | Assigned To | KristÃ³f Szabados => Jens Grabowski
26-10-2017 14:41 | KristÃ³f Szabados | Status | assigned => confirmed
31-03-2018 09:11 | KristÃ³f Szabados | File Added: MTS-203790-00F_ed111v001_with_exceptions_v4.docx |
31-03-2018 09:12 | KristÃ³f Szabados | Note Added: 0015073 |
16-04-2018 09:44 | Jens Grabowski | Assigned To | Jens Grabowski => Kristof.Szabados
16-04-2018 09:44 | Jens Grabowski | Status | confirmed => assigned
17-04-2018 09:04 | KristÃ³f Szabados | Assigned To | Kristof.Szabados => KristÃ³f Szabados
17-04-2018 09:05 | KristÃ³f Szabados | Note Added: 0015088 |
17-04-2018 14:06 | Tomas Urban | File Added: CR7731-TRI-TCI-1.docx |
17-04-2018 14:06 | Tomas Urban | File Deleted: CR7731-TRI-TCI-1.docx |
18-04-2018 08:34 | KristÃ³f Szabados | Relationship added | related to 0007731
18-04-2018 09:51 | KristÃ³f Szabados | Note Added: 0015096 |
18-04-2018 09:51 | KristÃ³f Szabados | Status | assigned => closed
18-04-2018 09:51 | KristÃ³f Szabados | Resolution | open => fixed

Notes

(0014729)
Jacob Wieland - Spirent
10-07-2017 09:57

Unfortunately, this isn't really true about the granularity.
If an exception occurs on one component, only that component state can be affected, i.e. only that component's data can be in a possibly inconsistent state.
The call/getreply/catch pattern is much safer in that regard, as it can not lead to the caller getting into an inconsistent state because the control flow is in their hands (and not in the hands of the called function).
Just some things that need to be considered/addressed.

(0014737)
Jens Grabowski
24-07-2017 14:15

To be discussed in the STF.

(0014796)
KristÃ³f Szabados
28-07-2017 14:13

I have uploaded a first draft of the proposal.
Please Note 0: still work in progress.
Please Note 1: for the time being I had to start from the core standard, but the final version will be part of the Object Oriented extension ... modification will be needed
Please Note 2: for the time being I had to start from the concepts of the core standard. These should be updated/harmonized with the concepts of the Object Oriented extension once they are available.

(0014814)
KristÃ³f Szabados
05-09-2017 11:38

some editorial fixes and added the changes to external functions

(0014824)
KristÃ³f Szabados
08-09-2017 09:58

After feedback from Jacob there were some fixes:
- a ',' is needed between the types in the exception list
- "[{" is not useful in the syntactical structure examples
- the exception list must have at least one element
- the exception list might not be exhaustive, for backward compatibility.
(but is recommended to be updated to precisely communicate to callers (user/tool) what exceptions to prepare for, or even to expect the possibility of exceptions)
- Statementblock -> statement block
- there is no need for '('')' after the raise keyword.
- some re-phrasing to make the sentences easier to read.
- added note to draw attention to exceptions are caught precisely by their type, so even for literals it is advised to write them down.
- added note saying that an exception not handled latest in the testcase results in a dynamic error ... where the error is not the throwing of the exception, but not handling it.
- it became disallowed to raise an exception or use return statement in a finally block (for now), as that might result in un-intuitive behaviour.
- raising exceptions are not allowed in certain places (together with other execution altering operations) where they could alter snapshot semantics.
We received one more feedback that the "finally" keyword might not be the best choice as the Object-oriented extension might use it in a slightly different meaning.

(0014878)
KristÃ³f Szabados
26-10-2017 08:48

uploaded the same content in the new extension package format (work in progress)

(0014896)
KristÃ³f Szabados
26-10-2017 14:41

Could you please check the latest version (MTS-203790-00F_ed111v001_with_exceptions_v2.docx). I tried to use the list of extensions style present in the advanced parameterization ... should I restructure the text?

(0015073)
KristÃ³f Szabados
31-03-2018 09:12

improved the text (fixed typos, phrases, some numbering, etc..)

(0015088)
KristÃ³f Szabados
17-04-2018 09:05

Updated CR 7731 based on these changes (MTS-203790-00F_ed111v002.docx)

(0015096)
KristÃ³f Szabados
18-04-2018 09:51

Solved as part of the OO extension (CR 7731)