Opened 10 years ago

Closed 10 years ago

#3256 closed defect (fixed)

Memory leak in ModelicaSimulationError?

Reported by: Rüdiger Franke Owned by: Rüdiger Franke
Priority: critical Milestone: 1.9.3
Component: Cpp Run-time Version: trunk
Keywords: Cc: Nils Menager, Volker Waurich, Niklas Worschech, Martin Flehmig

Description

r25329 (re-)commits the code:

class ModelicaSimulationError : public std::runtime_error 
{ 
  public: 
    ModelicaSimulationError(SIMULATION_ERROR error_id, const std::string& error_info) 
    : runtime_error(strdup(error_info.c_str())) 
    , _error_id(error_id) 
    { 
    } 

Who frees the memory allocated with strdup?

Change History (5)

comment:1 by Marcus Walther, 10 years ago

Owner: changed from Marcus Walther to Niklas Worschech
Status: newassigned

comment:2 by Marcus Walther, 10 years ago

Cc: Martin Flehmig added

comment:3 by Adrian Pop, 10 years ago

I remember I added the strdup because sometimes crashed on throw.
You can try to remove it and see which models fail and why.

Version 0, edited 10 years ago by Adrian Pop (next)

comment:4 by Rüdiger Franke, 10 years ago

Owner: changed from Niklas Worschech to Rüdiger Franke

comment:5 by Rüdiger Franke, 10 years ago

Resolution: fixed
Status: assignedclosed

I think the overloaded what() method was the problem. It created the message in a local variable and returned a pointer to it. r25356 creates the message during construction instead, exploiting its storage in std::runtime_error.

Last edited 10 years ago by Rüdiger Franke (previous) (diff)
Note: See TracTickets for help on using tickets.