empirical-soft / empirical-lang

A language for time-series analysis
https://www.empirical-soft.com/
Other
168 stars 13 forks source link

Quitting the REPL after an "unfinished" line causes a crash #18

Closed chrisaycock closed 5 years ago

chrisaycock commented 5 years ago

This problem only started after yesterday's fix. Ie, solving one crash in ANTLR has led to another.

Empirical version 0.1.0-10-ge074929
Copyright (C) 2019 Empirical Software Solutions, LLC

>>> 1 +
line 1:2 no viable alternative at input '+'
Error: unable to parse

>>> quit
Segmentation fault: 11

As explained in the bug report today, shared_ptr won't work. The above crash is evidence of that.


For posterity: The exact issue is that ANTLR's error handling relies on exception objects that maintain pointers of state. Only in some cases are those pointers freed.

In C++, throw by default copies the exception object and then invokes its destructor; a catch will receive an exception object whose destructor has previously been evoked!