1 <?xml version="1.0" encoding="iso-8859-1"?>
3 <title>What to do when something goes wrong</title>
5 <indexterm><primary>problems</primary></indexterm>
7 <para>If you still have a problem after consulting this section,
8 then you may have found a <emphasis>bug</emphasis>—please
9 report it! See <xref linkend="bug-reporting"/> for details on how to
10 report a bug and a list of things we'd like to know about your bug.
11 If in doubt, send a report—we love mail from irate users
14 <para>(<xref linkend="vs-Haskell-defn"/>, which describes Glasgow
15 Haskell's shortcomings vs. the Haskell language definition, may
16 also be of interest.)</para>
18 <sect1 id="wrong-compiler">
19 <title>When the compiler “does the wrong thing”</title>
21 <indexterm><primary>compiler problems</primary></indexterm>
22 <indexterm><primary>problems with the compiler</primary></indexterm>
26 <term>“Help! The compiler crashed (or `panic'd)!”</term>
28 <para>These events are <emphasis>always</emphasis> bugs in
29 the GHC system—please report them.</para>
34 <term>“This is a terrible error message.”</term>
36 <para>If you think that GHC could have produced a better
37 error message, please report it as a bug.</para>
42 <term>“What about this warning from the C
43 compiler?”</term>
45 <para>For example: “…warning: `Foo' declared
46 `static' but never defined.” Unsightly, but shouldn't
52 <term>Sensitivity to <filename>.hi</filename> interface files:</term>
54 <para>GHC is very sensitive about interface files. For
55 example, if it picks up a non-standard
56 <filename>Prelude.hi</filename> file, pretty terrible things
57 will happen. If you turn on
58 <option>-fno-implicit-prelude</option><indexterm><primary>-fno-implicit-prelude
59 option</primary></indexterm>, the compiler will almost
60 surely die, unless you know what you are doing.</para>
62 <para>Furthermore, as sketched below, you may have big
63 problems running programs compiled using unstable
69 <term>“I think GHC is producing incorrect code”:</term>
71 <para>Unlikely :-) A useful be-more-paranoid option to give
73 <option>-dcore-lint</option><indexterm><primary>-dcore-lint
74 option</primary></indexterm>; this causes a
75 “lint” pass to check for errors (notably type
76 errors) after each Core-to-Core transformation pass. We run
77 with <option>-dcore-lint</option> on all the time; it costs
78 about 5% in compile time.</para>
83 <term>“Why did I get a link error?”</term>
85 <para>If the linker complains about not finding
86 <literal>_<something>_fast</literal>,
87 then something is inconsistent: you probably didn't compile
88 modules in the proper dependency order.</para>
93 <term>“Is this line number right?”</term>
95 <para>On this score, GHC usually does pretty well,
96 especially if you “allow” it to be off by one or
97 two. In the case of an instance or class declaration, the
98 line number may only point you to the declaration, not to a
99 specific method.</para>
101 <para>Please report line-number errors that you find
102 particularly unhelpful.</para>
108 <sect1 id="wrong-compilee">
109 <title>When your program “does the wrong thing”</title>
111 <indexterm><primary>problems running your program</primary></indexterm>
113 <para>(For advice about overly slow or memory-hungry Haskell
114 programs, please see <xref
115 linkend="sooner-faster-quicker"/>).</para>
120 <term>“Help! My program crashed!”</term>
122 <para>(e.g., a `segmentation fault' or `core dumped')
123 <indexterm><primary>segmentation
124 fault</primary></indexterm></para>
126 <para>If your program has no foreign calls in it, and no
127 calls to known-unsafe functions (such as
128 <literal>unsafePerformIO</literal>) then a crash is always a
129 BUG in the GHC system, except in one case: If your program
130 is made of several modules, each module must have been
131 compiled after any modules on which it depends (unless you
132 use <filename>.hi-boot</filename> files, in which case these
133 <emphasis>must</emphasis> be correct with respect to the
134 module source).</para>
136 <para>For example, if an interface is lying about the type
137 of an imported value then GHC may well generate duff code
138 for the importing module. <emphasis>This applies to pragmas
139 inside interfaces too!</emphasis> If the pragma is lying
140 (e.g., about the “arity” of a value), then duff
141 code may result. Furthermore, arities may change even if
144 <para>In short, if you compile a module and its interface
145 changes, then all the modules that import that interface
146 <emphasis>must</emphasis> be re-compiled.</para>
148 <para>A useful option to alert you when interfaces change is
149 <option>-hi-diffs</option><indexterm><primary>-hi-diffs
150 option</primary></indexterm>. It will run
151 <command>diff</command> on the changed interface file,
152 before and after, when applicable.</para>
154 <para>If you are using <command>make</command>, GHC can
155 automatically generate the dependencies required in order to
156 make sure that every module <emphasis>is</emphasis>
157 up-to-date with respect to its imported interfaces. Please
158 see <xref linkend="sec-makefile-dependencies"/>.</para>
160 <para>If you are down to your
161 last-compile-before-a-bug-report, we would recommend that
162 you add a <option>-dcore-lint</option> option (for extra
163 checking) to your compilation options.</para>
165 <para>So, before you report a bug because of a core dump,
166 you should probably:</para>
169 % rm *.o # scrub your object files
170 % make my_prog # re-make your program; use -hi-diffs to highlight changes;
171 # as mentioned above, use -dcore-lint to be more paranoid
172 % ./my_prog ... # retry...
175 <para>Of course, if you have foreign calls in your program
176 then all bets are off, because you can trash the heap, the
177 stack, or whatever.</para>
182 <term>“My program entered an `absent' argument.”</term>
184 <para>This is definitely caused by a bug in GHC. Please
185 report it (see <xref linkend="bug-reporting"/>).</para>
190 <term>“What's with this `arithmetic (or `floating')
191 exception' ”?</term>
193 <para><literal>Int</literal>, <literal>Float</literal>, and
194 <literal>Double</literal> arithmetic is
195 <emphasis>unchecked</emphasis>. Overflows, underflows and
196 loss of precision are either silent or reported as an
197 exception by the operating system (depending on the
198 platform). Divide-by-zero <emphasis>may</emphasis> cause an
199 untrapped exception (please report it if it does).</para>
209 ;;; Local Variables: ***
211 ;;; sgml-parent-document: ("users_guide.xml" "book" "chapter") ***