Calls to error or get_env with '\0' in string crash Mars

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

Bug Description

Expected:
?> error(['a', '\0', 'b'])
Runtime Error: ab

Actual:
?> error(['a', '\0', 'b'])
Uncaught Mercury exception:
univ_cons(univ_cons(univ_cons(software_error("string.from_char_list: null character in list"))))

This is due to a call to string.from_char_list in interpret.m:mars_value_to_string, which crashes Mercury if it has a '\0'. Mercury strings may not have null characters in them; Mars strings can. This should be solved on a builtin-by-builtin basis. mars_value_to_string should return a list(char) instead, and the builtins should deal with null characters accordingly. error should ignore the characters; get_env should return the empty string (as if a lookup failed).

The string.semidet_from_char_list predicate is useful.

Related branches

Matt Giuca (mgiuca)
Changed in mars:
importance: Medium → High
Revision history for this message
Matt Giuca (mgiuca) wrote :

Fixed in trunk r981.

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.