Home » Eclipse Projects » Eclipse Titan » compiler segmentation fault on specific template usage [titan 10.0.0](Compiler from Titan 10.0.0 segfault with specific template usage)
compiler segmentation fault on specific template usage [titan 10.0.0] [message #1862432] |
Mon, 04 December 2023 19:22 |
Anton Kozhemyachenko Messages: 15 Registered: June 2021 |
Junior Member |
|
|
Hello,
We are switching from Titan 8.0.0 to 10.0.0 version and get core dump in compiler phase (from ttcn to c++ generation). Previously it was OK.
Titan is built on bcf519d commit.
There are a few issues, but the first one, we have localized is here (also attached as a file):
module Test {
type union GenValue {
charstring tokenOrHost,
charstring quotedString
};
type record GenericParam
{
charstring id,
GenValue paramValue optional
};
template (value) GenericParam cs_GenericParam_Common(charstring p_Id, template (omit) GenValue p_GenValue := omit) :=
{
id := p_Id,
paramValue := p_GenValue
};
template (value) GenValue cs_GenValueToken(template (value) charstring p_ParamValue) := {tokenOrHost := p_ParamValue};
function fl_GenValue_TX(template (omit) charstring p_ParamValue) return template (omit) GenValue
{
var template (omit) GenValue v_GenValue := omit;
if (isvalue(p_ParamValue)) { v_GenValue := cs_GenValueToken(valueof(p_ParamValue)); }
return v_GenValue;
}
template (value) GenericParam cs_GenericParam(charstring p_Id, template (omit) charstring p_ParamValue := omit) :=
cs_GenericParam_Common(p_Id, fl_GenValue_TX(p_ParamValue));
template (value) GenericParam cs_SigCompParam := cs_GenericParam("comp", "sigcomp");
}
The 'compiler' app crashes:
make: *** [Makefile:213: compile] Segmentation fault (core dumped)
The build command is: $(TTCN3_DIR)/bin/compiler -L -R -d Test.ttcn
The error goes from cs_SigCompParam definition. Also if comment this checking in fl_GenValue_TX function: , then there is no issue (but this is not what we need, it is required actually to check for omit value).
Here is the gdb backtrace:
#0 0x000055b56c22f770 in Common::Value::rearrange_init_code (this=0x18, str=0x55b56c9de280 "current_location.update_lineno(31);\n/* Test.ttcn, line 31 */\n", usage_mod=0x55b56c9c1070) at Value.cc:14010
#1 0x000055b56c36c96d in Ttcn::LengthRestriction::rearrange_init_code (this=0x55b56c9e61c0, str=0x55b56c9de280 "current_location.update_lineno(31);\n/* Test.ttcn, line 31 */\n", usage_mod=0x55b56c9c1070) at Templatestuff.cc:869
#2 0x000055b56c35dbca in Ttcn::Template::rearrange_init_code (this=0x55b56c9e6140, str=0x55b56c9de280 "current_location.update_lineno(31);\n/* Test.ttcn, line 31 */\n", usage_mod=0x55b56c9c1070) at TtcnTemplate.cc:4426
#3 0x000055b56c23009c in Common::Value::rearrange_init_code (this=0x55b56c9e61f0, str=0x55b56c9de280 "current_location.update_lineno(31);\n/* Test.ttcn, line 31 */\n", usage_mod=0x55b56c9c1070) at Value.cc:14199
#4 0x000055b56c328226 in Ttcn::Statement::rearrange_init_code (this=0x55b56c9e7580, str=0x55b56c9de280 "current_location.update_lineno(31);\n/* Test.ttcn, line 31 */\n", usage_mod=0x55b56c9c1070) at Statement.cc:7428
#5 0x000055b56c30d395 in Ttcn::StatementBlock::rearrange_init_code (this=0x55b56c9e5e70, str=0x55b56c9de280 "current_location.update_lineno(31);\n/* Test.ttcn, line 31 */\n", usage_mod=0x55b56c9c1070) at Statement.cc:835
#6 0x000055b56c364d6d in Ttcn::Template::rearrange_init_code_refd (this=0x55b56c9e9a20, str=0x55b56c9de280 "current_location.update_lineno(31);\n/* Test.ttcn, line 31 */\n", usage_mod=0x55b56c9c1070) at TtcnTemplate.cc:6057
#7 0x000055b56c35d996 in Ttcn::Template::rearrange_init_code (this=0x55b56c9e9a20, str=0x55b56c9de280 "current_location.update_lineno(31);\n/* Test.ttcn, line 31 */\n", usage_mod=0x55b56c9c1070) at TtcnTemplate.cc:4389
#8 0x000055b56c36844a in Ttcn::TemplateInstance::rearrange_init_code (this=0x55b56c9e9590, str=0x55b56c9de280 "current_location.update_lineno(31);\n/* Test.ttcn, line 31 */\n", usage_mod=0x55b56c9c1070) at TtcnTemplate.cc:6919
#9 0x000055b56c2f3973 in Ttcn::ActualPar::rearrange_init_code (this=0x55b56c9e9370, str=0x55b56c9de280 "current_location.update_lineno(31);\n/* Test.ttcn, line 31 */\n", usage_mod=0x55b56c9c1070) at AST_ttcn3.cc:12901
#10 0x000055b56c2f522d in Ttcn::ActualParList::rearrange_init_code (this=0x55b56c9e80c0, str=0x55b56c9de280 "current_location.update_lineno(31);\n/* Test.ttcn, line 31 */\n", usage_mod=0x55b56c9c1070) at AST_ttcn3.cc:13312
#11 0x000055b56c364d16 in Ttcn::Template::rearrange_init_code_refd (this=0x55b56c9e9e30, str=0x55b56c9de280 "current_location.update_lineno(31);\n/* Test.ttcn, line 31 */\n", usage_mod=0x55b56c9c1070) at TtcnTemplate.cc:6053
#12 0x000055b56c35d996 in Ttcn::Template::rearrange_init_code (this=0x55b56c9e9e30, str=0x55b56c9de280 "current_location.update_lineno(31);\n/* Test.ttcn, line 31 */\n", usage_mod=0x55b56c9c1070) at TtcnTemplate.cc:4389
#13 0x000055b56c364dfb in Ttcn::Template::rearrange_init_code_refd (this=0x55b56c9eb3b0, str=0x55b56c9de280 "current_location.update_lineno(31);\n/* Test.ttcn, line 31 */\n", usage_mod=0x55b56c9c1070) at TtcnTemplate.cc:6067
#14 0x000055b56c35dff9 in Ttcn::Template::generate_code_init_refd (this=0x55b56c9eb3b0, str=0x55b56c9de280 "current_location.update_lineno(31);\n/* Test.ttcn, line 31 */\n", name=0x55b56c9de050 "template_cs__SigCompParam")
at TtcnTemplate.cc:4491
#15 0x000055b56c35d569 in Ttcn::Template::generate_code_init (this=0x55b56c9eb3b0, str=0x55b56c9de280 "current_location.update_lineno(31);\n/* Test.ttcn, line 31 */\n", name=0x55b56c9de050 "template_cs__SigCompParam")
at TtcnTemplate.cc:4315
#16 0x000055b56c2d2447 in Ttcn::Def_Template::generate_code (this=0x55b56c9eb4c0, target=0x55b56c9ed250) at AST_ttcn3.cc:5809
#17 0x000055b56c2d285a in Ttcn::Def_Template::generate_code (this=0x55b56c9eb4c0, cgh=...) at AST_ttcn3.cc:5836
#18 0x000055b56c2c3c53 in Ttcn::Definitions::generate_code (this=0x55b56c989080, cgh=...) at AST_ttcn3.cc:2857
#19 0x000055b56c2c8a4b in Ttcn::Module::generate_code_internal (this=0x55b56c9c1070, cgh=...) at AST_ttcn3.cc:3875
#20 0x000055b56c12dee2 in Common::Module::generate_code (this=0x55b56c9c1070, cgh=...) at AST.cc:1692
#21 0x000055b56c126f65 in Common::Modules::generate_code (this=0x55b56c9c0dc0, cgh=...) at AST.cc:274
#22 0x000055b56c150a6d in main (argc=5, argv=0x7fff079d9df8) at main.cc:1271
With the following patch, the compiler can produce the code (attached also):
diff --git a/compiler2/ttcn3/Statement.cc b/compiler2/ttcn3/Statement.cc
index 21bd89107..211ffe6d9 100644
--- a/compiler2/ttcn3/Statement.cc
+++ b/compiler2/ttcn3/Statement.cc
@@ -7455,7 +7455,7 @@ error:
for (size_t i = 0; i < select.scs->get_nof_scs(); ++i) {
SelectCase* sc = select.scs->get_sc_byIndex(i);
TemplateInstances* tis = sc->get_tis();
- for (size_t j = 0; j < tis->get_nof_tis(); ++j) {
+ for (size_t j = 0; j < (tis ? tis->get_nof_tis() : 0); ++j) {
str = tis->get_ti_byIndex(j)->rearrange_init_code(str, usage_mod);
}
str = sc->get_block()->rearrange_init_code(str, usage_mod);
diff --git a/compiler2/ttcn3/TtcnTemplate.cc b/compiler2/ttcn3/TtcnTemplate.cc
index 0bbccacdc..cfbc0aeda 100644
--- a/compiler2/ttcn3/TtcnTemplate.cc
+++ b/compiler2/ttcn3/TtcnTemplate.cc
@@ -4423,7 +4423,7 @@ end:
default:
break;
}
- if (length_restriction) str = length_restriction->rearrange_init_code(str, usage_mod);
+ if (length_restriction && templatetype != TEMPLATE_ERROR) str = length_restriction->rearrange_init_code(str, usage_mod);
return str;
}
The patch targets two issues. The first chunk with NULL tis is not for the code here, but we also faced this issue. The chunk with templatetype != TEMPLATE_ERROR actually allows to fix the issue described here.
However we are not sure, if the provided patch is correct, or has some effects on generating the code.
Could you please review this issue. Please let me know if you need any further details.
Thank you.
-
Attachment: Test.ttcn
(Size: 1.01KB, Downloaded 52 times) -
Attachment: tmp_fix.diff
(Size: 1.13KB, Downloaded 38 times)
|
|
| | | | |
Goto Forum:
Current Time: Thu Oct 10 03:39:12 GMT 2024
Powered by FUDForum. Page generated in 0.03687 seconds
|