[m-rev.] diff: workaround deep profiler bug
Julien Fischer
juliensf at csse.unimelb.edu.au
Thu Apr 5 12:45:37 AEST 2007
Zoltan, PeterW and myself have identified the problem that has been
causing the deep profiler to seg fault. With the following diff I can
now bootstrap the compiler in asm_fast.gc.profdeep and pass all but one
of the relevant test cases. (The failing test case seems to be related
to the change in quantification using tree_bitsets not working with the
deep profiling transformation.)
Estimated hours taken: 5 recently, lots more in the past.
Branches: main
Workaround the problem that has been causing the deep profiler to seg fault.
Fix some broken documentation.
Fix some test case failure in deep profiling grades.
runtime/mercury_conf_param.h:
Do not define MR_CHECK_DU_EQ if MR_DEEP_PROFILING is enabled.
The short circuit enabled by the former causes execution to miss a
call to the exit port code, which in turn corrupts the data
structures used by the deep profiler.
runtime/mercury_unify_compare_body.h:
Document the problem with MR_CHECK_DU_EQ and deep profiling.
compiler/options.m:
doc/user_guide.texi:
s/--no-warn-known-bad-format-call/--no-warn-bad-format-calls/
s/--warn-unknown-format-call/--warn-unknown-format-calls/
tests/hard_coded/profdeep_seg_fault.m:
Include an explanation of why this test was failing.
tests/general/Mercury.options:
Run string_format_test_{2,3} with `--no-warn-known-bad-format-calls'
since the implementation of that check catches an exception and
this will cause a compiler built in a deep profiling grade to abort.
tests/invalid/Mmakefile:
Don't run the string_format_bad and string_format_unknown tests
in deep profiling grades for the same reason.
test/hard_coded/Mmakefile:
The test case null_char should not be run in deep profiling grades
since it catches exceptions.
Julien.
Index: compiler/options.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.551
diff -u -r1.551 options.m
--- compiler/options.m 2 Mar 2007 02:56:38 -0000 1.551
+++ compiler/options.m 5 Apr 2007 02:39:27 -0000
@@ -2958,11 +2958,11 @@
"\tthat cannot be proved to terminate. This option is only",
"\tenabled when termination analysis is enabled.",
"\t(See the ""Termination Analysis Options"" section below).",
- "--no-warn-known-bad-format-call",
+ "--no-warn-known-bad-format-calls",
"\tDo not warn about calls to string.format or io.format that",
"\tthe compiler knows for sure contain mismatches between the",
"\tformat string and the supplied values.",
- "--warn-unknown-format-call",
+ "--warn-unknown-format-calls",
"\tWarn about calls to string.format or io.format for which",
"\tthe compiler cannot tell whether there are any mismatches",
"\tbetween the format string and the supplied values.",
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.514
diff -u -r1.514 user_guide.texi
--- doc/user_guide.texi 3 Mar 2007 06:19:20 -0000 1.514
+++ doc/user_guide.texi 5 Apr 2007 02:39:27 -0000
@@ -6146,15 +6146,15 @@
(See @ref{Termination analysis options} for further details).
@sp 1
- at item --no-warn-known-bad-format-call
- at findex --no-warn-known-bad-format-call
+ at item --no-warn-known-bad-format-calls
+ at findex --no-warn-known-bad-format-calls
Do not warn about calls to string.format or io.format that
the compiler knows for sure contain mismatches between the format
string and the supplied values.
@sp 1
- at item --warn-unknown-format-call
- at findex --warn-unknown-format-call
+ at item --warn-unknown-format-calls
+ at findex --warn-unknown-format-calls
Warn about calls to string.format or io.format for which
the compiler cannot tell whether there are any mismatches between
the format string and the supplied values.
Index: runtime/mercury_conf_param.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_conf_param.h,v
retrieving revision 1.94
diff -u -r1.94 mercury_conf_param.h
--- runtime/mercury_conf_param.h 2 Mar 2007 02:56:40 -0000 1.94
+++ runtime/mercury_conf_param.h 5 Apr 2007 02:39:27 -0000
@@ -586,7 +586,11 @@
#undef MR_DEEP_PROFILING_MEMORY
#endif
-#ifndef MR_DISABLE_CHECK_DU_EQ
+/*
+** XXX MR_CHECK_DU_EQ is currently not compatible with deep profiling.
+** See the comment in mercury_unify_compare_body.h for an explanation.
+*/
+#if !defined(MR_DISABLE_CHECK_DU_EQ) && !defined(MR_DEEP_PROFILING)
#define MR_CHECK_DU_EQ
#endif
Index: runtime/mercury_unify_compare_body.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_unify_compare_body.h,v
retrieving revision 1.44
diff -u -r1.44 mercury_unify_compare_body.h
--- runtime/mercury_unify_compare_body.h 16 Feb 2007 05:36:28 -0000 1.44
+++ runtime/mercury_unify_compare_body.h 5 Apr 2007 02:39:27 -0000
@@ -186,7 +186,13 @@
int cur_slot;
int arity;
int i;
-
+ /*
+ ** XXX MR_CHECK_DU_EQ doesn't not currently work in deep profiling grades
+ ** since the resulting short circuit means that the exit port call
+ ** for the unification or comparison predicate is never made.
+ ** This results in the data structures used by the deep profiler
+ ** becoming corrupted.
+ */
#ifdef MR_CHECK_DU_EQ
#ifdef select_compare_code
if (x == y) {
Index: tests/general/Mercury.options
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/general/Mercury.options,v
retrieving revision 1.2
diff -u -r1.2 Mercury.options
--- tests/general/Mercury.options 26 Jul 2004 00:35:48 -0000 1.2
+++ tests/general/Mercury.options 5 Apr 2007 02:39:27 -0000
@@ -20,3 +20,13 @@
# tracking it down.
MLFLAGS-string_test = --no-strip
+# If the compiler is build in a .profdeep grade then attempting to compile
+# these tests with `--warn-known-bad-format-call' will abort since the
+# code that implements that check catches an exception. The deep profiler
+# cannot currently handle code that catches exceptions.
+# Also, it's not worth doing the check for these test cases anyway since
+# the entire point of them is to check that string.format is aborts when
+# passed an invalid format string.
+#
+MCFLAGS-string_format_test_2 = --no-warn-known-bad-format-calls
+MCFLAGS-string_format_test_3 = --no-warn-known-bad-format-calls
Index: tests/hard_coded/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/Mmakefile,v
retrieving revision 1.313
diff -u -r1.313 Mmakefile
--- tests/hard_coded/Mmakefile 12 Mar 2007 02:19:31 -0000 1.313
+++ tests/hard_coded/Mmakefile 5 Apr 2007 02:39:27 -0000
@@ -143,7 +143,6 @@
nonascii \
nondet_copy_out \
nondet_ctrl_vn \
- null_char \
nullary_ho_func \
one_member \
opt_dup_bug \
@@ -440,6 +439,7 @@
init_excp \
map_merge_test \
mutable_excp \
+ null_char \
io_globals_deadlock \
test_array2d \
test_injection \
Index: tests/hard_coded/profdeep_seg_fault.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/profdeep_seg_fault.m,v
retrieving revision 1.2
diff -u -r1.2 profdeep_seg_fault.m
--- tests/hard_coded/profdeep_seg_fault.m 20 Nov 2006 05:30:00 -0000 1.2
+++ tests/hard_coded/profdeep_seg_fault.m 5 Apr 2007 02:39:27 -0000
@@ -3,6 +3,10 @@
% When compiled in a deep profiling grade at -O2 or below it aborts with a
% segmentation fault.
%
+% The problem was caused by short circuit in the code for
+% builtin.{unify, compare} that is enabled by MR_CHECK_DU_EQ causing execution
+% to avoid calling the exit port code for builtin.{unify, compare}.
+%
:- module profdeep_seg_fault.
:- interface.
Index: tests/invalid/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/Mmakefile,v
retrieving revision 1.210
diff -u -r1.210 Mmakefile
--- tests/invalid/Mmakefile 18 Mar 2007 23:35:03 -0000 1.210
+++ tests/invalid/Mmakefile 5 Apr 2007 02:39:27 -0000
@@ -167,8 +167,6 @@
state_vars_test3 \
state_vars_test4 \
state_vars_test5 \
- string_format_bad \
- string_format_unknown \
tc_err1 \
tc_err2 \
test_may_duplicate \
@@ -242,6 +240,14 @@
TYPE_SPEC_MODULES = \
type_spec
+# The following don't work when bootstrapping the compiler in .profdeep
+# grades since the code in the compiler that implements these checks
+# catches exceptions.
+#
+NON_PROFDEEP_MODULES = \
+ string_format_bad \
+ string_format_unknown
+
# XXX we do not yet pass the following tests:
# foreign_type_line_number (due to some errors being reported in .c
# files and .mh files rather than in .m files,
@@ -283,6 +289,12 @@
TRAILED_PROGS = $(TRAILED_MODULES)
endif
+ifeq "$(findstring profdeep,$(GRADE))" ""
+ NON_PROFDEEP_PROGS = $(NON_PROFDEEP_MODULES)
+else
+ NON_PROFDEEP_PROGS =
+endif
+
# The java back-end ignores pragma type_spec, so it doesn't diagnose errors
# in them. (XXX Perhaps the code to ignore them in make_hlds.m should be moved
# to after the error-checking?)
@@ -297,6 +309,7 @@
$(RESERVE_TAG_PROGS) \
$(TRAILED_PROGS) \
$(TYPE_SPEC_PROGS)
+ $(NON_PROFDEEP_PROGS)
#-----------------------------------------------------------------------------#
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list