Errors raised by evaluating a CGC in interactive are not caught

Bug #697929 reported by Matt Giuca
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mars
Fix Released
High
Matt Giuca

Bug Description

Given the program:

def undefined :: a = error("Undefined")

Type at the interactive prompt:

?> undefined
Uncaught Mercury exception:
mars_error("Undefined")
(Mars terminates)

Expected behaviour:

Runtime Error: Undefined
(Mars prompt resumes)

In the LLVM backend, this same scenario results in a segfault by dereferencing NULL.

Related branches

Revision history for this message
Matt Giuca (mgiuca) wrote :

Hm. It looks like this bug was fixed (or at least, that particular example, disregarding the LLVM backend) in trunk r1184 (merge from branch separate-globals) as part of fixing bug #699721. In that branch, the entire framework for calling CGCs changed (no longer calls them implicitly when mentioning a varname; there is an explicit ld_cgc instruction to call them), so it is not surprising that this accidentally got fixed.

(The bug was probably due to the implicit mention of a variable not being surrounded by a try.)

Revision history for this message
Matt Giuca (mgiuca) wrote :

Fixed in trunk r1184.

Yes, this was entirely fixed by that branch in January (I just didn't notice until now). The bug was caused because in interactive, exec_stmt_internal would do the following:
1. Try (execute the statement) catch (print error cleanly).
2. Print the result.

In the case of CGCs, prior to trunk r1184, the execution of the statement simply returned the thunk object, which didn't do any computation. Printing the result forced the evaluation of the CGC, which caused the error to not be caught.

As of r1184, all of the infrastructure has changed. Executors can no longer return thunks (the eval_and_show_var method is totally gone). The code explicitly executes a ld_cgc instruction in the first step, inside the try block. Therefore, this is totally fixed. Also, tested on the LLVM branch and it worked fine.

Changed in mars:
status: Triaged → Fix Committed
Matt Giuca (mgiuca)
Changed in mars:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.