Opened 12 years ago

Closed 12 years ago

#1775 closed defect (fixed)

Concatenating a string with an unbound string variable segfaults

Reported by: adabe588@… Owned by: Martin Sjölund
Priority: high Milestone: 1.9.0
Component: Backend Version:
Keywords: Cc:

Description

package StringAppend

function test
  input String s;
  output String s2;
algorithm
  // Causes a segfault.
  s2 := s +& s2;
end test;

end StringAppend;

script file:

setCommandLineOptions({"+d=rml,noevalfunc,failtrace","+g=MetaModelica","+showAnnotations","+showErrorMessages"});

loadFile("StringAppend.mo"); getErrorString();

StringAppend.test("X"); getErrorString();

// Expected
// Something along the line of "Cannot read from unbound output variable".

// Actual:
// Segmentation fault: 11
// endResult

Change History (3)

comment:1 by Martin Sjölund, 12 years ago

It does in C as well :)

Results are undefined according to Modelica semantics, so the segfault is "fine". Making a null-pointer check here costs too much time at run-time. Checks for unbound variables are planned for later.

comment:2 by Martin Sjölund, 12 years ago

Owner: changed from somebody to Martin Sjölund
Status: newassigned

comment:3 by Martin Sjölund, 12 years ago

Resolution: fixed
Status: assignedclosed

Fixed in r12733 (see #1776). We now print a warning saying this is bad.

Note: See TracTickets for help on using tickets.