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