Opened 9 years ago

Closed 9 years ago

#3420 closed defect (fixed)

List.find() causes segmentation fault

Reported by: Jan Silar Owned by: Martin Sjölund
Priority: high Milestone: 1.9.3
Component: Code Generation Version: trunk
Keywords: Cc:

Description (last modified by Per Östlund)

When List.find is called and later fail() is called than the latter call causes segmentation fault.

To reproduce the problem add somewhere:

 _ := List.find({1,2,3,4}, findTestF);
  fail();

...

protected function findTestF
  input Integer inI;
  output Integer outI;
algorithm
  outI := match inI
    case 3
    then 9;
  end match;
end findTestF;

Change History (4)

comment:1 by Per Östlund, 9 years ago

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

Martin is working on this. Prefer using List functions that takes functions returning true or false instead of succeeding or failing though, it's more efficient since fail/matchcontinue costs more than checking a boolean. In this case we don't seem to have a specific List function that does the equivalent of List.find, but you could do e.g. someMapFunc(List.getMemberOnTrue({1, 2, 3, 4}, isThree)) (or just implement List.findOnTrue).

comment:2 by Per Östlund, 9 years ago

Description: modified (diff)

comment:3 by Per Östlund, 9 years ago

List.find has now been replaced with List.mapFirst, and List.find is instead the old List.selectFirst. See 1981ce9. The issue in this ticket still needs to be fixed though.

comment:4 by Martin Sjölund, 9 years ago

Component: UnknownCode Generation
Milestone: Future1.9.3
Resolution: fixed
Status: assignedclosed

Fixed the bug in 9138159.

Note: See TracTickets for help on using tickets.