Fix crah in the optimizer profiler.
Merge pull request #1672 from nouiz/fix_opt_profiler

[MRG]Fix opt profiler