<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged clojure.main</title>
<link>https://ask.clojure.org/index.php/tag/clojure.main</link>
<description></description>
<item>
<title>clojure.main/report-error contains a call to pprint which may throw, obscuring the real failure</title>
<link>https://ask.clojure.org/index.php/11489/clojure-report-error-contains-pprint-which-obscuring-failure</link>
<description>&lt;p&gt;See the gist: &lt;a rel=&quot;nofollow&quot; href=&quot;https://gist.github.com/karolinepauls/d5e6398dcfd25e6c2f36abcd6b9eba98&quot;&gt;https://gist.github.com/karolinepauls/d5e6398dcfd25e6c2f36abcd6b9eba98&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I have produced some preliminary patches, how do I proceed from now? I suppose I need to sign the CA and request a Jira account?&lt;/p&gt;
&lt;p&gt;From the gist:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;The problem reproduced here occurs when an exception is thrown from&lt;br&gt;
user code and reaches clojure.main code responsible for exception&lt;br&gt;
reporting. Due to the use of pprint, reporting code can fail,&lt;br&gt;
obscuring the error and printing a rather unexpected Java stack trace,&lt;br&gt;
which is probably most obscure in case of StackOverflow.&lt;/p&gt;
&lt;p&gt;The root cause is potentially buggy ex-info (ex-data with values&lt;br&gt;
having broken pprint methods or reference cycles, like&lt;br&gt;
&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/overtone/at-at/issues/20&quot;&gt;https://github.com/overtone/at-at/issues/20&lt;/a&gt;) being passed to&lt;br&gt;
Throwable-&amp;gt;map in clojure.main/report-error. Throwable-&amp;gt;map itself&lt;br&gt;
calls ex-data in a couple of places.&lt;/p&gt;
&lt;p&gt;The &quot;less simple&quot; of the attached patches replaces :clojure.main/trace&lt;br&gt;
(the result of Throwable-&amp;gt;map) in the report, however an even more&lt;br&gt;
advanced one would be able to replace ex-data everywhere in&lt;br&gt;
:clojure.main/trace where it can occur.&lt;/p&gt;
&lt;p&gt;Being able to narrow down which part of the report caused pprint to&lt;br&gt;
fail is an open problem - I haven't looked much into clojure.pprint&lt;br&gt;
itself.&lt;/p&gt;
&lt;p&gt;In the patch drafts, I haven't considered the intricacies of reporting&lt;br&gt;
errors reporting errors - I think a Java stack trace should be enough,&lt;br&gt;
otherwise what if we get another nasty ex-data when reporting an error&lt;br&gt;
reporting an error reporting an error?&lt;/p&gt;
&lt;p&gt;I also haven't checked if it's possible to break pprint for things&lt;br&gt;
other than ex-data keys/values - maybe exceptions or even stack frames&lt;br&gt;
themselves? Those cases though should be less common.&lt;/p&gt;
&lt;p&gt;I was basing on the master branch Clojure, commit 5451cee0 when&lt;br&gt;
preparing and testing patch drafts.&lt;/p&gt;
&lt;/blockquote&gt;
</description>
<category>REPL</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11489/clojure-report-error-contains-pprint-which-obscuring-failure</guid>
<pubDate>Mon, 17 Jan 2022 00:01:25 +0000</pubDate>
</item>
</channel>
</rss>