View Issue Details
573 [mercury] Bug minor always 2024-02-22 15:16 2024-02-23 16:44
wangp  
zs  
normal  
resolved  
fixed  
none    
none  
   
mmc --make regression remaking .opt files unnecessarily
Commit 8b5cc5125 ("Use string builders for .*opt files.")
introduces a regression where .opt files are remade unnecessarily.
Using the samples/diff program for example:

    % mmc --intermod-opt -j32 -m diff
    [... trimmed output ...]
    Making diff

    % touch match.m

    % mmc --intermod-opt -m diff
    Making Mercury/int3s/match.int3
    Making Mercury/ints/match.int
    Making Mercury/opts/match.opt
    ** Nothing to be done for `diff'.

    % mmc --intermod-opt -m diff
    Making Mercury/int3s/match.int3
    Making Mercury/opts/match.opt
    ** Nothing to be done for `diff'.

where every subsequent invocation of mmc --make will keep remaking match.opt.
 
Notes
(0001231)
zs   
2024-02-23 16:44   
Fix committed 2024 feb 23.




View Issue Details
572 [mercury] Bug minor always 2024-02-19 10:44 2024-02-20 17:38
juliensf  
zs  
normal  
resolved  
fixed  
none    
none  
   
Code generator abort in debugging grades
The attached is a cut-down version of a program that causes an abort in debugging grades originally reported by Volker Wysk on the reviews list on 3 January 2024. Compiling it in a debugging grade results in:

Uncaught Mercury exception:
Software Error: predicate `ll_backend.liveness.require_equal'/4: Unexpected: branches of if-then-else disagree on liveness
First: ArgDesc_3, Values_4, MDef_5, Default_6, TypeClassInfo_for_argument_21, TypeInfo_22_22
Rest: ArgDesc_3, Values_4, MDef_5, Default_6, TypeInfo_22_22
mmc -s asm_fast.gc.debug -C bug572.m

https://lists.mercurylang.org/archives/reviews/2024-January/024517.html
bug572.m (2,643 bytes) 2024-02-19 10:44
https://bugs.mercurylang.org/file_download.php?file_id=329&type=bug
 
Notes
(0001230)
zs   
2024-02-20 17:38   
Fix committed 2024 02 20.




View Issue Details
571 [mercury] Feature Request minor have not tried 2024-02-09 15:29 2024-02-09 15:29
juliensf  
 
normal  
new  
open  
none    
none  
   
Improve unsatisfiable typeclass constraint errors
The attached program generates the following error messages:

    unsat_error.m:015: In clause for predicate `create_schedule'/3:
    unsat_error.m:015: unsatisfiable typeclass constraint:
    unsat_error.m:015: `unsat_error.logger(L)'.

For cases like this it would better if we could provide the user some indication of the cause of this constraint being unsatisfiable, namely that the there is no constraint on the type variable Logger in the predicate declaration.
unsat_error.m (314 bytes) 2024-02-09 15:29
https://bugs.mercurylang.org/file_download.php?file_id=328&type=bug
 
There are no notes attached to this issue.




View Issue Details
570 [mercury] Bug crash always 2023-12-13 13:20 2023-12-13 19:06
wangp  
zs  
normal  
assigned  
open  
none    
none  
   
merge switch after switch bug
The compiler aborts during the deforestation, when simplify tries to merge a switch after switch:

% mmc -C --deforestation bug.m
Uncaught Mercury exception:
Software Error: map.lookup: key not found
        Key Type: parse_tree.prog_data.cons_id
        Key Value: cons(qualified(unqualified("bug"), "prepare_edit"), 0, type_ctor(qualified(unqualified("bug"), "prepare_temp"), 0))
        Value Type: uint
Stack dump follows:
   0 pred exception.throw/1-0 (erroneous) (exception.m:312)
   1 pred require.error/1-0 (erroneous) (require.m:173)
   2 pred require.report_lookup_error/3-0 (erroneous) (require.m:277)
   3 pred map.lookup/3-0 (det) (map.m:1333)
   4 pred check_hlds.simplify.simplify_goal_conj.build_maps_second_switch_cons_id/5-0 (det) (simplify_goal_conj.m:663)
   5 pred check_hlds.simplify.simplify_goal_conj.build_maps_second_switch/7-0 (det) (simplify_goal_conj.m:648)
   6 pred check_hlds.simplify.simplify_goal_conj.try_to_merge_switch_after_switch/6-0 (det) (simplify_goal_conj.m:586)
   7 6* pred check_hlds.simplify.simplify_goal_conj.simplify_conj/10-0 (det) (simplify_goal_conj.m:285 and others)
  13 pred check_hlds.simplify.simplify_goal_conj.simplify_goal_plain_conj/10-0 (det) (simplify_goal_conj.m:82)
  14 pred check_hlds.simplify.simplify_goal.simplify_goal_expr/10-0 (det) (simplify_goal.m:331)
  15 pred check_hlds.simplify.simplify_goal.simplify_goal/8-0 (det) (simplify_goal.m:285)
  16 2* pred check_hlds.simplify.simplify_goal_switch.simplify_switch_cases/15-0 (det) (simplify_goal_switch.m:278 and others)
  18 pred check_hlds.simplify.simplify_goal_switch.simplify_goal_switch/10-0 (det) (simplify_goal_switch.m:85)
  19 pred check_hlds.simplify.simplify_goal.simplify_goal_expr/10-0 (det) (simplify_goal.m:344)
  20 pred check_hlds.simplify.simplify_goal.simplify_goal/8-0 (det) (simplify_goal.m:285)
  21 pred check_hlds.simplify.simplify_proc.do_simplify_top_level_goal/6-0 (det) (simplify_proc.m:708)
  22 pred check_hlds.simplify.simplify_proc.simplify_top_level_goal/7-0 (det) (simplify_proc.m:611)
  23 pred check_hlds.simplify.simplify_proc.simplify_goal_update_vars_in_proc/11-0 (det) (simplify_proc.m:201)
  24 pred transform_hlds.pd_util.pd_simplify_goal/5-0 (det) (pd_util.m:264)
  25 pred transform_hlds.deforest.push_goal_into_goal/8-0 (det) (deforest.m:1844)
  26 pred transform_hlds.deforest.handle_deforestation/9-0 (det) (deforest.m:761)
  27 3* pred transform_hlds.deforest.deforest_conj/6-0 (det) (deforest.m:566 and others)
  30 pred transform_hlds.deforest.deforest_goal_expr/6-0 (det) (deforest.m:319)
  31 pred transform_hlds.deforest.deforest_goal/4-0 (det) (deforest.m:294)
  32 pred transform_hlds.deforest.deforest_proc_deltas/5-0 (det) (deforest.m:230)
  33 pred transform_hlds.deforest.deforest_proc/3-0 (det) (deforest.m:204)
  34 5* pred list.foldl/4-0 (det) (list.m:3731 and others)
  39 pred transform_hlds.deforest.deforest_module/3-0 (det) (deforest.m:132)
  40 pred top_level.mercury_compile_middle_passes.maybe_deforestation/7-0 (det) (mercury_compile_middle_passes.m:1130)
  41 pred top_level.mercury_compile_middle_passes.middle_pass/10-0 (det) (mercury_compile_middle_passes.m:232)
  42 pred top_level.mercury_compile_main.after_front_end_passes/15-0 (det) (mercury_compile_main.m:2177)
  43 pred top_level.mercury_compile_main.process_augmented_module/17-0 (det) (mercury_compile_main.m:2052)
  44 pred top_level.mercury_compile_main.augment_and_process_module/15-0 (det) (mercury_compile_main.m:1926)
  45 pred list.map_foldl3/9-0 (det) (list.m:4080)
  46 pred top_level.mercury_compile_main.augment_and_process_all_submodules/16-0 (det) (mercury_compile_main.m:1872)
  47 pred top_level.mercury_compile_main.read_augment_and_process_module_ok/17-0 (det) (mercury_compile_main.m:1730)
  48 pred top_level.mercury_compile_main.read_augment_and_process_module/15-0 (det) (mercury_compile_main.m:1672)
  49 pred top_level.mercury_compile_main.do_process_compiler_arg/13-0 (det) (mercury_compile_main.m:1238)
  50 pred top_level.mercury_compile_main.setup_and_process_compiler_arg/17-0 (det) (mercury_compile_main.m:1102)
  51 pred top_level.mercury_compile_main.setup_and_process_compiler_cmd_line_args/19-0 (det) (mercury_compile_main.m:1013)
  52 pred top_level.mercury_compile_main.do_op_mode_args/16-0 (det) (mercury_compile_main.m:859)
  53 pred top_level.mercury_compile_main.do_op_mode/14-0 (det) (mercury_compile_main.m:662)
  54 pred top_level.mercury_compile_main.main_after_setup/9-0 (det) (mercury_compile_main.m:614)
  55 pred top_level.mercury_compile_main.real_main_after_expansion/5-0 (det) (mercury_compile_main.m:315)
  56 pred top_level.mercury_compile_main.real_main/2-0 (det) (mercury_compile_main.m:153)
  57 pred mercury_compile.main/2-0 (det) (mercury_compile.m:32)
bug.m (2,436 bytes) 2023-12-13 13:20
https://bugs.mercurylang.org/file_download.php?file_id=327&type=bug
 
There are no notes attached to this issue.




View Issue Details
569 [mercury] Bug minor always 2023-12-04 12:26 2023-12-06 12:51
wangp  
wangp  
normal  
resolved  
fixed  
none    
none  
   
timestamp regression with nested submodules in mmc --make
Here is a problem with nested submodules attributed to commit 4d4ef3e3a "Cache timestamps by target file."

This sequence of commands:
```
#!/bin/sh
touch nested_module_test.m
mmc -m nested_module_test
sleep 1
echo --------
mmc -m nested_module_test
```

exhibits this incorrect behaviour:

Making Mercury/int3s/nested_module_test.int3
Making Mercury/int0s/nested_module_test.int0
Making Mercury/ints/nested_module_test.int
Making Mercury/cs/nested_module_test.c
Making Mercury/os/nested_module_test.o
Making nested_module_test
--------
Making Mercury/int3s/nested_module_test.int3
Making Mercury/os/nested_module_test.sub.o
Making nested_module_test

where nested_module_test.sub.o and nested_module_test are re-made by the second call to mmc --make, when they should already be up-to-date.


The previous (correct) behaviour is:

Making Mercury/int3s/nested_module_test.int3
Making Mercury/int0s/nested_module_test.int0
Making Mercury/ints/nested_module_test.int
Making Mercury/cs/nested_module_test.c
Making Mercury/os/nested_module_test.o
Making Mercury/os/nested_module_test.sub.o
Making nested_module_test
--------
Making Mercury/int3s/nested_module_test.int3
** Nothing to be done for `nested_module_test'.

[Actually, nested_module_test.int3 should not need to be remade either - that is a long-standing bug, but a minor one.]
nested_module_test.m (651 bytes) 2023-12-04 12:26
https://bugs.mercurylang.org/file_download.php?file_id=326&type=bug
 
Notes
(0001227)
zs   
2023-12-05 12:58   
It is possible that this is related to bug 568. Commit 764eab72a
touched make.timestamp.m in a way that removed the special treatment
of modules that are NOT the top modules of their source file.

I am testing a fix for 568 that reverses that commit, but also
fixes the old misleading documentation that led to it. That diff
may, or may not, also fix this bug. I have just posted it to m-rev.
(0001229)
wangp   
2023-12-06 12:51   
Fix committed 2023 dec 6.




View Issue Details
568 [mercury] Bug major always 2023-12-04 10:35 2023-12-05 13:42
wangp  
zs  
normal  
resolved  
fixed  
none    
none  
   
nested sub-modules broken in mmc --make
mmc --make fails to make programs making using of nested sub-modules.

The problem first appears with commit 764eab72a "Stop using module_dep_infos in computing filenames."

% mmc --make nested_module_test
** dependencies for `Mercury/int3s/nested_module_test.int3' do not exist: nested_module_test.sub.m
** This indicates a bug in `mmc --make'.
nested_module_test.m (651 bytes) 2023-12-04 10:35
https://bugs.mercurylang.org/file_download.php?file_id=325&type=bug
 
Notes
(0001228)
zs   
2023-12-05 13:42   
Fix committed 2023 dec 5.




View Issue Details
567 [mercury] Bug major always 2023-11-07 13:00 2023-11-08 17:59
wangp  
zs  
normal  
resolved  
fixed  
none    
none  
   
regression due to merging consecutive switches
I have bisected a regression to commit 43dd12bd5b9608dcd150ea0c7bdc1e3f256f15d2
"Merge consecutive switches on the same variable."

See the attached test case.

This is incorrect:

% mmc -O2 regression_merge_switches && ./regression_merge_switches
header(field_name("Message-ID"), header_value("Tue, 7 Nov 2023 12:29:43 +1100"))
header(field_name("Message-ID"), header_value("<20231107122943.GB219@example>"))

The correct output is this:

% mmc -O1 regression_merge_switches && ./regression_merge_switches
header(field_name("Date"), header_value("Tue, 7 Nov 2023 12:29:43 +1100"))
header(field_name("Message-ID"), header_value("<20231107122943.GB219@example>"))
regression_merge_switches.m (2,046 bytes) 2023-11-07 13:00
https://bugs.mercurylang.org/file_download.php?file_id=324&type=bug
 
Notes
(0001226)
zs   
2023-11-08 17:59   
Fix committed 2023 nov 8.




View Issue Details
566 [mercury] Bug minor always 2023-10-12 12:40 2023-10-16 17:01
wangp  
wangp  
normal  
resolved  
fixed  
none    
none  
   
undefined variable warnings with GNU Make 4.4.0.90
Since GNU Make 4.4.0.90, we get warnings about undefined variables '*' and '@':

/tmp/mmake.RTEA5X:64: warning: undefined variable '*'
/tmp/mmake.RTEA5X:64: warning: undefined variable '@'
/tmp/mmake.RTEA5X:64: warning: undefined variable '@'

The problem first appears with GNU Make commit 15dfad96d77c9445d11be939a5042675e4ca8c65 "[SV 63439, SV 63452] Don't warn on undefined internal variables"
https://git.savannah.gnu.org/cgit/make.git/commit/?id=15dfad96d77c9445d11be939a5042675e4ca8c65

The code that ultimately triggers these warnings is in Mmake.vars.in, from lines 374 onwards, that says:

# `TARGET_<prog>FLAGS' is used to pass different flags to <prog> for
# different targets. By setting MCFLAGS-foo, for example, you can add
# extra values to TARGET_MCFLAGS that will used only for compiling foo.m.
#
# For each program <prog>, `TARGET_<prog>FLAGS' expands to
# `$(<prog>FLAGS-$@)' and/or `$(<prog>FLAGS-$*)'.
# $@ and $* are the builtin variables that expand to the
# current target and (for pattern rules) the base name of the current target,
# respectively. So $* is used for flags variables used by pattern rules,
# whereas $@ is used for flags variables used by hard-coded rules,
# including the ones in the generated .dep files.
#
# The code below uses some tricky GNU Make hacks to avoid expanding
# <prog>FLAGS-$* and <prog>FLAGS-$@ if these vars are not defined,
# so that we can avoid spurious warnings if the warning about
# undefined variables is enabled.

 
Notes
(0001219)
zs   
2023-10-12 12:55   
Are you saying that the variable references that trigger bug
are the ones in the *comment* you quoted? That would seem to be
a serious issue in gnu make. Has this been reported to its maintainers?

For us, there is an obvious workaround: put something between
the $ and the @ or *, with a comment saying *why* that something is there.
(0001220)
wangp   
2023-10-12 13:09   
Sorry, not in the comment, but in the code that the comment is describing:

TARGET_GRADEFLAGS = \
  $(maybe-base-GRADEFLAGS-$(findstring undefined,\
        $(origin GRADEFLAGS-$(patsubst %_init,%,$*)))) \
  $(maybe-target-GRADEFLAGS-$(findstring undefined,\
          $(origin GRADEFLAGS-$(patsubst $(cs_subdir)%_init.c,%,$@))))
maybe-base-GRADEFLAGS- = $(GRADEFLAGS-$(patsubst %_init,%,$*))
maybe-base-GRADEFLAGS-undefined =
maybe-target-GRADEFLAGS- = $(GRADEFLAGS-$(patsubst $(cs_subdir)%_init.c,%,$@))
maybe-target-GRADEFLAGS-undefined =

etc.


It could well be a bug in GNU Make. Before reporting I'd like to understand the issue properly, and construct a smaller test case.
(0001221)
zs   
2023-10-12 13:26   
If you get the error for the occurrences of $* and $@ in those
variable definitions, then those occurrences are being expanded
at variable-definition-time. Both $* and $@ are defined with respect
to a make rule, and there is no rule here. Their evaluation should
be delayed until the variable being defined is actually used in a rule.
If it is evaluated at any time before then, then $* and $@ are unusable
in variable definitions, which I would classify as a serious regression.
(0001222)
wangp   
2023-10-12 15:46   
The warnings about $@ and $* being undefined are occurring when VPATH is being evaluated, outside of any rule.

The chain of references goes
VPATH -> MMAKE_VPATH -> UNIX_MERCURY_EXTRA_INIT_DIRS -> MERCURY_EXTRA_INIT_DIRS -> EXTRA_INIT_DIRS -> GRADESTRING -> ALL_GRADEFLAGS -> USUAL_GRADEFLAGS -> TARGET_GRADEFLAGS -> $* and $@
(0001223)
zs   
2023-10-12 16:02   
In what context is VPATH being evaluated? The condition of
of a ifeq/ifneq line? The search for a file? Because in both cases,
I can see why the new warning from make would be justified.

I can understand why VPATH depends on the grade; I don't see
why it should depend on a grade modified by *module-specific* flags,
as opposed to *program-specific* flags.
(0001224)
wangp   
2023-10-12 17:46   
VPATH is evaluated once before considering any target, and
this value of VPATH is used to find prerequisites of all targets (from what I gather).

Here is a makefile for demonstration:

    VPATH = srcs.$@ \
        $(shell echo Evaluating VPATH now for target [$@] >&2 )

    # Put foo.c in srcs.foo
    foo: foo.c
        @echo VPATH in recipe is $(VPATH)

    # Put bar.c in current dir
    bar: bar.c
        @echo VPATH in recipe is $(VPATH)

This is the log for `make --warn-undefined-variables -d -r foo`.
foo.c cannot be found because VPATH is set to "srcs.", and *not* "srcs.foo".

    GNU Make 4.4.1
    Built for x86_64-unknown-linux-gnu
    Copyright (C) 1988-2023 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    Reading makefiles...
    Reading makefile 'Makefile'...
    Makefile:1: warning: undefined variable '@'
    Makefile:1: warning: undefined variable '@'
    Evaluating VPATH now for target []
    Updating makefiles....
     Considering target file 'Makefile'.
      Looking for an implicit rule for 'Makefile'.
      No implicit rule found for 'Makefile'.
     Finished prerequisites of target file 'Makefile'.
     No need to remake target 'Makefile'.
    Updating goal targets....
    Considering target file 'foo'.
     Considering target file 'foo.c'.
      File 'foo.c' does not exist.
      Looking for an implicit rule for 'foo.c'.
      No implicit rule found for 'foo.c'.
     Finished prerequisites of target file 'foo.c'.
     Must remake target 'foo.c'.
    make: *** No rule to make target 'foo.c', needed by 'foo'. Stop.


This is the log for `make --warn-undefined-variables -d -r bar`.
bar.c exists in the current directory so it is found.
VPATH is evaluated again only when executing the recipe, now with $@ set to the target.

    GNU Make 4.4.1
    Built for x86_64-unknown-linux-gnu
    Copyright (C) 1988-2023 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    Reading makefiles...
    Reading makefile 'Makefile'...
    Makefile:1: warning: undefined variable '@'
    Makefile:1: warning: undefined variable '@'
    Evaluating VPATH now for target []
    Updating makefiles....
     Considering target file 'Makefile'.
      Looking for an implicit rule for 'Makefile'.
      No implicit rule found for 'Makefile'.
     Finished prerequisites of target file 'Makefile'.
     No need to remake target 'Makefile'.
    Updating goal targets....
    Considering target file 'bar'.
     File 'bar' does not exist.
     Considering target file 'bar.c'.
      Looking for an implicit rule for 'bar.c'.
      No implicit rule found for 'bar.c'.
     Finished prerequisites of target file 'bar.c'.
     No need to remake target 'bar.c'.
    Finished prerequisites of target file 'bar'.
    Must remake target 'bar'.
    Evaluating VPATH now for target [bar]
    Makefile:10: update target 'bar' due to: target does not exist
    echo VPATH in recipe is srcs.bar
    Putting child 0x557e7dcb1010 (bar) PID 18703 on the chain.
    Live child 0x557e7dcb1010 (bar) PID 18703
    VPATH in recipe is srcs.bar
    Reaping winning child 0x557e7dcb1010 PID 18703
    Removing child 0x557e7dcb1010 PID 18703 from chain.
    Successfully remade target file 'bar'.
    Directory srcs. cache invalidated (count 2 != command 4)


So what mmake tries to do with VPATH (i.e. trying to take into account target-specific flags to change where to look for prerequisites) probably never actually worked.
(0001225)
wangp   
2023-10-16 17:01   
Fix committed 2023-10-16




View Issue Details
208 [mercury] Bug feature N/A 2011-07-31 15:38 2023-10-08 12:24
aross  
juliensf  
normal  
resolved  
fixed  
none    
none  
   
add help and version command line options to mslice and mdice
-h and -v are pretty standard command line options, but mslice and mdice don't support them. For example:

ajrross@goofy:~$ mslice -h
unrecognized option `-h'

Since the usage information of both programs is already displayed when the user gives an incorrect number of arguments, -h could show the same information.
version rotd-2011-07-29
 
Notes
(0001218)
juliensf   
2023-10-08 12:24   
Fixed in commit 3513ed6.




View Issue Details
563 [mercury] Bug crash always 2022-08-03 13:04 2023-09-04 15:05
wangp  
zs  
normal  
resolved  
fixed  
none    
none  
   
type constructor for equivalence type not found
The compiler throws an exception when compiling the attached test case in hlc (and probably other MLDS grades).

quirks.m defines an equivalence type in the implementation which uses a type constructor that it imports:
    :- import_module set.
    :- type quirks == set(string).

But when generating code for a module that imports quirks.m, that type constructor is not found.

% mmake GRADE=hlc.gc getprop.depend
% mmake GRADE=hlc.gc getprop.c
% cat getprop.err
Uncaught Mercury exception:
Software Error: map.lookup: key not found
        Key Type: string
        Key Value: "set"
        Value Type: tree234.tree234(parse_tree.prog_data.type_ctor, hlds.hlds_data.hlds_type_defn)
Stack dump follows:
   0 pred exception.throw/1-0 (erroneous) (exception.m:313)
   1 pred require.error/1-0 (erroneous) (require.m:172)
   2 pred require.report_lookup_error/3-0 (erroneous) (require.m:276)
   3 pred map.lookup/3-0 (det) (map.m:1272)
   4 pred hlds.hlds_data.lookup_type_ctor_defn/3-0 (det) (hlds_data.m:598)
   5 func check_hlds.type_util.classify_type_ctor/2-0 (det) (type_util.m:1038)
   6 func ml_backend.mlds.mercury_type_to_mlds_type/2-0 (det) (mlds.m:2661)
   7 pred ml_backend.ml_code_util.ml_gen_local_var_decl/6-0 (det) (ml_code_util.m:998)
   8 pred ml_backend.ml_code_gen.ml_gen_local_var_decls/6-0 (det) (ml_code_gen.m:1392)
   9 pred ml_backend.ml_code_gen.ml_gen_goal/7-0 (det) (ml_code_gen.m:611)
  10 pred ml_backend.ml_proc_gen.ml_gen_proc_body/10-0 (det) (ml_proc_gen.m:1688)
  11 pred ml_backend.ml_proc_gen.ml_gen_proc/11-0 (det) (ml_proc_gen.m:620)
  12 pred list.foldl3/8-0 (det) (list.m:3556)
  13 pred ml_backend.ml_proc_gen.ml_gen_scc_code/10-0 (det) (ml_proc_gen.m:322)
  14 pred ml_backend.ml_proc_gen.ml_gen_scc/12-0 (det) (ml_proc_gen.m:227)
  15 pred ml_backend.ml_proc_gen.ml_gen_sccs/12-0 (det) (ml_proc_gen.m:211)
  16 pred ml_backend.ml_proc_gen.ml_gen_preds/9-0 (det) (ml_proc_gen.m:121)
  17 pred ml_backend.ml_top_gen.ml_code_gen/6-0 (det) (ml_top_gen.m:84)
  18 pred top_level.mercury_compile_mlds_back_end.mlds_backend/8-0 (det) (mercury_compile_mlds_back_end.m:128)
  19 pred top_level.mercury_compile_main.after_front_end_passes/13-0 (det) (mercury_compile_main.m:1930)
  20 pred top_level.mercury_compile_main.process_augmented_module/14-0 (det) (mercury_compile_main.m:1756)
  21 pred top_level.mercury_compile_main.augment_and_process_module/15-0 (det) (mercury_compile_main.m:1646)
  22 pred list.map_foldl3/9-0 (det) (list.m:3892)
  23 pred top_level.mercury_compile_main.augment_and_process_all_submodules/15-0 (det) (mercury_compile_main.m:1588)
  24 pred top_level.mercury_compile_main.read_augment_and_process_module_ok/13-0 (det) (mercury_compile_main.m:1420)
  25 pred top_level.mercury_compile_main.read_augment_and_process_module/11-0 (det) (mercury_compile_main.m:1362)
  26 pred top_level.mercury_compile_main.do_process_compiler_arg/10-0 (det) (mercury_compile_main.m:1138)
  27 pred top_level.mercury_compile_main.setup_and_process_compiler_arg/14-0 (det) (mercury_compile_main.m:1010)
  28 pred top_level.mercury_compile_main.setup_and_process_compiler_cmd_line_args/16-0 (det) (mercury_compile_main.m:929)
  29 pred top_level.mercury_compile_main.do_op_mode_args/13-0 (det) (mercury_compile_main.m:742)
  30 pred top_level.mercury_compile_main.do_op_mode/12-0 (det) (mercury_compile_main.m:577)
  31 pred top_level.mercury_compile_main.main_after_setup/7-0 (det) (mercury_compile_main.m:532)
  32 pred top_level.mercury_compile_main.real_main_after_expansion/3-0 (det) (mercury_compile_main.m:276)
  33 pred top_level.mercury_compile_main.real_main/2-0 (det) (mercury_compile_main.m:138)
  34 pred mercury_compile.main/2-0 (det) (mercury_compile.m:32)
eqv-type-module-import-bug.tar.gz (10,240 bytes) 2022-08-03 13:04
https://bugs.mercurylang.org/file_download.php?file_id=322&type=bug
 
Notes
(0001200)
wangp   
2022-08-03 15:47   
The regression was introduced in commit 45d6c5bde3d6df2cba786a2ab821b1ce3ebb86ff "The first step in reducing .int2 files to essentials.", which made this change to the .int2 file:

diff --git a/Mercury.good/int2s/quirks.int2 b/Mercury.bad/int2s/quirks.int2
index af739867c..2c5455d64 100644
--- a/Mercury.good/int2s/quirks.int2
+++ b/Mercury.bad/int2s/quirks.int2
@@ -2,5 +2,4 @@
 :- interface.
 :- type quirks.
 :- implementation.
-:- use_module set.
 :- type quirks == set.set(string).
(0001217)
zs   
2023-09-04 15:05   
Fix committed 2023 sep 4.




View Issue Details
565 [mercury] Bug major have not tried 2023-09-04 00:27 2023-09-04 14:07
juliensf  
juliensf  
normal  
assigned  
open  
none    
none  
   
Installed mmake cannot build programs
Attempting to build hello word, using the mmake from an installed compiler results in:

    gmake: *** No rule to make target `builtin.int', needed by `hello.c_date'. Stop.

This appears to be occurring as far back as rotd-2023-07-01 (which is the oldest compiler I have
installed on my system).


    $ mmake hello.depend
    $ mmake hello
Linux x86_64 / gcc 4.8.5
 
Notes
(0001208)
zs   
2023-09-04 10:51   
I have a longer history of (compressed) install directories on my laptop.
I will try to isolate when the problem arose.

The downloads page lists rotds back to 2023 jul 10. I don't know what
algorithm we are currently using to decide that cutoff, but we should
consider changing it to

- keeping the first rotd of each year forever, plus
- keeping the first rotd of each month until the end of the *following* year,
  or until the next stable release, whichever is later (so that there is
  always at least 12 months of monthly rotds around), plus
- keeping the last N rotds as now, but with a smaller N if this is needed
  to keep storage costs in check.
(0001209)
juliensf   
2023-09-04 11:13   
The problem also occurs on the release branch :-(
Specifically, it occurs between 22.01.5 and 22.01.6. My suspicion is that
some of the changes to the digraph module have tickled some latent bug
in the compiler. (The release procedure needs to be updated to explicitly
check that the installed mmake works, but that's another matter ...)

The cutoff for the rotds we keep on the downloads page is governed by the amount
of disk space available (which is not huge). The mercury-srcdist repo. on github should have every ROTD going back several years.
(0001210)
zs   
2023-09-04 11:30   
In that case, it should be possible to use mercury-srcdist to hone in
on which rotd introduced the problem. Your server machines seem better
suited to that than my laptop.

About checking that mmake works: while adding an entry to the release
checklist wouldn't hurt, I think a new entry added to the end of the
action for "mmake install" would be even better. Remind me to do that
once this bug is found and fixed (since there is no point in adding a test
whose correctness we cannot check :-()
(0001211)
juliensf   
2023-09-04 11:35   
Not a problem, I'll identify the ROTD that introduced the problem.
(0001212)
wangp   
2023-09-04 11:49   
I've bisected it to this change

commit 8a3be4eae
Author: Julien Fischer <juliensf@gmail.com>
Date: Fri Apr 7 19:14:34 2023 +1000

    Avoid a warning from make on Windows.
    
    scripts/Mmake.vars.in:
        The cygpath utility prints a warning if it is invoked with an empty
        argument.



BTW, another location you can download old srcdists is
http://testing.mercurylang.org/archives/
However, these will also be cleared out from time to time to make space.
(0001213)
juliensf   
2023-09-04 12:15   
Yes, that appears to be the commit that broke it; its not obvious to me
*why* it breaks it.
(0001214)
zs   
2023-09-04 12:20   
Since any fix will have to work on Windows as well as Linux,
I am not the one to fix this.

Peter, whether the clearing out is done automatically or manually,
could we adopt the retention policy I proposed above?
(0001215)
juliensf   
2023-09-04 12:28   
I will revert the affected commit for now -- the warnings from cygpath are annoying but otherwise harmless.
(0001216)
wangp   
2023-09-04 14:07   
> Peter, whether the clearing out is done automatically or manually,
> could we adopt the retention policy I proposed above?

Unless there is a script to automate it, I will forget such an intricate policy. But it doesn't matter: at the current rate we should be able to retain 2 or more years worth of archives on the server. The mercury-srcdist repository has everything anyway. The archives on testing.mercurylang.org are mainly a side-effect of how the testing setup works; I mention it only in passing.




View Issue Details
494 [mercury] Bug minor have not tried 2020-01-23 11:41 2023-08-02 11:11
juliensf  
juliensf  
normal  
resolved  
fixed  
none    
none  
   
hard_coded/nonascii fails on Windows
hard_coded/nonascii fails on Windows (mingw64-{32,64},MSVC); it outputs "premature EOF" for most of the output.
 
Notes
(0001072)
juliensf   
2020-01-27 04:13   
The reason for failure is that text mode in Windows treats the byte 0x1a (i.e. Ctrl-Z) as EOF. (There's not much we can do about this, short of switching files to binary mode on Windows.)
(0001207)
juliensf   
2023-08-02 11:11   
Fixed in commit 837a677c37fa7a341f2733cdc7071457d3ad83ef.




View Issue Details
162 [mercury] Bug minor always 2010-09-09 22:47 2022-10-11 16:43
pbone  
 
normal  
new  
open  
none    
none  
   
No compiler error for a mode involving an instantation state that doesn't match the argument type.
In the following code I expect to receive a compiler error telling me that the instantiation state that I'm trying to use is incorrect for the type that I'm using.

If the body of the predicate is more detailed and for example uses the empty list for the head variable then the compiler complains that the empty list doesn't match the instantiation state for the some_type type.

This is reproducible on taura (Linux x86-64, Mercury version rotd-2010-08-22, gcc (Ubuntu 4.4.1-4ubuntu9) 4.4.1 with default compilation options (asm_fast.gc)


:- module inst_state.

:- interface.

:- import_module list.

:- type some_type
    ---> f1
    ; f2.

:- inst some_types_inst
    ---> f1.

    % Note that I forget to wrap the inst in a list(I) inst so that it matches
    % the type.
    %
:- pred some_pred(list(some_type)::out(some_types_inst)) is erroneous.

:- implementation.

:- import_module require.

some_pred(_) :-
    error("unimplemented").
 
Notes
(0001205)
juliensf   
2022-10-11 16:43   
If you declare what type the inst is for you will now get such an error:

    :- inst some_types_inst for some_type/0
          ---> f1.

(Since declaring the types for insts will eventually become the default, I don't think we need to do
anything here.)




View Issue Details
151 [mercury] Bug trivial always 2010-05-30 16:25 2022-10-11 16:35
pbone  
juliensf  
normal  
resolved  
fixed  
none    
none  
   
Incorrect documentation for string.unsafe_set_char
James Cussens found that the documentation for this standard library predicate and function doesn't match the implementation. The documentation says that it is a constant time operation but it involves a strcpy.

The unsafe part of the name says that there is no bounds check and that a strlen call isn't performed.
 
Notes
(0000265)
juliensf   
2010-05-30 16:28   
The documentation refers to the commented out mode of unsafe_set_char, which
is constant time. The problem is that the mode that is enabled isn't.
(0001204)
juliensf   
2022-10-11 16:35   
This was fixed in commit f71b5f20.




View Issue Details
564 [mercury] Bug minor always 2022-09-08 14:27 2022-09-08 15:35
wangp  
 
normal  
new  
open  
none    
none  
   
unnecessary use_module in .opt files
I was trying to figure out why a seemingly small change to one module causes a project-wide recompilation when developing with intermodule module optimisation enabled.


For the attached test case, mmc --make-opt-int fib.m produces:

:- module fib.
:- use_module builtin.
:- use_module int.
:- use_module io.
:- use_module map.
:- use_module private_builtin.

:- func fib.fib(int) = int.
:- mode fib((builtin.in)) = (builtin.out) is det.

:- pragma inline(func((fib.checked_fib)/1)).
fib.checked_fib(V_3) = V_4 :-
    ( if
      V_5 = 40 : int,
      int.(V_3 >= V_5)
    then
      V_4 = -1 : int
    else
      V_4 = fib.fib(V_3)
    ).

I don't see the need for:

:- use_module io.
:- use_module map.

The io module is only used by a predicate not exported or opt-exported from fib.m.
The map module is not used at all.

Not sure about private_builtin either.
fib.m (551 bytes) 2022-09-08 14:27
https://bugs.mercurylang.org/file_download.php?file_id=323&type=bug
 
Notes
(0001203)
zs   
2022-09-08 15:35   
Unfortunately, this is not so much a bug, as an as-yet-unimplemented feature,
because at the moment, we just generate a use_module declaration for
*every* module imported by the module whose .opt file we are creating,
*regardless* of whether it is needed or not. See the XXXs in intermod.m
starting at line 1386.

I think the reason for this non-attempt was that originally, .trans_opt
files used to be written out piecemeal; each analysis pass, after it was run,
appended its results to that file. This made it complicated to find out
up front which modules would be needed, and writing out the use_modules
at the end could have screwed up the then-rigid ordering requirements
of the make_hlds pass. Such considerations would have affected .opt files
as well, because .opt files are also written out in two pieces by two
separate algorithms, as explained by the comment starting on line 58.
However, the above is speculation, since I am not intermod.m's original
author.

As for why builtin and private_builtin are in the .opt file:
they are *always* implicitly imported and used respectively in every module,
whether needed or not, and intermod.m blindly copies them to the .opt file.




View Issue Details
562 [mercury] Bug minor always 2022-08-03 10:37 2022-08-18 20:01
wangp  
zs  
normal  
resolved  
fixed  
none    
none  
   
performance regression since rotd-2022-05-01
The attached module compiles much slower than it used to.

I have bisected the regression to commit 911bc5ea0c6565b9ae48132b153182627b3ddbea "Convert more modules to use var_tables". The slow down occurs during the Fully expanding equivalence types step.


% time ~/local/stow/mercury-srcdist-rotd-2022-04-29/bin/mmc -C parse_tables.m
0.63s user 0.03s system 99% cpu 0.662 total

% time ~/local/stow/mercury-srcdist-rotd-2022-05-01/bin/mmc -C parse_tables.m
7.51s user 0.03s system 99% cpu 7.553 total
parse_tables.m (246,635 bytes) 2022-08-03 10:37
https://bugs.mercurylang.org/file_download.php?file_id=321&type=bug
 
Notes
(0001202)
zs   
2022-08-18 20:01   
Fix committed 2022 aug 18.




View Issue Details
559 [mercury] Bug minor always 2022-05-03 16:12 2022-08-03 19:41
juliensf  
zs  
normal  
resolved  
fixed  
none    
none  
   
Stack overflow in hlc.gc Mercury 22.01.1 compiler on Windows
The attached module is derived from a stress test for the Zinc compiler. Compiling this with a Mercury 22.0.1 compiler built in the hlc.gc results in a stack overflow on Windows when reading the module. (The significance of Window is that the stack size is very small, even though IIRC we bump it up a bit.)
(This is not a new problem, Mercury 20.01 also has the same problem.)

    $ mmc -C zm_hug_flat_case.m
zm_huge_flat_case.m.gz (96,956 bytes) 2022-05-03 16:12
https://bugs.mercurylang.org/file_download.php?file_id=319&type=bug
 
Notes
(0001194)
zs   
2022-05-03 18:06   
I believe I have diagnosed the problem, though I cannot confirm it,
since I am not set up to program on Windows.

Compiling zm_huge_flat_case.m with a debug grade compiler under mdb,
the command "min_depth 10000" shows very deep mutual recursion in
parse_goal.m between parse_goal, parse_non_call_goal, and parse_goal_semicolon.
Basically, you need three stack frames for each disjunct in that big
disjunction, and the different determinisms (parse_non_call_goal is semidet,
the others are det) prevent both the MLDS and the LLDS code generator
from being able to do tail recursion.

I have an idea for a solution and will try it out tomorrow, but it may
add some overhead. Once I have an implementation ready, I will need you
to run some benchmarks to see whether it adds any overhead for run-of-the-mill,
non-extreme Mercury code, and if so, whether that overhead is significant.
(0001201)
zs   
2022-08-03 19:41   
Last part of the fix committed 2022 may 7.




View Issue Details
561 [mercury] Bug minor have not tried 2022-06-22 23:46 2022-06-22 23:46
juliensf  
 
normal  
new  
open  
none    
none  
   
Segmentation fault with GCC 12 (Github issue 0000103)
The attached test case is for Github issue 0000103. It causes a segmentation fault when compiled in asm_fast.gc with GCC 12.
gh_103.m (984 bytes) 2022-06-22 23:46
https://bugs.mercurylang.org/file_download.php?file_id=320&type=bug
 
There are no notes attached to this issue.




View Issue Details
560 [mercury] Bug crash always 2022-05-27 17:37 2022-05-31 16:24
wangp  
 
normal  
new  
open  
none    
none  
   
asm_fast.gc crashes on aarch64 with gcc 10.2
Configure enables asm_fast.gc by default on aarch64 but it doesn't work with newer versions of gcc:

gcc 10.2, Debian 11 - crash
gcc 8.3.0, Debian 10 - ok
gcc 6.3.0, Debian 9 - ok

reg.gc works so far on a few small programs. I have not tried a bootcheck yet (emulation is slow).
 
Notes
(0001195)
juliensf   
2022-05-27 17:50   
Does the crash with the sample programs occur with GCC 10.2 occur with:

    a. --mercury-linkage shared
    b. --mercury-linkage static
    c. both

Have you tried compiling with gcc -O0?
(0001196)
wangp   
2022-05-30 12:10   
It crashes in all three cases (--mercury-linkage shared, --mercury-linkage static, compiling the standard library and hello.m with gcc -O0).
(0001197)
wangp   
2022-05-31 12:37   
Debian 11 also has a package for gcc version 9.3.0.

The sample programs also crash in asm_fast.gc using gcc 9.3.0 in all three cases (--mercury-linkage shared, --mercury-linkage static, compiling the standard library and hello.m with gcc -O0).
(0001198)
juliensf   
2022-05-31 14:18   
In the absence of an immediate fix, I suggest we disable the use of asm_fast as the LLDS base grade on aarch64 for GCC >= 9 on both the master and release branches (assuming reg.gc is ok.)
(0001199)
wangp   
2022-05-31 16:24   
It has something to do with PIC. Adding this to Mmake.params and compiling the sample programs without PIC makes them not crash:

EXTRA_CFLAGS = -fno-pic -fno-PIC -static
EXTRA_MLFLAGS = -static

(That makes me a bit suspicious that it is something similar to the PIC register issue on x86, but it might be completely unrelated.)

For now I agree we should disable asm_fast on aarch64 with GCC >= 9. I'm doing a partial bootcheck on reg.gc to make sure that works ok.




View Issue Details
558 [mercury] Bug major always 2022-04-21 17:42 2022-04-22 00:36
pbone amd64  
juliensf Linux  
normal  
resolved  
fixed  
none    
none  
   
The mprof.1 manpage is currupt
The mprof.1 manpage contains:

.TH 1 "2022-04-21" "Mercury Programmer's Manual"
\&../scripts/mprof: 24: exec: ../profiler/mercury_profile: not found
.SH AUTHORS
The Mercury team.
.SH COPYRIGHT
This program and its documentation are copyright by
the University of Melbourne and the Mercury team.
They may be copied only under the terms of the
GNU General Public License \-
see the file COPYING in the Mercury distribution.
.SH SEE ALSO
The Mercury User's Guide.
.PP
<http://www.mercurylang.org/information/documentation.html>
Build the source distribution, don't need to install, look in doc/mprof.1
The script/mprof script fails to execute ../profiler/mercury_profile, it's unclear why, that executable exists.

A second problem is that the mprof script lacks the -e flag causing the error to be ignored.
 
Notes
(0001191)
juliensf   
2022-04-21 18:37   
The compiler and profiler directories are missing as dependencies from the doc target in the top-level Mmakefile. (As well as any other directories containing executables that we generated manual pages for.)
(0001192)
juliensf   
2022-04-22 00:25   
Fix in commit 336215914.
(The fix is available in rotd-2022-04-21 and 22.01.2-beta-2022-04-21.)
(0001193)
pbone   
2022-04-22 00:36   
Thanks, I backported your patch for the debian package.




View Issue Details
557 [mercury] Bug minor always 2022-04-11 01:08 2022-04-11 13:42
dirkz Mac  
zs MacOS  
normal Catalina  
resolved  
fixed  
none    
none  
   
Ambiguous type causes compiler error without giving a useful error message for debugging
Mercury-Versions: 22.01 and rotd-2022-04-07

Two discriminated union types are defined in separate modules foo.m and bar.m and share the same name `ambiguous_type`. The module foo.m defines a record type of which one field has type `ambiguous_type`. A module qualification for the type of this record field is missing.

Actual result:
The compiler aborts with error and without giving a useful error message for debugging.

Expected result:
The compiler aborts with error, complaining about the missing module qualification for the ambiguous type.
Run the attached test case (foo.m and bar.m)

mmc --make foo
test-case.tar.xz (3,584 bytes) 2022-04-11 01:08
https://bugs.mercurylang.org/file_download.php?file_id=318&type=bug
 
Notes
(0001190)
zs   
2022-04-11 13:42   
Fix committed 2022 apr 11.




View Issue Details
556 [mercury] Bug minor have not tried 2022-04-06 12:10 2022-04-07 12:56
juliensf  
zs  
normal  
resolved  
fixed  
none    
none  
   
Stage 2 compiler does not build with --intermod-opt -O5 and rotd-2022-04-04
From testing.mercurylang.org

fact_table.m:2543: error: the user defined inst
fact_table.m:2553: error: the user defined inst
fact_table.m:3400: error: the user defined inst
building of stage 2 compiler not successful

In non-truncated form it is:

fact_table.m:2543: In the second argument of predicate `get_hash_table_type'/2:
fact_table.m:2543: error: the user defined inst
fact_table.m:2543: `ll_backend.fact_table.key_char'/0
fact_table.m:2543: is declared to be applicable only to values of type
fact_table.m:2543: `char.char'/0,
fact_table.m:2543: but here it is applied to values of type
fact_table.m:2543: `character'/0.
fact_table.m:2553: In the third argument of predicate
fact_table.m:2553: `get_hash_table_type_loop'/3:
fact_table.m:2553: error: the user defined inst
fact_table.m:2553: `ll_backend.fact_table.key_char'/0
fact_table.m:2553: is declared to be applicable only to values of type
fact_table.m:2553: `char.char'/0,
fact_table.m:2553: but here it is applied to values of type
fact_table.m:2553: `character'/0.
fact_table.m:3400: In the fifth argument of predicate
fact_table.m:3400: `generate_hash_lookup_code'/7:
fact_table.m:3400: error: the user defined inst
fact_table.m:3400: `ll_backend.fact_table.key_char'/0
fact_table.m:3400: is declared to be applicable only to values of type
fact_table.m:3400: `char.char'/0,
fact_table.m:3400: but here it is applied to values of type
fact_table.m:3400: `character'/0.

It looks like equivalence types are not being expanded in insts correctly.




 
Notes
(0001187)
zs   
2022-04-06 15:18   
I started fixing this by expanding type_ctors in inst definitions,
but realised that this is wrong approach. The reason is that the inst
will (in virtually all cases) contain function symbols of the named type,
and thus makes sense only if the user who wrote the inst knows the
ultimate expansion of the "for typector". If they know it, why not write it?

Therefore I propose to fix this bug in two ways.

- Replace char with character in the inst definition in fact_table.m.

- Add code that detects when the "for type_ctor" part of an inst defn
  is an equivalence type, and generates a version of the error messag
  above that mentions this fact.
  
Any objections?
(0001188)
juliensf   
2022-04-06 15:37   
I don't have any particularly strong objections. Your proposed fix does introduce a certain lack
of uniformity with respect to how equivalence types are treated by different parts of the language.
(It's probably not too bad in presence of an error message describing what is wrong.)

As to "if they know, why not write it?", I think this bug answers that question. It wasn't written because the equivalence type is the preferred name for the type in question. When deprecating a type name we quite often start by introducing an equivalence that defines the new name and then swapping them around later, before finally (after a respectable interval) deleting the original name. (That isn't quite the story with character / char, but it's close.)

Another reason a user may have used char instead of character here, is that they may have read the library documentation. It is fairly emphatic on the point:

    Originally we used `character' rather than `char' for the type name
    because `char' was used by NU-Prolog to mean something different.
    But now we use `char' and the use of `character' is discouraged.
(0001189)
zs   
2022-04-07 12:56   
Fix committed 2022 apr 7.




View Issue Details
555 [mercury] Feature Request minor N/A 2022-04-05 12:12 2022-04-05 12:12
wangp  
 
normal  
new  
open  
none    
none  
   
do not implicitly import modules imported by ancestor modules
We may want to change the submodule visibility rule so that declarations from modules imported by ancestor modules are NOT automatically visible to a submodule.

E.g.
Module a declares foo, and happens to import io.
Module a.b can see foo, but it must import io itself if it wants to use io.

This change would reduce unwanted coupling between the parent module and submodule (as described in commit 92438b2ec). It would also allow the compiler to warn about unnecessary imports that currently *might* be required by a submodule.

An argument against this change is that since nested submodules are written in the same source file as the parent module, it does seem somewhat natural (in a "block scoping" way) for imports in the parent module to also affect a nested submodule. We would not want to have different visibility rules for nested or separate submodules.

May be related to Mantis bug 0000505
 
There are no notes attached to this issue.




View Issue Details
554 [mercury] Bug minor have not tried 2022-03-29 01:17 2022-03-29 13:55
juliensf  
juliensf  
normal  
resolved  
fixed  
none    
none  
   
mmake realclean does not remove .dep_err files
mmake realclean deletes any .err files, but does not delete .dep_err files.
 
Notes
(0001186)
juliensf   
2022-03-29 13:55   
Fixed in commit 0cbe2c6.




View Issue Details
553 [mercury] Feature Request minor have not tried 2022-03-23 20:07 2022-03-23 20:07
juliensf  
 
normal  
new  
open  
none    
none  
   
mmc --make and GNU make jobserver integration
It would be useful for mmc --make to be able to (optionally) use GNU make's jobserver protocol, so that the number of parallel jobs inside the Mercury compiler can be limited by the number of jobs a top-level make is invoked with.

Reference: <https://www.gnu.org/software/make/manual/html_node/Job-Slots.html#Job-Slots>
 
There are no notes attached to this issue.




View Issue Details
552 [mercury] Bug minor have not tried 2022-03-16 21:31 2022-03-17 15:00
juliensf  
zs  
normal  
resolved  
fixed  
none    
none  
   
Compiler aborts in deep_profiler directory in Java grade with --intermod-opt
Building the Mercury system with

    MCFLAGS = --intermod-opt -O0

in the Java grade causes the following abort in the deep_profiler directory

Making Mercury/javas/jmercury/dense_bitset.java
Making Mercury/javas/jmercury/display.java
Making Mercury/javas/jmercury/display_report.java
Uncaught Mercury exception:
Software Error: map.lookup: key not found
        Key Type: term.var(parse_tree.prog_data.prog_var_type)
        Key Value: var(287)
        Value Type: ml_backend.ml_gen_info.ml_ground_terma


Mercury: 22.01-beta-2022-03-16, rotd-2022-03-16
GCC: 4.8.5
OS: CentOS 7
 
Notes
(0001182)
zs   
2022-03-16 21:42   
That is a strange pair of build flags. Do not optimize anything,
but do so across module boundaries? :-)
(0001183)
juliensf   
2022-03-16 22:00   
Yes and no. It's not something I would do by choice. The script I am using to test the release steps through all combinations of -O0 -> -O6 with and without --intermod-opt; the problem arose there. I suspect the issue may arise at other optimisation levels as well.
(0001184)
zs   
2022-03-17 09:09   
I know the cause of the problem. I am testing a fix.
(0001185)
zs   
2022-03-17 15:00   
Fix committed 2022 mar 17.




View Issue Details
549 [mercury] Bug minor have not tried 2022-02-18 22:50 2022-03-01 13:57
juliensf  
 
normal  
new  
open  
none    
none  
   
Segmentation fault building stage 3 dependencies with GCC 9, -O6 and debug grades
Build staging 3 source file mappings or dependencies causes a segmentation fault when bootchecking
in either of the grades asm_fast.gc.debug.stseg or asm_fast.gc.decldebug.stseg. This occurs (only) when
compiling with -O6 (with and without --intermod-opt).

Mercury: 22.01-beta-2022-02-16
C compiler: GCC 9.3.1
OS: CentOS 7

The issue did not occur with same optimisation settings and GCC 4.8.5 on the same machine.
(I have GCC versions 10 and 11 installed on the same machine and will try them as well.)






make: Target 'dep_library' not remade because of errors.
cd mdbcomp && PATH=../scripts:../util:../mfilterjavac:../../mfilterjavac:$PATH MMAKE_VPATH=. MMAKE_DIR=../scripts DESTDIR= ../scripts/mmake mer_mdbcomp.depend
gmake[1]: Entering directory '/home/jfischer/release/mercury.git/stage3/mdbcomp'
config.status: creating MDBCOMP_FLAGS
/home/jfischer/release/betas/22.01-beta-2022-02-12/bin//mmc --grade asm_fast.gc.debug.stseg -O6 --intermod-opt --flags MDBCOMP_FLAGS -f *.m

*** Mercury runtime: caught strange segmentation violation ***
PC at signal: 28623904 (1b4c420)

--------------------------------------------------------------------

home/jfischer/release/betas/22.01-beta-2022-02-12/bin//mmc --grade asm_fast.gc.decldebug.stseg -O6 --intermod-opt --flags GRADE_LIB_FLAGS -f *.m
Uncaught Mercury exception:
Software Error: predicate `io.record_env_var_equal_value'/3: Unexpected: No = in environment entry
Stack dump follows:
   0 pred exception.throw_impl/1-0 (erroneous) (exception.m:695)
   1 pred exception.throw/1-0 (erroneous) (exception.m:313)
   2 pred require.error/1-0 (erroneous) (require.m:172)
   3 pred require.unexpected/2-0 (erroneous) (require.m:203)
   4 pred io.record_env_var_equal_value/3-0 (det) (io.m:11818)
reached unknown label




 
Notes
(0001180)
juliensf   
2022-02-27 02:19   
The issue does not occur with GCC 10.
(0001181)
juliensf   
2022-03-01 13:57   
The issue also does not occur with GCC 11.




View Issue Details
547 [mercury] Bug minor random 2022-02-09 12:32 2022-02-26 07:20
juliensf  
 
normal  
new  
open  
none    
none  
   
Test failure: intermittent failure of valid/foreign_import_module
The test case valid/foreign_import_module intermittently fails like in the output below. This appears to be a timing related issue (a missing dependency perhaps?) as there doesn't appear to be much of pattern in the failures.


home/jfischer/release/trunk-test/mercury.git-2/stage2/scripts/mmc --make-interface --grade hlc.gc.prof -O5 --intermod-opt --flags ../TESTS_FLAGS --flags ../WS_FLAGS foreign_import_module
/home/jfischer/release/trunk-test/mercury.git-2/stage2/scripts/mmc --make-interface --grade hlc.gc.prof -O5 --intermod-opt --flags ../TESTS_FLAGS --flags ../WS_FLAGS foreign_import_module_2
/home/jfischer/release/trunk-test/mercury.git-2/stage2/scripts/mmc --make-optimization-interface --grade hlc.gc.prof -O5 --intermod-opt --flags ../TESTS_FLAGS --flags ../WS_FLAGS foreign_import_module
/home/jfischer/release/trunk-test/mercury.git-2/stage2/scripts/mmc --make-optimization-interface --grade hlc.gc.prof -O5 --intermod-opt --flags ../TESTS_FLAGS --flags ../WS_FLAGS foreign_import_module_2
/home/jfischer/release/trunk-test/mercury.git-2/stage2/scripts/mmc --compile-to-c --grade hlc.gc.prof -O5 --intermod-opt --flags ../TESTS_FLAGS --flags ../WS_FLAGS foreign_import_module > foreign_import_module.err 2>&1
/home/jfischer/release/trunk-test/mercury.git-2/stage2/scripts/mmc --compile-to-c --grade hlc.gc.prof -O5 --intermod-opt --flags ../TESTS_FLAGS --flags ../WS_FLAGS foreign_import_module_2 > foreign_import_module_2.err 2>&1
/home/jfischer/release/trunk-test/mercury.git-2/stage2/scripts/mgnuc --grade hlc.gc.prof -- -c foreign_import_module.c -o foreign_import_module.o
foreign_import_module.c:166:38: fatal error: foreign_import_module_2.mh: No such file or directory
 #include "foreign_import_module_2.mh"
                                      ^
compilation terminated.
gmake[3]: *** [foreign_import_module.o] Error 1
/home/jfischer/release/trunk-test/mercury.git-2/stage2/scripts/mgnuc --grade hlc.gc.prof -- -c foreign_import_module_2.c -o foreign_import_module_2.o
/home/jfischer/release/trunk-test/mercury.git-2/stage2/scripts/mgnuc --grade hlc.gc.prof -- -c foreign_import_module_init.c -o foreign_import_module_init.o
gmake[3]: Target `foreign_import_module.runtest' not remade because of errors.
gmake[3]: Leaving directory `/home/jfischer/release/trunk-test/mercury.git-2/tests/hard_coded'
DIFF.fim.d (3,540 bytes) 2022-02-26 07:20
https://bugs.mercurylang.org/file_download.php?file_id=317&type=bug
 
Notes
(0001173)
zs   
2022-02-09 20:35   
The bug description says valid/foreign_import_module, but
the test cases is in tests/hard_coded.

This test has been intermittently failing as long as I remember.
(0001179)
zs   
2022-02-26 07:20   
The attached diff shows the difference between

- the contents of the main module's .d file immediately after
  generating dependencies, and
- its contents after trying to (and failing) to build the executable.

Like Julien, I believe the issue is a missing dependency. Specifically,
I think it is the fact that the dependency of the main module's .o file
on the submodule's .mh file (foreign_import_module_2.mh) is missing
from the *initial contents of the .d file. It is there after the failed
attempt to build the executable, but by then, the test has failed.

As the comment in do_process_compiler_arg in mercury_compile_main.m says,
the root cause of the problem is that --generate-dependencies uses its
own algorithm for computing what goes into .d files, an algorithm that is
completely separate from that used to update the .d file's contents
on every subsequent compiler invocation. The algorith used by --generate
-dependencies shouldn't be fixed; it should be replaced, using the
algorithm used by all other compiler invocations as the basis.




View Issue Details
545 [mercury] Bug minor have not tried 2022-02-06 15:22 2022-02-22 02:50
juliensf  
zs  
normal  
resolved  
fixed  
none    
none  
   
Data constructor named "event" results in invalid optimisation interface
The attached program has been extracted from <https://github.com/dzyr/mercury-xml>.
It illustrates a problem where a type has a data constructor named event, which becomes
the subject of a direct_arg clause in the optimisation interface. This causes a syntax error
when reading in xml_read.opt because event is not escaped using parentheses.

mmc --intermod-opt --make use_xml_read
event_bug.tar.gz (732 bytes) 2022-02-06 15:22
https://bugs.mercurylang.org/file_download.php?file_id=316&type=bug
 
Notes
(0001178)
zs   
2022-02-22 02:50   
Fix committed 2022 feb 9.




View Issue Details
551 [mercury] Bug minor have not tried 2022-02-21 17:11 2022-02-21 21:03
juliensf  
zs  
normal  
resolved  
fixed  
none    
none  
   
Information messages refer to non-existent pragma
The compiler is emitting information messages like the following for the tests in tests/debugger when bootchecking in grade asm_fast.par.gc:

gmake[3]: Leaving directory `/home/jfischer/release/mercury.git/tests/debugger'
ERROR OUTPUT
io_tab_goto.m:029: Ignoring the
io_tab_goto.m:029: `:- pragma table_io(entry_stores_procid_inputs_outputs, alone)'
io_tab_goto.m:029: declaration for predicate `io_tab_goto.goto'/2 mode 0,
io_tab_goto.m:029: because tabling is not compatible with parallel execution.

At the source code level, there is AFAIK no such thing as a table_io pragma.

Mercury: 22.01-beta-2022-02-16
C compiler: GCC 4.8.5
OS: CentOS 7
 
Notes
(0001177)
zs   
2022-02-21 21:03   
Fix for the misleading error message committed 2022 feb 21.

(The test case may still fail due to mismatch with the expected output,
but that is a separate issue.)




View Issue Details
548 [mercury] Bug minor have not tried 2022-02-09 18:21 2022-02-12 10:57
juliensf  
zs  
normal  
resolved  
fixed  
none    
none  
   
Stage 2 compiler fails in hlc.gc.pregen -O4 bootcheck
Bookchecking in the grade hlc.gc.pregen with -O4 fails due to an errors in the generated C code like:

transform_hlds.loop_inv.c:373:11: error: duplicate member ‘transform_hlds__loop_inv__gen_aux_proc_goal_3_p_0_env_0__Var_87’
   MR_Word transform_hlds__loop_inv__gen_aux_proc_goal_3_p_0_env_0__Var_87;
  
This occurs both with both --intermod-opt and --no-intermod-opt.
The problem does not occur with other optimisation levels.
Mercury: 22.01-beta-2022-02-08
GCC: 4.8.5
OS: CentOS 7
 
Notes
(0001174)
zs   
2022-02-09 20:47   
The error occurs in the code generated for the gen_aux_proc_goal
predicate, and the repeated variables are part of the implementation
of the invariant_goal predicate, which is inlined into the switch arm
for generic_calls, unifies and foreign_procs indirectly through
gen_aux_proc_handle_nonrecursive_call. Some implementation methods
for switches that ml_switch_gen.m can choose from can duplicate
the code we generate for an arm, and that is what seems to have
happened here. I don't yet know why.
(0001175)
zs   
2022-02-10 00:27   
Actually, there are two separate bugs involved here.
One results in the duplication of auxiliary functions,
and one results in the duplication of fields in environment
structures.

I have a simple fix for the first problem, which I will document
and post tomorrow. The second problem is harder.
(0001176)
zs   
2022-02-12 10:57   
Fixes have been committed for both problems.




View Issue Details
8 [mercury] Bug minor always 2007-09-27 23:55 2022-02-09 12:38
anonymous  
 
normal  
new  
open  
none    
none  
   
code hanging in asm_fast.gc.prof
From bojar@csse.unimelb.edu.au Tue Sep 4 12:07:44 2007
Date: Tue, 04 Sep 2007 12:07:43 +1000
From: Ondrej Bojar <bojar@csse.unimelb.edu.au>
To: mercury-bugs@csse.unimelb.edu.au
Subject: [Fwd: "hang-up in C-code in asm_fast.gc.prof" - possible solution]

Hi, all.

I've received this suggestion from Krzysztof Foltman some while ago and now I
tested it. Indeed, if I use sigprocmask to block SIGPROF just before
io.call_system_return_signal and unblock it afterwards, my program does not hang
up in asm_fast.gc.prof as it would without any treatment.

I'm using rotd-2007-08-13, so I assume this issue was not fixed yet.

Could you please add the temporary blocking of SIGPROF around every system() or
fork() calls in the standard library, if compiled in profiling grade?

Thanks, Ondrej.

-------- Original Message --------
Subject: "hang-up in C-code in asm_fast.gc.prof" - possible solution
Date: Wed, 15 Aug 2007 16:36:58 +0100
From: Krzysztof Foltman <krzysztof@foltman.com>
To: bojar@csse.unimelb.edu.au

It's probably too late for this, but I think I've found the reason your
code hangs under profiler.

You need to temporarily block the SIGPROF signal with pthread_sigmask or
sigprocmask for the time of system() or fork(), otherwise the profiler
causes those functions to hang indefinitely.

Chris

--
Ondrej Bojar (mailto:obo@cuni.cz / bojar@ufal.mff.cuni.cz)
http://www.cuni.cz/~obo
 
Notes
(0001172)
juliensf   
2022-02-09 12:38   
This appears to affect stage 2 compilers when bootchecking in .prof grades.




View Issue Details
544 [mercury] Bug minor have not tried 2022-02-05 17:08 2022-02-07 18:10
juliensf  
zs  
normal  
resolved  
fixed  
none    
none  
   
Test failure: valid/static causes compiler abort in grade hlc.gc.tr at -O5 and above
valid/static is failing with a compiler abort in the grade hlc.gc.tr at -O5 and above.

Uncaught Mercury exception:
Software Error: map.lookup: key not found
        Key Type: term.var(parse_tree.prog_data.prog_var_type)
        Key Value: var(6)
        Value Type: ml_backend.ml_gen_info.ml_ground_term

Mercury: 22.01-beta-2022-02-04
OS: CentOS 7
GCC: 4.8.5
bug544.m (597 bytes) 2022-02-06 12:55
https://bugs.mercurylang.org/file_download.php?file_id=315&type=bug
 
Notes
(0001165)
zs   
2022-02-06 12:55   
I have diagnosed the problem on the attached cut-down test case.

The predicate that causes the problem, s, includes a cc_nondet scope
that constructs a static term, Result. In non-trailing grades, this works
just fine.

The add_trail_ops transformation replaces that cc_nondet scope with
a disjunction, whose first disjunct is the cc_nondet scope with some
trail ops around it, and whose second disjunct does some trail ops and
then fails.

The problem comes in the fact that ml_gen_ordinary_model_det_semi_disj
generates code for each disjunct by invoking ml_gen_goal_as_branch_block
on it, and this predicate discards any updates to the const_var_map
done while processing a disjunct. So that we generate an entry for
Result in the const_var_map when we process its generator unification,
but then throw away the resulting const_var_map at the end of the branch.
When the code generator reaches the code that wants to *use* Result,
just after the scope or the disjunction it turns into, its lookup
in the const_var_map fails.

The guilty party in this case is add_trail_ops.m, because it leaves
the unification that uses Result as in input marked with construct_statically,
even though its addition of the disjunction invalidated the grounds
that justified that marker. We could fix this by having add_trails_ops
marking everything that it can construct_dynamically. The next pass is
mark_static, which could turn unifications back to construct_statically
if it is safe to do so.

Another way to fix the bug is to change ml_gen_goal_as_block, and the
predicates that call it, so that at the end of each branched control
structure we end up not with the const_var_map that we entered with
(the current situation), but with the "consensus" of the const_var_maps
at the ends of the branches, *provided* the branch end is reachable.
In this case, and in all other cases where add_trail_ops introduces
disjunctions like this, there will be one reachable branch end and
one unreachable branch end, so we will end up with the const_var_map
of the first branch.

Note that both possible fixes are too drastic to add to the release
without at least a week or two of testing.

Opinions?
(0001166)
zs   
2022-02-06 13:01   
To clarify: by "consensus", I mean the intersection
of the const_var_maps at the ends of the reachable branches,
when each map is viewed as a set of key/value pairs.
We already have similar operations on other structures
in our code generators.
(0001167)
juliensf   
2022-02-06 14:55   
Having the HLDS coming out of add_trail_op pass be inconsistent is a possible source of future bugs (in addition to causing this one), for that reason I would favour the first fix. So far as merging a fix on to the release branch is concerned, the first fix has less of an impact on everything else (i.e. the non-trailing MLDS grades).

For the release, I've set up one of Opturion's larger servers to systematically bootcheck all the usual grades using -O0 to -O6, with and without --intermod-opt. We can do the same hlc grades on the master branch once a fix is available -- and for there release branch, if/when the fix is merged onto it. [Fortunately, bootchecks are reasonably fast with -j16 ;-)]
(0001168)
zs   
2022-02-06 15:13   
With the second approach, the HLDS coming out of add_trail_ops
would still be consistent, just with respect to a changed definition
of "under what circumstances is a construct unification allowed to assume
that one of the rhs variable is constant". The updated definition would
of course have to be documented somewhere, but

- the only thing that pays attention to the construct_how annotations
is the MLDS code generator, and
- we would update that in accordance with the updated definition.

About the first approach: probably the simplest way to implement it would be
to get add_trail_ops to add a marker to the disjunctions it creates, which
the following mark_static pass would look for. If it found it, then it would
replace every construct_how annotation reachable from the end of that disjunction
on forward execution with construct_dynamically (the default), and rebuild it
from its own knowledge. That way, you would avoid having to teach add trail ops
about static terms.

BTW, I would be comfortable doing the fix using the second approach,
but not the first.
(0001169)
juliensf   
2022-02-06 15:28   
Ok, not having to teach add_trail_ops about static terms is a convincing reason for the second approach.
(0001171)
zs   
2022-02-07 18:10   
Fix committed 2022 feb 7.




View Issue Details
546 [mercury] Feature Request minor N/A 2022-02-07 14:34 2022-02-07 16:56
wangp  
 
normal  
new  
open  
none    
none  
   
make io.system_error public
As discussed on mercury-users (05 Feb 2022) we should give access to the system error code from an io.error value. Something like this:

    % implementation
    :- type io.error
        ---> io_error(system_error, string).

    :- func make_io_error(system_error, string) = io.error.

    :- pred get_system_error(io.error::in, system_error::out)
        is semidet.


(Assign yourself if you want to work on it.)
 
Notes
(0001170)
juliensf   
2022-02-07 16:56   
A complication here is that on Windows, there are two different sets of error codes: one for the system calls and another for the library functions that report their errors via errno. Currently we don't distinguish between the two, which means any potential user of a public system_error type won't know which is which.




View Issue Details
510 [mercury] Bug crash always 2020-06-19 17:33 2022-01-25 22:15
zs  
zs  
normal  
feedback  
reopened  
none    
none  
   
compiler crash due to missing type definition
The valid/bug510 test case (which I added and committed just now) causes a compiler crash.
It occurs when the compiler tries to look up the definition of the sparse_bitset type,
but does not find it, due to it being hidden behind module abstraction barriers.
 
Notes
(0001162)
zs   
2022-01-25 03:55   
Some change in the last 18 or so months has fixed this test case,
since it does not cause a compiler crash anymore.
(0001163)
zs   
2022-01-25 22:15   
The crash is still present in MLDS grades.




View Issue Details
499 [mercury] Bug minor always 2020-04-06 13:08 2022-01-25 01:51
wangp  
zs  
normal  
resolved  
fixed  
none    
none  
   
unqualified type encountered assertion
The compiler crashes on the attached (erroneous) source file:

% mmc --make-interface bug
Uncaught Mercury exception:
Software Error: predicate `parse_tree.comp_unit_interface.accumulate_modules_used_by_type_ctor'/3: Unexpected: unqualified type encountered
bug.m (91 bytes) 2020-04-06 13:08
https://bugs.mercurylang.org/file_download.php?file_id=297&type=bug
 
Notes
(0001161)
zs   
2022-01-25 01:51   
An immediate fix was committed 2020 april 8. The underlying problem,
ignoring errors by default when making .intN files, has been sortof-solved
by making --halt-at-invalid-interface the default, with the immediate fix
from 2020 preventing a compiler crash if it is ever explicitly switched off.




View Issue Details
530 [mercury] Feature Request minor have not tried 2021-02-26 18:03 2022-01-25 01:41
zs  
zs  
normal  
resolved  
fixed  
none    
none  
   
diagnose inapplicable insts in mode declarations
This is (or was) real code from library/hash_table.m:

:- pred update_item_in_bucket(K, V, hash_bucket(K, V), hash_bucket(K, V)).
:- mode update_item_in_bucket(in(hb_two_plus), in, in, out) is semidet
:- mode update_item_in_bucket(in, in, in, out) is semidet.

The in(hb_two_plus) was intended to be applied to the third argument,
the initial hash bucket, not to the key, whose type is unknown, and is
extremely unlikely to be a hash bucket of any size :-(

The compiler should check whether the modes of arguments in mode declarations
match the types (if any) of the corresponding arguments, and generate
error messages for any mismatches.
 
Notes
(0001160)
zs   
2022-01-25 01:41   
Feature implemented on 2021 dec 30.




View Issue Details
521 [mercury] Bug minor always 2020-09-29 17:23 2022-01-25 01:24
dirkz Mercury 20.06  
zs macOS Catalina  
normal 10.15.7  
resolved  
fixed  
none    
none  
   
Missing error message about an 'undefined type'; misleading error message instead
The compiler should clearly complain about an 'undefined type'.

Expected error message:
thing_def.m:17 error: undefined type `list'/1.

Actual error message:
main.m:033: In clause for predicate `get_wrapped_things'/1:
main.m:033: in argument 1 of functor `list_wrapper/1':
main.m:033: type error in unification of argument
main.m:033: and constant `get_things'.
main.m:033: argument has type `list.list(thing_def.thing)',
main.m:033: constant `get_things' has type `list(thing_def.thing)'.
For more information, recompile with `-E'.
mmc --make main
Attached example:

Module thing_def.m declares this function without importing the list module:

:- func get_things = list(thing).

Not importing the list module is the actual problem. But the compiler does not complain about the missing import. Instead it issues a misleading error message.
example.tgz (434 bytes) 2020-09-29 17:23
https://bugs.mercurylang.org/file_download.php?file_id=307&type=bug
 
Notes
(0001108)
zs   
2020-10-08 16:10   
I just added code to compiler to complain about the missing import. It should
be in the next ROTD. You still get the misleading error message, but you
also get a non-misleading pointer to where the error is.

The error should really be diagnosed when the compiler makes the interface file
for the module with the missing import. The compiler has had an option named
--print-errors-warnings-when-generating-interface for a while now which does
exactly that, but for now, it is not turned on by default, because it is part
of a bigger set of changes that are not complete yet. However, if you are willing to live with an experimental-for-now feature, you can enable it manually.
(0001111)
dirkz   
2020-10-12 05:15   
Thank you for fixing the error message.

I just performed a successful test with rotd-2020-10-09 on MacOS High Sierra 10.13.6.
(0001159)
zs   
2022-01-25 01:24   
The compiler has been diagnosing such errors when making interface files
for some time now.




View Issue Details
541 [mercury] Bug minor have not tried 2021-12-22 00:39 2022-01-25 01:21
juliensf  
zs  
normal  
resolved  
fixed  
none    
none  
   
Standard lib compilation aborts in asm_fast.gc.profdeep.stseg with --intermod-opt -O5
Compilation of a number of stdlib modules (bit_buffer, io, rtti_implementation, store, type_desc) fails with the following:

     Uncaught Mercury exception:
     Software Error: predicate `ll_backend.code_gen.generate_goal'/7: Unexpected: semidet model in det context
     Stack dump not available in this grade.

in grade asm_fast.gc.profdeep.stseg with --intermodule-optimization -O5.
This was with rotd-2021-12-19.
 
Notes
(0001158)
zs   
2022-01-25 01:21   
Fix was committed 2022 jan 3.




View Issue Details
542 [mercury] Bug minor have not tried 2022-01-24 17:07 2022-01-24 22:59
juliensf  
zs  
normal  
resolved  
fixed  
none    
none  
   
Test failure: hard_coded/gh72 causes compiler abort at -O5
Bootchecking in asm_fast.gc with -O5 causes the compiler to abort on tests/hard_coded/gh72
with the following:

    ERROR OUTPUT
    Uncaught Mercury exception:
    Software Error: predicate `hlds.instmap.merge_instmapping_delta_vars'/9: Unexpected: error merging var 5

Mercury: 22.01-beta-2022-01-24
OS: CentOS 7
GCC: 4.8.5

 
Notes
(0001157)
zs   
2022-01-24 22:59   
Fix committed 2022 jan 24.




View Issue Details
543 [mercury] Bug minor have not tried 2022-01-24 17:39 2022-01-24 20:47
juliensf  
zs  
normal  
resolved  
fixed  
none    
none  
   
Test failures: hard_coded/backend_external -- invalid C code at -O6
hard_coded/backend_external_func in grade asm_fast.gc
hard_coded/backend_external in grade asm_fast.gc
hard_coded/backend_external_pred in grade asm_fast.gc

At -O6, the above all failing when compiling the generated C code, with errors like:

backend_external.c:133:1: error: redefinition of ‘backend_external_module’
backend_external.m:84:1: note: previous definition of ‘backend_external_module’ was here

Mercury: 22.01-beta-2022-01-24
OS: CentOS 7
GCC: 4.8.5

 
Notes
(0001156)
zs   
2022-01-24 20:47   
Fix committed 2022 jan 24.




View Issue Details
540 [mercury] Feature Request minor have not tried 2021-11-08 17:29 2021-11-08 17:29
zs  
 
normal  
new  
open  
none    
none  
   
making up for not updating insts
When mode analysis processes a conjunction such as A = f(B, C), B = g(D),
it updates the insts of only the variables of the primitive operation it is
looking at at each point in time. This means that when we process B = g(D),
we update the inst of B to say that it is bound to g, but we do NOT update
the insts of the variables whose terms include B. Therefore if a later part
of that conjunction passes A to a predicate whose in an argument position
that requires the inst of the argument to be f(g(ground), ground), we get
an error, because while mode analysis knows that A's inst is f(ground, ground),
it does not know that the first ground is now known to be g(ground).

Alias tracking turned out to be a bad idea when done all the time, but we could
maybe get around this by doing it "on demand". It would apply only when
all the mode errors for a procedure have the form "var A is expected to have
inst InstSpec, but its actual inst is InstGen", where InstSpec is an
instance of InstGen that differs from it by requiring a ground inst of
a specific shape (such as "g(ground)") for some part of InstGen
that is simply "ground". In such cases, we would redo the mode analysis
after making a trial modification of the procedure body for each such error.
If these modifications fix all the errors, we keep the modified body;
otherwise, we revert to the original procedure body and report the errors.

The trial modification needs as input the identity of the variable in the error,
its required inst, and the goal path of the goal with the error. (We can keep
this info in the mode_error structure.) The modification would traverse the
procedure body while keeping a set of variable it is on the lookout for.
Initially, this set would contain only the variable in the error. When we find
either a construction or deconstruction unification with a lookout variable
on the left hand side, we would (a) record in a map the right hand corresponding
to this left hand side, and (b) we would add all the variables in the right hand
side to the lookout set. This way, we could enable the reconstruction of *all*
the constructed and/or deconstructred parts of the original variable, even when
some of those unifications don't directly reference it.

The above works in the absence of branched goals. In their presence, we would
need to (a) start processing each branch with the same initial binding map,
(b) process each branch independently, and (b) take the intersection of the
final binding maps of the branches as the final map of the branched control
structure itself. This intersection operation throws away information,
and this may prevent being able to reconstruct the binding of the original
variable at the error site.

However, if we *can* reconstruct that binding, then we can add a new goal
before the error site that rebuilds the same term as the original variable,
as e.g. A' = f(B, C), and replaces all references to A with references to A'
in all the places where that reconstruction is valid. (This means all goals
for which the value of A is supplied by the unifications that we used to
construct A'; references to A outside any of their scopes must NOT be replaced.)
Given the unification sequence B = g(D), A' = f(B, C), mode analysis *will*
record the inst of A' as f(g(ground), ground), which should fix the original
mode error. This extra unification will be deleted, long after mode analysis,
by common structure elimination.

With the right housekeeping, it should be possible to (try to) fix all mode errors
of this form in a procedure body at the same time.

Of course, this is rather a lot of machinery for a relatively rare problem.
Simply adding a verbose-only component to the original error message reminding
the programmer that manually adding this redundant unification may fix
the mode error (and why) may get most of the benefit at much lower cost.
 
There are no notes attached to this issue.




View Issue Details
539 [mercury] Bug minor always 2021-10-11 12:56 2021-10-14 13:17
wangp  
zs  
normal  
resolved  
fixed  
none    
none  
   
placing nondummy var which has no state (LCMC)
The compiler aborts during code generation in low-level C grades when LCMC is enabled. (There are other similar bug reports involving debugging or parallel conjunction which may or may not be related.)


% mmc -s asm_fast.gc --optimise-constructor-last-call -C soupy
Uncaught Mercury exception:
Software Error: predicate `ll_backend.var_locn.actually_place_var'/6: Unexpected: placing nondummy var 6 which has no state
Stack dump follows:
   0 pred exception.throw/1-0 (erroneous) (exception.m:313)
   1 pred require.error/1-0 (erroneous) (require.m:172)
   2 pred require.unexpected/2-0 (erroneous) (require.m:203)
   3 pred ll_backend.var_locn.actually_place_var/6-0 (det) (var_locn.m:1807)
   4 pred ll_backend.var_locn.var_locn_place_var/5-0 (det) (var_locn.m:1706)
   5 pred ll_backend.var_locn.actually_place_vars/4-0 (det) (var_locn.m:1730)
   6 pred ll_backend.var_locn.var_locn_place_vars/4-0 (det) (var_locn.m:1722)
   7 pred ll_backend.code_loc_dep.setup_call/7-0 (det) (code_loc_dep.m:3325)
soupy.m (2,707 bytes) 2021-10-11 12:56
https://bugs.mercurylang.org/file_download.php?file_id=314&type=bug
 
Notes
(0001152)
zs   
2021-10-12 02:14   
I have diagnosed the source of the problem, and outlined two possible
approaches to a fix, in the version of this test case I added to
the test suite as tests/valid/bug539.m.

The bug is solely in lco.m, which sets a buried mine; the code generator,
which is where the abort occurs, merely steps on it.
(0001153)
wangp   
2021-10-12 11:46   
Thanks for looking into it.

Of the two proposed solutions, I favour the second. I don't see a reason why lco.m should be replacing the non-self-recursive call to type_check/2 with the lco-optimised version in the first place.
(0001154)
zs   
2021-10-12 18:53   
The reason why lco.m replaces the call to type_check in fun_type
is that these two predicates are mutually recursive, i.e. they are
in the same SCC. If we restricted lco.m to optimize only self-recursive
tail calls, lco couldn't generate code for mutually recursive predicates
that could handle unlimited input sizes in constant stack space.

lco.m should avoid transforming that call to type_check in fun_type
NOT because the call is not SELF-recursive, but because it is not
TAIL recursive (in the lco sense, i.e. modulo constructors).
A call that is a tail call in this sense *cannot* be followed by
consumers of the original output variable, which is the cause of the
compiler abort.
(0001155)
zs   
2021-10-14 13:17   
Fix committed 2021 oct 13.




View Issue Details
538 [mercury] Bug minor always 2021-09-13 00:13 2021-09-13 05:34
dirkz mercury-srcdist-rotd-2021-09-08  
zs macOS Catalina  
low 10.15.7  
resolved  
no change required  
none    
none  
   
Compiler does not recognise a chained subtype definition
Example:
========

    % Html content categories modelled as subtypes (simplified)
    % 1. All html elements belong to the base type flow_content
    % 2. Phrasing_content is a subset of flow_content
    % 3. Nesting of a-elements (hyperlinks) is invalid. Neither direct nor
    % indirect nesting is allowed.
    %
:- type flow_content
    ---> p(list(phrasing_content))
    ; div(list(flow_content))
    ; a(list(flow_content_without_a))
    ; text(string).


:- type flow_content_without_a =< flow_content
    ---> p(list(phrasing_content_without_a))
    ; div(list(flow_content_without_a))
    ; text(string).


:- type phrasing_content =< flow_content
    ---> a(list(phrasing_content_without_a))
    ; text(string).


    % 1. Explicitly declared subtype of phrasing_content
    % 2. Implicit subtype of flow_content_without_a, because both share the
    % same base type (flow_content) and the subtype only omits constructor
    % definitions
    %
:- type phrasing_content_without_a =< phrasing_content
    ---> text(string).


Expected result:
================
The module should compile without error.


Actual result:
==============
Compiler error. Mercury does not recognise the implicit (undeclared) subtype
relationship between subtype phrasing_content_without_a and its supertype
flow_content_without_a. The subtype definition is valid, because both share
the same base type (flow_content) and phrasing_content_without_a only omits
constructor definitions of flow_content_without_a.

$ mmc --make subtype
Making Mercury/int3s/subtype.int3
Making Mercury/ints/subtype.int
Making Mercury/cs/subtype.c
subtype.m:036: Error: the first argument of `a' has a type,
subtype.m:036: `list.list(subtype.phrasing_content_without_a)', which is not
subtype.m:036: a subtype of the corresponding argument type
subtype.m:036: `list.list(subtype.flow_content_without_a)' in the supertype.
** Error making `Mercury/cs/subtype.c'.
Run attached Mercury module with:
mmc --make subtype
subtype.m (1,645 bytes) 2021-09-13 00:13
https://bugs.mercurylang.org/file_download.php?file_id=313&type=bug
 
Notes
(0001151)
zs   
2021-09-13 05:34   
As you say in the bug report, the attached code gets a compiler error because
"Mercury does not recognise [an] implicit (undeclared) subtype relationship".
This is because Mercury is not *designed* to do so. It pays attention only
to *declared* subtype relationships, and there is no such relationship between
the two types involved in the error, phrasing_content_without_a and flow_content_without_a.

Letting a type have two or more supertypes, such as letting phrasing_content_without_a have both phrasing_content and flow_content_without_a as supertypes, would not be
a bug fix. It would be a new feature, and it would have to be designed as such.
It would certainly require new language rules. At the moment, when each subtype
has exactly one supertype, every subtype-to-supertype chain ends in a unique base type.
If we allowed more than supertype, there would be many possible subtype-to-supertype
chains starting at any given subtype, and we would definitely have to require that
they all end in the same base type. However, other rules may be required as well.




View Issue Details
537 [mercury] Feature Request feature N/A 2021-08-31 20:40 2021-08-31 20:40
zs  
 
low  
new  
open  
none    
none  
   
unique file handles
At the moment, once you open a file and get a file handle, you can
(try to) perform operations using that handle even after the handle
is closed.

We could add a new module to the library, called maybe uio.m,
where an open of a file gives you a *unique* file handle. Every
operation then takes a di,uo pair of the relevant kind of unique
file handle ({in,out}put, {text,binary}, and gives you back the
same handle you gave it. The exception is the close operation,
which takes a di file handle. This way, mode analysis could guarantee
the absence of operations on closed files.

The implementation would be simple, using type casts to the existing
file handle types with foreign code, followed by a call to the
equivalent predicate in io.m.

We would need some mechanism to detect the duplication of these unique
file handles during forks and fork-like operations, but that shouldn't
be too hard.
 
There are no notes attached to this issue.




View Issue Details
536 [mercury] Bug minor always 2021-06-07 14:25 2021-06-25 16:06
wangp  
 
normal  
new  
open  
none    
none  
   
--track-flags unreliable when invoked quickly
mmc --make fails to rebuild modules when invoked multiple times quickly with different flags, despite using --track-flags. Presumably this has something to do with the poor resolution of timestamps returned by io.file_modification_time, so is a specific case of a more general problem with mmc --make.


Script
=======
#!/bin/sh
set -x
rm -rf ./Mercury
mmc -m e --track-flags -s hlc.gc
#sleep 1
mmc -m e --track-flags -s hlc.gc -O3
#sleep 1
mmc -m e --track-flags -s hlc.gc -O4


Output
========
+ rm -rf ./Mercury
+ mmc -m e --track-flags -s hlc.gc
Making Mercury/int3s/e.int3
Making Mercury/ints/e.int
Making Mercury/cs/e.c
Making Mercury/os/e.o
Making e
+ mmc -m e --track-flags -s hlc.gc -O3
** Nothing to be done for `e'.
+ mmc -m e --track-flags -s hlc.gc -O4
** Nothing to be done for `e'.
 
Notes
(0001148)
juliensf   
2021-06-25 15:22   
As starting point, I think we should decouple the notion of file timestamps from the other time related types in the standard library. (The latter are quite limited and ought to replaced, but that's a separate issue.)

I propose we introduce a new type io.file_time/0 (and whatever supporting operations are required) which maps on to whatever the highest resolution file time representation on the underlying platform is (.e.g java.nio.file.attribute.FileTime in Java, FILETIME structure on Windows etc.). We then add a new version of file_modification_time that returns that rather than a time_t.
(0001149)
zs   
2021-06-25 16:06   
That is a good idea.




View Issue Details
535 [mercury] Bug minor always 2021-06-05 16:13 2021-06-05 16:13
juliensf  
 
normal  
new  
open  
none    
none  
   
Abort during make install with grade hlc.gc on Windows 10
During 'make install' for grade 'hlc.gc' we get:

     Uncaught Mercury exception:
    Software Error: predicate `parse_tree.write_deps_file.generate_d_file'/7: Unexpected: source file name doesn't end in `.m'

Modifying the compiler to print out the name of the "source" file that doesn't end with .m results in a file name that appears to contain rubbish:

    Uncaught Mercury exception:
    Software Error: predicate `parse_tree.write_deps_file.generate_d_file'/7: Unexpected: source file name doesn't end in `.m': it is "<80>Í^?#W"

This is occurring on:

* Windows 10, MSYS2 3.2.0-340 x86_64
* MinGW-w64 GCC 10.3.0
* Mercury commit 567704838
* Compiler built in in 'asm_fast.gc'.
* Boostrapped using rotd-202-05-01


 
There are no notes attached to this issue.




View Issue Details
534 [mercury] Bug crash always 2021-05-28 07:32 2021-05-28 07:32
emacstheviking Apple  
Catalina  
normal 10.15.7  
new  
open  
none    
none  
   
Uncaught Mercury exception when using try[] on predicate optimsied away to true?
Whilst trying to use try/catch, I was calling a predicate that attempted to abstract away the perceived repetition of using trace[]. I created a local predicate, atrace, which then calls a more common code ftrace, the intent was to be able to abstract out the check for an environment variable being present and then only cause output to happen of the debug level of that variable was past a given threshold.

Zoltan says all three predicates are effectively useless, which I can almost understand, but nonetheless it caused the compiler to choke on my awful code.

Thank you.
This code:
on_lexer(Lx, AST) :-
    AST = astcon,
    list.filter_map(promote, lexer.tokens(Lx), ATokens),
    atrace("after promotion: %s\n\n--", [s(string(ATokens))]),
    (
        try []
            ast([], Tree, ATokens, Rest)
        then
            atrace("then block, Rest: %s\n", [s(string(Rest))])
        else
            atrace("else block\n", [])
        catch syntax_error(Pos, Why) ->
            atrace("oops: %s at %s", [s(Why), s(string(Pos))])
    ).

coupled with the following implementation of atrace and ftrace gave rise to the issue.

:- pred atrace(string::in, list(string.poly_type)::in) is det.
atrace(Format, Args) :-
    atrace(0, Format, Args).
:- pred atrace(int::in, string::in, list(string.poly_type)::in) is det.
atrace(Level, Format, Args) :-
    utils.ftrace(Level, "FELT_AST", "\n", Format, Args).

and

:- pred ftrace(
    int::in, string::in, string::in, string::in, list(string.poly_type)::in) is det.
ftrace(Level, Flag, Prefix, Format, Args) :-
    trace[io(!Dbg)] (
        utils.get_env_int(Flag, 0, N, !Dbg),
        (if N >= Level then
            io.print(Prefix, !Dbg),
            io.format(Format, Args, !Dbg)
        else true)
    ).
Mercury Compiler, version 20.06.1, on x86_64-apple-darwin19.6.0
Copyright (C) 1993-2012 The University of Melbourne
Copyright (C) 2013-2020 The Mercury team
Usage: mmc [<options>] <arguments>
Use `mmc --help' for more information.

 
There are no notes attached to this issue.




View Issue Details
532 [mercury] Bug minor always 2021-05-12 15:52 2021-05-13 20:00
wangp  
zs  
normal  
resolved  
fixed  
none    
none  
   
constant_prop_2 failure in low-level C grades
The hard_coded/constant_prop_2.m test case fails in low-level C grades. When --loop-invariants is enabled (e.g. with -O5) the first test is not being optimised away:

    ( if "abc" ++ "xyz" = "abcxyz" then
        io.write_string("yes", !IO), io.nl(!IO)
    else
        link_error(!IO)
    ).

I have bisected it to commit 18e222656 "Stop common_struct from interfering with mark_static_terms."

When --loop-invariants is enabled, the mark_static_terms.m pass is run, which marks the unification as construct_statically:

% constant_prop_2.hlds_dump.148-mark_static
constant_prop_2.main(STATE_VARIABLE_IO_0, STATE_VARIABLE_IO) :-
  ( if
    ( % conjunction
      V_6 = "abcxyz"
      % V_6 <= "abcxyz"
      % cell_is_unique
      % construct statically
      ,
      V_6 = "abcxyz"
      % V_6 ?= "abcxyz"
    )
  then
    ( % conjunction
      V_9 = "yes"
      % V_9 <= "yes"
      % cell_is_unique
      % construct statically
      ,
      io.write_string(V_9, STATE_VARIABLE_IO_0, STATE_VARIABLE_IO_10)
      ,
      io.nl(STATE_VARIABLE_IO_10, STATE_VARIABLE_IO)
    )
  else
    constant_prop_2.link_error(STATE_VARIABLE_IO_0, STATE_VARIABLE_IO)
  ).

But commit 18e222656 disables the optimisation unless How = construct_dynamically.

NOTE: the comment in common_optimise_unification incorrectly states that
mark_static_terms.m is only run in MLDS grades. maybe_mark_static_terms is currently located in mercury_compile_mlds_back_end.m, but it is called by maybe_loop_inv.
 % mmc -s asm_fast.gc --loop-invariants constant_prop_2.m
/usr/bin/ld: constant_prop_2.o: in function `<predicate 'main'/2 mode 0>':
constant_prop_2.c:(.text+0x59): undefined reference to `<predicate 'constant_prop_2.link_error'/2 mode 0>'

Whether you actually get a link error seemingly depends on your version of gcc, linker, and phase of the moon.
 
Notes
(0001135)
zs   
2021-05-12 16:30   
Two things.

First, I have started on a diff to move maybe_mark_static_terms
from mercury_compile_mlds_backend.m to mark_static_terms.m, which
is already in the backend-neutral hlds package.

Second, I can see two broad approaches for the restoration of
the status-quo-ante of that bisected commit. One is to modify
loop_inv, which screws things up for the LLDS backend by getting
mark_static_terms to tinker with the construct_how fields in ways
that the LLDS backend does not expect, by making it clean up its
mess, and put the original values back into those fields. This
works only if we know what those original values are. The other
way is to set a flag in the simplify_info that specifies whether
we are targeting a backend that wants to pay attention to
construct_statically values in construct_how fields, or not.
In the latter case, we get commom_optimise_unification to accept
How = construct_statically as well as construct_dynamically.

The second is much easier to program, but imposes a (tiny) cost
on all compilations. I think that cost is too small to worry about,
so I would prefer the second approach.

Opinions?
(0001136)
wangp   
2021-05-12 18:38   
(Last edited: 2021-05-12 18:38)
The second sounds okay. There could be a danger that someone tries to make use of construct_statically in the LLDS backend when that information is no longer valid, but that will have to be clarified through comments.

Or, would it be possible to rerun mark_static_terms.m to recompute the how_to_construct fields after common.m makes a change that might invalidate those fields (for the MLDS backend only)?

(0001137)
zs   
2021-05-12 19:49   
Since the LLDS backend's code for creating static data predates
mark_static_terms.m, it should not pay any attention to construct_statically.
You are right, that should be documented as part of fixing this bug.

I don't understand your second paragraph. I am proposing that the code
in common.m that may invalidate the construct_how fields for the MLDS backend
be run ONLY when targeting the LLDS backend, so the situation assumed by
your question wouldn't arise.
(0001138)
wangp   
2021-05-13 12:10   
> I don't understand your second paragraph. I am proposing that the code
> in common.m that may invalidate the construct_how fields for the MLDS backend
> be run ONLY when targeting the LLDS backend, so the situation assumed by
> your question wouldn't arise.

Sorry, here is the context:

I am considering what if we allow common.m to optimise away
constructions marked 'construct_statically',
i.e. the situation before commit 18e222656.

That would obviously reintroduce bug 0000493 for the MLDS backend,
because a construction that is optimised away may invalidate a
'construct_statically' annotation on another construction
in the same procedure.

I think we can fix that by making common.m re-run the mark_static_terms
algorithm on a procedure if it optimises away a construction marked
'construct_statically'.
      
We would need to change mark_static_terms so that it can change
constructions from 'construct_statically' back to 'construct_dynamically'
if a variable on the RHS of the construction is NOT in the static set.
(0001139)
zs   
2021-05-13 12:27   
I think we are still talking at cross purposes. I am proposing
a change that would not affect what we do in MLDS grades at all.
(I have actually implemented it, the bootcheck is going right now.)
It affects only what we do in LLDS grades. Since LLDS grades
do not pay attention to construct_statically (treating it the same
as construct_dynamically), they do not CARE whether or not the invariants
established by mark_static_terms.m are preserved by common.m.
(0001140)
zs   
2021-05-13 20:00   
Fix committed 20201 may 13.




View Issue Details
526 [mercury] Bug minor always 2020-11-11 11:34 2021-04-28 11:17
wangp  
wangp  
normal  
resolved  
fixed  
none    
none  
   
unused imports affected by opt-imported typeclass instances
Some basic investigation of why warnings/bug412.m fails when intermodule optimisation is enabled.

The `io' module is considered used because polymorphism adds a typeclass info to the constant structure database due to opt-imported typeclass instances. Then const_struct_used_modules treats every constant structure as a use:

const_struct_used_modules(_ConstNum - ConstStruct, !UsedModules) :-
    % Every const_struct in the const_struct_db was put there because
    % it is used in module. None of the uses can be in the interface.
 
Notes
(0001124)
zs   
2020-11-12 03:13   
The obvious fix is to add a field to each entry to the const_struct_db
that says "does this entry come from the current module, or not?",
and then ignore the fields with "no" answers when it comes to computing
the set of used modules. The only nontrivial aspect I see is when
two or more const structs use a smaller const struct; the smaller
const struct should say "for this module" if any of its users also say so.

Do you see anything wrong with this approach?
(0001125)
wangp   
2020-11-30 13:35   
I think your approach should work.

(Sorry for the late response; the notification was caught by GMail's spam filter.)
(0001134)
wangp   
2021-04-28 11:17   
Fixed by zs on 2021-01-23




View Issue Details
531 [mercury] Bug major always 2021-04-26 23:57 2021-04-27 00:17
hyphz Windows  
10  
normal 20H2  
new  
open  
none    
none  
   
20.06.1 will not compile in MingW32 2013072200 w/gcc 9.2.0-2: gettimeofday is deprecated
Seems to be no workaround for this or way to add the -W flag to disable it?
Install MSYS with latest gcc, flex and bison
Run configure and make on mercury
 
Notes
(0001133)
juliensf   
2021-04-27 00:06   
(Last edited: 2021-04-27 00:17)
Creating a file named Mmake.params at the top-level of the source tree that contains the following
should workaround the problem:

    EXTRA_CFLAGS=-Wno-deprecated-declarations

(or whatever the appropriate -W option is in this case.)





View Issue Details
529 [mercury] Bug minor always 2021-02-20 15:47 2021-02-26 17:57
wangp  
zs  
normal  
resolved  
fixed  
none    
none  
   
higher order inst from existentially quantified data constructors
As reported on m-users 2021-02-16, deconstructing a data constructor with existentially quantified type variables leaves a higher order argument with inst 'ground' even if higher order inst information is available from the du type definition.
% mmc -e exist_cons_ho_arg.m
exist_cons_ho_arg.m:026: In clause for `main(di, uo)':
exist_cons_ho_arg.m:026: in argument 1 (i.e. the predicate term) of
exist_cons_ho_arg.m:026: higher-order predicate call:
exist_cons_ho_arg.m:026: mode error: variable `Pred' has instantiatedness
exist_cons_ho_arg.m:026: `ground',
exist_cons_ho_arg.m:026: expecting higher-order pred inst of arity 1.
exist_cons_ho_arg.m (484 bytes) 2021-02-20 15:47
https://bugs.mercurylang.org/file_download.php?file_id=310&type=bug
 
Notes
(0001132)
zs   
2021-02-26 17:57   
Fix committed 2021 feb 24.




View Issue Details
528 [mercury] Bug minor always 2021-01-29 21:40 2021-01-30 01:46
dirkz Mercury 20.06 / rotd-2021-01-27  
zs MacOS Catalina, Intel  
normal 10.15.7  
resolved  
fixed  
none    
none  
   
Compiler aborts when constructing invalid inst
I want Mercury's mode checker to enforce following HTML validation rules via insts:
- An ul tag (unordered list) allows only li tags (list item) as direct children
- An li tag must have an ol tag as immediate parent

Expected result:
Compiler should report an error when creating an invalid inst.

Actual result:
Compiler aborts.

The error occurs with Mercury 20.06 as well as with rotd-2021-01-27.
mmc --make html
$ mmc --make html
Making Mercury/int3s/html.int3
Making Mercury/ints/html.int
Making Mercury/cs/html.c
Uncaught Mercury exception:
Software Error: map.det_insert: key already present
    Key Type: parse_tree.prog_data.inst_name
    Key Value: user_inst(qualified(unqualified("html"), "non_empty_list"), [defined_inst(user_inst(qualified(unqualified("html"), "top_body_elem"), []))])
    Value Type: list.list(parse_tree.error_util.format_component)
** Error making `Mercury/cs/html.c'.
html.m (1,907 bytes) 2021-01-29 21:40
https://bugs.mercurylang.org/file_download.php?file_id=309&type=bug
 
Notes
(0001129)
zs   
2021-01-30 01:34   
I am testing a fix now.

However, if I were you, I would choose a HTML representation that
encoded HTML's invariants in the type, not in the mode. It would
not have any representation for
  • tags at all. Instead, the function
    symbol for lists would look like this:

    :- type html_elem
      ---> list(html_elem, list(html_elem))
      ...

    The
  • tags would be added only when a list is unparsed.
    (Not having an explicit representation for
  • guarantees
    that this representation cannot be put anywhere it shouldn't :-)
    And storing the first element of the list separately guarantees
    that the empty list is not representable.
  • (0001130)
    zs   
    2021-01-30 01:36   
    Sorry about the formatting of the above note. I didn't realize
    that Mantis does not quote html in notes :-( Those bullets were
    originally a sequence of <, l, i, and >.
    (0001131)
    zs   
    2021-01-30 01:46   
    Fix committed 2021 Jan 30.




    View Issue Details
    527 [mercury] Bug minor always 2021-01-27 13:00 2021-01-27 13:00
    wangp  
     
    normal  
    new  
    open  
    none    
    none  
       
    daio pass and inlining
    The compiler aborts on gh72.m test during the inlining pass, with intermodule optimisation turned OFF.

    % mmc -s asm_fast.gc -O5 --no-intermod-opt gh72.m
    Uncaught Mercury exception:
    Software Error: predicate `hlds.instmap.merge_instmapping_delta_vars'/9: Unexpected: error merging var 5
    Stack dump follows:
       0 pred exception.throw/1-0 (erroneous) (exception.m:310)
       1 pred require.error/1-0 (erroneous) (require.m:172)
       2 pred require.unexpected/2-0 (erroneous) (require.m:203)
       3 2* pred hlds.instmap.merge_instmapping_delta_vars/9-0 (det) (instmap.m:1334 and others)
       5 pred hlds.instmap.merge_instmapping_delta/8-0 (det) (instmap.m:1290)
       6 pred hlds.instmap.merge_instmap_delta/8-0 (det) (instmap.m:1271)
       7 pred hlds.instmap.merge_instmap_deltas_2/8-0 (det) (instmap.m:1376)
       8 pred hlds.instmap.merge_instmap_deltas/7-0 (det) (instmap.m:1345)
       9 pred check_hlds.mode_util.recompute_instmap_delta_disj/9-0 (det) (mode_util.m:1602)
      10 pred check_hlds.mode_util.recompute_instmap_delta_1/8-0 (det) (mode_util.m:1391)
      11 pred check_hlds.mode_util.recompute_instmap_delta_conj/8-0 (det) (mode_util.m:1577)
      12 pred check_hlds.mode_util.recompute_instmap_delta_1/8-0 (det) (mode_util.m:1379)
      13 pred check_hlds.mode_util.recompute_instmap_delta/8-0 (det) (mode_util.m:1353)
      14 pred check_hlds.mode_util.recompute_instmap_delta_proc/5-0 (det) (mode_util.m:1346)
      15 pred transform_hlds.inlining.inline_in_proc/6-0 (det) (inlining.m:706)
      16 pred transform_hlds.inlining.inline_in_scc/6-0 (det) (inlining.m:298)
      17 10* pred transform_hlds.inlining.inline_in_sccs/5-0 (det) (inlining.m:282 and others)
      27 pred transform_hlds.inlining.inline_in_module/2-0 (det) (inlining.m:269)
      28 pred top_level.mercury_compile_middle_passes.maybe_do_inlining/6-0 (det) (mercury_compile_middle_passes.m:977)
      29 pred top_level.mercury_compile_middle_passes.middle_pass/8-0 (det) (mercury_compile_middle_passes.m:212)
      30 pred top_level.mercury_compile_main.after_front_end_passes/13-0 (det) (mercury_compile_main.m:2416)
      31 pred top_level.mercury_compile_main.process_augmented_module/14-0 (det) (mercury_compile_main.m:1793)
      32 pred top_level.mercury_compile_main.augment_and_process_module/15-0 (det) (mercury_compile_main.m:1687)
      33 pred list.map_foldl3/9-0 (det) (list.m:3335)
      34 pred top_level.mercury_compile_main.augment_and_process_all_submodules/15-0 (det) (mercury_compile_main.m:1627)
      35 pred top_level.mercury_compile_main.read_augment_and_process_module/11-0 (det) (mercury_compile_main.m:1447)
      36 pred top_level.mercury_compile_main.do_process_compiler_arg/10-0 (det) (mercury_compile_main.m:1207)
      37 pred top_level.mercury_compile_main.process_compiler_arg_build/11-0 (det) (mercury_compile_main.m:1091)
      38 pred make.build.build_with_module_options_args_invoked/13-0 (det) (make.build.m:234)
      39 pred make.build.build_with_module_options_args/12-0 (det) (make.build.m:185)
      40 pred top_level.mercury_compile_main.process_compiler_arg/12-0 (det) (mercury_compile_main.m:1052)
      41 pred top_level.mercury_compile_main.process_compiler_cmd_line_args/14-0 (det) (mercury_compile_main.m:1010)
      42 pred top_level.mercury_compile_main.do_op_mode_args/11-0 (det) (mercury_compile_main.m:845)
      43 pred top_level.mercury_compile_main.do_op_mode/10-0 (det) (mercury_compile_main.m:710)
      44 pred top_level.mercury_compile_main.main_after_setup/7-0 (det) (mercury_compile_main.m:672)
      45 pred top_level.mercury_compile_main.real_main_after_expansion/3-0 (det) (mercury_compile_main.m:443)
      46 pred top_level.mercury_compile_main.real_main/2-0 (det) (mercury_compile_main.m:137)
      47 pred mercury_compile.main/2-0 (det) (mercury_compile.m:32)


    The problem occurs when doing inlining in the predicate gh72.direct_arg_in_out_0_disj_init/3. It tries to merge the insts of a variable between two disjuncts:

            InstA
    bound(clobbered, inst_test_no_results,
      [bound_functor(cons(qualified(unqualified("gh72"), "f1"), 1, type_ctor(qualified(unqualified("gh72"), "t"), 0)), [ground(clobbered, none_or_default_func)]),
       bound_functor(cons(qualified(unqualified("gh72"), "f2"), 1, type_ctor(qualified(unqualified("gh72"), "t"), 0)), [ground(clobbered, none_or_default_func)]),
       bound_functor(cons(qualified(unqualified("gh72"), "f3"), 1, type_ctor(qualified(unqualified("gh72"), "t"), 0)), [ground(clobbered, none_or_default_func)]),
       bound_functor(cons(qualified(unqualified("gh72"), "f4"), 1, type_ctor(qualified(unqualified("gh72"), "t"), 0)), [ground(clobbered, none_or_default_func)])])

           InstB
    bound(clobbered, inst_test_no_results,
      [bound_functor(cons(qualified(unqualified("gh72"), "f1"), 1, type_ctor(qualified(unqualified("gh72"), "t"), 0)), [free]),
       bound_functor(cons(qualified(unqualified("gh72"), "f2"), 1, type_ctor(qualified(unqualified("gh72"), "t"), 0)),
         [bound(clobbered, inst_test_no_results,
            [bound_functor(cons(qualified(unqualified("gh72"), "package"), 2, type_ctor(unqualified(""), -1)),
               [bound(clobbered, inst_test_no_results, [bound_functor(string_const("fill2"), [])]), ground(clobbered, none_or_default_func)])])]),
       bound_functor(cons(qualified(unqualified("gh72"), "f3"), 1, type_ctor(qualified(unqualified("gh72"), "t"), 0)),
         [bound(clobbered, inst_test_no_results,
            [bound_functor(cons(qualified(unqualified("gh72"), "package"), 2, type_ctor(unqualified(""), -1)),
               [bound(clobbered, inst_test_no_results, [bound_functor(string_const("fill3"), [])]), ground(clobbered, none_or_default_func)])])]),
       bound_functor(cons(qualified(unqualified("gh72"), "f4"), 1, type_ctor(qualified(unqualified("gh72"), "t"), 0)), [ground(shared, none_or_default_func)])])


     
    There are no notes attached to this issue.




    View Issue Details
    71 [mercury] Bug minor always 2008-07-30 17:55 2021-01-09 15:59
    juliensf  
     
    normal  
    new  
    open  
    none    
    none  
       
    compiler abort when building programs in debugging grades
    The attached program aborts with the following:

    Uncaught Mercury exception:
    Software Error: map.lookup: key not found
        Key Type: term.var(parse_tree.prog_data.prog_var_type)
        Key Value: var(37)
        Value Type: ll_backend.var_locn.var_state

    Compile with: mmc --grade asm_fast.gc.tr.debug -C zinc_fdic_solver.m
    zinc_fdic_solver.m (3,764 bytes) 2008-07-30 17:55
    https://bugs.mercurylang.org/file_download.php?file_id=56&type=bug
     
    Notes
    (0000109)
    zs   
    2008-08-01 12:29   
    The problem arises from the duplication by switch detection of the deconstruction unification that bind a typeclassinfo. Originally,
    that typeclassinfo is var 37. It is duplicated as var 81. The duplication
    updates the rtti_var_info but not the type_info varmap or the typeclass_info
    varmap, as shown below from this extract from the HLDS dump after switch detection:

    % type_info varmap:
    % I_1 (number 1) -> typeclass_info(TypeClassInfo_for_int_var_37, 1) (number 37)
    % typeclass_info varmap:
    % zinc_fdic_solver.int_var(I_1) -> TypeClassInfo_for_int_var_37

    % rtti_var_info:
    % TypeClassInfo_for_int_var_37 (number 37) -> typeclass_info for zinc_fdic_solver.int_var(I_1)
    % TypeClassInfo_for_int_var_81 (number 81) -> typeclass_info for zinc_fdic_solver.int_var(I_1)

    The code generator looks at the first two maps when generating layout structures for the debugger.
    (0001127)
    juliensf   
    2021-01-09 15:59   
    The abort message is now:

    Uncaught Mercury exception:
    Software Error: predicate `ll_backend.var_locn.actually_place_var'/6: Unexpected: placing nondummy var which has no state




    View Issue Details
    512 [mercury] Bug minor always 2020-07-02 11:38 2020-10-29 19:36
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    branches of if-then-else disagree on liveness
    See attached test case. This is not a recent bug as I can reproduce it with the 11.07 compiler as well.

    % mmc -C liveness_test_case.m -s asm_fast.gc -O5 --intermod-opt
    Uncaught Mercury exception:
    Software Error: predicate `ll_backend.liveness.require_equal'/4: Unexpected: branches of if-then-else disagree on liveness
    First:
    Rest: Cs_8
    liveness_test_case.m (628 bytes) 2020-07-02 11:38
    https://bugs.mercurylang.org/file_download.php?file_id=301&type=bug
     
    Notes
    (0001123)
    zs   
    2020-10-29 19:36   
    Fix committed 2020 oct 23.




    View Issue Details
    525 [mercury] Bug minor have not tried 2020-10-29 19:35 2020-10-29 19:35
    zs  
     
    normal  
    new  
    open  
    none    
    none  
       
    compiler should detect missing included module
    The compiler should generate an error message for situations
    such as:

    backend_libs.m has an include_module for erlang_rtti
    erlang_rtti is deleted, along with all import_modules for it
    the include_module for erlang_rtti becomes an orphan
     
    There are no notes attached to this issue.




    View Issue Details
    524 [mercury] Bug block always 2020-10-14 20:21 2020-10-16 07:16
    dirkz Mac  
    zs macOS Catalina  
    normal 10.15.7  
    resolved  
    fixed  
    none    
    none  
       
    Installing rotd-2020-10-13 aborts with error
    Installing rotd-2020-10-13 aborts with this error message:

    backend_libs.bytecode_data.c:256:14: error: "Weird-endian architecture"
                #error "Weird-endian architecture"
                 ^
    backend_libs.bytecode_data.c:339:14: error: "Weird-endian architecture"
                #error "Weird-endian architecture"
                 ^
    backend_libs.bytecode_data.c:457:14: error: "Weird-endian architecture"
                #error "Weird-endian architecture"
                 ^
    3 errors generated.
    make[2]: *** [backend_libs.bytecode_data.o] Error 1
    make[2]: *** Waiting for unfinished jobs....
    make[1]: *** [compiler] Error 2
    make: *** [all] Error 2
    sh configure --disable-most-grades
    make PARALLEL=-j8
    $ gcc -v
    Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
    Apple clang version 12.0.0 (clang-1200.0.32.2)
    Target: x86_64-apple-darwin19.6.0
    Thread model: posix
    InstalledDir: /Library/Developer/CommandLineTools/usr/bin


    $ llvm-gcc -v
    Apple clang version 12.0.0 (clang-1200.0.32.2)
    Target: x86_64-apple-darwin19.6.0
    Thread model: posix
    InstalledDir: /Library/Developer/CommandLineTools/usr/bin


    $ clang -v
    Apple clang version 12.0.0 (clang-1200.0.32.2)
    Target: x86_64-apple-darwin19.6.0
    Thread model: posix
    InstalledDir: /Library/Developer/CommandLineTools/usr/bin
    config.log (362,768 bytes) 2020-10-14 22:45
    https://bugs.mercurylang.org/file_download.php?file_id=308&type=bug
     
    Notes
    (0001113)
    juliensf   
    2020-10-14 21:07   
    Hi Dirk,

    The above will only occur if the configure script cannot determine the endianness of the system.
    Somewhere amongst the output of configure it should say something like:

        checking whether we can use unboxed 64-bit integers... yes
        checking whether architecture is big-endian... no
        checking whether architecture is little-endian... yes
        checking whether we can use files as locks... yes

    Do both the endianness checks return "no" on your system? If so, could you please check in config.log
    and see why those checks are failing? (Or post that file into Mantis and we'll take a look.)
    (0001114)
    juliensf   
    2020-10-14 21:31   
    BTW, I think the issue here is that Xcode 12 sets -Werror=implicit-function-declaration and the configure
    script contains several tests (including the ones for testing endianness) that do implicitly declare functions.
    (0001115)
    dirkz   
    2020-10-14 22:45   
    Hi Julien,

    both endianness checks return "no":
      checking whether we can use unboxed 64-bit integers... yes
      checking whether architecture is big-endian... no
      checking whether architecture is little-endian... no
      checking whether we can use files as locks... yes

    config.log (attached) states:
    configure:9044: checking whether architecture is big-endian
    configure:9071: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    conftest.c:146:21: error: implicitly declaring library function 'exit' with type 'void (int) __attribute__((noreturn))' [-Werror,-Wimplicit-function-declaration]
                        exit(0);
                        ^
    conftest.c:146:21: note: include the header <stdlib.h> or explicitly provide a declaration for 'exit'
    1 error generated.
    configure:9071: $? = 1
    configure: program exited with status 1
    (0001116)
    zs   
    2020-10-14 22:55   
    Julien has already committed a diff to #include stdlib.h.
    It should show up in the next ROTD, or you could check it out
    of github, and try it out.
    (0001117)
    juliensf   
    2020-10-14 22:56   
    Hi Dirk,

    Thanks for that. The issue is the changed settings for Xcode 12; commit 00d5ede should fix the
    problem. (It will be included in the next rotd.)
    (0001118)
    dirkz   
    2020-10-15 03:22   
    Hi Julien,
    Hi Zoltan,

    rotd-2020-10-14 builds from source successfully now.

    Thank you for fixing this.
    (0001122)
    zs   
    2020-10-16 07:16   
    Fix committed 2020 oct 13.




    View Issue Details
    522 [mercury] Bug minor have not tried 2020-10-08 21:55 2020-10-16 07:15
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Compiler not building in Java grade with rotd-2020-09-29 onwards
    The Java code we generate for update_opt_tuple/7 in compiler/optimization_options.m exceeds the 64k limit on method byte code size in Java.

    Making Java class files
    Mercury/javas/jmercury/libs__optimization_options.java:13287: error: code too large
      update_opt_tuple_7_p_0(
      ^
    Note: Some input files use unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    1 error
     
    Notes
    (0001109)
    zs   
    2020-10-08 22:04   
    The obvious fix is to make each arm of the switch
    its own predicate. I can do that, if you like.

    BTW, why the hell is such a limit still in effect
    in 2020, especially without an override flag?
    Are they concerned about porting programs to PDP-11s?
    (0001110)
    juliensf   
    2020-10-08 22:28   
    Thanks, I suspect that's probably the best short term fix for this. (A better fix might be to get the
    MLDS->Java code generator to do such splitting on switches past a certain size threshold, but
    that may too much work for one instance of the problem.)

    IIRC, that limit (and a few others) are pretty deeply baked into the design of the JVM and changing
    them while preserving backwards compatibility would be non trivial.
    (0001121)
    zs   
    2020-10-16 07:15   
    Fix committed 2020 oct 13.




    View Issue Details
    508 [mercury] Bug minor have not tried 2020-05-17 01:31 2020-10-16 07:11
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Type constructors that are also Mercury operators result in invalid .int3 files
    Type constructors that are also Mercury operators (like rule or pragma) result in .int3 files the compiler cannot read back in. This is due to the operators not being escaped in :- type_representation items. For example, extras/moose/grammar.m contains a type named rule/0, which results in the following in the .int3 file

        :- type_representation(grammar.rule, is_word_aligned_ptr)

    Currently, extras/moose and samples/muz cannot being compiled with the current ROTD.

    (Also, why does the first argument of the type_representation item need to be module qualified?)



     
    Notes
    (0001120)
    zs   
    2020-10-16 07:11   
    Fix was committed 2020 may 17.




    View Issue Details
    515 [mercury] Bug minor always 2020-07-31 01:34 2020-10-16 07:06
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Library not building in deep profiling grades with rotd-2020-07-26
    Compilation of the the standard library in grade asm_fast.gc.profdeep.stseg with rotd-2020-07-26 onwards results in:

    ../scripts/mgnuc --grade asm_fast.gc.profdeep.stseg -- -c exception.c -o exception.o
    In file included from exception.m:2101:0:
    ../runtime/mercury_exception_catch_body.h: In function ‘hand_written_exception_module’:
    ../runtime/mercury_exception_catch_body.h:61:5: error: ‘mercury__profiling_builtin__non_call_port_code_sr_5_0’ undeclared (first use in this function)
    ../runtime/mercury_exception_catch_body.h:61:5: note: each undeclared identifier is reported only once for each function it appears in
    ../runtime/mercury_exception_catch_body.h:64:5: error: ‘mercury__profiling_builtin__prepare_for_ho_call_2_0’ undeclared (first use in this function)
    ../runtime/mercury_exception_catch_body.h:82:5: error: ‘mercury__profiling_builtin__non_exit_port_code_sr_3_0’ undeclared (first use in this function)
    In file included from exception.m:2161:0:
    ../runtime/mercury_exception_catch_body.h:99:5: error: ‘mercury__profiling_builtin__non_redo_port_code_sr_2_0’ undeclared (first use in this function)
    ../runtime/mercury_exception_catch_body.h:115:5: error: ‘mercury__profiling_builtin__non_fail_port_code_sr_3_0’ undeclared (first use in this function)
    exception.c: At top level:

    This is occurring on testing.mercurylang.org. (Also, checked on my Linux machine with GCC 4.8)
    PATCH.2020_07_31_exception (1,036 bytes) 2020-07-31 14:27
    https://bugs.mercurylang.org/file_download.php?file_id=304&type=bug
     
    Notes
    (0001101)
    zs   
    2020-07-31 14:27   
    I have fix for the linking issue (attached). However, a bootstrap in the deep
    profiling grade now gets a SIGSEGV when making the stage 3 dependencies,
    even when if I undo the commit that fixed Mantis bug 514 (commit c5b35aca...),
    which was the previous change that directly affected deep profiling.
    So this needs further investigation.
    (0001119)
    zs   
    2020-10-16 07:06   
    The fix was committed 2020 aug 1.




    View Issue Details
    523 [mercury] Bug minor have not tried 2020-10-13 00:47 2020-10-13 11:27
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Compiler abort with rotd-2020-10-{11,12}
    Several modules in the compiler are causing it abort when compiled with grade hlc.gc, -O5 --intermodule-optimization.

    Uncaught Mercury exception:
    Software Error: predicate `check_hlds.simplify.common.common_standardize_and_record_construct'/13: Unexpected: GoalExpr0 has unexpected shape

    Affected files are:

        compiler/lp_rational.m
        compiler/transform.m
     
    Notes
    (0001112)
    zs   
    2020-10-13 11:27   
    Fix committed 2020 oct 13.




    View Issue Details
    495 [mercury] Bug minor always 2020-02-04 14:02 2020-10-06 21:33
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    -O<n> options not additive
    The -O<n> options are not additive in that they will reset certain options to default values, e.g. in

        mmc --optimise-constructor-last-call -O5 -C list.m

    the --optimise-constructor-last-call option has no effect.

    While the behaviour could be defended, I hit the problem trying to enable -O5 on the standard library by adding:

        EXTRA_MCFLAGS = -O5

    to Mmake.params. This silently disabled the --optimise-constructor-last-call option present in library/LIB_FLAGS. It turns out you need to write this instead:

        MCFLAGS += -O5
     
    Notes
    (0001107)
    zs   
    2020-10-06 21:33   
    Feature implemented by 2020 september 29.




    View Issue Details
    520 [mercury] Bug minor always 2020-09-18 02:23 2020-10-02 17:46
    keri  
     
    normal  
    new  
    open  
    none    
    none  
       
    possible GCC ICE when compiling library/int.m in asm_fast.gc.tr.debug.stseg grade with -O1
    I'm not really sure this is even a Mercury bug.

    When mercury is configured with --enabled-trail-grades an internal compiler error may occur when compiling library/int.m or library/uint.m in the asm_fast.gc.tr.debug.stseg grade and -O2 optimizations exist in CFLAGS.

    To reproduce:

    $ ./configure --enable-trail-grades
    $ echo "EXTRA_CFLAGS = -O1" >> Mmake.params
    $ make
    $ make install

    Alternatively, if mercury is already installed with a asm_fast.gc.tr.debug.stseg grade:

    $ cd mercury-srcdist/library
    $ mmc --compile-to-c --grade asm_fast.gc.tr.debug.stseg int
    $ mgnuc --grade asm_fast.gc.tr.debug.stseg -- -O1 -c int.c int.o

    In both cases the following ICE has been observed:

    int.c: In function 'int_module123':
    int.c:21687:1: error: unable to generate reloads for:
    (insn 162 161 163 11 (parallel [
                (set (reg/v:DI 43 r15 [ MR_mr3 ])
                    (ashift:DI (reg/v:DI 42 r14 [ MR_mr2 ])
                        (const_int 6 [0x6])))
                (clobber (reg:CC 17 flags))
            ]) "int.m":1013:18 520 {*ashldi3_1}
         (expr_list:REG_UNUSED (reg:CC 17 flags)
            (nil)))
    during RTL pass: reload
    int.c21687:1: internal compiler error: in curr_insn_transform, at lra-constraints.c:3962

    The ICE only seems to occur with GCC 9.x. I've tried the following versions of GCC:

    * 8.3.0: no ICE
    * 9.2.0: ICE
    * 9.3.0: ICE
    * 10.2.0: no ICE
     
    Notes
    (0001104)
    juliensf   
    2020-09-18 16:28   
    It's a Mercury bug to the extent that we would ideally apply workarounds to avoid the bugs in the affected versions of GCC.
    (0001106)
    juliensf   
    2020-10-02 17:46   
    This is the issue from bug 0000492. The compiler already has a workaround for the problem, but by setting EXTRA_CFLAGS=-O1 you are overriding that workaround.

    The underlying issue is not present in the GCC 8 and 10 branches, but seems to affect all versions of GCC 9 for x86_64.




    View Issue Details
    519 [mercury] Bug minor always 2020-09-17 05:14 2020-10-01 23:08
    keri  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    extras/graphics/mercury_tcltk library may contain reference to unknown matherr symbol
    mtcltk.m contains the following:

    /*
    ** The following variable is a special hack that is needed in order for
    ** Sun shared libraries to be used for Tcl.
    */

    :- pragma foreign_code("C", "
        extern int matherr(void);
        int *tclDummyMathPtr = (int *) matherr;
    ").


    This workaround is no longer necessary with modern versions of Tcl and the matherr() function has been removed since version 8.4. [1]

    While libmercury_tcltk.so may be built, the resultant library may cause problems. For example, after building extras/graphics/mercury_tcltk:

    $ cd extras/graphics/samples/calc
    $ mmc --search-lib-files-dir ../../mercury_tcltk --library mercury_tcltk --make calc
    <snip>
    Making calc
    ** Error making 'calc'.
    ../../mercury_tcltk/libmercury_tcltk.so: undefined reference to 'matherr'
    collect2: error: ld returned 1 exit status


    We could either just remove the workaround or perhaps wrap it in some ifdef/endif block.


    [1] https://wiki.tcl-lang.org/page/tclDummyMathPtr
     
    Notes
    (0001105)
    juliensf   
    2020-10-01 23:08   
    I've deleted it; I'm pretty sure we don't care about versions of Tcl from before 1999 any more.




    View Issue Details
    518 [mercury] Bug minor have not tried 2020-09-17 00:07 2020-09-17 07:18
    keri  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Typo in extras/odbc.m
    When compiling extras/odbc.m a function symbol (stat) is being used instead of a variable (Statement) leading to the following warning:

    odbc.m: In function 'odbc_module16':
    odbc.m:1349:5: warning: the comparison will always evaluate as 'true for the address of 'stat' will never be NULL [-Waddress]
    Attached is a diff to resolve this.
    mercury-extras-odbc.patch (455 bytes) 2020-09-17 00:07
    https://bugs.mercurylang.org/file_download.php?file_id=306&type=bug
     
    Notes
    (0001103)
    zs   
    2020-09-17 07:18   
    The supplied patch has been committed. Thank you.




    View Issue Details
    517 [mercury] Bug minor always 2020-09-16 23:51 2020-09-16 23:51
    keri  
     
    normal  
    new  
    open  
    none    
    none  
       
    extras/mopenssl fails to compile in a par grade with libressl
    Using a par grade mopenssl.c fails to compile with libressl:

    Making Mercury/os/mopenssl.o
    mopenssl.m: In function 'mopenssl_module10':
    mopenssl.m:116.49: error: 'pthreads_thread_id' undeclared (first use in this function)
    mopenssl.m:116.49: note: each undeclared identifier is reported only once for each function it appears in
    mopenssl.m:116:5: warning: function declaration isn't a prototype [-Wstrict-prototypes]
    mopenssl.m:117.45: error: 'pthreads_locking_callback' undeclared (first use in this function); did you mean 'CRYPTO_SET_locking_callback'?
    mopenssl.m:117.45: note: each undeclared identifier is reported only once for each function it appears in
    mopenssl.m:117:5: warning: function declaration isn't a prototype [-Wstrict-prototypes]
    mopenssl.m: At top level:
    mopenssl.m:125:6: warning: no previous prototype for 'pthreads_locking_callback' [-Wmissing-prototypes]
    mopenssl.m:135.15: warning: no previous prototype for 'pthreads_thread_id' [-Wmissing-prototypes]
    ** Error making 'Mercury/os/mopenssl.o'.
    * use a version of Mercury configured with --enable-par-grades
    * compile extras/mopenssl on a host with libressl installed

    $ cd extras/mopenssl
    $ cp ../net/*.m ./
    $ mmc --grade asm_fast.par.gc.stseg --make libopenssl
    The attached diff adds function prototype declarations which allows mopenssl to compile.
    mercury-extras-mopenssl.patch (505 bytes) 2020-09-16 23:51
    https://bugs.mercurylang.org/file_download.php?file_id=305&type=bug
     
    There are no notes attached to this issue.




    View Issue Details
    516 [mercury] Bug minor have not tried 2020-08-04 11:34 2020-08-09 20:39
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Failure of tests/general/mode_inference_reorder with recent ROTDs.
    tests/general/mode_interference_reorder aborts with an uncaught exception when compiled
    with --intermodule-optimization -O5 using rotds 2020-07-30 through to 2020-08-01.

        Uncaught Mercury exception:
        Software Error: map.lookup: key not found
                Key Type: int
                Key Value: -1
                Value Type: hlds.hlds_pred.proc_info

    The last working ROTD was 2020-07-29.
     
    Notes
    (0001102)
    zs   
    2020-08-09 20:39   
    A fix for this symptom was committed 2020 aug 8.

    That diff documents the underlying problem but does not fix it,
    since the problem occurs only in very rare circumstances, and
    any proper fix would require work far out of proportion to its
    usefulness.




    View Issue Details
    513 [mercury] Bug minor have not tried 2020-07-15 20:16 2020-07-29 01:56
    maoko  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    higher-order terms in freebsd bug.
    Higher-order terms with multi deterministic behave weirdly in FreeBSD. The attached code print weird number whereas normally it should print 5. I guess it print some random value on the stack.
    a.m (481 bytes) 2020-07-15 20:16
    https://bugs.mercurylang.org/file_download.php?file_id=302&type=bug
    bug513.c (1,189 bytes) 2020-07-15 23:38
    https://bugs.mercurylang.org/file_download.php?file_id=303&type=bug
     
    Notes
    (0001094)
    zs   
    2020-07-15 22:38   
    On my Mac, the test case works in hlc, but fails in none.gc.
    (0001095)
    juliensf   
    2020-07-15 22:47   
    On my Linux system it fails (producing [take(0)]) on asm_fast.gc with the current rotd and 20.01.
    (It does work with Mercuy 14.01.1.)

    It also works with the MLDS backends in general (hlc.gc,java,csharp)
    (0001096)
    zs   
    2020-07-15 23:38   
    I have diagnosed the bug. It has nothing to do with higher order code or
    solutions. The problem is caused by incorrect tracking of where N is stored.

    The attached code is the code we generate for revert in LLDS grades.
    Initially, as the first argument, N is in r1. Since N is needed in the second
    disjunct but r1 may be overwritten in code executed after the if-then-else
    before execution backtracks to the second disjunct, we save N in framevar 1,
    and the second disjunct gets it from there.

    The problem is that (a) the else case of the if-then-else also gets N from
    framevar 1, but (b) the code for saving N in framevar 1 occurs *after* the
    test N % 2 = 0, and since 5 % 2 != 0, it is never executed. So yes, maoko
    was right: the value that the else case wraps up in take(), i.e. framevar 1,
    *is* a random value on the stack.
    (0001100)
    zs   
    2020-07-29 01:56   
    Fix committed 2020 July 29.




    View Issue Details
    514 [mercury] Bug minor always 2020-07-23 00:53 2020-07-28 19:19
    keri  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    asm_fast.gc.profdeep.stseg grade fails to compile with GCC 10
    Compiling Mercury with GCC 10 and profiling grades enabled can lead to a link-time failure:

    $ ./configure --enable-prof-grades

    $ make

    $ make install

    <snip>

    gcc -shared -Wl,--no-undefined \
        -o libmer_rt.so mercury.pic_o mercury_accurate_gc.pic_o mercury_agc_debug.pic_o mercury_atomic_ops.pic_o mercury_backjump.pic_o mercury_bitmap.pic_o mercury_builtin_types.pic_o mercury_construct.pic_o mercury_context.pic_o mercury_debug.pic_o mercury_deconstruct.pic_o mercury_deep_copy.pic_o mercury_deep_profiling.pic_o mercury_dlist.pic_o mercury_dummy.pic_o mercury_engine.pic_o mercury_file.pic_o mercury_float.pic_o mercury_getopt.pic_o mercury_getopt_long.pic_o mercury_grade.pic_o mercury_hash_table.pic_o mercury_heap_profile.pic_o mercury_hgc.pic_o mercury_ho_call.pic_o mercury_int.pic_o mercury_label.pic_o mercury_layout_util.pic_o mercury_memory.pic_o mercury_memory_handlers.pic_o mercury_memory_zones.pic_o mercury_minimal_model.pic_o mercury_misc.pic_o mercury_mm_own_stacks.pic_o mercury_overflow.pic_o mercury_par_builtin.pic_o mercury_prof.pic_o mercury_prof_mem.pic_o mercury_prof_time.pic_o mercury_profiling_builtin.pic_o mercury_reg_workarounds.pic_o mercury_region.pic_o mercury_regs.pic_o mercury_runtime_util.pic_o mercury_signal.pic_o mercury_stack_layout.pic_o mercury_stack_trace.pic_o mercury_stacks.pic_o mercury_stm.pic_o mercury_string.pic_o mercury_tabling.pic_o mercury_term_size.pic_o mercury_thread.pic_o mercury_threadscope.pic_o mercury_timing.pic_o mercury_trace_base.pic_o mercury_trace_term.pic_o mercury_trail.pic_o mercury_type_desc.pic_o mercury_type_info.pic_o mercury_type_tables.pic_o mercury_wrapper.pic_o mercury_wsdeque.pic_o \
        -Wl,-rpath,''/usr/local/lib/mercury/lib \
        -L/home/keri/mercury-srcdist-rotd-2020-07-17/install_grade_dir.asm_fast.gc.profdeep.stseg/boehm_gc -L/usr/local/lib -lgc_prof -lm ` case "asm_fast.gc.profdeep.stseg" in *.hlc.par*) echo -lpthread -ldl ;; *.par*) echo "-lpthread -ldl " ;; esac ` \
        `gcc -print-libgcc-file-name` -lm -lc
    /usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../x86_64-pc-linux-gnu/bin/ld: mercury_ho_call.pic_o:/home/keri/mercury-srcdist-rotd-2020-07-17/install_grade_dir.asm_fast.gc.profdeep.stseg/runtime/mercury_builtin_types_proc_layouts.h:71: multiple definition of `mercury_data__proc_layout__mercury____Compare___type_desc__type_ctor_desc_0_0'; mercury_builtin_types.pic_o:/home/keri/mercury-srcdist-rotd-2020-07-17/install_grade_dir.asm_fast.gc.profdeep.stseg/runtime/mercury_builtin_types_proc_layouts.h:71: first defined here

    <snip>

    /usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../x86_64-pc-linux-gnu/bin/ld: mercury_ho_call.pic_o:/home/keri/mercury-srcdist-rotd-2020-07-17/install_grade_dir.asm_fast.gc.profdeep.stseg/runtime/mercury_builtin_types_proc_layouts.h:41: multiple definition of `mercury_data__proc_layout__mercury____Unify___builtin__int8_0_0'; mercury_builtin_types.pic_o:/home/keri/mercury-srcdist-rotd-2020-07-17/install_grade_dir.asm_fast.gc.profdeep.stseg/runtime/mercury_builtin_types_proc_layouts.h:41: first defined here
    collect2: error: ld returned 1 exit status


    GCC 10 has included -fno-common in it's default set of flags. (The above build failure should be able to be reproduced with older versions of GCC by setting -fno-common in CFLAGS).


    The workaround I'm using at the moment is to is include -fcommon in CFLAGS.
     
    Notes
    (0001097)
    juliensf   
    2020-07-24 01:04   
    Placing proc layouts in common blocks is deliberate -- see the coment at the head of runtime/mercury_builtin_types_proc_layouts.h; we will need to arrange for -fcommon to be passed to GCC 10 and above.
    (0001098)
    zs   
    2020-07-24 13:09   
    I read that comment differently. To me, it says that the symbols of the *declarations*
    of the proc layout structures will end up in a common block whether we them to or not,
    and that we put those declarations into a separate .h file so that

    - we can control where those declarations are referenced from, and thereby
    - prevent those declarations from being mistaken by the linker for definitions.

    The better solution that the linkers at the time did not permit is to put the
    declarations in mercury_builtin_types.h, next to the definitions in the
    corresponding .c file. If all the compilers (and compiler versions) that
    we support have -fno-common or some equivalent, then we should switch to
    that solution.

    However, that will require us to fix another problem that I just discovered,
    which is that *some* of the proc_layout structures that we declare we don't define,
    and vice versa. Specifically, the definitions and declarations disagree about
    the arity of two type constructors in private_builtin.m: type_info and type_ctor_info.
    One says they are arity 0, while the other says arity 1, and the mismatch arises
    because the arity ends up in the name of the proc layout structure. I am just now
    bootchecking a fix for this problem. The only reason why this problem was not visible
    until now was the use of common storage, with its peculiar "declarations can act
    as definitions" rules.
    (0001099)
    zs   
    2020-07-28 19:19   
    Fix committed 2020 July 26.




    View Issue Details
    511 [mercury] Bug minor always 2020-06-19 18:22 2020-06-19 18:22
    zs  
    zs  
    normal  
    assigned  
    open  
    none    
    none  
       
    missing warning with --warn-unused-imports
    The versions of two compiler modules before the application of the attached diff
    contain unused imports that the compiler

    - warns about if --warn-unused-imports is NOT specified, but
    - does NOT warn about if --warn-unused-imports IS specified,

    which is the exact opposite of the expected behavior.

    The reason for this inversion is that warn_unused_interface_import in
    module_qual.qual_errors.m generates a less-informative error message
    that it disables if --warn-unused-imports is specified, on the grounds that
    the code in unused_imports.m, which implements --warn-unused-imports,
    will generate a more informative error message for the same issue.
    However, in these cases, unused_imports.m does not do so.
    DIFF.bug511 (1,268 bytes) 2020-06-19 18:22
    https://bugs.mercurylang.org/file_download.php?file_id=300&type=bug
     
    There are no notes attached to this issue.




    View Issue Details
    509 [mercury] Bug minor have not tried 2020-06-16 02:47 2020-06-16 02:47
    zs  
    zs  
    normal  
    assigned  
    open  
    none    
    none  
       
    higher_order.m optimizes soon-to-be-dead procedures
    When the compiler has read in a bunch of predicate/function definitions from .opt files,
    those definitions get added to set of valid preds. higher_order.m looks for optimization
    opportunities among the set of valid preds. However, the common case is that
    those .opt files contain a whole bunch of predicates of which the current module
    uses only a few either directly or indirectly. (When have you written any module
    that calls all or even most of the predicates exported from e.g. list.m or map.m?)
    Optimizing the predicates that one of the following compiler passes will soon delete
    as dead code is a performance bug.

    We should modify either higher_order.m or its caller to delete dead procedures
    from the HLDS before it starts its work.

    Note that we will still need to do a round of dead proc elimination *after* higher_order.m,
    since higher_order.m can sometimes replace all calls to a predicate with calls to a
    specialized version, which makes the original version obsolete. However, maybe
    this could be done by higher_order.m itself *faster* than dead_proc_elim.m could
    do it, since it should be possible to avoid the need to construct a full call graph
    to do the job; counting unspecialized call sites should do the job.
     
    There are no notes attached to this issue.




    View Issue Details
    502 [mercury] Feature Request minor have not tried 2020-04-28 23:25 2020-06-09 11:37
    zs  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    print unsigned numbers
    string.format and io.format should be able to print unsigned integers without
    the user having to explicitly convert them to a signed integer first.

    At the monent, signed ints can be printed with the d and i conversion chars,
    which print them as the signed ints they are, and with the o, u, x, X, and p
    conversion chars, which print them as if they were unsigned. I think the last
    five should be the conversion chars for which one should be able to pass
    *either* a i(int) poly_type, *or* a u(uint) polytype.
    When targeting C, the Mercury standard library can use either sprintf,
    or its own implementation. We have long defaulted to using sprintf, but
    we do already bypass it when dealing with data it would mishandle,
    such as non-ASCII UTF chars. The argument in favor of using sprintf
    has always been that it is faster than the library's format string interpreter,
    but this argument has lost most of its force when we started interpreting
    format strings at compile time. Perhaps it is time to stop using sprintf.

     
    Notes
    (0001090)
    juliensf   
    2020-04-29 17:42   
    It was always intended that the format predicates be extended to support all of the new integer types (not just uint). The first thing that needs to be decided is which conversion specifiers apply to which types (in particular should format support printing out unsigned integers as signed values).

    There are two main uses of sprintf in the standard library:

    1. in the primitive to_string conversion of things like integers and floats; here it's most probably a loss for us since the conversion specifier is fixed and we end up wasting time processing it.

    2. in the implementation of the format predicates

    I'm in favour of replacing use case (2) for the C backends now.
    (0001091)
    zs   
    2020-05-01 17:33   
    I don't know any use case that would justify being able to print uint values
    as signed with %d or %i. The use case for reverse (being able to print int
    values as unsigned with %u, %o, %x, %X or %p) was two-fold and obvious:
    the absence of uint at the time, and the fact that we implemented printing
    by calling C's print, which allowed it. In fact, it allowed this precisely because
    due to its variadic nature, printf couldn't be told that any integers passed to it
    were unsigned. So in both cases, the possible loss of meaning as a negative
    number was treated as unsigned was unavoidable. That is not the case here.
    (0001092)
    juliensf   
    2020-05-01 18:21   
    I'm not arguing that we need to support signed conversion specifiers with unsigned values -- I can't see any obvious use case for it either -- just that we need to define what is / will be supported.
    (0001093)
    juliensf   
    2020-06-09 11:37   
    Implemented by commit 9528f32.




    View Issue Details
    507 [mercury] Feature Request minor have not tried 2020-05-01 17:52 2020-05-01 17:52
    zs  
     
    normal  
    new  
    open  
    none    
    none  
       
    detect missing foreign_procs
    We should add a compiler option that causes the compiler
    to generate a warning for every procedure that passes neither
    of the following tests:

    Test 1: it has a Mercury definition.

    Test 2: it has a definition in each of C, Java, C# and (maybe) Erlang.

    The test is for procedures, not predicate or functions,
    because foreign_procs are for procedures, and with mode-specific
    clauses, Mercury clauses can be as well. However, if a predicate
    or function has two or more procedures, and they all fail both tests,
    we should probably generate one message, not several.

    At the moment, I believe a substantial chunk of the test case failures
    in C# and Java grades are caused by missing foreign_procs for these
    languages that this option should help us find more easily. More important,
    enabling this warning for all modules in the library, which is compiled with
    --halt-at-warn, should help us not just to fix this, but *keep* it fixed.

    As for the option name, how about --warn-missing-foreign-procs?
     
    There are no notes attached to this issue.




    View Issue Details
    505 [mercury] Feature Request minor have not tried 2020-05-01 16:46 2020-05-01 17:23
    zs  
    zs  
    normal  
    assigned  
    open  
    none    
    none  
       
    allow reference only to explicitly imported modules
    This one could be viewed as either a feature request or a bug fix, depending
    on perspective.

    Have the type and mode checkers generate an error if a predicate defined
    in the module being compiled has a reference to a type, inst, mode, predicate,
    function, or typeclass that is not defined in an *explicitly* imported module.

    The point is that the compiler implicitly imports some modules. For example,
    if the module being compiled contains a try/catch goal, we implicitly import
    the exception module, because our implementation of try/catch includes
    adding references to entities defined in that module. Currently, this means
    that such modules need not explicitly import exception even if the *rest* of
    the module makes references to entities defined in exception.m, because
    such references are satisfied by the implicit import. But this behavior looks
    inconsistent to users, since they don't know or care how try/catch is
    implemented, from their point of view, exception.m became available
    to the module being compiled as if magic.

    This access-as-if-by-magic can happen to some other modules
    that we can import implicitly, and even to user modules, which can be
    made available to the module being compiled if intermodule optimization
    is enabled via the int-for-opt mechanism, whereby we read the interface
    files of not-explicitly-imported modules because they are needed to
    allow type- and mode-checking of code included in .opt files.
    This is why the restriction would apply *only* when type- and mode-checking
    predicates defined in the module being compiled; applying it to code
    included from .opt files would defeat the purpose of reading int-for-opt files.
     
    There are no notes attached to this issue.




    View Issue Details
    506 [mercury] Feature Request minor have not tried 2020-05-01 17:22 2020-05-01 17:23
    zs  
    zs  
    normal  
    assigned  
    open  
    none    
    none  
       
    --recommend-order
    It would be nice if the compiler could recommend an order for the predicates
    (and functions) defined in a module. The order I am thinking of having the
    compiler recommend would be computed as:

    - Compute the SCCs of predicate call graph, each SCC containing
      a set of mutually recursive predicates.

    - Compute the dependencies between SCCs as a tree
      that the following steps flatten to a list that is *consistent*
      with the tree, in the sense that if SCC A contains a call to something
      in SCC B, then have SCC A appear before SCC B in the list of SCCs.

    - If the module contains N exported predicates, named e.g. Exported1
      through ExportedN, the compute the call tree of each exported predicate.
      (Consider each set of mutually-recursive exported predicates to be
      just one exported predicate, for simplicity of exposition in the following.)
      By the definition of SCCs, each call tree will contain either all the predicates
      in an SCC or none of them, so we can speak of each call tree as being
      composed of SCCs. Partition the SCCs into N+1 partitions, with partition I
      consisting of the SCCs that part of the call tree of *only* ExportedI,
      with the last partition consisting of the SCCs that are part of the call tree
      of more than one exported predicate. Put all the SCCs in each partition
      before all the SCCs in any later partitions.

    - In each of the first N partitions, put the one containing the exported predicate(s)
      first.

    - If the relative order of two SCCs in a partition is not determined by the rules
       above, order them by the line number of the context where the first reference
      to them occurs. (This may be a call to a predicate in the SCC, or the construction
      of a closure containing a reference to such a predicate.) This should yield
      a complete order of the SCCs that do contains some reference to them.
      The SCCs that have no such references contain dead code, and they should be
      reported as such.

    - Within each non-dead SCC, put the exported predicates (if any) first, in order of
      the line numbers of their declarations. The nonexported predicates should follow,
      in the order of the line numbers of the first references to them. This should establish
      a complete order among the non-dead predicates.
     
    There are no notes attached to this issue.




    View Issue Details
    503 [mercury] Feature Request minor have not tried 2020-04-28 23:51 2020-04-29 17:25
    zs  
     
    normal  
    new  
    open  
    none    
    none  
       
    unsigned shift amounts
    At the moment, the shift amount is always a signed int, even when the
    value being shifted has type uint. It should be possible to make the shift amount
    an unsigned int. This would have the advantage that of the two checks that
    checked shifts have to do, checking for negative shift amounts and checking for
    shift amounts bigger than the word size, an unsigned shift amount would need
    only the latter.

    The key question is the syntax. Unlike e.g. C++, we cannot overload <<, >>, and
    their unchecked equivalents; we would need new function names. I can see
    using either <<< and >>>, or <<u and >>u as the names of the unsigned
    versions of << and >>. And maybe unchecked_{left,right}_shift_by_uint
    or unchecked_{left,right}_ushift for their unchecked versions.

    Any ideas for better names, or opinions on these names?
     
    Notes
    (0001085)
    wangp   
    2020-04-29 16:26   
    The two checks are supposed to be performed using a single unsigned comparison on the shift amount, so is there anything to gain?

    I don't think the new operators would be used enough to justify them. Also, Java has >>> meaning logical right shift (I had to look that up) -- it would be best not to introduce operators that conflict with operators in well known languages.
    (0001086)
    zs   
    2020-04-29 16:39   
    The gain I am after is not efficiency. The gain is being able to write code
    such as "1u <<u NumBits" instead of "1u << uint.cast_to_int(NumBits)".
    I am working on a version of du_type_layout.m that would work at
    "create .int file" time instead of code generation time, and that code
    is full of things that cannot be negative: number of arguments in a functor,
    word lengths, bitfield sizes, shift amount etc. It is a pain having to choose
    between

    (a) using ints, and losing the >= 0 invariant, and
    (b) using uints, and having to pepper calls to most library functions
    with casts, because those functions take only signed ints, to the extent
    that the casts obscure the actual logic of the code.
    (0001087)
    zs   
    2020-04-29 16:40   
    On the topic of avoiding >>>, I agree; if we don't have to create
    such conflicts of notation, we shouldn't.
    (0001088)
    wangp   
    2020-04-29 17:03   
    You could define an overload in a compiler module to improve clarity:

    :- func uint << uint = uint.

    X << Y = uint.(X << cast_to_int(Y)).


    That is not to say we should not add named functions taking unsigned shift amounts to the standard library.
    (0001089)
    juliensf   
    2020-04-29 17:25   
    Java only has >>> for logical right shifts because it doesn't support unsigned types but does provide (some) unsigned operations on its signed types. AFAIK, it is the only well known language that has that.

    I'd be fine with unchecked_{left, right}_ushift for the unchecked versions. I'm not really a fan of things like >>u and <<u, but I can probably live with them. (I guess just having the functions left_ushift and right_ushift is too ungainly?)




    View Issue Details
    504 [mercury] Feature Request minor have not tried 2020-04-28 23:58 2020-04-28 23:58
    zs  
    zs  
    normal  
    assigned  
    open  
    none    
    none  
       
    make checked shifts builtins
    At the moment, we generate inline code for unchecked shifts, but a call
    to a library function for checked shifts. We should generate inline code
    for the latter as well. This would require extending the simple_code type
    in builtin_ops.m to be able to handle not just a test *or* an assignment,
    but a test *and* an assignment (if the test succeeds) *and* an abort
    (if it fails).

    That functionality should also allow us to generate inline code for
    checked quotients and remainders.
     
    There are no notes attached to this issue.




    View Issue Details
    497 [mercury] Feature Request minor always 2020-04-03 15:13 2020-04-20 15:09
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    make disable_warning forwards compatible
    Currently if the compiler does not recognise a warning name in a disable_warning(s) goal, it will report an error. I think we can reduce the severity of an unknown warning name from an error to a warning. This will provide a transition period in which a source file that has been updated to suppress warnings when using a newer compiler version, will still compile (with warnings) when using an older compiler.
     
    Notes
    (0001077)
    zs   
    2020-04-04 02:43   
    Feature implemented 2020 april 4.
    (0001078)
    wangp   
    2020-04-04 13:07   
    Thanks for taking a look.

    However, the change is incomplete. When the clause is to be added in module_add_clause_2, MaybeBodyGoal is error1(...), the clause is not added, and compilation stops soon after.

    BTW, this also affects duplicated names in disable_warnings scopes. The error message says "Error:" but the error spec has severity_warning.
    (0001084)
    wangp   
    2020-04-20 15:08   
    Fixed in commit 4f32c5082




    View Issue Details
    461 [mercury] Bug minor sometimes 2018-05-17 11:15 2020-04-20 15:06
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    MR_verify_final_engine_sleep_sync assertion failure (parallel conjunction)
    Tests in par_conj fail intermittently in asm_fast.par.gc with an assertion failure of the form:

    dep_par_17: mercury_context.c:1839: MR_verify_final_engine_sleep_sync: Assertion `esync->d.es_action == MR_ENGINE_ACTION_NONE' failed.


    (As I remember, it doesn't just affect parallel conjunction but threads as well.)
     
    Notes
    (0001081)
    wangp   
    2020-04-17 13:40   
    I found that I can reproduce this without parallel conjunction. The following command fails reliably on my machine. (parallel is GNU parallel; closeable_channel_test is from tests/hard_coded)

    parallel ./closeable_channel_test >/dev/null ::: `seq 1 1000`

    When the assertion in MR_verify_final_engine_sleep_sync fails, the value of esync->d.es_action is always MR_ENGINE_ACTION_SHUTDOWN.
    (0001082)
    wangp   
    2020-04-17 17:34   
    In MR_do_idle_worksteal we have:

            switch (esync->d.es_action) {
                case MR_ENGINE_ACTION_SHUTDOWN:
                    action_shutdown_ws_engine();

    Then the call sequence goes:

    action_shutdown_ws_engine -> MR_finalize_thread_engine -> MR_shutdown_engine_for_threads -> MR_verify_final_engine_sleep_sync

    Nothing changes esync->d.es_action before MR_verify_final_engine_sleep_sync asserts its value:

        assert(esync->d.es_action == MR_ENGINE_ACTION_NONE);


    So the fix is either to widen the assertion, or to set esync->d.es_action = MR_ENGINE_ACTION_NONE somewhere after switching on it.
    (0001083)
    wangp   
    2020-04-20 15:06   
    Fix committed 2020-04-20




    View Issue Details
    480 [mercury] Bug minor always 2019-08-05 17:09 2020-04-15 12:58
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    regression in cse_detection.m
    The attached test case fails to compile.

    % mmc -C cse_detection_regression.m
    cse_detection_regression.m:013: Error: invalid determinism for `to_bool'(in) =
    cse_detection_regression.m:013: out:
    cse_detection_regression.m:013: the primary mode of a function cannot be
    cse_detection_regression.m:013: `nondet'.
    cse_detection_regression.m:013: In `to_bool'(in) = out:
    cse_detection_regression.m:013: error: implicit determinism declaration not
    cse_detection_regression.m:013: satisfied.
    cse_detection_regression.m:013: Declared `det', inferred `nondet'.
    cse_detection_regression.m:022: Unification with `maybe.yes(V_8)' can fail.
    cse_detection_regression.m:024: Disjunction has multiple clauses with
    cse_detection_regression.m:024: solutions.
    cse_detection_regression.m:025: Unification with `maybe.no' can fail.
    For more information, recompile with `-E'.


    I bisected the problem to this change:

    commit 2466524308930c380483a90c7d767a74e7c8507b
    Author: Zoltan Somogyi <zoltan.somogyi@runbox.com>
    Date: Sun Jun 30 20:16:07 2019 +0200

        Fix cse_detection.m's interaction with uniqueness.
        
        This fixes github issue 0000064.

    compiler/cse_detection.m:
            When pulling a unification X = f(Y1, ..., Yn) out of an arm of
            a disjunction, switch or if-then-else, require the instantiation state
            of X to be free of unique or mostly_unique components.
        
            Put the requirements on X's inst into a single predicate.
        
            Add a mechanism to make debugging similar issues easier.
        
    cse_detection_regression.m (503 bytes) 2019-08-05 17:09
    https://bugs.mercurylang.org/file_download.php?file_id=288&type=bug
    bug480b.m (470 bytes) 2019-08-19 13:48
    https://bugs.mercurylang.org/file_download.php?file_id=290&type=bug
     
    Notes
    (0001042)
    zs   
    2019-08-05 21:11   
    Commit 9fab528bba40d614fb5b715a350330a5f346da9f should fix
    most occurrences of this bug.
    (0001043)
    wangp   
    2019-08-19 13:48   
    Attaching a test case. (I previously posted it to the reviews list but it belongs here.)
    (0001044)
    zs   
    2019-08-19 19:07   
    It seems that with the current mode analysis system, there can't
    really be a simple satisfactory fix for the root cause of this problem.
    This is due to the fact that replacing "X = f(Y1, Y2)" with
    "X = f(A1, A2), A1 = Y1, A2 = Y2", which is the basic transformation
    on which cse is built, makes it lose track of any uniqueness in
    X's arguments.

    The original change to cse in June to fix github issue 64 was
    too conservative in that it avoided making that transformation
    not just when it would screw up uniqueness, but in other cases
    as well. The original and updated fixes to Mantis bug 480 made
    cse less conservative but still conservative enough. However,
    Peter's latest test case shows that the current approach will
    never be able to draw the line correctly between too conservative
    and not conservative enough. This is because it involves uniqueness
    in arguments that (a) the cse transformation would screw up, but
    (b) the program does not *care* if this uniqueness is screwed up,
    because it is only an accidental byproduct of that argument being
    a newly constructed term, and the uniqueness of this argument
    (the visited field in bug480b.m) is never required by any of its
    consumers. Part b is not a local property; it involves at least
    all of the rest of the procedure, and in the presence of mode inference,
    it may involve the code of the rest of the module as well.

    A way to solve this problem would be to downgrade unique insts
    to ground insts in situations that do not care about uniqueness.
    However, actually doing this would be hard, because it would require
    circular interaction between compiler phases. We do cse in stage 45,
    determinism analysis in stage 50, and unique mode checking in stage 55.
    Each phase depends on the results of the previous phase. We don't *know*
    which unique insts are required and which are not, until the end of
    stage 55, yet cse would need this info in stage 45.

    We *could* get cse to pull unifications out of disjunctions even if
    it would screw up uniqueness, but handle github issue 64 by recording
    this fact in the proc_info, and then redoing everything from cse onward
    if we get any error during unique mode analysis for any procedure
    that has been so marked. However, I would not call such a solution "simple",
    not least because a procedure may have done N such pulls involving unique args,
    and we don't know *which subset* of those N pulls we have to undo (to preserve
    uniqueness-correctness), which subset we *must not* undo (to preserve the
    expected determinism), and which subset would be fine either way.

    I would prefer to leave this issue in its current state with only one change:
    a note in NEWS mentioning that due to a bug fix, switches on variables' fields
    (as opposed to switches on variables themselves) may not be recognized as such,
    and telling people to replace such code with a switch on a variable. This would
    get users to do manually what cse used to do before the github 64 fix, the
    difference being that they should (would?) not be surprised by any errors
    involving uniqueness arising out of such a change.

    Since determinism analysis is inherently undecidable, such changes in heuristics
    are easily defensible.

    We could revisit this decision if/when a constraint based mode analysis
    is able to track uniqueness through the extra unifications added by cse.
    (0001045)
    wangp   
    2019-08-20 10:35   
    Thanks for the explanation. I think leaving it in the current state is acceptable.
    (0001080)
    zs   
    2020-04-15 12:58   
    Mantis bug 496 is a duplicate of this issue. It was resolved, to the extent
    possible, on 2020 feb 7.




    View Issue Details
    496 [mercury] Bug minor have not tried 2020-02-05 10:20 2020-04-15 12:56
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Determinism error in 20.01 for code that compiles successfully in 14.01.1
    The attached predicate compiles successfully with Mercury 14.01.1 but
    gets a determinism error with 20.01. (It also compiles successfully with
    rotd-2018-05-10.)
    bug496.m (1,807 bytes) 2020-02-05 10:20
    https://bugs.mercurylang.org/file_download.php?file_id=296&type=bug
     
    Notes
    (0001074)
    zs   
    2020-02-05 11:04   
    The cause of this bug is the fix for another bug: github 64.
    That fix did come with an announcement that reqressions like this
    would happen.

    I also think this bug is probably a duplicate of Mantis bug 480.

    The problem is that the code that constructs the final value of !:Actions
    gives it an inst that contains unique components (specifically, the constants
    action_canonicalise and action_split). In the presence of insts containing unique
    components, cse_detection.m refuses to automatically transform the switch
    on AllActions to the commented-out version, which directly leads to the bug.

    As mentioned in the discussion of bug 480, fixing this properly is hard.
    I can see a possible band-aid solution that *could* fix this and similar instances,
    though of course not all others. This would involve changing the test in
    cse_detection.m from "does the inst of the variant concerned (AllActions) include
    any unique components" to "does it contains any unique components on
    non-constants" (since constants do not have cells on the heap). The "could"
    part above is because I am pretty sure this change would revive github bug 64,
    but don't know whether fixing that in the constants-only case is possible.

    Even if it didn't, it would have the downside that it would make the rules
    followed by determinism analysis (when viewed from a user's point of view,
    and so including cse) more complex still.

    Who thinks this tradeoff is worth making?
    (0001075)
    juliensf   
    2020-02-05 11:25   
    I don't think the tradeoff is worth making; it's going to make an already complicated situation even more complicated.

    Question: how feasible is it to detect the above situation and make the error message suggest the refactoring?
    (0001076)
    zs   
    2020-02-05 11:45   
    It should be easy to

    - have cse record, in the proc_info the fact that it declined to pull a common unification
      out of a disjunction due to uniqueness concerns, and

    - have determinism analysis look at this flag, and if set, and there are determinism errors,
      print a message about this fact being a possible cause of the errors.

    What I am not sure about is whether we can give this message a useful context,
    for two reasons. One: by definition, a common deconstruction involves at least
    two contexts, maybe more, and listing them all probably wouldn't be useful.
    We can probably use the smallest context (i.e. the one with the smallest
    line number). Two, when cse pulls a deconstruction unification out of the arms
    of a disjunction, the pulled-out unification does not come from any one place,
    so there is no one "right" context it can record for it. Again, we can probably
    use the smallest context among the pulled-out unifications. This would then
    be a context we could report if there is a problem in the *next* invocation
    of cse on that procedure body. But given the approximations above, I am not sure
    whether the context they would yield would useful in the common cases.

    However, given that the pointer to the cause of the error would be useful
    even without a specific context, I will implement it.
    (0001079)
    zs   
    2020-04-15 12:56   
    The reminder about this possible cause of the determinism error,
    based on a flag set by cse_detection.m, was added to the compiler
    on 2020 feb 7.




    View Issue Details
    498 [mercury] Feature Request minor have not tried 2020-04-04 21:01 2020-04-04 21:01
    zs  
    zs  
    normal  
    assigned  
    open  
    none    
    none  
       
    handle misalignment of arguments in type errors better.
    Suppose you have a predicate p with arguments A, B, C.
    When you add an extra arg at the start of the argument list, say X,
    then existing calls p(A, B, C) won't match the new definition p(X, A, B, C),
    but they *could* be taken as attempts to curry a call to p.

    We currently generate an error message that says 1: arg A should have type X,
    2: arg B should have type A, 3: arg C should have type B.

    The compiler should notice that each arg i has the type expected of arg i+j,
    where j is the number of added arguments, and generate an error message
    that reports *this*, instead of generating a message about each argument's
    wrong type.
     
    There are no notes attached to this issue.




    View Issue Details
    120 [mercury] Bug minor have not tried 2009-12-18 10:51 2020-02-04 17:24
    juliensf  
    juliensf  
    normal  
    resolved  
    won't fix  
    none    
    none  
       
    bootchecking in reg.gc fails on Mac OS 10.6
    Bootchecking in grade reg.gc fails on Mac OS 10.6. It gets as far as building
    the stage 2 dependencies and then we get out of memory errors from the GC.
     
    Notes
    (0000253)
    juliensf   
    2010-02-27 18:23   
    This still fails even with the Boehm GC upgrade (to 7.2alpha4).
    (0001073)
    juliensf   
    2020-02-04 17:24   
    There's not much use fixing this; Apple no longer support OS 10.6, so there's no point in us supporting it.




    View Issue Details
    484 [mercury] Feature Request minor N/A 2019-09-18 23:00 2020-01-24 17:56
    zs  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    error message could be more specific
    The error message is
    bug484.m:018: In clause for `p(in, out, out)':
    bug484.m:018: in call to predicate `list.foldl'/4:
    bug484.m:018: mode error: arguments `V_8, As, X, B' have the following insts:
    bug484.m:018: /* unique */ (pred(in, in, out) is det),
    bug484.m:018: free,
    bug484.m:018: ground,
    bug484.m:018: free
    bug484.m:018: which does not match any of the modes for predicate
    bug484.m:018: `list.foldl'/4.

    It should point that it is only the second argument whose mode is wrong.
    bug484.m (485 bytes) 2019-09-18 23:00
    https://bugs.mercurylang.org/file_download.php?file_id=292&type=bug
     
    Notes
    (0001071)
    zs   
    2020-01-24 17:56   
    Error message improved on 2020 jan 24.




    View Issue Details
    493 [mercury] Bug minor always 2020-01-22 14:50 2020-01-23 11:46
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    MLDS ground terms bug
    MLDS backend crashes on the attached test case when --loop-invariants is enabled (or -O5).

    % ./build.sh
    + mmc -s hlc.gc --make-interface codepoint
    + mmc -s hlc.gc --loop-invariants -C bug
    Uncaught Mercury exception:
    Software Error: map.lookup: key not found
            Key Type: term.var(parse_tree.prog_data.prog_var_type)
            Key Value: var(7)
            Value Type: ml_backend.ml_gen_info.ml_ground_term
    mlds_ground_term_bug.tar.gz (10,240 bytes) 2020-01-22 14:50
    https://bugs.mercurylang.org/file_download.php?file_id=295&type=bug
     
    Notes
    (0001070)
    zs   
    2020-01-23 11:46   
    Fix committed 2020 Jan 22.




    View Issue Details
    492 [mercury] Bug minor always 2020-01-13 18:41 2020-01-18 22:23
    juliensf x86_64  
    juliensf Fedora  
    normal 31  
    resolved  
    fixed  
    none    
    none  
       
    make install fails with GCC internal error on Fedora 31
    The 'make install' step fails for 20.01-beta-2020-01-12 on Fedora 31 with the following message when attempting to build the library in the asm_fast.gc.debug.stseg grade. The GCC version is 9.2.1.

    mmc --compile-to-c --grade asm_fast.gc.debug.stseg --mercury-linkage shared --flags LIB_FLAGS --flags INTER_FLAGS -R/home/juliensf/mercury-20.01-beta-2020-01-12/lib/mercury/lib/asm_fast.gc.debug.stseg -R/home/juliensf/mercury-20.01-beta-2020-01-12/lib/mercury/lib hash_table > hash_table.err 2>&1
    /home/juliensf/mercury-srcdist-20.01-beta-2020-01-12/install_grade_dir.asm_fast.gc.debug.stseg/scripts/mgnuc --grade asm_fast.gc.debug.stseg -- -c hash_table.c -o hash_table.o
    hash_table.c: In function ‘hash_table_module45’:
    hash_table.c:11468:1: error: unable to generate reloads for:
    (insn 498 497 499 32 (parallel [
                (set (reg/v:DI 43 r15 [ MR_mr3 ])
                    (ashift:DI (reg/v:DI 42 r14 [ MR_mr2 ])
                        (const_int 31 [0x1f])))
                (clobber (reg:CC 17 flags))
            ]) "hash_table.c":11443:33 520 {*ashldi3_1}
         (expr_list:REG_UNUSED (reg:CC 17 flags)
            (nil)))
    during RTL pass: reload
    hash_table.c:11468:1: internal compiler error: in curr_insn_transform, at lra-constraints.c:3962
    Please submit a full bug report,
    with preprocessed source if appropriate.
    See <http://bugzilla.redhat.com/bugzilla> for instructions.
    Preprocessed source stored into /tmp/ccOvGbry.out file, please attach this to your bugreport.
    gmake[2]: *** [/tmp/mmake.kZqh3s:89984: hash_table.o] Error 1
     
    Notes
    (0001065)
    wangp   
    2020-01-13 19:54   
    I previously reported it here:
    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91430
    (0001066)
    juliensf   
    2020-01-13 20:05   
    Do you know if there is a workaround we can use for it?
    (0001067)
    wangp   
    2020-01-13 20:52   
    Unfortunately, no.
    (0001068)
    juliensf   
    2020-01-15 14:42   
    Also, occurs with Alpine Linux 3.11 (GCC 9.2). I think we will just need to force GCC to use -O0 in debug grades with GCC 9.1 and 9.2. (The bug only seems to be triggered in debug grades.)
    (0001069)
    juliensf   
    2020-01-18 22:23   
    We now force the use of gcc -O0 in debug grades with GCC 9.
    (Confirmed that installation of the source distribution works with
    both Fedora 31 and Alpine Linux 3.11 out of the box.)




    View Issue Details
    489 [mercury] Bug minor always 2020-01-09 14:31 2020-01-15 19:54
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    mmc --make gets confused by source files with same name as standard library module
    mmc --make gets confused by a source file in the current directory that matches the name of a standard library module, e.g. in the attached test case, lexer.m contains the sub-module `test.lexer'.


    Test 1 - tries to make lexer.mih from lexer.m
    ---------------------------------------------
    % mmc -s hlc.gc -m test -v
    Making Mercury/mihs/lexer.mih
    Invoking self `mmc [...] lexer' <-- not test.lexer
    ...
    lexer.m:010: In module `lexer': error:
    lexer.m:010: the absence of an `:- import_module' or `:- use_module'
    lexer.m:010: declaration for `test' prevents access to the `:- import_module'
    lexer.m:010: declaration for its child module `test.other'.



    Test 2 - likewise for .opt files
    --------------------------------
    % mmc -s asm_fast.gc --intermod-opt -m test
    Making Mercury/opts/test.opt
    Making Mercury/opts/test.lexer.opt
    Making Mercury/opts/test.other.opt
    Making Mercury/opts/lexer.opt
    lexer.m:010: In module `lexer': error:
    lexer.m:010: the absence of an `:- import_module' or `:- use_module'
    lexer.m:010: declaration for `test' prevents access to the `:- import_module'
    lexer.m:010: declaration for its child module `test.other'.
    ** Error making `Mercury/opts/lexer.opt'.
    mmc_make_source_filename_confusion.tar.gz (10,240 bytes) 2020-01-09 14:31
    https://bugs.mercurylang.org/file_download.php?file_id=294&type=bug
     
    Notes
    (0001056)
    wangp   
    2020-01-09 16:23   
    Notes:

    do_get_module_dependencies assumes the SourceFileName returned by module_name_to_file_name can only be the source file for the given ModuleName, so the solution may require reading the `:- module` item before proceeding with make_module_dependencies.

    If a source file map is present, it may be helpful to rule out the default source file name: if "lexer.m" is mapped to `test.lexer' then it cannot be the source file for module `lexer'.
    (0001057)
    zs   
    2020-01-09 21:18   
    The documentation of the -f option states:

    "Output the module name to file name mapping for the list of source files given as non-option arguments to ‘mmc’ to Mercury.modules. This must be done before ‘mmc --generate-dependencies’ if there are any modules for which the file name does not match the module name. If there are no such modules the mapping need not be generated."

    So if there is NO source file map present, mmc --make is *allowed* to assume that lexer.m
    contains a module named "lexer", and *not* a module named "test.lexer".

    The error message it generates could of course be improved, e.g. by drawing attention
    to this fact, but in this case, I don't think the compiler is confused; more like it is misled,
    which is not its fault.

    Or am I missing something?
    (0001058)
    wangp   
    2020-01-09 21:53   
    The section on separate sub-modules states:

    "For a module named ‘foo.bar.baz’, The University of Melbourne Mercury implementation requires the source to be located in a file named foo.bar.baz.m, bar.baz.m, or baz.m."
    (0001059)
    zs   
    2020-01-11 18:57   
    We have two endpoints of a spectrum where the answer to the question
    "should you have to run mmc -f *.m?" is clear-cut.

    Endpoint A: every module is in a file whose name is the fully qualified module name.

    Endpoint B: every module is a file whose name has no relationship to the module name.

    It is clear that at Endpoint A, the answer is "no", while at endpoint B, it is "yes".

    At the moment, the answer is also "no" if every module is in a file whose name is either
    the fully qualified module name *or a subsequence* of the fully qualified sequence.
    The code that implements that check, in read_first_module_decl in parse_module.m,
    already has an XXX, on code that accepts module A.B.C not just as being in file A.C.m,
    but also as being in file A.D.B.C.m. And your bug report demonstrates another problem
    with the existing code.

    There are two ways to fix this bug. One is to change this code to require the expected
    module name and the actual module name to be identical. Without mmc -f, this would mean
    that the answer is "yes" everywhere except at Endpoint A. This would be a change from
    the current situation, and would require a change in the manual, but the rule would be simple
    and easy to obey: always use mmc -f. The other possible approach to the fix, which I read
    your initial note as supporting, would require the compiler to look for a known module name
    (test.lexer) in one file name after another (all being subsequences of the fully qualified
    module name) until it found one whose :- module declaration had the looked-for name.
    (In this case, we would need to look in just two places, test.lexer.m and lexer.m, but in
    general, the list could be a lot longer). In effect, this approach would require mmc
    --generate-dependencies to do a significant part of the job of mmc -f. I, for one,
    would find that solution more complex than necessary, from the user's point of view
    as well as from an implementor's.
    (0001060)
    wangp   
    2020-01-12 12:08   
    The current rules have always seemed oddly lax to me, and I think most larger Mercury project would be using mmc -f for one reason or another, so I have no problem with changing the compiler's behaviour such that modules must be in a file whose names is the fully qualified module name (.m), or else listed in the source file map.
    (0001061)
    zs   
    2020-01-12 12:14   
    In that case, I will post a proposed diff for doing this later today.

    I also propose that this change be part of 20.01. Any objections?
    (0001062)
    juliensf   
    2020-01-12 12:55   
    There are definitely some larger Mercury projects that do *not* use mmc -f; Opturion's runtime library is an example. That's not an objection since the fix is trivial, but the proposed change is going to break some things.

    No objections to including this in 20.01 for me.
    (0001063)
    zs   
    2020-01-12 22:28   
    Fix committed 2020 jan 12.
    (0001064)
    wangp   
    2020-01-13 10:49   
    A file listed in the source file map needs to be not returned as the source file for some different module. (assigning to self; Mantis only has a "Request feedback" button)




    View Issue Details
    491 [mercury] Feature Request minor have not tried 2020-01-12 22:32 2020-01-12 22:32
    zs  
    zs  
    normal  
    assigned  
    open  
    none    
    none  
       
    implicit imports in interface files
    We currently scan items in interface files we have just read in
    to find out what builtin modules they implicitly need (e.g. tabling_statistics.m
    if a pragma memo specifies the gathering of tabling statistics).

    Instead of requiring the N readers of the interface file to compute this set,
    the one generator of the interface file should compute this and put the
    result into the interface file as a new kind of declaration.
     
    There are no notes attached to this issue.




    View Issue Details
    490 [mercury] Feature Request minor N/A 2020-01-11 18:18 2020-01-11 18:18
    zs  
    zs  
    normal  
    assigned  
    open  
    none    
    none  
       
    when importing A.B, do not require importing A
    Currently, a module X that imports A.B must also import A; if it does not, it gets
    an error about A.B being inaccessible. This makes C unnecessarily dependent on A,
    which is undesirable; for example, it leads to X having to be recompiled when
    a new submodule A.C gets added to A, even though X has nothing to do with A.C.

    This issue was discussed on m-rev in november of 2015 in a thread named
    "should we break up module_qual.m". This discussion reached a concensus
    in favour of this change.
     
    There are no notes attached to this issue.




    View Issue Details
    488 [mercury] Bug minor have not tried 2019-10-27 17:14 2019-10-28 05:02
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Variable as pred name in predmode decl causes generates incorrect error message
    Using a variable as predicate name in a predmode decl, for example:

        :- pred MyPred(int::in, int::out) is semidet.

    results in the following:

       foo.m:007: Error: some but not all arguments have modes.
       foo.m:007: The argument without a mode is the first.

    Using a variable in a separate predicate or mode declaration for a predicate results in a
    correct error message.


     
    Notes
    (0001055)
    zs   
    2019-10-28 05:02   
    Fix committed 2019 10 28.




    View Issue Details
    487 [mercury] Bug minor always 2019-10-08 17:04 2019-10-08 21:06
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Incomplete and confusing error message
    Among the error messages generated for the attached test case is:

        bug487.m:029: When the condition succeeds, the if-then-else defines, but when
        bug487.m:029: the condition fails, it does not.

    Defines what?
    bug487.m (1,537 bytes) 2019-10-08 17:04
    https://bugs.mercurylang.org/file_download.php?file_id=293&type=bug
     
    Notes
    (0001054)
    zs   
    2019-10-08 21:06   
    Fix committed 2019 oct 8.




    View Issue Details
    486 [mercury] Bug minor have not tried 2019-09-29 04:00 2019-09-29 14:06
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Partially qualified types in foreign_enum pragmas not working with rotd-2019-09-28
    extras/graphics/mercury_glut/glut.window.m contains the following type and foreign_enum declaration.

        :- type window.state
            ---> x
            ; y
            ; window_width
            ....

           :- pragma foreign_enum("C", window.state/0,
           [
               x - "GLUT_WINDOW_X",
               y - "GLUT_WINDOW_Y",
               window_width - "GLUT_WINDOW_WIDTH"

    Building the short interface for glut.window now results in:

        glut.window.m:689: Error: `:- pragma foreign_enum' declaration for the
        glut.window.m:689: undeclared type `state'/0.

    (The error goes away if the type name in the foreign_enum pragma is fully qualified.)



     
    Notes
    (0001053)
    zs   
    2019-09-29 14:06   
    Fix committed 2019 sep 29.




    View Issue Details
    485 [mercury] Bug minor have not tried 2019-09-29 03:54 2019-09-29 14:05
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Various bits of extras not building with rotd-2019-09-28
    Various graphics library bindings (e.g. the OpenGL one) in extras no longer build due to the fact
    that they contain things like:

        :- module foo.
        :- interface.

        :- type quad_boolean_state ---> color_writemask.

        :- implementation.

        :- pragma foreign_enum("C", quad_boolean_state/0, [
            color_writemask - "561"
        ]).

    Building the interface files now results in:

        foo.m:008: Error: the Mercury definition of `quad_boolean_state'/0 is not an.
        foo.m:008: enumeration type, so there must not be any
        foo.m:008: `:- pragma foreign_enum' declarations for it.
        foo.m:004: That Mercury definition is here.

     
    Notes
    (0001048)
    zs   
    2019-09-29 04:04   
    I think the bugs in each extra should be fixed by whoever understands that program
    the best.
    (0001049)
    juliensf   
    2019-09-29 04:18   
    Why does the compiler think that quad_boolean_state/0 is not an enumeration? Because it's a dummy type? If so, that's wrong, because the presence of a foreign_enum pragma should suppress the dummyness of the type.
    (0001050)
    zs   
    2019-09-29 04:31   
    The Mercury definition is a dummy type, and the type as a whole is a dummy type
    on every platform on which that foreign_enum is not applicable.

    The crux here is that

    - enum types have N functors of arity 0
    - dummy types have 1 functor of arity 0

    so yes, dummy types can be viewed as a special case of enum types
    in terms of whether a foreign enum is applicable to them.

    The question for me is: when someone writes code like that (Mercury dummy type
    paired with a foreign enum with one constant) is it likely to be an error? The type
    requires representation on some backends, but not others, which is strange.

    I haven't used foreign enums much, so I don't know the answer.
    (0001051)
    juliensf   
    2019-09-29 05:05   
    (Last edited: 2019-09-29 05:05)
    This issue arises in the OpenGL, GLFW and Allegro bindings. Since they are all bindings to C libraries the issue of the type requiring a representation on some backends but not others is a non-issue; those bindings cannot be meaningfully compiled with the other backends anyway.

    The information conveyed by such types is the foreign value of the functor. In the example I gave above, even though quad_boolean_state only has a single value in Mercury, the functions that use it in C can take many other values -- in Mercury, we represent those other values are represented using other enum types.

    Another reason this may arise is due to a library binding being incomplete.

    Both the code in extras and not treating foreign_enums as dummy types is intentional.

    (0001052)
    zs   
    2019-09-29 14:05   
    Fix committed 2019 sep 29.




    View Issue Details
    483 [mercury] Bug minor always 2019-09-02 16:17 2019-09-02 18:27
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Spurious warning about unused module import
    The compiler generates a warning about an unused module import for the attached program. Entities exported by the module are used in the 'for' clause of the inst definition, but unused module check doesn't seem to be considering that.
    bug483.m (227 bytes) 2019-09-02 16:17
    https://bugs.mercurylang.org/file_download.php?file_id=291&type=bug
     
    Notes
    (0001047)
    zs   
    2019-09-02 18:27   
    Fix committed 2019 sep 2.




    View Issue Details
    482 [mercury] Bug minor have not tried 2019-08-25 16:23 2019-08-25 16:23
    pbone x86_64  
    Linux  
    normal  
    new  
    open  
    none    
    none  
       
    Deep profiler "Restart" menu option doesn't restart the mdprof_cgi server
    When I clicked the restart button it brought me back to the home screen of the deep profiler without restarting the profiler (and re-reading my program's profile).
    1. Build a program for deep profiling.
    2. Use the profiler to find the bottleneck, fix it.
    3. Recompile the program and re-run it producing an updated Deep.data file
    4. Click Restart in the deep profiler
    5. Observe that it returns to the home screen without reading the new profile with the performance improvement.
     
    There are no notes attached to this issue.




    View Issue Details
    481 [mercury] Bug minor always 2019-08-19 13:38 2019-08-20 11:34
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    abort in MLDS code generator with --static-ground-terms
    The compiler aborts on the following test case in hlc grades.

    % mmc -s hlc.gc -C mlds_ground_term.m
    Uncaught Mercury exception:
    Software Error: map.lookup: key not found
            Key Type: term.var(parse_tree.prog_data.prog_var_type)
            Key Value: var(4)
            Value Type: ml_backend.ml_gen_info.ml_ground_term
    mlds_ground_term.m (329 bytes) 2019-08-19 13:38
    https://bugs.mercurylang.org/file_download.php?file_id=289&type=bug
     
    Notes
    (0001046)
    zs   
    2019-08-20 11:34   
    Fixed by commit 1afe0df4e95cf65f9e32a4f60caad2ea4d1c81cf.




    View Issue Details
    401 [mercury] Bug minor always 2015-12-17 18:00 2019-08-04 09:39
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    different module import styles in interface and implementation
    In the following test case the module does a `:- use_module' in the interface section, but also `:- import_module' of the same module in the implementation section.

    % mmc -m int_impl_imports.err
    int_impl_imports.m:004: In module `int_impl_imports':
    int_impl_imports.m:004: warning: module `int_impl_imports_2' is imported in
    int_impl_imports.m:004: the interface, but it is not used in the interface.
    int_impl_imports.m:006: In definition of type `int_impl_imports.foo'/0:
    int_impl_imports.m:006: error: undefined type `int_impl_imports_2.bar'/0.
    int_impl_imports.m:006: (The module `int_impl_imports_2' has not been
    int_impl_imports.m:006: imported in the interface.)

    It worked up to at least rotd-2015-10-06 (which I happen to have installed).
    int_impl_imports.m (175 bytes) 2015-12-17 18:00
    https://bugs.mercurylang.org/file_download.php?file_id=253&type=bug
    int_impl_imports_2.m (65 bytes) 2015-12-17 18:01
    https://bugs.mercurylang.org/file_download.php?file_id=254&type=bug
     
    Notes
    (0000872)
    zs   
    2015-12-17 23:38   
    The bug is caused by process_module_long_interfaces in modules.m.
    In int_impl_imports.m, the submodule int_impl_imports_2 is referenced twice:
    it is used in the interface, and imported in the implementation.
    grab_imported_modules process the import in the implementation first.
    This reads the _2 module's .int file, and (since the import is NOT
    in the interface) records that type bar is NOT available in the interface.
    So far, so good. But when grab_imported_modules calls process_module_long_interfaces for the use in the interface,
    it does not process the .int file again, since it has seen it before.

    Not processing the .int file again is both right and wrong. Right because
    it avoids double definitions, wrong because it leaves the incorrect permissions
    for the type bar.

    It is quote possible that earlier versions of Mercury got this right
    only by accident.
    (0000873)
    zs   
    2015-12-18 15:20   
    I am now sure that 14.01 got this right only by accident.
    It also processes int_impl_imports_2.int just once,
    for the import_module in the implementation. Its just that
    due to a bug, the effect of that import was to make the
    imported module available in ALL of int_impl_imports.m,
    not just its interface. I fixed that bug on nov 11 in
    commit 0821b301f25241bc706a325d4ae0cb9c18dd250b.
    The fix of THAT bug exposed THIS bug.

    I am now working on a fix.
    (0000875)
    zs   
    2016-01-14 15:46   
    fix committed 2016 jan 11.
    (0000876)
    wangp   
    2016-01-18 20:11   
    There is still a problem with the fix committed.

    In tests/valid_seq:

    % mmake int_impl_imports.depend
    % mmake int_impl_imports.int
    mmc --make-interface --grade asm_fast.gc --flags ../TESTS_FLAGS int_impl_imports
    int_impl_imports.m:004: In module `int_impl_imports':
    int_impl_imports.m:004: warning: module `int_impl_imports_2' is imported in
    int_impl_imports.m:004: the interface, but it is not used in the interface.
    int_impl_imports.m:006: In definition of type `int_impl_imports.foo'/0:
    int_impl_imports.m:006: error: undefined type `int_impl_imports_2.bar'/0.
    int_impl_imports.m:006: (The module `int_impl_imports_2' has not been
    int_impl_imports.m:006: imported in the interface.)
    `int_impl_imports.int' not written.
    (0001041)
    zs   
    2019-08-04 09:39   
    Fix committed 2019 aug 3.




    View Issue Details
    479 [mercury] Bug minor always 2019-07-07 06:31 2019-07-07 11:51
    user411 Linux  
    Debian  
    normal 9  
    resolved  
    fixed  
    none    
    none  
       
    warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE when compiling mercury code
    mmc --make hello2
    Making Mercury/int3s/hello2.int3
    Making Mercury/ints/hello2.int
    Making Mercury/cs/hello2.c
    Making Mercury/os/hello2.o
    Making hello2
    In file included from /usr/include/stdlib.h:24:0,
                     from /usr/lib/mercury/inc/mercury_std.h:23,
                     from /usr/lib/mercury/inc/mercury_goto.h:13,
                     from /usr/lib/mercury/inc/mercury_init.h:84,
                     from Mercury/cs/hello2_init.c:16:
    /usr/include/features.h:148:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
     # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
       ^~~~~~~
    In file included from /usr/include/stdlib.h:24:0,
                     from /usr/lib/mercury/inc/mercury_std.h:23,
                     from /usr/lib/mercury/inc/mercury_goto.h:13,
                     from /usr/lib/mercury/inc/mercury_init.h:84,
                     from Mercury/cs/hello2_init.c:16:
    /usr/include/features.h:148:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
     # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
    ... error log truncated, see `hello2.err' for the complete log.
    Any mercury code gives me the same error.
     
    Notes
    (0001039)
    user411   
    2019-07-07 07:03   
    It seems that compiling mercury code with :

    --cflags -D_DEFAULT_SOURCE

    do not show the warning messages anymore.
    (0001040)
    wangp   
    2019-07-07 11:51   
    This was fixed in commit b70619d2f. Please use an ROTD or use your workaround.




    View Issue Details
    477 [mercury] Feature Request minor have not tried 2019-04-17 16:51 2019-04-20 14:58
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Infinite recursion through exception handlers
    Code such as the following is may be worth a warning.

    :- pred reconstruct_route(logger::in, jscenario::in, jsolution::out)
        is cc_multi.

    reconstruct_route(Log, JScenario, JSolution) :-
        ( try []
            reconstruct_route(Log, JScenario, JSolution0)
        then
            JSolution = JSolution0
        catch_any Excp ->
            trace [io(!IO)] (
                Msg = "Exception during route reconstruction: " ++ string(Excp),
                slf4j.error(Log, Msg, !IO)
            ),
            JSolution = null_jsolution
        ).
    bug477.m (871 bytes) 2019-04-18 00:37
    https://bugs.mercurylang.org/file_download.php?file_id=287&type=bug
     
    Notes
    (0001023)
    zs   
    2019-04-17 22:28   
    Can you please add a full test case?
    (0001029)
    juliensf   
    2019-04-18 00:37   
    There's a cut-down version that exhibits the behaviour attached. The current check carried out by simplify for recursive calls with the same input arguments doesn't look through higher-order calls since in general it cannot. I suspect it may be worth making a special case of try/2 (and its syntax sugared form) since wrapping an exception handler around the entry point to a Mercury program that is called from a foreign language application (which is the original setting for this) is not uncommon. Nor unfortunately is forgetting to use the correct predicate name inside the try goal which is what I did :-(
    (0001038)
    zs   
    2019-04-20 14:58   
    Feature implemented 2019 April 20.




    View Issue Details
    478 [mercury] Bug minor have not tried 2019-04-17 23:06 2019-04-18 05:27
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    ssdb directory does not build in csharp grade with commit 0d667a7
    Compilation of the ssdb directory aborts in the csharp grade with commit 0d667a7 (i.e. what would have been rotd-2019-04-17).

    gmake[1]: Entering directory `/mnt/opturion/jfischer/mercury-4.git/ssdb'
    ../Mmake.common:469: warning: undefined variable `mer_ssdb.mhs'
    ../Mmake.common:472: warning: undefined variable `mer_ssdb.mhs'
    ../Mmake.common:478: warning: undefined variable `mer_ssdb.os'
    /tmp/mmake.og2WZB:930: warning: undefined variable `mer_ssdb.ms'
    /tmp/mmake.og2WZB:942: warning: undefined variable `mer_ssdb.ms'
    /tmp/mmake.og2WZB:1324: warning: overriding recipe for target `realclean_local'
    /tmp/mmake.og2WZB:978: warning: ignoring old recipe for target `realclean_local'
    { echo MCFLAGS += '--grade csharp --options-file ../Mercury.options --mercury-linkage shared --flags SSDB_FLAGS --allow-stubs --no-warn-stubs --use-subdirs '; echo MCFLAGS += ' '; echo CFLAGS += ' '; echo JAVACFLAGS += '-J"-Xmx1024m" '; echo CSCFLAGS += ' '; echo C2INITARGS += ' ../library/mer_std.init ../runtime/mer_rt.init '; echo MLLIBS += ' -lmer_std '; echo MLOBJS += ' '; echo LDFLAGS += ' '; echo LD_LIBFLAGS += ' '; echo EXTRA_LIBRARIES += ''; echo EXTRA_LIB_DIRS += ''; echo LIBGRADES = 'asm_fast.gc asm_fast.gc.debug.stseg asm_fast.gc.debug.trseg.stseg asm_fast.gc.decldebug.stseg asm_fast.gc.memprof asm_fast.gc.prof asm_fast.gc.profdeep.stseg asm_fast.gc.trseg asm_fast.par.gc.stseg csharp hlc.gc hlc.gc.trseg hlc.par.gc java '; echo INSTALL_PREFIX = '/usr/local/mercury-DEV'; echo LINKAGE = 'shared'; echo MERCURY_LINKAGE = 'shared'; } | /mnt/opturion/mercury/rotd-2019-04-17/bin/mmc --make --options-file - libmer_ssdb
    Making Mercury/int3s/mer_ssdb.int3
    Making Mercury/int3s/ssdb.int3
    ** Error reading file `mdb.browse.m' to generate dependencies.
    ** Module `mdb.browse' is imported or included by module `ssdb'.
    mercury_compile: cannot find source for module `mdb.browse' in directories `.'
    gmake[1]: *** [libmer_ssdb] Error 1
    gmake[1]: Leaving directory `/mnt/opturion/jfischer/mercury-4.git/ssdb'
    gmake: *** [ssdb] Error 2
     
    Notes
    (0001024)
    juliensf   
    2019-04-17 23:20   
    Ditto for the Java grade. The issue is not present in rotd-2019-04-16.
    (0001025)
    zs   
    2019-04-17 23:23   
    The problem was probably triggered by commit df47de186bf59c8c97010455c29c7ad765bfa3da,
    but that was on March 31. So two things that may be
    worth looking into are (a) why hasn't been a problem
    in the last two weeks, and (b) why isn't this a problem
    in other grades?
    (0001026)
    zs   
    2019-04-17 23:25   
    It seems our notes crossed paths. If the problem was not present
    in rotd-2019-04-16, then the March 31 commit could not have been
    the cause.

    What was the last commit present in rotd-2019-04-16?
    (0001027)
    juliensf   
    2019-04-17 23:35   
    (Last edited: 2019-04-17 23:35)
    rotd-2019-04-16 was commit b70bdb2d9557ccc3f62abbc291a25dbc2f8dfc23.
    (FYI, commit ids for all rotds are listed on the download page.)

    The obvious point of difference between the csharp / java grades and the others is that the former
    are compiled using --use-mmc-make.

    (0001028)
    zs   
    2019-04-17 23:54   
    There has been only one commit since, and that was a refactoring that should have had
    only one change that could cause a change in behavior: the addition of this sanity test
    in modules.m:

    expect(unify(ModuleName, ParseTreeModuleName), ...)

    Does the problem still occur if this is taken out? I can't check since my machine
    does not have C#. (I will get a new laptop soon, which will get C# and Java.)
    (0001030)
    juliensf   
    2019-04-18 00:55   
    Yes, the problem still occurs if that check is taken out.
    (0001031)
    juliensf   
    2019-04-18 01:00   
    Annoyingly I can't check if the same issue occurs with --use-mmc-make and the C grades since
    we have some problem there with the .mh files in the browser directory not being created, specifically
    when we got to compile the trace directory:

        ./scripts/mgnuc --grade asm_fast.gc --c-debug --no-ansi -- -I. -IMercury/mihs/. -c mercury_trace_browse.c -o mercury_trace_browse.o
    mercury_trace_browse.c:28:25: fatal error: mdb.browse.mh: No such file or directory
    (0001032)
    juliensf   
    2019-04-18 01:13   
    Actually the issue with the trace directory is likely a manifestation of the same problem since building with --use-mmc-make works fine in asm_fast.gc with rotd-2019-04-16. (The C# and Java grades skip over the trace directory which is why the problem shows up in different places.)
    (0001033)
    zs   
    2019-04-18 01:16   
    I just found and fixed a cut-and-paste bug. I think it should fix bug 478.
    Please try it out.

    By the way, testing proposed bug fixes for bugs with --use-mmc-make have
    always been harder for me than testing for fixes for other kinds of bugs.
    For other bugs, I build the maybe-fixed executable in a workspace, and use
    a wrapper around lmc to try it out. But the lmc script sets up the environment
    only for compilations that do NOT use --use-mmc-make, so this does not
    work for --use-mmc-make bugs.

    Since I don't use --use-mmc-make frequently, this is rarely a problem for me.
    Since you use the Java and C# grades reasonably regularly, I expect it would be
    more of a problem for you. How do you handle it?
    (0001034)
    juliensf   
    2019-04-18 01:43   
    I've just restarted the ROTD build, so we'll know in a bit.

    Generally, if I'm working on stuff related to the C# and Java grades I just install the whole system
    and and work with that. (Once it is installed you can do an install from within the compiler directory if,
    for example, the work is related to the compiler.) That's obviously not a great solution and I suspect it's only bearable because I have access to machines with lots of cores and lots of memory, so parallel builds at -j8 or more are feasible.
    (0001035)
    zs   
    2019-04-18 01:48   
    That is what I do as well.

    The reason why I don't find it satisfactory is not the CPU workload,
    but the context switch overhead. I have to switch to doing something else
    while waiting for the install, and switch back later when it is complete.
    This wipes out details held in my brain's short term memory, requiring
    them to the rebuilt later (and maybe again and again).

    I was hoping you, or someone else who works with --use-mmc-make more than me,
    would have found it less work in the long term just to teach lmc about --use-mmc-make.
    (0001036)
    juliensf   
    2019-04-18 02:55   
    The fix worked.
    (0001037)
    zs   
    2019-04-18 05:27   
    Fix committed




    View Issue Details
    476 [mercury] Bug minor have not tried 2019-04-07 15:20 2019-04-08 03:16
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Compiler aborts during typeclass check
    With the attached test case, rotd-2019-02-23 aborts with the following error:

    Uncaught Mercury exception:
    Software Error: check_hlds.check_typeclass: predicate `check_hlds.check_typeclass.check_instance_pred'/14: Unexpected: no constraint on class method

    rather than printing a proper error message.

    Compile with: mmc -C
    bug476.m (1,694 bytes) 2019-04-07 15:20
    https://bugs.mercurylang.org/file_download.php?file_id=286&type=bug
     
    Notes
    (0001022)
    zs   
    2019-04-08 03:16   
    Fix committed 2019 april 8.




    View Issue Details
    475 [mercury] Feature Request minor N/A 2019-02-04 01:14 2019-02-04 01:14
    zs  
    zs  
    normal  
    assigned  
    open  
    none    
    none  
       
    flatten maybe output args across calls
    Many predicates have an output argument which is a maybe(T): they either
    return no, or they return yes(value). The caller tests whether the result is yes(X).
    If it is, it picks up X = value, and the heap cell containing the yes wrapper
    is never referred to again.

    A compiler optimization should look for predicates where every call is like this,
    and transform them so that the callee returns TWO results: a boolean which
    is always meaningful, and a value of type T, which is meaningful only if the bool
    is yes.
     
    There are no notes attached to this issue.




    View Issue Details
    473 [mercury] Bug minor always 2018-11-17 22:37 2018-11-19 11:46
    pbone  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    JS sources should be included for minified files in scripts/
    There are some minified JavaScript files in scripts/ I noticed that the debian packaging system complained that their non-minified sources are not also included. Ideally those should be included and the minified versions build from them.

    I don't know how you actually go about doing that, just noting that Debian stuff complains and a readable version of the source orght to be provided.
     
    Notes
    (0001019)
    zs   
    2018-11-17 22:48   
    I presume you are talking about jstree.min.js and jquery.slim.min.js.
    They were added in the same commit in 2017, and not touched since.
    The log message says they are from jstree.com and jquery.com respectively.
    See whether those sites contain their nonminimized versions.
    (0001020)
    wangp   
    2018-11-18 10:35   
    There's no need to build the minified sources from the non-minified sources, just using the code in the original form is enough. I'll take care of it.




    View Issue Details
    474 [mercury] Bug major always 2018-11-18 23:01 2018-11-18 23:23
    pbone i386  
    Linux  
    normal Debian 9  
    new  
    open  
    none    
    none  
       
    Mercury cannot be installed, compiler crashes
    The mercury compiler crashes when building the first libgrade:

    root@oxygen:/tmp/mercury-rotd-20181114# cat install_grade_dir.asm_fast.gc.decldebug.stseg/library/mer_std.dep_err
    Uncaught Mercury exception:
    Software Error: map.lookup: key not found
            Key Type: libs.options.option
            Key Value: profile_time
            Value Type: getopt_io.option_data
    Stack dump not available in this grade.

    It crashes when invoked with no arguments.

    root@oxygen:/tmp/mercury-rotd-20181114# ./compiler/mercury_compile
    Uncaught Mercury exception:
    Software Error: map.lookup: key not found
            Key Type: libs.options.option
            Key Value: profile_time
            Value Type: getopt_io.option_data
    Stack dump not available in this grade.

    I don't think this is a configuration problem because it works on amd64, this is just happening on i386 (32-bit). Maybe something to do with argument packing on 32bit systems when those arguments are used as map keys?
    I found this while building Mercury to make Debian packages. My scripts install a minimal system in /tmp/bootstrap and then clean the build directory and use the first version to build a more complete version, it seems that the second generation compiler is crashing.
     
    Notes
    (0001021)
    juliensf   
    2018-11-18 23:23   
    It's not likely to be argument packing since that's currently not enabled by default.

    - What version of GCC are you using?
    - Is the bootstrap compiler the hlc.gc.pregen one? If not, what grade is it compiled in?

    (Also, there are issues with the asm_fast grades on x86 systems at the moment, see 0000453.)




    View Issue Details
    472 [mercury] Bug minor have not tried 2018-11-09 23:24 2018-11-17 22:40
    pbone x86_64  
    zs Linux  
    normal 4.something  
    resolved  
    fixed  
    none    
    none  
       
    Touching a .m file does not rebuild other modules that may depend on C foreign code that is opt-exported from that module
    Within Plasma https://github.com/PlasmaLang/plasma I have a C header runtime/pz_format.h, I have some Makefile rules to touch src/pz.m and src/pz.bytecode.m if it is updated, so that any foreign code is rebuilt. However if I change an enum in runtime/pz_format.h causing these .m files to be touched and rebuilt the tests "make test" can fail.

    I think what might be happening is that because the Mercury code didn't actually change, mmc does not update the pz.mh file and therefore other .c files generated from output are not rebuilt to object code.

    I can work-around this by touching the .mh files as well, I still need to touch the .m file so that mmc checks the .mh file.
    Mercury 14.01.1
     
    Notes
    (0001016)
    pbone   
    2018-11-09 23:38   
    Here's the workaround in Plasma's Makefile:

    https://github.com/PlasmaLang/plasma/commit/c5c1fb9a55a3ba773308e228cae93e74a837f1e6
    (0001017)
    zs   
    2018-11-09 23:41   
    This is working as designed. Mmc does not generate .mh files directly;
    it generated .mh.tmp files, and then invokes mercury_update_interface
    to copy that across to the .mh file IF AND ONLY IF the new contents
    are different from the old contents. This saves a huge number of
    unnecessary recompilations. We do NOT want to undo this optimization
    just because your Makefile does not express all the dependencies.

    I think you need to change your Makefile to express the dependency
    of all the modules that need pz_format.h on pz_format.h directly,
    not through pz.m.
    (0001018)
    pbone   
    2018-11-17 22:40   
    I'll double check but I think I've only put this dependency all the .m files that that have a C FFI #include for pz_format.h. If I could also tell Mercury (easily?) that pz.write.o depends on pz_format.h because it reads pz.mh then that seems like the best option. I'll double check.




    View Issue Details
    458 [mercury] Feature Request minor N/A 2018-05-03 07:24 2018-10-03 09:23
    zs  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    optimize unify and compare for packed arguments
    At the moment, when unifying or comparing the arguments of two functors,
    we extract each argument from each functor and unify/compare the corresponding
    arguments individually.

    If two or more arguments of a functor are packed together into a single word,
    we could test whether they are *all* equal by testing whether the words are equal. (We always set all the unused bits to zeroes.)

    For comparison, the situation is trickier, but there is still room for optimization.

    First, we would need to change our allocation strategy. Our current strategy
    of putting the first packed argument into the least significant bits and the
    following arguments into more and more significant bits is exactly wrong
    for comparing the packed arguments all at once: we would need to put
    an earlier packed argument into more significant bits than a later argument
    packed into the same word.

    Second, even then we could compare a sequence of arguments packed
    into a word by comparing the full word only if all the packed arguments
    compare as unsigned values. If any of them are of type int{8,16,32}, then
    those would have to compared separately. However, any contiguous subsequence
    of unsigned arguments could and should be compared together.

    The most complex part of this would be devising the right HLDS representation
    of the operations that compare more than one argument at a time. Maybe we could
    generate foreign proc goals for them.

    Also note that this feature request somewhat modifies Mantis 0000446;
    we should NOT fetch the arguments that are packed together into the same word
    separately.
     
    Notes
    (0001015)
    zs   
    2018-10-03 09:23   
    The diff implementing this feature request was committed 2018 oct 3.




    View Issue Details
    471 [mercury] Bug minor always 2018-09-22 14:01 2018-09-22 14:01
    wangp  
     
    normal  
    new  
    open  
    none    
    none  
       
    float rounding
    float.round_to_int and math.round are implemented with
        floor(X + 0.5)

    There are problems with very large floats that behave as integers, e.g.
        round(8333333333388609.0) -> 8333333333388610.0

    or when the fractional part is the predecessor of 0.5, e.g.
        round_to_int(0.49999999999999994) -> 1

    See http://blog.frama-c.com/index.php?post/2013/05/02/nearbyintf1

    I think no real programs would intentionally depend on the current behaviour so we should be free to fix the implementation.

    ---

    BTW {ceiling,floor,round,truncate}_to_int should specify the behaviour if the value would overflow the result type [or if the input is NaN]. But that's only one aspect of overflow handling that we don't do yet.
     
    There are no notes attached to this issue.




    View Issue Details
    408 [mercury] Feature Request minor always 2016-04-18 11:00 2018-09-22 12:19
    wangp  
     
    normal  
    resolved  
    fixed  
    none    
    none  
       
    make_temp and make_temp_directory should not throw exceptions
    We should add an alternative to io.make_temp which returns a success code instead of throwing an exception.

    io.make_temp_directory is still new (as of now) so we can still change it to return a success code without maintaining backwards compatibility.
     
    Notes
    (0000885)
    pbone   
    2016-04-18 11:20   
    I agree with this change and I'm happy to do it since I'm working on this code anyway.
    (0000978)
    pbone   
    2018-03-13 14:38   
    Unassigned things from me.
    (0001014)
    wangp   
    2018-09-22 12:19   
    make_temp is deprecated and its replacements don't throw exceptions.




    View Issue Details
    435 [mercury] Bug minor have not tried 2017-03-29 10:00 2018-09-22 12:16
    juliensf x86_64-pc-linux-gnu  
    wangp Alpine Linux  
    normal 3.5  
    resolved  
    fixed  
    none    
    none  
       
    Old workaround in runtime causes compilation warnings
    The #include of <sys/signal.h> in runtime/mercury_memory_handlers.c and runtime/mercury_memory_zones.c causes compilation warnings with musl libc, namely:

        warning redirecting incorrect #include <sys/signal.h> to <signal.h>

    (glibc does a similar redirection minus the warning.)

    The #include of sys/signal.h is a workaround for problems with FreeBSD around 2001.
     
    Notes
    (0001013)
    wangp   
    2018-09-22 12:16   
    Fixed by commit 58345256f




    View Issue Details
    469 [mercury] Bug major always 2018-09-16 12:25 2018-09-19 11:19
    taigua  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    mercury-srcdist-rotd-2018-09-11 compile failed on MinGW64 (Win10 64bit)
    Enviroment:
      Windows 10 64bit
      Msys2
      Mingw64: GCC 8.2.0

    Compile failed log:
    io.m: In function 'mercury__io__do_make_temp_8_p_0':
    io.m:16798:9: error: 'strncat' output may be truncated copying 6 bytes from a string of length 255 [-Werror=stringop-truncation]
    io.m: In function 'mercury__io__make_temp_file_6_p_0':
    io.m:24403:9: error: 'strncat' output may be truncated copying 6 bytes from a string of length 255 [-Werror=stringop-truncation]
    Compile steps:
    $ ./configure --prefix=D:/mercury --host=x86_64-w64-mingw32
    $ make PARALLEL=-j4

    Then it complains:
    io.m: In function 'mercury__io__do_make_temp_8_p_0':
    io.m:16798:9: error: 'strncat' output may be truncated copying 6 bytes from a string of length 255 [-Werror=stringop-truncation]
    io.m: In function 'mercury__io__make_temp_file_6_p_0':
    io.m:24403:9: error: 'strncat' output may be truncated copying 6 bytes from a string of length 255 [-Werror=stringop-truncation]
     
    Notes
    (0001012)
    wangp   
    2018-09-19 11:19   
    Should be fixed in commit 90c29e772




    View Issue Details
    470 [mercury] Bug major always 2018-09-16 15:07 2018-09-16 17:18
    taigua  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    mercury-srcdist-rotd-2018-09-11 compile failed on Linux (Ubuntu and Archlinux)
    Enviroment: Ubuntu/Archlinux 64 bit
    GCC Version: gcc 5.4.0/ gcc 8.2.0

    Compile failed log:

    In file included from mercury_deconstruct.c:29:0:
    mercury_ml_expand_body.h: In function ‘MR_expand_functor_args’:
    mercury_ml_expand_body.h:719:28: error: ‘MR_ALLOC_ID’ undeclared (first use in this function)
    mercury_ml_expand_body.h:719:28: note: each undeclared identifier is reported only once for each function it appears in
    In file included from mercury_deconstruct.c:40:0:
    mercury_ml_expand_body.h: In function ‘MR_expand_functor_args_limit’:
    mercury_ml_expand_body.h:719:28: error: ‘MR_ALLOC_ID’ undeclared (first use in this function)
    In file included from mercury_deconstruct.c:58:0:
    mercury_ml_expand_body.h: In function ‘MR_expand_args_only’:
    mercury_ml_expand_body.h:719:28: error: ‘MR_ALLOC_ID’ undeclared (first use in this function)
    /tmp/mmake.0B6hj1:1495: recipe for target 'mercury_deconstruct.o' failed
    Compile steps:
    $ ./configure --prefix=~/mercury
    $ make PARALLEL=-j4 # This step success
    $ make PARALLEL=-j4 install

    Then it complains:
    In file included from mercury_deconstruct.c:29:0:
    mercury_ml_expand_body.h: In function ‘MR_expand_functor_args’:
    mercury_ml_expand_body.h:719:28: error: ‘MR_ALLOC_ID’ undeclared (first use in this function)
    mercury_ml_expand_body.h:719:28: note: each undeclared identifier is reported only once for each function it appears in
    In file included from mercury_deconstruct.c:40:0:
    mercury_ml_expand_body.h: In function ‘MR_expand_functor_args_limit’:
    mercury_ml_expand_body.h:719:28: error: ‘MR_ALLOC_ID’ undeclared (first use in this function)
    In file included from mercury_deconstruct.c:58:0:
    mercury_ml_expand_body.h: In function ‘MR_expand_args_only’:
    mercury_ml_expand_body.h:719:28: error: ‘MR_ALLOC_ID’ undeclared (first use in this function)
    /tmp/mmake.0B6hj1:1495: recipe for target 'mercury_deconstruct.o' failed
     
    Notes
    (0001011)
    wangp   
    2018-09-16 17:18   
    Thanks for the report. The problem is probably only with low-level C memprof grades, fixed now in commit bb35de8b3.




    View Issue Details
    467 [mercury] Feature Request minor always 2018-08-18 16:15 2018-09-07 10:23
    wangp  
     
    normal  
    new  
    open  
    none    
    none  
       
    compiling with -Wuninitialized or -Wmaybe-uninitialized
    The high-level C backend generates code like this:

        if (succeeded)
          U_4 = UPrime_5;
        else
        {
          mercury__require__error_1_p_0((MR_String) "uint.det_from_int: cannot convert int to uint");
        }
        return U_4;

    gcc does not know that the function call will not return so it MAY warn that U_4 is never initialised. mgnuc just happens to suppress the warnings on x86 and x86-64 for an unrelated reason:

    case "$FULLARCH" in
        i*86-*|x86_64*)
            # The use of stack_pointer in the ASM_JUMP macro defined in
            # runtime/mercury_goto.h causes lots of warnings about using possibly
            # uninitialized variables; there's no easy way to suppress them except
            # by disabling the warning.
            case "$COMPILER" in
                gcc)
                    CHECK_OPTS="$CHECK_OPTS -Wno-uninitialized"
                    ;;
            esac
            ;;

    Ideally we would ONLY disable uninitialized variable warnings in the low-level C grades where it is unavoidable.

    In high-level C grades, I think we should declare the C function corresponding to an `erroneous' Mercury procedure as not returning, e.g. using the macro MR_NO_RETURN or similar. MR_NO_RETURN has implementations for gcc/clang/msvc. C11 also adds _Noreturn.

    Alternatively, we could add assert(0) after calls to functions that will not return, but presumably that would increase code size.
     
    Notes
    (0001007)
    juliensf   
    2018-08-19 15:21   
    No objections from me to using MR_NO_RETURN on erroneous procedures. (We probably can't rely on C11 just yet, although MR_NO_RETURN could be updated to use _Noreturn if the C implementation is C11.)
    (0001010)
    zs   
    2018-09-07 10:23   
    I started work on adding a new function flag that will tell mlds_to_c_func.m
    whether it should emit MR_NO_RETURN for a function being declared or defined.




    View Issue Details
    468 [mercury] Bug minor always 2018-08-19 13:05 2018-09-03 12:29
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    free argument packed with other argument uses uninitialised variable
    In high-level C grades, the goal from packed_arg_partial_inst.m

            X = struct(42, _, yes, orange, _, _, _),

    compiles to

            {
              MR_Word TypeCtorInfo_13_13;
              MR_Integer Var_10;
              MR_Word Var_11;
              MR_Word Var_12;
              MR_Word Var_6;
              MR_Word Var_7;
              MR_Word Var_8;
              MR_String Var_9;

              Var_10 = (MR_Integer) 42;
              Var_11 = (MR_Integer) 1;
              Var_12 = (MR_Integer) 2;
              {
                MR_Word base;
                base = (MR_Word) MR_new_object(MR_Word, ((MR_Integer) 3 * sizeof(MR_Word)), NULL, NULL);
                (env_ptr)->packed_arg_partial_inst__foo_2_p_0_env_0__X_5 = base;
                MR_hl_field(MR_mktag(0), base, 0) = ((MR_Box) (Var_10));
                MR_hl_field(MR_mktag(0), base, 1) = (MR_Box)
            (((((MR_Unsigned) (Var_6) << (MR_Integer) 6)) |
             (((((MR_Unsigned) (Var_11) << (MR_Integer) 5)) |
             (((((MR_Unsigned) (Var_12) << (MR_Integer) 3)) |
             (((((MR_Unsigned) (Var_7) << (MR_Integer) 2)) |
             (MR_Unsigned) (Var_8)))))))));
                MR_hl_field(MR_mktag(0), base, 2) = NULL;
              }

    where Var_6, Var_7, Var_8 are used without being initialised.
     
    Notes
    (0001008)
    zs   
    2018-08-19 15:24   
    I am working on a change that involves that code anyway.
    (0001009)
    zs   
    2018-09-03 12:29   
    Fix committed 2018 sep 3.




    View Issue Details
    464 [mercury] Bug minor N/A 2018-07-25 15:12 2018-08-19 17:02
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    MR_fatal_error should not read errno
    MR_fatal_error prints "Error = %d" if errno happens to be non-zero when it is called, leading to potential confusion if the value in errno has nothing to do with the reason MR_fatal_error was called, and spurious test failures.

    There are too many calls to MR_fatal_error for me to go through right now. My guess is that the majority of calls to MR_fatal_error do not follow a function call that returned an error and set errno.
     
    Notes
    (0001003)
    zs   
    2018-07-27 14:07   
    The obvious solution is to add an enum arg to MR_fatal_error, with two
    values: PRINT_ERRNO_MSG and DONT_PRINT_ERRNO_MSG, and fix
    all the C compiler errors that result by specifying one or the other
    at all the complained-about call sites.




    View Issue Details
    460 [mercury] Bug minor random 2018-05-17 11:04 2018-08-09 22:07
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    failure of hard_coded/thread_barrier_test in asm_fast.par.gc
    Got a seemingly hard to reproduce failure of this thread_barrier_test in asm_fast.par.gc yesterday.

    Comparing thread_barrier_test.out with thread_barrier_test.exp*,
        results in thread_barrier_test.res
    ** thread_barrier_test.out did not match the expected output
    ** (closest match was thread_barrier_test.res1)
    --- thread_barrier_test.exp 2015-10-19 16:49:08.017755334 +1100
    +++ thread_barrier_test.out 2018-05-16 18:04:31.775872403 +1000
    @@ -41,7 +41,7 @@
     Messages from thread 1:
         thread starting
         fib(10) = 89
    - waiting: before release
    + waiting: after release
         done waiting: after release
     Messages from thread 2:
         thread starting
     
    There are no notes attached to this issue.




    View Issue Details
    426 [mercury] Bug minor always 2016-10-21 15:47 2018-08-09 22:05
    juliensf  
     
    normal  
    new  
    open  
    none    
    none  
       
    Tabling broken on 32-bit Cygwin
    Pretty much every tabling test case and the compiler itself (the CTGC code uses pragma memo)
    abort with an error about having detected infinite recursion. In the tabling transformation, det procedures are transformed as follows:

        p(A, B) :-
           TO = <table pointer for p/2>,
           impure table_lookup_insert(T0, A, T),
           impure table_loop_setup(T, Status),
           (
               Status = loop_active,
               error("detected infinite recursion in ...")
          ;
               Status = loop_inactive,
               ...
          )

    On Cygwin the variable Status gets set to a rubbish value at some points. It actually ends up matching the default case of the C switch we generate for the above Mercury switch but then falls through to the infinite recursion case. (Enabling assertions would cause it to abort.) I haven't tracked down why this is occurring although it may have something to do with the fact that on Windows sizeof(int) == sizeof(long). (Is the tabling code making assumption that sizeof(long) > sizeof(int) somewhere?)




         

    fast_loose.txt.gz (338,918 bytes) 2018-08-09 22:05
    https://bugs.mercurylang.org/file_download.php?file_id=285&type=bug
     
    Notes
    (0001006)
    wangp   
    2018-08-09 22:05   
    Probably the same issue with the fast_loose.m test case on 32-bit Linux, but strangely it's only reproducible in .par grades (at least hlc.par.gc and reg.par.gc).

    I've attached a debug log with MR_TABLE_DEBUG and MERCURY_OPTIONS=-dT enabled if it would help. The last lines show:

    TABLE 0x804f498: gen f036a279 type 0x804edf8 => 0xf0149508
    status of memo table 0xf0149508: -262636112 (f0587db0)

    where f0587db0 is an address seen earlier:

    allocated answer block 0xf0149508 -> 0xf0587db0, 1 words
    saving to answer block: 0xf0587db0, slot 0 = 6351




    View Issue Details
    281 [mercury] Bug minor always 2013-05-06 13:15 2018-08-08 13:12
    juliensf x86_64  
    Mac OS X  
    normal 10.8.3  
    resolved  
    fixed  
    none    
    none  
       
    Tabling test case failures
    The following tests cases fail in the grade none.gc.decldebug with 13.05-beta-2013-05-06.

    * tests/tabling/specified

    A diff of the expected and actual outputs:

    aplp_vs_vplp: tabling works
     apli_vs_vpli: tabling works
    -vvll_vs_vpll: tabling works
    +vvll_vs_vpll: tabling does not appear to work

    * tests/tabling/specified_stats

    The latter appeared to go into a loop and not terminate.

    (This was all at the default optimisation level.)
     
    Notes
    (0001004)
    wangp   
    2018-08-08 12:32   
    In the final set of trials, vp_ll_fib, the "faster" predicate vp_ll_fib is not that much faster (consistently) over the "slower" predicate vv_ll_fib for the heuristics in perform_trials.

    These parameters just happen to work on my machine:

    perform_trials(vvll_vs_vpll, [7, 3, 0, 4], 7304, 30, 0, 0, !IO).

    The faster predicate manages to run twice as fast as the slower predicate for ten trials in a row, breaking out of the loop. I wouldn't count on it being repeatable on different machines.

    NumTrials0: 0, Time: 330, MTime: 100, IntN: 7304, NumDouble: 1
    NumTrials0: 1, Time: 230, MTime: 100, IntN: 7334, NumDouble: 2
    NumTrials0: 2, Time: 250, MTime: 100, IntN: 7364, NumDouble: 3
    NumTrials0: 3, Time: 260, MTime: 100, IntN: 7394, NumDouble: 4
    NumTrials0: 4, Time: 240, MTime: 110, IntN: 7424, NumDouble: 5
    NumTrials0: 5, Time: 250, MTime: 100, IntN: 7454, NumDouble: 6
    NumTrials0: 6, Time: 240, MTime: 100, IntN: 7484, NumDouble: 7
    NumTrials0: 7, Time: 250, MTime: 100, IntN: 7514, NumDouble: 8
    NumTrials0: 8, Time: 250, MTime: 100, IntN: 7544, NumDouble: 9
    vvll_vs_vpll: tabling works


    I think the NumDoubles threshold in perform_trials can be relaxed. Also, perform_trials should give up more easily. I guess the 10 second time limit on a single trial will probably not be reached on a modern machine, and 1000 potential trials makes the test take took long.
    (0001005)
    wangp   
    2018-08-08 13:12   
    Should be fixed by commits bc0e8e812 and 1a5df94bc




    View Issue Details
    466 [mercury] Bug minor have not tried 2018-07-29 04:50 2018-07-29 04:50
    juliensf  
     
    normal  
    new  
    open  
    none    
    none  
       
    Test failures in asm_fast.par.gc.stseg
    Several tests are failing (due to code generator aborts) in the grade asm_fast.par.gc.stseg

       tests/par_conj/par_dep_7
       tests/par_conj/dep_par_21
       tests/par_conj/dep_par_24
       tests/par_conj/dep_par_24b

    all abort with:

    Uncaught Mercury exception:
    Software Error: predicate `ll_backend.var_locn.actually_place_var'/7: Unexpected: placing nondummy var which has no state

      tests/par_conj/consume_in_some_branches
      tests/par_conj/consume_wait

    abort with:

    Uncaught Mercury exception:
    Software Error: predicate `ll_backend.var_locn.clobber_lval_in_var_state_map'/6: Unexpected: empty state

       tests/par_conj/consume_in_some_branches_and_after

    aborts with:

    Uncaught Mercury exception:
    Software Error: predicate `ll_backend.var_locn.var_locn_check_and_set_magic_var_location'/4: Unexpected: in use




     
    There are no notes attached to this issue.




    View Issue Details
    465 [mercury] Bug trivial always 2018-07-27 10:05 2018-07-27 10:05
    yuan MS-VisualC2010  
    Windows  
    normal 10  
    new  
    open  
    none    
    none  
       
    link lib error when compiling hello.m
    C:\Users\Yun\Downloads\hello>mmc.bat -v hello
    % Parsing module `hello' and imported interfaces...
    % Module qualifying items...
    % done.
    % Expanding equivalence types...
    % done.
    % Converting parse tree to hlds...
    % done.
    % Writing auto-dependency file `hello.d'... done.
    % Post-processing type definitions...
    % Checking typeclasses...
    % Checking instance declaration types...
    % Checking typeclass instances...
    % Checking for cyclic classes...
    % Checking for missing concrete instances...
    % Checking functional dependencies on instances...
    % Checking typeclass constraints...
    % Checking that insts have matching types... done.
    % Type-checking...
    % Type-checking clauses...
    % Program is type-correct.
    % Purity-checking clauses...
    % Program is purity-correct.
    % Substituting implementation-defined literals...
    % done.
    % Transforming polymorphic unifications... done.
    % Mode-checking clauses...
    % Program is mode-correct.
    % Detecting switches...
    % done.
    % Detecting common deconstructions...
    % done.
    % Doing determinism checking...
    % done.
    % Program is determinism-correct.
    % Checking for backtracking over unique modes...
    % Program is unique-mode-correct.
    % Transforming try goals...
    % done.
    % Simplifying goals...
    % done.
    % Transforming tabled predicates... done.
    % Transforming lambda expressions... done.
    % Transforming stm expressions... done.
    % Fully expanding equivalence types... done.
    % Generating type_ctor_info structures... done.
    % Specializing higher-order and polymorphic predicates...
    % done.
    % Maybe apply source to source debugging transformation ...
    % done.
    % Inlining...
    % done.
    % Eliminating dead procedures...
    % done.
    % Updating interface:
    % hello.mh' has not changed.
    % Simplifying goals...
    % done.
    % Marking static ground terms...
    % done.
    % Mapping args to regs... done.
    % Converting HLDS to MLDS...
    % done.
    % Generating RTTI data...
    % done.
    % Detecting tail calls...
    % done.
    % Optimizing MLDS...
    % done.
    % Flattening nested functions...
    % done.
    % Optimizing MLDS again...
    % done.
    % Converting MLDS to C...
    % Writing to file `hello.c'...
    % done.
    % Writing to file `hello.mih.tmp'...
    % done.
    % Updating interface:
    % hello.mih' has not changed.
    % Finished converting MLDS to C.
    % Compiling `hello.c':
    % Invoking system command `cl -IC:\mercury-14.01-vs2013\lib\mercury\lib\hlc.gc\inc -IC:\mercury-14.01-vs2013\lib\mercury\conf -IC:\mercury-14.01-vs2013\lib\mercury\inc -DMR_HIGHLEVEL_CODE -DMR_CONSERVATIVE_GC -DMR_BOEHM_GC -DMR_TAGBITS=2 -nologo -c hello.c -Fohello.obj'...
    % done.
    hello.c
    % Touching `hello.c_date'... done.
    % Creating initialization file...
    % Invoking system command `mkinit -g hlc.gc -o hello_init.c.tmp -I C:\mercury-14.01-vs2013\lib\mercury\modules\hlc.gc -f C:\Users\Yun\AppData\Local\Temp\mtmp002.308'...
    % done.
    % Updating interface:
    % hello_init.c' has not changed.
    % Compiling initialization file...
    % Compiling `hello_init.c':
    % Invoking system command `cl -IC:\mercury-14.01-vs2013\lib\mercury\lib\hlc.gc\inc -IC:\mercury-14.01-vs2013\lib\mercury\conf -IC:\mercury-14.01-vs2013\lib\mercury\inc -DMR_HIGHLEVEL_CODE -DMR_CONSERVATIVE_GC -DMR_BOEHM_GC -DMR_TAGBITS=2 -nologo -c hello_init.c -Fohello_init.obj'...
    % done.
    hello_init.c
    % Linking...
    % Invoking system command `lib @C:\Users\Yun\AppData\Local\Temp\mtmp002.310'...
    % done.
    % Invoking system command `echo C:\Users\Yun\AppData\Local\Temp\mtmp002.30E.lib'...
    % done.
    C:\Users\Yun\AppData\Local\Temp\mtmp002.30E.lib
    % Invoking system command `cl -Fehello.exe C:\Users\Yun\AppData\Local\Temp\mtmp002.30E.lib -link -LIBPATH:C:\mercury-14.01-vs2013\lib\mercury\lib -LIBPATH:C:\mercury-14.01-vs2013\lib\mercury\lib\hlc.gc -nologo -subsystem:console -machine:x86 -entry:wmainCRTStartup -defaultlib:libcmt C:\mercury-14.01-vs2013\lib\mercury\lib\hlc.gc\libmer_std.lib C:\mercury-14.01-vs2013\lib\mercury\lib\hlc.gc\libmer_rt.lib C:\mercury-14.01-vs2013\lib\mercury\lib\libgc.lib '...


    C:\Users\Yun\Downloads\hello>cl -Fehello.exe C:\Users\Yun\AppData\Local\Temp\mtmp002.30E.lib -link -LIBPATH:C:\mercury-14.01-vs2013\lib\mercury\lib -LIBPATH:C:\mercury-14.01-vs2013\lib\mercury\lib\hlc.gc -nologo -subsystem:console -machine:x86 -entry:wmainCRTStartup -defaultlib:libcmt C:\mercury-14.01-vs2013\lib\mercury\lib\hlc.gc\libmer_std.lib C:\mercury-14.01-vs2013\lib\mercury\lib\hlc.gc\libmer_rt.lib C:\mercury-14.01-vs2013\lib\mercury\lib\libgc.lib
    LINK : warning LNK4001: Object file not specified; library used
    libmer_std.lib(io.obj) : error LNK2019: Unresolved external symbol ___report_rangecheckfailure, this symbol is referenced in function _mercury__io__read_char_code_2_4_p_0
    libmer_std.lib(parsing_utils.obj) : error LNK2001: Unresolved external symbol ___report_rangecheckfailure
    libmer_std.lib(string.obj) : error LNK2001: Unresolved external symbol ___report_rangecheckfailure
    libgc.lib(dbg_mlc.obj) : error LNK2001: Unresolved external symbol ___report_rangecheckfailure
    libmer_rt.lib(mercury_wrapper.obj) : error LNK2019: Unresolved external symbol _fesetround, this symbol is referenced in function _MR_process_options
    libmer_rt.lib(mercury_float.obj) : error LNK2019: Unresolved external symbol __dclass, the symbol is referenced in function _MR_is_nan
    hello.exe : fatal error LNK1120: 3 external commands that cannot be resolved
    1. create a hello.m in the tutorial https://www.mercurylang.org/documentation/papers/book.pdf
    2. run mmc.bat --make hello -v in cmd
    3. run cl -Fehello.exe C:\Users\Yun\AppData\Local\Temp\mtmp002.30E.lib -link -LIBPATH:C:\mercury-14.01-vs2013\lib\mercury\lib -LIBPATH:C:\mercury-14.01-vs2013\lib\mercury\lib\hlc.gc -nologo -subsystem:console -machine:x86 -entry:wmainCRTStartup -defaultlib:libcmt C:\mercury-14.01-vs2013\lib\mercury\lib\hlc.gc\libmer_std.lib C:\mercury-14.01-vs2013\lib\mercury\lib\hlc.gc\libmer_rt.lib C:\mercury-14.01-vs2013\lib\mercury\lib\libgc.lib in cmd
     
    There are no notes attached to this issue.




    View Issue Details
    463 [mercury] Bug minor always 2018-07-17 19:54 2018-07-20 16:51
    keri  
    juliensf Linux  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    build failure on Linux when mono 5 is installed
    Mono 5 installs both csc and mcs binaries. If the mercury configure script is invoked *without* --with-csharp-compiler=/path/to/mcs, then csc is selected as the C# compiler:

    $ ./configure
    <snip>
    checking for mono... /usr/bin/mono
    checking for a C sharp compiler...
    checking for csc... /usr/bin/csc
    checking version of .NET libraries... 4.0.0.0

    This leads to an eventual build failure:

    mmc --generate-dependencies --grade reg.gc --mercury-linkage shared --flags LIB_FLAGS --flags INTER_FLAGS -R/usr/lib64/mercury/lib/reg.gc -R/usr/lib64/mercury/lib --no-warn-nothing-exported --no-warn-unused-imports mer_std
    mercury_compile: `--host-env-type posix` is incompatible with
      `--csharp-compiler-type microsoft'.
    Mercury Compiler, version 14.01.1, configured for x86_64-pc-linux-gnu
    Copyright (C) 1993-2014 The University of Melbourne
    Usage: mmc [<options>] <arguments>
    Use `mmc --help' for more information.
    gmake[2]: *** [/var/tmp/portage/dev-lang/mercury-14.01.1/temp/mmake.ypfgqB:1500: mer_std.depend] Error 1


    This looks to be a different flavour of an older bug (see bug 0000255) where the Chicken Scheme Compiler (csc) would be selected as the C# compiler. However this time, the csc binary does pass the 'grep "^Microsoft"' configure check:

    $ csc
    Microsoft (R) Visual C# Compiler version 2.6.0.62309 (d3f6b8e7)
    Copyright (C) Microsoft Corporation. All rights reserved.
    warning CS2008: No source files specified.
    error CS1562: Outputs without source must have the /out option specified


    The version of mono installed is 5.12:
    $ mono --version
    Mono JIT compiler version 5.12.0.226
    after installing mono 5:

    $ ./configure
    $ make
     
    Notes
    (0001001)
    juliensf   
    2018-07-18 16:24   
    The basic problem is that Mercury's current detection and recognition of
    C# compilers predates the inclusion of the Roslyn C# compiler in Mono.
    In particular, Mercury requires (as mentioned in the error message), that
    if you are using a MS C# compiler then it needs to be running on Windows.
    (This is mainly so that it set up the command lines used to invoke the C#
    compiler appropriately, e.g. use Windows style paths etc.)
    (0001002)
    juliensf   
    2018-07-20 16:51   
    Fixed by commit c323cc2.




    View Issue Details
    462 [mercury] Feature Request minor N/A 2018-06-08 22:40 2018-06-08 22:41
    zs  
    zs  
    normal  
    assigned  
    open  
    none    
    none  
       
    packing notag arguments
    Given a type such as

    :- type t1
       ---> f1(int8, bool, bool, int8, int).

    we currently pack the first four arguments into a single word.

    However, given a type such as

    :- type t2
       ---> f2(nt_int8, nt_bool, nt_bool, nt_int8, int).

    where

    :- type nt_int8
       ---> nt_int8(int8).

    :- type nt_bool
       ---> nt_bool(bool).

    we do NOT pack the first four args of f2 into a single word.
    We should be able to.
    pack_args_notag.m (3,416 bytes) 2018-06-08 22:40
    https://bugs.mercurylang.org/file_download.php?file_id=284&type=bug
     
    There are no notes attached to this issue.




    View Issue Details
    451 [mercury] Feature Request minor N/A 2018-02-20 16:41 2018-06-08 22:19
    zs  
    zs  
    normal  
    assigned  
    open  
    none    
    none  
       
    unpack packed args only as necessary in field updates
    Given a type such as

    :- type thing
        ---> thing(bool, bool, int, bool, bool, t6 :: bool),

    and two variables A and B of this type, the field update
    unification B = A ^ t6 := ... now gets compiled to code that
    picks up the value of every argument of A, except possibly
    the one being replaced, and puts them one-by-one into
    the newly allocated memory cell. Since the adjacent bools
    are packed into one word, the first of those steps requires
    using shifts and masks to unpack all of arguments 1, 2, 4 and 5,
    operations that the second step then reverses.

    In the common situation where the code following the field update
    does not look at the fields that were not updated, we should be able
    to generate code that picks up the first word of A as a complete entity
    and assigns it to the first word of B. For the third word, part of which is
    being replaced, it should still be possible to pick up the value of the
    4th and 5th argument as a unit, and shift and OR it together with the
    new value of the 6th field *without* separating the 4th and 5th from each
    other.
    This probably needs to be done during code generation, because
    a post-code-generation optimization pass would have no way of knowing
    that the values of the padding bits don't matter.
    y.m (788 bytes) 2018-02-20 16:41
    https://bugs.mercurylang.org/file_download.php?file_id=275&type=bug
     
    Notes
    (0001000)
    zs   
    2018-06-08 22:19   
    Implemented for hlc grades in a diff committed on 2018 June 2.

    Not yet implemented for LLDS grades.




    View Issue Details
    459 [mercury] Bug minor always 2018-05-07 02:08 2018-05-07 07:45
    zs  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    bootcheck applies stage 2 settings to stage 1
    Doing a bootcheck in the csharp and java grades sets use_mmc_make and use_subdirs. This is fine for the stage 2, but the bootcheck script applies
    these settings to stage 1 as well. If the stage 1 did NOT use subdirs,
    then this will screw it up.
     
    Notes
    (0000999)
    zs   
    2018-05-07 07:45   
    Fix committed 2018 may 6.




    View Issue Details
    457 [mercury] Bug minor always 2018-04-29 12:19 2018-04-30 18:49
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    abort on construct_statically in var_locn
    The compiler aborts on the attached test case in low-level C grades with --loop-invariants --intermod-opt. The --loop-invariants option calls the mark_static_terms pass, which is (as I understand) otherwise only used for MLDS grades. var_locn.m aborts when it sees the construct_statically introduced by mark_static_terms.

    The original comment:
      % XXX We should probably throw an exception if we find either
      % construct_statically or reuse_cell here.
    was added by Quan for his RBMM work. I suspect var_locn_assign_dynamic_cell_to_var should just treat construct_statically like construct_dynamically.
    construct_statically_abort.m (623 bytes) 2018-04-29 12:19
    https://bugs.mercurylang.org/file_download.php?file_id=283&type=bug
     
    Notes
    (0000998)
    wangp   
    2018-04-30 18:49   
    Fixed in commit 72bc36afc




    View Issue Details
    456 [mercury] Feature Request minor N/A 2018-04-26 10:47 2018-04-26 10:47
    wangp  
     
    normal  
    new  
    open  
    none    
    none  
       
    structured concurrency
    Explains it well:
    https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/

    Spawning threads which can run indefinitely long is almost never what I want.
     
    There are no notes attached to this issue.




    View Issue Details
    455 [mercury] Bug minor always 2018-04-21 13:01 2018-04-21 21:16
    wangp  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    intermodule optimisation with fixed sized integer modules
    The compiler crashes on the attached test case:

    % mmc --intermod-opt -m mod_a
    Making Mercury/cs/mod_a.c
    Uncaught Mercury exception:
    Software Error: check_hlds.simplify.simplify_goal_call: predicate `check_hlds.simplify.simplify_goal_call.simplify_make_binary_op_goal_expr'/8: Unexpected: cannot find unchecked_left_shift
    mod_a.m (389 bytes) 2018-04-21 13:01
    https://bugs.mercurylang.org/file_download.php?file_id=281&type=bug
    mod_b.m (280 bytes) 2018-04-21 13:02
    https://bugs.mercurylang.org/file_download.php?file_id=282&type=bug
     
    Notes
    (0000996)
    juliensf   
    2018-04-21 17:43   
    The problem is that the simplification pass can introduce calls to unchecked_left_shift, but that
    dead predicate elimination hasn't been updated correctly to tell it not to delete the clauses
    for that predicate; I'll post a fix for this later this evening.
    (0000997)
    juliensf   
    2018-04-21 21:16   
    Fixed in commit bb55d65.




    View Issue Details
    445 [mercury] Bug minor N/A 2018-01-24 16:57 2018-03-19 15:19
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    __builtin_bswap16/32 support
    Detect support for __builtin_bswap{16,32} in configure, or figure out the earliest version of gcc/clang that support those builtins on relevant platforms.

    e.g. the builtins are unavailable in gcc 4.2.1 on OpenBSD 6.2 (which is stuck on an old gcc for ideological reasons). It may be that we should only support clang on OpenBSD.
     
    Notes
    (0000962)
    juliensf   
    2018-01-24 17:54   
    (Last edited: 2018-01-24 17:56)
    bswap32 and bswap64 first appeared in GCC 4.3.
    bswap16 first appeared in GCC 4.8.

    They are *not* listed among the platform specific builtins so I would assume
    they are available on all platforms from those versions onward.





    View Issue Details
    453 [mercury] Bug crash always 2018-03-09 15:57 2018-03-16 15:15
    wangp  
     
    normal  
    new  
    open  
    none    
    none  
       
    asm_fast does not work with gcc 5.4
    One of the test cases (of many) which crash is hard_coded/bit_buffer_test.

    This configuration crashes:
    Ubuntu 16.04 i386
    gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.9)
    Mercury rotd 2016-02-18 and rotd 2018-03-07
    asm_fast.gc
    (none.gc, reg.gc, hlc.gc are OK)
     
    Notes
    (0000976)
    wangp   
    2018-03-13 14:23   
    The previous configuration (gcc 5.4.0, asm_fast.gc, x86) passes bootcheck if the Mercury libraries are statically linked, i.e. ./configure --disable-dynamic-link
    (0000988)
    wangp   
    2018-03-15 12:57   
    I can reproduce a crash more simply with a call to string.count_codepoints/2. I've copied that predicate to a separate module for ease of debugging, and generated the assembly with mmake string2.pic_s. Then we can edit the assembly and create libmer_std.so with: as -g string2.pic_s -o string2.pic_o && mmake libmer_std.so


    This is the start of string2.count_codepoints:

               .globl _entry_mercury__string2__count_codepoints_2_0
       .type _entry_mercury__string2__count_codepoints_2_0,@function
    _entry_mercury__string2__count_codepoints_2_0:
       call 0f
    0:
       popl %ebx
       addl $_GLOBAL_OFFSET_TABLE_+[.-0b],%ebx
          
    # 0 "" 2
    .LDL1:
    #NO_APP
    .L4:
            movl -12(%ebp), %ebx
            leal .L5@GOTOFF(%ebx), %eax
    .LBB2:
            .loc 1 281 0
            movl MR_engine_base@GOT(%ebx), %eax
            movl 8(%eax), %ecx
            ...

    The four lines beginning with "call 0f" are due to MR_INLINE_ASM_FIXUP_REGS, to (as I understand it) load the position of the code into ebx. Right afterwards, gcc has added an instruction to copy something off the stack into ebx (presumably it would have stashed the correct value on the stack, but we've jumped into the middle of a C function).

    Inserting an instruction "movl %ebx, -12(%ebp)" to cancel out that instruction makes this particular predicate work, so I think this is on the right track.
    (0000989)
    wangp   
    2018-03-15 14:59   
    On the other hand... x86 usage is only decreasing, linking with Mercury shared libraries is not very important, and inter-function jumps were never officially supported by gcc anyway. Maybe it is time to drop support for the combination?
    (0000990)
    juliensf   
    2018-03-15 16:14   
    If you disable optimization in GCC (e.g. -O0) does the problem still occur?
    (0000991)
    wangp   
    2018-03-15 16:26   
    It works at -O0, but not -O1, and not at -O1 with -f* options I could find disabled (everything listed by "gcc -O1 -Q --help=optimizers").
    (0000992)
    wangp   
    2018-03-15 16:40   
    My guess is that it is related to this change in GCC 5.0:

    https://software.intel.com/en-us/blogs/2014/12/26/new-optimizations-for-x86-in-upcoming-gcc-50-32bit-pic-mode
    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54232

    Previously EBX was reserved for the GOT address so GCC probably had no need to save/restore it. If EBX can be used for other purposes then GCC might try to restore a value from the stack after our inline asm. The question is how to convince GCC not to do that.
    (0000993)
    wangp   
    2018-03-15 17:04   
    (convince GCC not to restore the GOT address from the stack, not only directly after the MR_INLINE_ASM_FIXUP_REGS sequence)
    (0000994)
    juliensf   
    2018-03-15 17:11   
    You could try starting at -O0 and adding optimizations. (Past experience of this
    kind of thing indicates that GCC is not entirely truthful about which optimizations it applies at which optimization level.)
    (0000995)
    wangp   
    2018-03-16 15:15   
    Ok, bootcheck still passes with these options (which are what gcc reports as being enabled by -O1):

    -fbranch-count-reg
    -fcombine-stack-adjustments
    -fcompare-elim
    -fcprop-registers
    -fforward-propagate
    -fguess-branch-probability
    -fif-conversion
    -fif-conversion2
    -finline-functions-called-once
    -fipa-profile
    -fipa-pure-const
    -fipa-reference
    -freorder-blocks
    -fshrink-wrap
    -fsplit-wide-types
    -fssa-phiopt
    -ftree-bit-ccp
    -ftree-builtin-call-dce
    -ftree-ccp
    -ftree-ch
    -ftree-coalesce-vars
    -ftree-copy-prop
    -ftree-dce
    -ftree-dse
    -ftree-fre
    -ftree-pta
    -ftree-sink
    -ftree-slsr
    -ftree-sra
    -ftree-ter


    Regardless, gcc 5 and up do not use a fixed PIC register on x86. Jumping into the middle of a function and putting the GOT address into EBX is not going to work if the rest of the function is not expecting it there.




    View Issue Details
    433 [mercury] Bug minor have not tried 2017-03-23 15:04 2018-03-13 14:38
    pbone amd64  
    pbone Linux Mint  
    normal  
    acknowledged  
    open  
    none    
    none  
       
    mmc --make calls programs without full path
    if you have multiple installations of Mercury then calling tools like mkinit without the full path can lead to problems.

    I have two installations of Mercury. In /usr I have 14.01.1 (this is the one I'm filing the bug against). And I have a recent ROTD in /usr/local (linked there by stow, stow is cool, check it out). But /usr/local is earlier in my path than /usr so that I can override my system's tools.

    $ which mmc
    /usr/local/bin/mmc

    If I invoke the version in /usr it breaks.

    $ /usr/bin/mmc --make hello
    Making Mercury/int3s/hello.int3
    Making Mercury/ints/hello.int
    Making Mercury/cs/hello.c
    Making Mercury/os/hello.o
    ** Error making `hello'.
    Mercury/cs/hello_init.c: In function ‘mercury_init’:
    Mercury/cs/hello_init.c:1736:29: error: ‘ML_std_library_init’ undeclared (first use in this function)
    Mercury/cs/hello_init.c:1736:29: note: each undeclared identifier is reported only once for each function it appears in
    Mercury/cs/hello_init.c:1737:27: error: ‘ML_std_library_finalize’ undeclared (first use in this function)
    Mercury/cs/hello_init.c: At top level:
    Mercury/cs/hello_init.c:1866:1: error: expected identifier or ‘(’ before ‘/’ token

    It appears to be excuting the first mkinit it finds in my $PATH, which is incompatible. If I override $PATH, then it works without a problem.
    I intend to fix this bug in the immediate future, I'm filing it now so that I can have a URL to point to it.
     
    Notes
    (0000946)
    pbone   
    2017-04-05 11:02   
    I've been looking at this issue.

    I'd like to store the full path to each of these tools (mkinit, mgnuc etc) in the configuration. scripts/Mercury.config.in seems like the best place to do that, and a similar change will need to be made for Mmake.

    It's also desirable to use the libexec directory, and in particular allow ./configure to set these directories rather than creating them ourselves, ignoring ./configure. However that may make it a little tricker to "move" a mercury installation, but that too should be solvable.

    Does anyone else seen any potential problems we may create by encoding the full paths in Mercury.config and allowing these files to be installed in different locations via ./configure's parameters?

    Thanks.
    (0000947)
    wangp   
    2017-04-05 11:24   
    I think using full paths is the correct thing to do.

    Allowing configure to adjust locations may get in the way of a different goal. I would like to see mmc --make and mmake use absolute paths built at runtime relative to a top-level directory either (1) deduced automatically based on the full path to mmc or mmake, or (2) manually overridden. This would allow moving the Mercury installation without touching any files. It would be especially useful for making prebuilt binary packages that could run immediately out of any user's home directory. (C compiler differences may still hamper that.)
    (0000948)
    pbone   
    2017-04-05 11:40   
    We can already move an installation by editing/rebuilding Mercury.config (and maybe another file). This change would make it more difficult to move an installation, there's just be more to edit within Mercury.config since it wouldn't build paths at runtime.

    There's another option. Rather than either writing (in Mercury.config) the path to each tool/library, or writing the prefix and building paths at runtime, we could write the path to @bindir@ and @libexecdir@ and build paths from those at runtime. It'd be a little easier to move an installation, but give full flexibility to autoconf/building packages for distros.

    I think either this, or writing the path to each tool in Mercury.config is the correct thing to do. There may be other ways to move an installation, such as by providing a simpler Mercury.config file that is based on most Linux distros' defaults with only one variable for the prefix.
    (0000949)
    wangp   
    2017-04-05 12:01   
    You can edit Mercury.config, but it is too difficult. Using Mercury on any (recent) Linux distribution should be as easy as tar xf mercury-bindist-xxxx.tar.gz

    I'm wary of introducing a variable syntax to Mercury.config. Which locations need customisation? I don't think anyone would object to libexec. If I remember, we had agreement to move most scripts out of bin.
    (0000950)
    juliensf   
    2017-04-05 12:03   
    Files containing paths are:

       lib/mercury/conf/Mercury.config
       lib/mercury/mdb/mdbrc
       lib/mercury/mmake/Mmake.vars

    as well as a bunch of scripts in the bin directory.

    Also, macOS you won't just be able to shift an installation without rewriting all of the install_names in the dylibs.

    @wangp: C compiler differences will definitely hamper that! In principle, we could build information about
    known C compilers into the system, so that by setting --cc, --c-compile-type and --fullarch appropriately
    it would select the correct set of flags. (I think I posted something to the developers list about this several years ago.) Of course, you will still have a problem with new C compiler versions that the Mercury compiler doesn't know about.
    (0000977)
    pbone   
    2018-03-13 14:38   
    Unassigned things from me.




    View Issue Details
    406 [mercury] Bug minor have not tried 2016-03-06 01:18 2018-03-13 14:38
    juliensf x86_64  
    pbone OS X  
    normal 10.9.5  
    acknowledged  
    open  
    none    
    none  
       
    parallelism in standalone java example aborts
    The example in samples/java_interface/standalone_java crashes with an OutOfMemoryError exception due to it trying to allocate ~2030 native threads. Commenting out the call to the parallelised Fiobnacci function in JavaMain.java causes the example to work.
    Java Information:

    java version "1.8.0_05"
    Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
    Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
     
    Notes
    (0000979)
    pbone   
    2018-03-13 14:38   
    Unassigned things from me.




    View Issue Details
    336 [mercury] Bug minor always 2014-06-20 10:30 2018-03-13 14:38
    wangp  
    pbone  
    low  
    acknowledged  
    open  
    none    
    none  
      15.11  
    java programs do not wait for all threads to finish
    The program terminates soon after the main thread exits, even if other threads are running.
     
    Notes
    (0000702)
    pbone   
    2014-06-20 11:49   
    Hi Peter,

    I'm about to do some work on the Java concurrency stuff for MCit. So I'll look at this at the same time.

    Thanks.
    (0000705)
    juliensf   
    2014-06-24 12:37   
    The behaviour of multi-threaded programs when the main thread terminates needs to be specified
    somewhere, reference manual(?) or in the comment at the head of thread.m. Furthermore the behaviour
    should be consistent across backends.
    (0000712)
    pbone   
    2014-06-26 18:50   
    Hi.

    What should be the behavior if an error is raised. For example:
     + The exit status is set to non-zero (I think it should wait).
     + An exception is uncaught in main/2 (Should it exit immediately?)
     + Can a mercury program call abort() like one can in C?
     + An internal error (in Mercury) (it should exit immediately).

    Thanks
    (0000714)
    wangp   
    2014-06-27 10:51   
    > What should be the behavior if an error is raised. For example:
    > + The exit status is set to non-zero (I think it should wait).

    Yes. It just sets a global variable.

    > + An exception is uncaught in main/2 (Should it exit immediately?)

    I think so.

    > + Can a mercury program call abort() like one can in C?

    Yes. Mercury can't prevent anyone doing so anyway.

    > + An internal error (in Mercury) (it should exit immediately).

    Yes. We can't continue after an internal (fatal) error.
    (0000715)
    pbone   
    2014-06-27 10:55   
    > > + Can a mercury program call abort() like one can in C?
    >
    > Yes. Mercury can't prevent anyone doing so anyway.

    What I mean is, do we provide something like abort in Mercury? (I don't remember one myself), something like:

    :- pred abort(int::in, io::di, io::uo) is det.

    Which doesn't return.
    (0000716)
    juliensf   
    2014-06-27 11:09   
    By making the determinism of abort/3 det, you are telling the compiler that it _does_ return.
    A better signature would be:

        :- pred abort(int::in, io::di) is erroneous.

    In any case, I don't see the need for abort in Mercury. Every time I have needed something like it, throwing an exception back to the top-level has always sufficed.
    (0000718)
    pbone   
    2014-06-27 11:20   
    Okay cool, I wasn't proposing abort/3 just asking if we already had something like this.
    (0000980)
    pbone   
    2018-03-13 14:38   
    Unassigned things from me.




    View Issue Details
    335 [mercury] Bug minor always 2014-06-17 15:42 2018-03-13 14:38
    wangp  
    pbone  
    normal  
    acknowledged  
    open  
    none    
    none  
       
    assertion failure in MR_do_sleep
        /*
        ** Either we slept and were notified, or were notified before we slept.
        ** Either way, check why we were notified.
        */
        MR_assert(state == ENGINE_STATE_NOTIFIED);
     
    Notes
    (0000701)
    wangp   
    2014-06-17 15:44   
    Sorry, I hit enter which submitted the issue prematurely.

    I get said assertion failure on any program in asm_fast.par.gc and -DMR_LOWLEVEL_DEBUG.
    (0000981)
    pbone   
    2018-03-13 14:38   
    Unassigned things from me.




    View Issue Details
    333 [mercury] Bug minor always 2014-06-16 11:41 2018-03-13 14:38
    wangp  
    pbone  
    normal  
    acknowledged  
    open  
    none    
    none  
       
    MR_num_idle_engines count goes wrong
    Hi Paul, I think you can solve this faster than I can.

    I've made a copy of the parallel fib benchmark, except that it repeats. Parallel execution works for the first fib call. Afterwards, fewer engines do any work. Soon, parallel execution never occurs again.

    MR_num_idle_engines should be the culprit:

    Program received signal SIGINT, Interrupt.
    0x0000000000405dac in fib_par_plain_module1 () at fib_par_plain.c:206
    206 MR_parent_sv(3) = MR_r1;
    (gdb) p MR_num_idle_engines
    $2 = -2
    (gdb) c
    Continuing.
    fib(40) = 165580141
    fib(40) = 165580141
    ^C
    Program received signal SIGINT, Interrupt.
    0x00007ffff6789d00 in sem_wait () from /lib64/libpthread.so.0
    (gdb) p MR_num_idle_engines
    $3 = 0
    fib_par_plain.m (435 bytes) 2014-06-16 11:41
    https://bugs.mercurylang.org/file_download.php?file_id=216&type=bug
     
    Notes
    (0000700)
    pbone   
    2014-06-16 12:14   
    It looks very odd where MR_num_idle_engines is -2. I'll take a look but I think 0000334 should be done first and might even help with this bug.

    Thanks.
    (0000982)
    pbone   
    2018-03-13 14:38   
    Unassigned things from me.




    View Issue Details
    295 [mercury] Bug minor always 2013-07-27 02:03 2018-03-13 14:38
    juliensf  
    pbone  
    normal  
    acknowledged  
    open  
    none    
    none  
       
    io.read_line_as_string/3 and CRLF line endings on Windows
    On Windows io.read_line_string/3 does not return a CRLF line ending in C grades, but does
    in Java grades. It would be preferable if this was consistent (or at least documented).
     
    Notes
    (0000557)
    juliensf   
    2013-07-27 02:06   
    Same for io.read_line/3.
    (0000983)
    pbone   
    2018-03-13 14:38   
    Unassigned things from me.




    View Issue Details
    274 [mercury] Bug minor always 2013-01-08 12:34 2018-03-13 14:38
    juliensf  
    pbone  
    normal  
    acknowledged  
    open  
    none    
    none  
       
    possibly incorrect purity cast in deep profiler
    The purity cast in predicate build_var_use_lists in deep_profiler/autopar_types.m is possibly
    in the wrong spot.
     
    Notes
    (0000984)
    pbone   
    2018-03-13 14:38   
    Unassigned things from me.




    View Issue Details
    163 [mercury] Bug major sometimes 2010-09-10 11:14 2018-03-13 14:38
    pbone  
    pbone  
    low  
    acknowledged  
    unable to reproduce  
    none    
    none  
       
    mdprof_cgi (deep profiler webserver) seems to lock up and leave processes running that should have timed out.
    Since setting up the deep profiler demo on taura I've noticed that deep profiler pages sometimes refused to be displayed, my browser waits forever for them.

    At the same time taura appears to be running many, many mdprof_cgi processes, killing them, and sometimes restarting apache temporarily fixes the problem.
     
    Notes
    (0000286)
    pbone   
    2010-09-10 11:16   
    I think that if the mdprof_cgi daemon processes dies due to an exception that the CGI process that is waiting for it fails to time-out/report the exception.
    (0000303)
    pbone   
    2011-02-02 13:10   
    I've lowered the priority and reproducibility of this bug. I haven't seen it for a while - it may exist but I'm not sure.
    (0000374)
    pbone   
    2011-11-02 14:22   
    This bug has stuck again, the problem with fixing it is that we don't really know how to cause it to happen.
    (0000985)
    pbone   
    2018-03-13 14:38   
    Unassigned things from me.




    View Issue Details
    157 [mercury] Bug minor always 2010-07-14 13:46 2018-03-13 14:38
    wangp  
    pbone  
    normal  
    acknowledged  
    open  
    none    
    none  
       
    mtags uninitialised value warnings
    perl v5.10.1 spews warnings on mtags.

    Use of uninitialized value $decl in pattern match (m//) at /usr/local/bin/mtags line 451, <SRCFILE> line 78.
    Use of uninitialized value $decl in pattern match (m//) at /usr/local/bin/mtags line 451, <SRCFILE> line 78.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 78.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 78.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 78.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 78.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 78.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 78.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 78.
    Use of uninitialized value $decl in pattern match (m//) at /usr/local/bin/mtags line 451, <SRCFILE> line 198.
    Use of uninitialized value $decl in pattern match (m//) at /usr/local/bin/mtags line 451, <SRCFILE> line 198.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 198.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 198.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 198.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 198.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 198.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 198.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 198.
    Use of uninitialized value $decl in pattern match (m//) at /usr/local/bin/mtags line 451, <SRCFILE> line 162.
    Use of uninitialized value $decl in pattern match (m//) at /usr/local/bin/mtags line 451, <SRCFILE> line 162.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 162.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 162.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 162.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 162.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 162.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 162.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 162.
    Use of uninitialized value $decl in pattern match (m//) at /usr/local/bin/mtags line 451, <SRCFILE> line 79.
    Use of uninitialized value $decl in pattern match (m//) at /usr/local/bin/mtags line 451, <SRCFILE> line 79.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 79.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 79.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 79.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 79.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 79.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 79.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 79.
    Use of uninitialized value $decl in pattern match (m//) at /usr/local/bin/mtags line 451, <SRCFILE> line 94.
    Use of uninitialized value $decl in pattern match (m//) at /usr/local/bin/mtags line 451, <SRCFILE> line 94.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 94.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 94.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 94.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 94.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 94.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 94.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 94.
    Use of uninitialized value $decl in pattern match (m//) at /usr/local/bin/mtags line 451, <SRCFILE> line 78.
    Use of uninitialized value $decl in pattern match (m//) at /usr/local/bin/mtags line 451, <SRCFILE> line 78.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 78.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 78.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 78.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 78.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 78.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 78.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 78.
    Use of uninitialized value $decl in pattern match (m//) at /usr/local/bin/mtags line 451, <SRCFILE> line 198.
    Use of uninitialized value $decl in pattern match (m//) at /usr/local/bin/mtags line 451, <SRCFILE> line 198.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 198.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 198.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 198.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 198.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 198.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 198.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 198.
    Use of uninitialized value $decl in pattern match (m//) at /usr/local/bin/mtags line 451, <SRCFILE> line 162.
    Use of uninitialized value $decl in pattern match (m//) at /usr/local/bin/mtags line 451, <SRCFILE> line 162.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 162.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 162.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 162.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 162.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 162.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 162.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 162.
    Use of uninitialized value $decl in pattern match (m//) at /usr/local/bin/mtags line 451, <SRCFILE> line 78.
    Use of uninitialized value $decl in pattern match (m//) at /usr/local/bin/mtags line 451, <SRCFILE> line 78.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 78.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 78.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 78.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 78.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 78.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 78.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 78.
    Use of uninitialized value $decl in pattern match (m//) at /usr/local/bin/mtags line 451, <SRCFILE> line 198.
    Use of uninitialized value $decl in pattern match (m//) at /usr/local/bin/mtags line 451, <SRCFILE> line 198.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 198.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 198.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 198.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 198.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 198.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 198.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 198.
    Use of uninitialized value $decl in pattern match (m//) at /usr/local/bin/mtags line 451, <SRCFILE> line 162.
    Use of uninitialized value $decl in pattern match (m//) at /usr/local/bin/mtags line 451, <SRCFILE> line 162.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 162.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 162.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 162.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 162.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 162.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 162.
    Use of uninitialized value $decl in string eq at /usr/local/bin/mtags line 461, <SRCFILE> line 162.
     
    Notes
    (0000307)
    pbone   
    2011-02-05 13:43   
    I can reproduce this by running mtags against tests/valid/constr_inst_syntax.m
    (0000987)
    pbone   
    2018-03-13 14:38   
    Unassigned things from me.




    View Issue Details
    156 [mercury] Bug text have not tried 2010-07-11 12:02 2018-03-13 14:38
    pbone  
    pbone  
    normal  
    acknowledged  
    open  
    none    
    none  
       
    Headers in deep profiler clique report are incorrect.
    The headers under 'Time' are incorrect when in "Times and per-call Times" mode. The same header label 'time' is used to represent self time and self and decedents time. The attachment contains the HTML page rendered by mdprof_cgi where the issue can be seen.
    mdprof_cgi.html (27,376 bytes) 2010-07-11 12:02
    https://bugs.mercurylang.org/file_download.php?file_id=105&type=bug
     
    Notes
    (0000986)
    pbone   
    2018-03-13 14:38   
    Unassigned things from me.




    View Issue Details
    454 [mercury] Bug minor always 2018-03-09 16:25 2018-03-13 14:19
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    arith_int64 failure
    arith_int64 fails on Ubuntu 16.04 x86_64
    gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.9)
    Mercury rotd 2018-03-07

    --- arith_int64.out 2018-03-09 16:23:20.780057386 +1100
    +++ arith_int64.exp 2018-02-03 23:05:01.000000000 +1100
    @@ -17,20 +17,20 @@
     
     *** Test unary operation '-' ***
     
    -- -9223372036854775808 = -9223372036841988320
    -- -2147483648 = 2160271136
    -- -64768 = 12852256
    -- -128 = 12787616
    -- 0 = 12787488
    -- 1 = 12787487
    -- 2 = 12787486
    -- 8 = 12787480
    -- 10 = 12787478
    -- 16 = 12787472
    -- 127 = 12787361
    -- 64767 = 12722721
    -- 2147483647 = -2134696159
    -- 9223372036854775807 = -9223372036841988319
    +- -9223372036854775808 = -9223372036854775808
    +- -2147483648 = 2147483648
    +- -64768 = 64768
    +- -128 = 128
    +- 0 = 0
    +- 1 = -1
    +- 2 = -2
    +- 8 = -8
    +- 10 = -10
    +- 16 = -16
    +- 127 = -127
    +- 64767 = -64767
    +- 2147483647 = -2147483647
    +- 9223372036854775807 = -9223372036854775807
     
     *** Test unary operation 'abs' ***
     
    @@ -56,15 +56,15 @@
     nabs -64768 = -64768
     nabs -128 = -128
     nabs 0 = 0
    -nabs 1 = 12787487
    -nabs 2 = 12787486
    -nabs 8 = 12787480
    -nabs 10 = 12787478
    -nabs 16 = 12787472
    -nabs 127 = 12787361
    -nabs 64767 = 12722721
    -nabs 2147483647 = -2134696159
    -nabs 9223372036854775807 = -9223372036841988319
    +nabs 1 = -1
    +nabs 2 = -2
    +nabs 8 = -8
    +nabs 10 = -10
    +nabs 16 = -16
    +nabs 127 = -127
    +nabs 64767 = -64767
    +nabs 2147483647 = -2147483647
    +nabs 9223372036854775807 = -9223372036854775807
     
     *** Test binary operation '+' ***
     
    sgt_int64.m (276 bytes) 2018-03-09 18:02
    https://bugs.mercurylang.org/file_download.php?file_id=279&type=bug
    bar_baz.m (759 bytes) 2018-03-13 06:14
    https://bugs.mercurylang.org/file_download.php?file_id=280&type=bug
     
    Notes
    (0000968)
    wangp   
    2018-03-09 16:56   
    For this program:

    main(!IO) :-
        X = 1i64,
        Y = -X,
        write_int64(Y, !IO),
        nl(!IO).

    the compiler is producing:

    void MR_CALL
    main_2_p_0(void)
    {
      {
        int64_t X_4 = INT64_C(1);
        int64_t Y_5 = (INT64_C(12789120) - X_4);

        mercury__io__write_int64_3_p_0(Y_5);
        mercury__io__nl_2_p_0();
      }
    }
    (0000970)
    wangp   
    2018-03-09 17:57   
    The problem is with a compiler in the .pregen grade.
    (0000971)
    wangp   
    2018-03-09 18:04   
    Ok, it's to do with (un)boxed int64s in a static ground term, see sgt_int64.m.
    (0000972)
    zs   
    2018-03-09 20:52   
    I have noticed that both unify_gen.m and ml_unify_gen.m still retain
    in most of their code the assumption that every argument of a functor
    occupies exactly one word in the memory cell. There are places that
    do deal with floats that take up double words and places that deal
    with two or more enum fields being packed into the same word,
    but they are post-processing the output of a word-oriented computation.

    I have started changing this over the last week or so, and will continue
    working on it, since doing so is prerequisite for improving argument packing.
    I think it very likely that this work will fix this bug.
    (0000973)
    zs   
    2018-03-13 06:14   
    The attached program, bar_baz.m, has code to allocate
    both a 64 bit float and a 64 bit integer both dynamically and statically.
    In pregen grades, all four allocations are boxed. This suggests to me
    that the bug is not in the allocation code, but I cannot check it
    since I don't have a 32 bit system. Can someone else who does
    try out this program (compiled with --no-inlining)?
    Maybe you could also check whether doing a deconstruct
    does the right thing for all of FX, FY, IX and IY, since deconstruct
    has special code (MR_arg_value_uncommon) for 64 bit floats
    but not for 64 bit ints.
    (0000974)
    wangp   
    2018-03-13 11:21   
    The problem is that MR_BOXED_INT64S should be defined in .pregen grades (whether or not we are on a 32-bit or 64-bit machine). I will run a bootcheck then send a patch.
    (0000975)
    wangp   
    2018-03-13 14:19   
    Fixed in commit b58cc673e




    View Issue Details
    409 [mercury] Bug minor have not tried 2016-06-16 13:04 2018-03-09 17:04
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    functor_ho_inst failing on 32-bit
    This was on Solaris/x86 but I assume it would affect any 32-bit platform.

    FAILED TEST hard_coded/functor_ho_inst in grade asm_fast.gc
    FAILED TEST hard_coded/functor_ho_inst_2 in grade asm_fast.gc
    FAILED TEST hard_coded/functor_ho_inst_excp in grade asm_fast.gc
    FAILED TEST hard_coded/functor_ho_inst_excp_2 in grade asm_fast.gc

    Uncaught Mercury exception:
    Software Error: transform_hlds.float_regs: predicate `transform_hlds.float_regs.lookup_pred_inst_info'/5: Unexpected: no higher order inst
     
    Notes
    (0000969)
    wangp   
    2018-03-09 17:04   
    Fixed by commit ac3891136




    View Issue Details
    359 [mercury] Bug minor always 2014-09-05 17:31 2018-03-06 15:45
    wangp  
     
    normal  
    new  
    open  
    none    
    none  
       
    constrained polymorphic modes
    Saving test cases to fix some other time.
    lambda.m (548 bytes) 2014-09-05 17:31
    https://bugs.mercurylang.org/file_download.php?file_id=223&type=bug
    ho_constrained_poly_inst.m (269 bytes) 2018-03-06 15:24
    https://bugs.mercurylang.org/file_download.php?file_id=277&type=bug
    create_test_unification.m (393 bytes) 2018-03-06 15:41
    https://bugs.mercurylang.org/file_download.php?file_id=278&type=bug
     
    Notes
    (0000793)
    wangp   
    2014-10-09 11:44   
    The problem in lambda.m:
    http://www.mercurylang.org/list-archives/users/2002-August/001921.html
    (0000843)
    mark   
    2015-07-15 11:37   
    A workaround for this is to use an explicit pred expression. For the lambda.m example, write:

        P = (pred(Z::out(bound(1))) is det :- id(1, Z))

    This will ensure that the inst variable for call to id/2 is bound in the way that is intended.
    (0000966)
    wangp   
    2018-03-06 15:31   
    While investigating something else, I found that modecheck_higher_order_call calls inst_expand which does not look past a top-level node of constrained_inst_vars. So this does not work, but I think there is no reason it should not work.

    :- inst b == (pred(in) is semidet).

    :- pred p2(pred(int)::in(I)) is semidet <= I =< b.

    p2(X) :- X(42).
    (0000967)
    wangp   
    2018-03-06 15:45   
    The compiler crashes on create_test_unification.m:

    Software Error: predicate `parse_tree.prog_mode.get_arg_insts'/4: Unexpected: defined_inst

    simplify_goal_switch.create_test_unification calls inst_expand (which does not touch an inst with constrained_inst_vars at the top level) followed by get_arg_insts (which expects the inst to be expanded).




    View Issue Details
    432 [mercury] Feature Request minor always 2017-03-21 13:12 2018-02-22 14:06
    wangp  
    zs  
    normal  
    assigned  
    open  
    none    
    none  
       
    pack constructor arguments in same word as primary tag
    When we have a data constructor with a primary tag, whose arguments have a total width less than or equal to the number of remaining bits, we could pack the arguments into the same word as the tag instead of a separate cell.

    e.g.

    :- type bits_or_string
        ---> bits(bool, bool, bool)
        ; string(string).

    This would be more useful once we have smaller-than-word-size ints.
     
    Notes
    (0000944)
    zs   
    2017-03-21 15:48   
    That is a good idea.

    Actually, it could also be applied to secondary tags. If a type has enough non-constant functors to need a secondary tag for some functors, then at the moment, we allocate
    the entire first word of the memory cells of those functors to the secondary tag.
    However, we could allocate only the minimum number of secondary tag bits
    needed to distinguish those functors, and allocate the rest to hold the packable
    arguments of those functors.

    However, I expect this would be useful much more rarely than Peter's original
    proposal.




    View Issue Details
    452 [mercury] Bug minor always 2018-02-21 15:16 2018-02-22 14:05
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    model_det need_bit_vec_check
    The compiler aborts on the attached test case:

    % mmc -s hlc.gc -C -v ml_lookup_switch_test.m
    ...
    % Converting HLDS to MLDS...
    Uncaught Mercury exception:
    Software Error: ml_backend.ml_lookup_switch: predicate `ml_backend.ml_lookup_switch.ml_gen_simple_atomic_lookup_switch'/13: Unexpected: model_det need_bit_vec_check


    (This is not urgent to fix.)
    ml_lookup_switch_test.m (725 bytes) 2018-02-21 15:16
    https://bugs.mercurylang.org/file_download.php?file_id=276&type=bug
     
    Notes
    (0000965)
    zs   
    2018-02-22 14:05   
    Fix committed feb 22.




    View Issue Details
    449 [mercury] Bug minor have not tried 2018-02-09 10:23 2018-02-13 12:55
    juliensf  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Switches on uint64s not working in java grade
    The test case tests/hard_coded/uint64_switch_test fails in the Java grade
    due to the generate code trying to perform a switch on a long value, which
    Java doesn't support.
    MERCURY_OPTIONS=
    gmake[3]: Entering directory `/mnt/opturion/jfischer/mercury-5.git/tests/hard_coded'
    { echo MCFLAGS += '--grade java --options-file /mnt/opturion/jfischer/mercury-5.git/stage2/Mercury.options --mercury-linkage static --flags ../TESTS_FLAGS --flags ../WS_FLAGS --use-subdirs '; echo MCFLAGS += ' '; echo CFLAGS += ' '; echo JAVACFLAGS += '-J"-Xmx1024m" '; echo CSCFLAGS += ' '; echo C2INITARGS += ' /mnt/opturion/jfischer/mercury-5.git/stage2/library/mer_std.init /mnt/opturion/jfischer/mercury-5.git/stage2/runtime/mer_rt.init '; echo MLLIBS += ' '; echo MLOBJS += ' '; echo LDFLAGS += ' '; echo LD_LIBFLAGS += ' '; echo EXTRA_LIBRARIES += ''; echo EXTRA_LIB_DIRS += ''; echo LIBGRADES = 'asm_fast.gc csharp erlang hlc.gc java '; echo INSTALL_PREFIX = '/mnt/opturion/jfischer/test-from-bytes'; echo LINKAGE = 'shared'; echo MERCURY_LINKAGE = 'shared'; } | /mnt/opturion/jfischer/mercury-5.git/stage2/scripts/mmc --make --options-file - uint64_switch_test.depend
    gmake[3]: Leaving directory `/mnt/opturion/jfischer/mercury-5.git/tests/hard_coded'
    gmake[3]: Entering directory `/mnt/opturion/jfischer/mercury-5.git/tests/hard_coded'
    { echo MCFLAGS += '--grade java --options-file /mnt/opturion/jfischer/mercury-5.git/stage2/Mercury.options --mercury-linkage static --flags ../TESTS_FLAGS --flags ../WS_FLAGS --use-subdirs '; echo MCFLAGS += ' '; echo CFLAGS += ' '; echo JAVACFLAGS += '-J"-Xmx1024m" '; echo CSCFLAGS += ' '; echo C2INITARGS += ' /mnt/opturion/jfischer/mercury-5.git/stage2/library/mer_std.init /mnt/opturion/jfischer/mercury-5.git/stage2/runtime/mer_rt.init '; echo MLLIBS += ' '; echo MLOBJS += ' '; echo LDFLAGS += ' '; echo LD_LIBFLAGS += ' '; echo EXTRA_LIBRARIES += ''; echo EXTRA_LIB_DIRS += ''; echo LIBGRADES = 'asm_fast.gc csharp erlang hlc.gc java '; echo INSTALL_PREFIX = '/mnt/opturion/jfischer/test-from-bytes'; echo LINKAGE = 'shared'; echo MERCURY_LINKAGE = 'shared'; } | /mnt/opturion/jfischer/mercury-5.git/stage2/scripts/mmc --make --options-file - uint64_switch_test
    Making Mercury/int3s/uint64_switch_test.int3
    Making Mercury/ints/uint64_switch_test.int
    Making Mercury/javas/jmercury/uint64_switch_test.java
    Making Java class files
    Mercury/javas/jmercury/uint64_switch_test.java:133: error: incompatible types: possible lossy conversion from long to int
            switch (Value_6) {
                   ^
    Note: Mercury/javas/jmercury/uint64_switch_test.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
     
    Notes
    (0000963)
    juliensf   
    2018-02-09 10:30   
    Not a limitation shared by C#, so this only affects the Java grade.
    (0000964)
    juliensf   
    2018-02-13 12:55   
    Fixed in commit 63572bc.




    View Issue Details
    450 [mercury] Bug minor sometimes 2018-02-13 10:17 2018-02-13 10:17
    juliensf  
     
    normal  
    new  
    open  
    none    
    none  
       
    tests/invalid/sub_c failing when running tests with -j8
    tests/invalid/sub_c fails due to (presumably) file creation time
    issues when running the tests with -j8. (On Linux/x86_64.)

    MERCURY_OPTIONS= --deep-random-write=25 --mdb-disable-progress
    gmake[3]: Entering directory `/mnt/opturion/jfischer/mercury-3.git/tests/invalid'
    /mnt/opturion/jfischer/mercury-3.git/stage2/scripts/mmc --generate-dependencies --grade asm_fast.gc --mercury-linkage static --flags ../TESTS_FLAGS --flags ../WS_FLAGS --verbose-error-messages --no-intermodule-optimization sub_c > sub_c.dep_err 2>&1
    gmake[3]: Leaving directory `/mnt/opturion/jfischer/mercury-3.git/tests/invalid'
    gmake[3]: Entering directory `/mnt/opturion/jfischer/mercury-3.git/tests/invalid'
    /mnt/opturion/jfischer/mercury-3.git/stage2/scripts/mmc --make-short-interface --grade asm_fast.gc --mercury-linkage static --flags ../TESTS_FLAGS --flags ../WS_FLAGS sub_a
    /mnt/opturion/jfischer/mercury-3.git/stage2/scripts/mmc --make-private-interface --grade asm_fast.gc --mercury-linkage static --flags ../TESTS_FLAGS --flags ../WS_FLAGS sub_a
    /mnt/opturion/jfischer/mercury-3.git/stage2/scripts/mmc --make-interface --grade asm_fast.gc --mercury-linkage static --flags ../TESTS_FLAGS --flags ../WS_FLAGS sub_a.m
    /mnt/opturion/jfischer/mercury-3.git/stage2/scripts/mmc --make-interface --grade asm_fast.gc --mercury-linkage static --flags ../TESTS_FLAGS --flags ../WS_FLAGS sub_a
    cp: cannot stat ‘sub_a.sub1.int.tmp’: No such file or directory
    Error creating `sub_a.sub1.int': can't open input file: No such file or directory
    Error: problem updating interface files.
    gmake[3]: *** [sub_a.date] Error 1
    gmake[3]: Target `sub_c.runtest' not remade because of errors.
    gmake[3]: Leaving directory `/mnt/opturion/jfischer/mercury-3.git/tests/invalid'
     
    There are no notes attached to this issue.




    View Issue Details
    448 [mercury] Bug minor always 2018-02-07 05:30 2018-02-07 05:30
    zs  
    zs  
    normal  
    assigned  
    open  
    none    
    none  
       
    singleton warning generation ignores variables in quantifications
    The problem is that quantification replaces the list of variables being quantified
    by a scope, ostensibly because that information is not needed by later compiler
    passes. However, it *is* needed by the code that generates warnings for singleton
    predicates.

    As it is, we get bad singleton warnings for code such as

        some [X] ( ... X ... )

    and may NOT get singleton warnings for code such as

        some [X] ( ... code in which there is no variable named X ... )
    The two halves of the problem are demonstrated by the test cases
    valid/bad_singleton_warning.m and warnings/missing_singleton_warning.m,
    which I just added to the repository.
    Simply keeping the quantified variables in place causes problems for later passes;
    it is such code in these later passes that are the actual bugs.
     
    There are no notes attached to this issue.




    View Issue Details
    447 [mercury] Feature Request feature N/A 2018-02-06 18:16 2018-02-06 18:16
    zs  
    zs  
    normal  
    assigned  
    open  
    none    
    none  
       
    direct_arg_switch type representation
    Some types, such as item and pragma_type in the Mercury compiler,
    consist of many functors of arity 1, each of whose arguments is a structure
    represented by an aligned pointer to the heap.

    At the moment, on 64 bit machines, we represent the first 7 functors
    as tagged pointers to those structures, and the remaining functors
    as two-word cells on the heap, with the first word being a secondary tag
    and the second being the structure pointer to the argument.

    This is probably the best representation we can get *if* the first 7 functors
    are the ones that occur most often. However, this may not be the case.
    Programmers can reorder the functors to *make* it the case, but this may
    not be desirable on software engineering grounds; for example, it may
    require that related functors not be put next to each other.

    It would be nice to have a pragma that tells the compiler the order of
    frequency of occurrence of the functors, so it can optimize the representation
    of the most frequently occurring functors. (Specifying the complete order
    would make this work regardless of the number of primary tag bits available.)

    It would be even better if a profiler generated that information automatically.
    This could be done by instrumenting e.g. every complete switch on the type
    to record which branch was taken.
     
    There are no notes attached to this issue.




    View Issue Details
    446 [mercury] Feature Request feature N/A 2018-01-30 02:32 2018-01-30 02:32
    zs  
    zs  
    low  
    assigned  
    open  
    none    
    none  
       
    smarter comparisons of structures
    The code we automatically generate two compare structures such as f(int, int, ..., int)
    looks like this:

       X = f(X1, X2, ..., Xn),
       Y = f(Y1, Y2, ..., Yn),
       ( if
          compare(R1, X1, Y),
          R1 != "="
       then
         R = R1
       else if
          compare(R2, X2, Y2),
          R2 != "="
       then
          R = R2
       ...
      )

    The problem with this is that we execute the code to retrieve X2 ... Xn and Y2 ... Yn
    even if X1 != X2.

    We should instead generate code that picks up the value of Xi and Yi just before
    we call compare on them, in the condition of the relevant if-then-else.

    If the comparison of Xi and Yi is quick (such as when they are integers),
    then the heap cells of X and Y should still be in the cache.

    If the comparison is NOT quick, such as when Xi and Yi are complex data structures,
    having to pick up Xi+1 and Yi+1 from the heap may add an extra cache miss.
    We should experiment with storing Xi+1 and Yi+1 in the stack frame in such cases
    (and in such cases *only*). That may pay back if Xi = Yi, but would be a cost if
    Xi != Yi (since in that case we won't need to compare Xi+1 and Yi+1).

    The same considerations apply to unify predicates.
    We should test whether, and if so how well, the stack_opt optimization can do this task already.
     
    There are no notes attached to this issue.




    View Issue Details
    444 [mercury] Bug crash always 2018-01-11 12:34 2018-01-12 17:33
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    static linking with musl crashes
    When using musl, static linking (i.e. --linkage static) causes the program to crash during initialisation of the GC. It has to do with passing the "-Wl,-defsym -Wl,_DYNAMIC=0" in the linking step. The program will not crash if _DYNAMIC is not defined.
     
    Notes
    (0000960)
    wangp   
    2018-01-11 12:50   
    Without "-Wl,-defsym -Wl,_DYNAMIC=0", the binary DOES have a symbol _DYNAMIC but with a non-zero address:

    bash-4.4$ nm -a hello | grep _DYNAMIC
    00000000006dcdf8 d _DYNAMIC

    bash-4.4$ ./hello
    Hello, world
    (0000961)
    wangp   
    2018-01-12 17:33   
    Fixed by commit ee177a481




    View Issue Details
    434 [mercury] Bug minor always 2017-03-29 09:55 2018-01-09 10:42
    juliensf x86_64-pc-linux-gnu  
    wangp Alpine Linux  
    normal 3.5  
    resolved  
    fixed  
    none    
    none  
       
    Alpine Linux / musl libc / x86_64 support
    Installing rotd-2017-03-28 from the source distribution on Alpine Linux (x86_64-pc-linux-gnu) results in a successful install, but the executables (e.g. hello world) generated by the compiler abort with:

        GC_is_visible test failed
        Aborted

    This seems to be occurring in every grade.
     
    Notes
    (0000945)
    FlyingJester   
    2017-03-30 18:46   
    I can confirm the same issue on VoidLinux for amd64, using musl.

    A possible clue to the issue is that using "--linkage static --mercury-linkage static" produces working executables.
    (0000955)
    wangp   
    2017-06-25 11:32   
    Progress:

    - upstream bdwgc has the necessary changes for musl (including parallel marking)

    - need to compile bdwgc with -DNO_GETCONTEXT -DHAVE_DL_ITERATE_PHDR

    - there is some other difference between the autotools-based buid and the Makefile.direct-based build. Mercury programs would crash when linked with libgc.{a,so} produced by Makefile.direct, but would run correctly when linked with the libgc produced by the autotools-generated makefile.

    - thread.spawn/spawn_native will need to set a reasonable stack size as musl gives threads something like 80 kB by default. We should also allow the user to choose a stack size when creating a thread.
    (0000959)
    wangp   
    2018-01-09 10:42   
    Fixed as of commit 323bad9ff




    View Issue Details
    443 [mercury] Bug minor always 2017-11-15 16:30 2017-11-15 16:30
    juliensf  
     
    normal  
    new  
    open  
    none    
    none  
       
    Segmentation fault in high-level C .par.trseg grades
    The attached program causes a segmentation fault when compiled in the
    grade hlc.par.gc.trseg. Thread local trailing has been supported since commit 1d50d41; I suspect it was broken for the high-level C backend when spawn_native/4 was implemented (based on the lack of any reference to trailing in library/thread.m.). The attached program is fine in asm_fast.par.gc.trseg.stseg.

    Reported against rotd-2015-11-21. Occurs in the current ROTD (2017-11-15).
    test.m (442 bytes) 2017-11-15 16:30
    https://bugs.mercurylang.org/file_download.php?file_id=274&type=bug
     
    There are no notes attached to this issue.




    View Issue Details
    442 [mercury] Bug minor always 2017-11-13 14:04 2017-11-13 14:04
    juliensf x86_64  
    Linux  
    normal Oracle 7  
    new  
    open  
    none    
    none  
       
    Building compiler with -j4 and --use-mmc-make fails
    Doing a parallel build of the compiler (-j4) with --use-mmc-make fails,
    the first error is:

        Making Mercury/int3s/term_io.int3
        Making Mercury/int3s/ops.int3
        Making Mercury/int3s/string.format.int3
        Making Mercury/int3s/string.format.int3
        Making Mercury/int3s/string.parse_runtime.int3
        Making Mercury/int3s/string.parse_runtime.int3
        Making Mercury/int3s/string.parse_util.int3
        ** Error making `Mercury/int3s/string.parse_runtime.int3'.
        cp: cannot stat ‘Mercury/int3s/string.parse_runtime.int3.tmp’: No such file or directory
        Error creating `Mercury/int3s/string.parse_runtime.int3': can't open input file: No such file or directory
        Error: problem updating interface files.
     
    There are no notes attached to this issue.




    View Issue Details
    441 [mercury] Bug minor always 2017-10-18 22:47 2017-10-18 23:42
    juliensf  
    zs  
    normal  
    assigned  
    open  
    none    
    none  
       
    Invalid C code for program in hlc.gc grade
    The attached program compiles and runs successfully in the asm_fast.gc grade. The generated C code
    fails to compile in the hlc.gc grade with the following error:

    Mercury/cs/test_vfm2.c: In function ‘test_vfm2__hello_1_f_0’:
    Mercury/cs/test_vfm2.c:130:18: error: void value not ignored as it ought to be
         HeadVar__2_2 = vfm2__printLine_2_f_0(TypeCtorInfo_5_5, TypeCtorInfo_6_6, ((MR_Box) (Var_4)), FIO_3);
                      ^
    ** Error making `Mercury/os/test_vfm2.o'.

    This is using rotd-2017-10-15 (although it also occurs with old roads).
    vfm2_bug.tar.gz (702 bytes) 2017-10-18 22:47
    https://bugs.mercurylang.org/file_download.php?file_id=273&type=bug
     
    Notes
    (0000958)
    zs   
    2017-10-18 23:42   
    The problem is NOT we generate the line that the error message is for.
    The problem is that vfm2.m knows that fio is a dummy type, and makes
    the return type of vfm2__printline_2_f_0 void accordingly, even though it keeps
    the definition of fio(T) *private*. This means that fio is NOT known to be a dummy
    type anywhere but inside the vfm2 module.

    We will need to split the concept of "dummy type" into two: dummy types
    that are known to be dummy everywhere, and those known to be dummy
    only in their defining module.




    View Issue Details
    411 [mercury] Bug major always 2016-06-22 14:03 2017-08-22 10:38
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    abstract type not hidden
    In the test case, foo.m exports an abstract type `foo' but bar.m is able to see that it is an equivalence type for int.

    Of the compilers I have installed:
    mercury-srcdist-rotd-2015-07-01 works correctly
    mercury-srcdist-rotd-2015-08-10 is broken
    mmc -m bar.m
    foo.m (426 bytes) 2016-06-22 14:03
    https://bugs.mercurylang.org/file_download.php?file_id=257&type=bug
    bar.m (410 bytes) 2016-06-22 14:04
    https://bugs.mercurylang.org/file_download.php?file_id=258&type=bug
     
    Notes
    (0000886)
    wangp   
    2016-06-22 14:08   
    Oops, the step to reproduce is obviously "mmc -m bar" without the .m suffix.
    (0000954)
    wangp   
    2017-06-22 15:38   
    I nearly filed this bug again, having forgotten about it. Strange coincidence!
    (0000957)
    wangp   
    2017-08-22 10:38   
    Fix committed.




    View Issue Details
    440 [mercury] Feature Request minor N/A 2017-08-10 11:08 2017-08-10 11:08
    wangp  
     
    normal  
    new  
    open  
    none    
    none  
       
    mdb: tab completion for function symbols
    It would improve the mdb experience greatly if you could tab complete function symbols in the term path part of a print command (and the browser?). For unnamed fields it may be worth cycling through the argument numbers. If the current subterm has exactly one argument, TAB could complete that without any prefix from the user.

    pp 5/1/box_content/1/1/5/1/2/1/box_content/1/1/1/5/1/1/spanbox_content
     
    There are no notes attached to this issue.




    View Issue Details
    439 [mercury] Bug minor always 2017-08-06 13:09 2017-08-06 13:09
    wangp  
     
    low  
    new  
    open  
    none    
    none  
       
    cannot build module which imports empty nested sub-module
    Both mmc --make and mmake are unable to build a module which tries to import an empty nested sub-module. Obviously this is extremely low priority, and the fix may be to disallow such sub-modules.


    % mmc -m empty_submodule
    Making Mercury/int3s/empty_submodule.int3
    empty_submodule.m:014: Warning: submodule `empty_submodule.nested' of module
    empty_submodule.m:014: `empty_submodule' is empty.
    ** Error reading file `empty_submodule.nested.m' to generate dependencies.
    ** Module `empty_submodule.nested' is imported or included by module `empty_submodule'.
    mercury_compile: cannot find source for module `empty_submodule.nested' in
      directories `.'


    % mmake empty_submodule.depend && mmake empty_submodule
    gmake: *** No rule to make target 'empty_submodule.nested.int', needed by 'empty_submodule.c_date'. Stop.
    empty_submodule.m (469 bytes) 2017-08-06 13:09
    https://bugs.mercurylang.org/file_download.php?file_id=272&type=bug
     
    There are no notes attached to this issue.




    View Issue Details
    437 [mercury] Bug minor always 2017-08-05 12:35 2017-08-06 02:50
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    abort on empty nested sub-module
    The compiler throws an exception if a nested sub-module is empty.

    % mmc parent.m
    Uncaught Mercury exception:
    Software Error: map.det_remove: key not found
        Key Type: mdbcomp.sym_name.sym_name
        Key Value: qualified(unqualified("parent"), "sub")
        Value Type: parse_tree.split_parse_tree_src.split_module_entry
    parent.m (169 bytes) 2017-08-05 12:35
    https://bugs.mercurylang.org/file_download.php?file_id=270&type=bug
     
    Notes
    (0000956)
    zs   
    2017-08-06 02:50   
    Fix committed 5 aug 2017.




    View Issue Details
    438 [mercury] Bug minor always 2017-08-05 14:55 2017-08-05 14:55
    wangp  
     
    normal  
    new  
    open  
    none    
    none  
       
    partial module qualification of use_module imported entity
    Commit 5649f36 (Handle "use_module in interface, import_module in implementation") changed the language definition such that entities imported via use_module must be *fully* module qualified.

    In the attached test case, we are still able to refer to a partially qualified bar.baz.in_baz (should be foo.bar.baz.in_baz).
    submodule_test.tar.gz (10,240 bytes) 2017-08-05 14:55
    https://bugs.mercurylang.org/file_download.php?file_id=271&type=bug
     
    There are no notes attached to this issue.




    View Issue Details
    410 [mercury] Bug minor always 2016-06-17 10:29 2017-06-17 11:00
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Syntax error causes compiler abort
    In the attached program a missing parenthesis in a predmode declaration is causing the following
    compiler abort:

    Uncaught Mercury exception:
    Software Error: map.lookup: key not found
        Key Type: int
        Key Value: 1
        Value Type: hlds.hlds_pred.proc_info

    This is occurring with rotd-2016-06-09.
    Mercury 14.01 correctly reports the syntax error:
    bug410.m (2,810 bytes) 2016-06-17 10:29
    https://bugs.mercurylang.org/file_download.php?file_id=256&type=bug
     
    Notes
    (0000953)
    zs   
    2017-06-17 11:00   
    Fix committed 17 june 2017.




    View Issue Details
    436 [mercury] Bug minor always 2017-04-28 16:38 2017-05-03 10:42
    wangp  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    unknown constructor in foreign_enum
    The compiler silently allows a constructor in a pragma foreign_enum that do not correspond a constructor of the type.
    foreign_enum_unknown_ctor.m (207 bytes) 2017-04-28 16:38
    https://bugs.mercurylang.org/file_download.php?file_id=269&type=bug
     
    Notes
    (0000951)
    juliensf   
    2017-04-28 16:45   
    That's a bit naughty of it -- I'll take a look it.
    (0000952)
    juliensf   
    2017-05-03 10:42   
    Fixed in commit c40f4300f.




    View Issue Details
    431 [mercury] Bug minor have not tried 2017-03-05 23:52 2017-03-06 15:45
    dirkz Mac  
    juliensf OS X Yosemite  
    normal 10.10.5  
    resolved  
    fixed  
    none    
    none  
       
    Install fails during make install of java grade in rotd-2017-02-22
    The installation of Mercury with the default set of grades fails on Mac OS X during installation of the Java grade.
    1. sh configure (OK)
    2. make PARALLEL=-j6 (OK)
    3. make PARALLEL=-j6 install (ERROR; see attached mer_std.err)
    mer_std.err (4,090 bytes) 2017-03-05 23:52
    https://bugs.mercurylang.org/file_download.php?file_id=268&type=bug
     
    Notes
    (0000940)
    juliensf   
    2017-03-06 01:15   
    What are the versions of OS X and Java are you using?
    (0000941)
    dirkz   
    2017-03-06 04:45   
    I'm using Mac OS X Yosemite 10.10.5

    Entering "java -version" in terminal shows this result:
    java version "1.6.0_65"
    Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)
    Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)
    (0000942)
    juliensf   
    2017-03-06 08:42   
    Ah, the OS version was above -- my phone chose to display it using a tiny font so I couldn't read it :-(

    It looks as though we are generating code that is not compatible with Java 1.6 for the uint type.
    I think I know what the problem is. (I can confirm that the current ROTD does work with Java 1.8,
    so if that's an option, you may wish to use that until a fix is available.)
    (0000943)
    juliensf   
    2017-03-06 15:45   
    Fixed in rotd-2017-03-06. (Part of the MLDS->Java code generator was not handling the builtin uint type correctly; the problem would only show in versions of Java that don't support autoboxing.)




    View Issue Details
    430 [mercury] Bug minor always 2017-01-28 17:47 2017-01-29 14:39
    wangp  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    optional underscores in numeric literals
    The parser does not accept these literals:

    0_0
    0_0.0
     
    Notes
    (0000939)
    juliensf   
    2017-01-29 14:39   
    Fixed in commit b3835dd.




    View Issue Details
    429 [mercury] Bug minor always 2017-01-19 18:47 2017-01-20 04:24
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    cse causes switch to be reported as non-switch
    The compiler reports for the given test case:

    switch_scope.m:016: Error: the goal inside the require_complete_switch [Index]
    switch_scope.m:016: scope is not a switch on `Index'.


    The problem is more apparent from the HLDS dump. After pass 045-cse the predicate looks like:

    switch_scope.clear(I, P0, P) :-
      require_complete_switch [Index] (
        ( % conjunction
          P0 = pair.(V_15 - V_14)
          ,
          ( % cannot_fail switch on `I'
            % I has functor switch_scope.first/0
            ( % conjunction
              V_12 = V_15
              ,
              Y = V_14
              ,
              V_12 = bool.yes
              ,
              V_13 = bool.no
              ,
              P = pair.(V_13 - Y)
            )
          ;
            % I has functor switch_scope.second/0
            ( % conjunction
              V_15 = X
              ,
              V_14 = V_10
              ,
              V_10 = bool.yes
              ,
              V_11 = bool.no
              ,
              P = pair.(X - V_11)
            )
          )
        )
      ).
    switch_scope.m (425 bytes) 2017-01-19 18:47
    https://bugs.mercurylang.org/file_download.php?file_id=267&type=bug
     
    Notes
    (0000938)
    zs   
    2017-01-20 04:24   
    Fix committed 2017 jan 20.




    View Issue Details
    428 [mercury] Bug major always 2016-10-25 06:14 2016-10-25 06:14
    lpimmes Dell Precision laptop  
    Ubuntu  
    urgent 16.04  
    new  
    open  
    none    
    none  
       
    standalone_c complains about return value 0 (OK) from main/2.
    Modified mercury_lib.m to output "STANDALONE" on console.

    Any help would be appreciated.
    Thanks.
    luke@luke-Precision-7710:~/mercury/standalone_c$ ls
    c_main.c Makefile mercury_lib.m

    *.c and Makefile are original files from installation.

    > make
    mmc --make libmercury_lib
    Making Mercury/int3s/mercury_lib.int3
    Making Mercury/ints/mercury_lib.int
    Making Mercury/cs/mercury_lib.c
    Making Mercury/os/mercury_lib.o
    Mercury/cs/mercury_lib.c:247:1: warning: return type of ‘main’ is not ‘int’ [-Wmain]
     main(void)
     ^
    Making libmercury_lib.a
    Making Mercury/os/mercury_lib.pic_o
    Mercury/cs/mercury_lib.c:247:1: warning: return type of ‘main’ is not ‘int’ [-Wmain]
     main(void)
     ^
    Making libmercury_lib.so
    ** Error making `libmercury_lib.so'.
    /usr/bin/ld: cannot find -lmer_std
    /usr/bin/ld: cannot find -lmer_rt
    collect2: error: ld returned 1 exit status
    Makefile:123: recipe for target 'mercury_lib.init' failed
    make: *** [mercury_lib.init] Error 1
    luke@luke-Precision-7710:~/mercury/standalone_c$
    mmc: 14.01
    standalone_c.tar.gz (30,720 bytes) 2016-10-25 06:14
    https://bugs.mercurylang.org/file_download.php?file_id=266&type=bug
     
    There are no notes attached to this issue.




    View Issue Details
    427 [mercury] Bug minor have not tried 2016-10-23 01:54 2016-10-23 01:54
    juliensf  
    juliensf  
    normal  
    assigned  
    open  
    none    
    none  
       
    Use of long and unsigned long in C runtime code
    Various parts of the C version of the Mercury runtime cast things to 'long' or 'unsigned long', presumably on the assumption that this is equal to or greater than the size of MR_Word, MR_Integer, MR_Unsigned.
    This assumption is untrue on 64-bit Windows systems were longs are 32-bit quantities. Most of this was cleaned up during the development of the initial 64-bit Windows port, but there are still various spots (mainly debugging code) that do this.
     
    There are no notes attached to this issue.




    View Issue Details
    425 [mercury] Bug minor always 2016-10-06 13:23 2016-10-10 20:42
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    mmc --make loop on wrongly named module
    Test case:

        echo 'module rong_name.' >wrong_name.m
        mmc -m wrong_name --debug-make

    produces

    Module dependencies file 'Mercury/module_deps/wrong_name.module_dep' not found in directories `.', `/home/wangp/local/stow/mercury-srcdist-rotd-2016-10-04/lib/mercury/ints'.
    Module dependencies file 'Mercury/module_deps/wrong_name.module_dep' not found in directories `.', `/home/wangp/local/stow/mercury-srcdist-rotd-2016-10-04/lib/mercury/ints'.
    Module dependencies file 'Mercury/module_deps/wrong_name.module_dep' not found in directories `.', `/home/wangp/local/stow/mercury-srcdist-rotd-2016-10-04/lib/mercury/ints'.

    etc. until the process runs out of file descriptors.

    Started occurring between rotd-2015-07-01 and rotd-2015-08-10 (that I have installed).
     
    Notes
    (0000937)
    zs   
    2016-10-10 20:42   
    Fix committed 2016 oct 10.




    View Issue Details
    424 [mercury] Bug minor always 2016-10-04 12:13 2016-10-07 15:28
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    error creating temporary file with --restricted-command-line
    This mainly affects Windows, but can be tested on other platforms by passing --restricted-command-line.

    % mmc -m e --restricted-command-line
    Making Mercury/int3s/e.int3
    Making Mercury/ints/e.int
    Making Mercury/cs/e.c
    Making Mercury/os/e.o
    Making e
    Could not create temporary file: error opening temporary file: Invalid argument
    ** Error making `e'.
     
    Notes
    (0000932)
    pbone   
    2016-10-04 12:28   
    Hi Peter.

    I think I broke this and have a guess about what went wrong. I can take a look at it this afternoon.

    Cheers.
    (0000936)
    wangp   
    2016-10-07 15:28   
    Fixed in commit 4bf82f6




    View Issue Details
    418 [mercury] Bug minor always 2016-09-07 13:57 2016-10-07 14:34
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    io error exceptions not working
    There is some problem with exceptions not being thrown or caught properly in low-level C grades, as in the attached test case:

    ./test|no_such_cmd
    zsh: command not found: no_such_cmd
    Errno = 32: Broken pipe
    Mercury runtime: reached not_reached
    test.m (633 bytes) 2016-09-07 13:57
    https://bugs.mercurylang.org/file_download.php?file_id=263&type=bug
    throw_from_foreign.m (778 bytes) 2016-09-19 17:53
    https://bugs.mercurylang.org/file_download.php?file_id=265&type=bug
     
    Notes
    (0000912)
    wangp   
    2016-09-19 17:53   
    Nothing to do with io.m.

    Note (to self) about throw_from_foreign.m in low-level C grades:

    The Mercury procedure dothrow/1 is foreign_exported, so we create a C wrapper function dothrow() which uses MR_call_engine() to enter the Mercury code. MR_call_engine() itself uses setjmp(). When dothrow/1 throws an exception it calls longjmp, but that sends us back to the setjmp point in the MR_call_engine call for the dothrow() wrapper function instead of the exception handler.
    (0000913)
    wangp   
    2016-09-20 11:57   
    The previous comment was wrong.

    try_io/builtin_catch creates a Mercury exception handler entry on the nondet stack.
    Then we enter the foreign proc `chucker',
    which calls the C wrapper `dothrow',
    which calls the C function `MR_call_engine' (with catch_exceptions=FALSE),
    which runs the Mercury proc `dothrow',
    which calls `throw'.

    throw/builtin_throw finds the Mercury exception handler on the nondet stack. It does NOT longjmp back to the MR_call_engine, but calls the Mercury exception handler. The C stack is not unwound, so some time later we end up returning into MR_call_engine.

    Anyone have suggestions for how builtin_throw should unwind the C stack?

    One way might be for builtin_catch to call setjmp so that builtin_throw always calls longjmp to unwind the C stack (like high-level C grades).

    Another way might for MR_call_engine to always intercept exceptions and rethrow them. e.g. if catch_exceptions=FALSE, it still needs to create an exception handler entry of type MR_C_LONGJMP_HANDLER on the nondet stack, so it can catch any exception and rethrow it.
    (0000914)
    juliensf   
    2016-09-20 12:19   
    With regard to throw_from_foreign.m, throwing exceptions across the C interface like that is currently documented as being undefined behaviour, it's not surprising that it doesn't work. Are you suggesting that it needs to work? (I could reproduce the issue with test.m on my machine; which grade are you using?)
    (0000915)
    wangp   
    2016-09-20 12:37   
    I couldn't find where it is documented.

    io.m does throw exceptions across the C interface. ML_throw_io_error is C wrapper for Mercury proc throw_io_error, and is called indirectly from many foreign_procs.

    I think I would not mind if throwing exceptions across the C interface is not supported (with better documentation, and perhaps runtime checks). I think a better way for io.m or any other module to handle errors is to return error codes from foreign_procs up to Mercury code, then for the Mercury code to throw exceptions.

    I'm testing with asm_fast.gc and none.gc.
    (0000916)
    juliensf   
    2016-09-20 13:51   
    It's documented in the comment at the head of library/exception.m.

    The ODBC library does it as well. I think ML_throw_io_error (probably) worked well enough once upon a time, but I suspect that various runtime changes may have contributed to it not working. it would be preferable if we didn't throw exceptions over the C interface (certainly in the standard library at least).

    We could insert runtime checks in the foreign_export wrappers, but there are probably performance implications with doings so (such checks could obviously be omitted in the case where we know the Mercury code is not going to throw an exception).

    I tried with none.gc.debug.trseg.stseg.
    (0000917)
    wangp   
    2016-09-20 15:58   
    It's very easy to write a Mercury predicate that may throw exceptions without meaning to. It would be preferable to support throwing exceptions across the C interface, perhaps even if there is some performance impact. The majority of foreign_exported predicates in extras might fall afoul of the rule.

    I will try to fix io.m.
    (0000918)
    juliensf   
    2016-09-20 18:20   
    If there are any proposals in this area, then I suggest we discuss them on the developers list.
    (0000935)
    wangp   
    2016-10-07 14:34   
    Fixed, io.m does not throw past the C interface any more.




    View Issue Details
    346 [mercury] Bug minor always 2014-07-11 17:41 2016-10-06 20:27
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    non-ANSI functions in header files
    dir.mih references DIR, but is included into C files compiled with gcc -ansi. For some reason this elicits an error from the gcc on AIX but seemingly not elsewhere.

    There might be other similar problems.
     
    Notes
    (0000739)
    juliensf   
    2014-07-11 20:08   
    It might be worth adding the dir module to the list of files in library/Mercury.options that are compiled with --no-ansi.

    OTOH, we should probably just not use -ansi at all -- IIRC, it (still) puts GCC into C90 mode (annoyingly it puts clang into C89 or GNU89 mode, which is slightly different).
    (0000743)
    wangp   
    2014-07-14 10:26   
    Yes, I don't understand why dir.m hasn't required --no-ansi yet.

    The bigger problem is that the non-ANSI stuff leaks into the header files generated for dir.m and ends up being included into almost everything else. That stuff should be hidden away, and only appear in `local' foreign_decls, foreign_codes, and foreign_procs marked `may_not_duplicate'.
    (0000744)
    juliensf   
    2014-07-14 10:31   
    I'd perfectly happy simply to not use -ansi with GCC. (I had to disable its use with clang recently anyway.)
    Another problem with it is that it affects the compilation of user foreign_procs. Most of the systems we
    support these days support POSIX / C99 well enough that disabling it isn't going to be a problem.
    The one major system that doesn't, Windows, already requires special treatment everywhere anyway.
    (0000745)
    juliensf   
    2014-07-14 10:33   
    All that said, restricting the stuff in the dir module to appear in 'local' foreign pragmas is also a worthwhile
    change IMO.
    (0000934)
    wangp   
    2016-10-06 20:27   
    Fixed as part of commit 1fbcfe3 (for dir.m anyway)




    View Issue Details
    422 [mercury] Bug minor always 2016-10-03 12:40 2016-10-04 21:11
    juliensf x86_64  
    OS X  
    normal 10.9.5  
    new  
    open  
    none    
    none  
       
    Intermittent runtime aborts in parallel conjunction tests
    Various tests in tests/par_conj intermittently abort on my system with:

         Mercury runtime: Unable to init shared engine thread.

    For example, with the spawn_many test case, about half the invocations correct and the other
    half abort with the above message.

    This is occurring in the grade none.par.gc.stseg.ll_debug.
    The C compiler on my system is:

    Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
    Target: x86_64-apple-darwin13.4.0
    Thread model: posix
     
    Notes
    (0000933)
    juliensf   
    2016-10-04 21:11   
    The problem does *not* occur with GCC 5 in the asm_fast.par.gc.stseg grade on OS X.




    View Issue Details
    404 [mercury] Bug minor always 2016-02-09 10:05 2016-10-03 13:42
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    mmc --rebuild not working
    mmc --rebuild is no longer causing anything to be rebuild. (Presumably caused by commit 1fcdc4c)
     
    Notes
    (0000904)
    wangp   
    2016-08-28 13:22   
    This is indeed due to commit 1fcdc4c which changed the internal representation of --rebuild as opm_top_make(opmm_must_rebuild). The problem is that the op_mode for sub-steps is not opm_top_make(opmm_must_rebuild) but opm_top_args(blah) so that check_dependency_timestamps has lost the indicator that --rebuild is in effect.

    I think we should change --rebuild back to a normal option that implies --make (opm_top_make).
    (0000906)
    zs   
    2016-08-29 07:20   
    Could either one of you add a test case for this bug? The reason I haven't looked at this bug when it was first filed is that I have no way of reproducing it, since I don't use --make myself.
    (0000907)
    juliensf   
    2016-08-29 09:32   
    Any valid Mercury program is a test case for this bug, samples/hello.m for instance.

         samples jfischer$ mmc --make hello
         Making Mercury/int3s/hello.int3
         Making Mercury/ints/hello.int
         Making Mercury/cs/hello.c
         Making Mercury/os/hello.o
         Making hello

        samples jfischer$ mmc --rebuild hello
        ** Nothing to be done for `hello'.
    (0000926)
    zs   
    2016-10-03 13:42   
    Fixed in commit 3485884 on 2016 oct 3.




    View Issue Details
    357 [mercury] Bug minor always 2014-09-02 16:05 2016-10-03 10:58
    juliensf x86_64  
    juliensf OS X  
    normal 10.9  
    resolved  
    fixed  
    none    
    none  
      15.11  
    Parallel conjunction broken on OS X
    Parallel conjunctions are broken on OS X (I used asm_fast.par.gc, but
    this presumably applies to the other grades as well), because although OS X defines the function
    sem_init (called from mercury_context.c), it defines it to only return an error.

    Possible solutions to this are either to use named semaphores, e.g. with sem_open, or to use
    Grand Central Dispatch. (I'm not sure how well the latter would work with GCC though.)
     
    Notes
    (0000779)
    wangp   
    2014-09-02 16:24   
    Or just condition variables, though presumably they perform worse so we would want to stick to semaphores on better platforms.
    (0000780)
    juliensf   
    2014-09-02 16:25   
    This would have shown up more obviously had the return value of sem_init been checked!

    There are also a bunch of calls to various pthread_* functions in the runtime, for example pthread_mutex_init and pthread_attr_init, where the return values are not checked.
    (0000921)
    pbone   
    2016-09-29 14:04   
    I remember some things about writing this code but not others.

    In particular I remember choosing semaphores for a very good reason, but I don't remember what that reason was :-(

    I'm not sure what should be used instead on OS X. Except that if we want to use GCD, then we should essentially write a different implementation for the N:M threading on OS X, as GCD will (and should) handle this for us. I suspect windows is a similar case as it supports fibers. However that's about all I know of either platform/API.

    So I'd recommend trying to replace this with named semaphores, if those are supported/work, or maybe condition variables - again there's a good reason why I didn't use those but I don't know what it is. And in the longer term consider writing an alternative implementation of all this code (maybe keep the work stealing) for OS X.
    (0000922)
    juliensf   
    2016-09-29 14:13   
    Hi Paul,

    Using GCD to do the N:M threading is a separate issue; the semaphore implementation in libdispatch is close enough to POSIX unnamed semaphores that it should be easy enough to use as a drop-in replacement. Using GCD in general on OS X is a much larger change.
    (0000923)
    pbone   
    2016-09-29 14:24   
    Agreed, which is why I said that's a longer term change, and by implication not really part of this bug. However I wasn't aware of the primitives provided by libdispatch so I didn't know that's what you meant when you said GCD. It sounds reasonable to me.
    (0000925)
    juliensf   
    2016-10-03 10:58   
    Fixed in commit 1fc495c.




    View Issue Details
    421 [mercury] Bug minor always 2016-10-01 22:59 2016-10-02 11:12
    juliensf  
    zs  
    normal  
    assigned  
    open  
    none    
    none  
       
    Code generator aborts in parallel conjunction tests
    The following tests are failing with rotd-2016-09-28 in .par grades:

        tests/par_conj/consume_wiat
        tests/par_conj/consume_in_some_branches
        tests/par_conj/consume_in)some_branches_and_after
        tests/par_conj/dep_par_24
        tests/par_conj/dep_par_24b
        tests/par_conj/dep_par_7

    The symptoms are something like:

    Uncaught Mercury exception:
    Software Error: ll_backend.var_locn: predicate `ll_backend.var_locn.clobber_lval_in_var_state_map'/6: Unexpected: empty state

    Uncaught Mercury exception:
    Software Error: map.lookup: key not found
        Key Type: term.var(parse_tree.prog_data.prog_var_type)
        Key Value: var(1)
        Value Type: ll_backend.var_locn.var_state

    Attempting to compile the above in any grade containing a .par grade, e.g.


       $ mmc -C --grade asm_fast.par.gc consume_wait
     
    Notes
    (0000924)
    zs   
    2016-10-02 11:11   
    I noticed this a couple of months ago. I worked out a partial fix then; it fixes
    the test failures above, but introduces a couple of others to replace them.
    I didn't have time at the time to look into those, but still, I think I am best placed
    to look into this.




    View Issue Details
    398 [mercury] Bug minor have not tried 2015-12-09 16:00 2016-09-28 16:04
    juliensf  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    mercury_compile.exe fails to link on Cygwin64 / MinGW64 with GCC 4.9.X
    Building the compiler on Cygwin64 and some versions of MinGW64 results in the compiler executable failing to link. The error is as follows:

    top_level_init.o:top_level_init.c:(.rdata$.refptr._bss_start__[.refptr._bss_start__]+0x0): undefined reference to `_bss_start__'
    top_level_init.o:top_level_init.c:(.rdata$.refptr._data_start__[.refptr._data_start__]+0x0):
    undefined reference to `_data_start__'
    top_level_init.o:top_level_init.c:(.rdata$.refptr._bss_end__[.refptr._bss_end__]+0x0):
    undefined reference to `_bss_end__'
    top_level_init.o:top_level_init.c:(.rdata$.refptr._data_end__[.refptr._data_end__]+0x0):
    undefined reference to `_data_end__'
    This as reported on the users list at <http://www.mercurylang.org/list-archives/developers/2015-November/016491.html>. I have noticed it myself on Cygwin64 (using Cygwin GCC 4.9.3 and binutils 2.25). Ian has reported it as occurring with MSYS2/MinGW64 GCC 4.9.2 and binutils 2.25. Using MSYS2/MinGW64 GCC 5.2 does work (on my machine), so it may be that there is a problem with GCC 4.9.X on 64-bit Windows. (I haven't tried GCC 5 on Cygwin64 yet as it would need to be built from source.)
     
    Notes
    (0000902)
    juliensf   
    2016-08-16 14:13   
    The same issue occurs with GCC 5.4.0 on 64-bit Cygwin.
    (0000903)
    juliensf   
    2016-08-17 09:22   
    The issue has been fixed in Boehm upstream.
    <https://github.com/ivmai/bdwgc/commit/4e24d219d29abb2b111bb9a9ccb13c3f149a855a>
    We will need to backport that change (or upgrade our version of the collector).
    (0000920)
    juliensf   
    2016-09-28 16:03   
    (Last edited: 2016-09-28 16:04)
    This has been resolved by upgrading the Boehm GC to version 7.6. I have tested it with rotd 2016-09-27.





    View Issue Details
    419 [mercury] Feature Request minor always 2016-09-14 12:15 2016-09-21 04:57
    wangp  
     
    normal  
    new  
    open  
    none    
    none  
       
    cannot write floats in break point conditions
    The mercury_trace_term.c parser does not accept float arguments. I don't know if more work would be required to make the break condition work. It is not very important to me.

    mdb> cond 2 != gray(float(1.0))
    syntax error in term: gray(float(1.0))
                                      ^ here
     
    Notes
    (0000909)
    zs   
    2016-09-14 17:56   
    The main problem I see is that equality with floats is not precisely defined in general.
    There is exactly one float x for which x = 1.0 should work, but there is no one float
    for which x = 1.1 should work, since 1.1 is not exactly representable in binary.
    One would have to pick either a relative or absolute epsilon, and have x = 1.1 succeed
    for all x for which |x - 1.1| < epsilon (absolute) or all x for which |x - 1.1|/1.1 < epsilon
    (relative).

    To support float tests in breakpoint conditions, one would either have to provide
    a means for users to specify their desired epsilon (with a default, of course),
    or enrich the condition language to allow the epsilon to be specified in the test
    itself. I think we need one or more specific use cases to guide our choice in
    fixing this issue. Does anyone have one?
    (0000911)
    wangp   
    2016-09-19 14:44   
    I only expected equality and inequality to work, like = and \= on floats in Mercury.

    I can see uses for an epsilon or specifying values in a range. That might be useful for int tests as well, e.g. stop only when this argument is negative.

    When I reported this bug, that was probably the first time that I've tried to use a float in a break point condition, so take that as you will.
    (0000919)
    zs   
    2016-09-21 04:57   
    A long time ago, I did a subject on numerical analysis. One of the first things mentioned
    was that floats should not be compared for equality, because their approximate nature
    makes such comparisons inherently unreliable. I expect well-written programs that handle
    floats, in Mercury or in other languages, to follow that advice.

    For the programs that ignore the advice, the right fix is probably to generate a compiler
    warning whenever two floats are compared for equality, to get the programmer to fix
    the equality test itself.

    This is why, for programs that follow the advice, the treatment of float equality during
    normal execution should not be the semantics one should strive to implement
    for breakpoint conditions in the debugger.

    Note that at the moment, the debugger treats the literal values in breakpoint conditions
    as uninterpreted and untyped terms. Adding a mechanism for comparisons would require
    effectively reimplementing breakpoint conditions in a type-aware manner.




    View Issue Details
    420 [mercury] Bug major always 2016-09-14 16:06 2016-09-19 14:31
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    try goals lost in .opt files
    `try' goals are not written out to .opt files. When the body is open coded into the caller, any exceptions that it was supposed to catch would not be caught.

    This is similar to bug 0000391 for trace goals.

    The test case currently produces this in the .opt file:

    try_goal_opt.bad_try(V_5, V_6, V_10, V_11) :-
        ( % try
          % io(V_10, V_11)
          exception.magic_exception_result(V_12),
          ( % disjunction
            V_12 = exception.succeeded(V_14) : exception.exception_result({}),
            V_14 = {} : {},
            some [] (
              V_15 = V_10,
              call(V_5, V_8, V_15, V_11)
            ),
            some [] (
              V_6 = V_8
            )
          ;
            V_12 = exception.exception(V_13) : exception.exception_result({}),
            V_9 = exception.exc_univ_value(V_13),
            exception.throw(V_9),
            V_11 = V_10
          )
        ).
    try_goal_opt.m (403 bytes) 2016-09-14 16:06
    https://bugs.mercurylang.org/file_download.php?file_id=264&type=bug
     
    Notes
    (0000910)
    wangp   
    2016-09-19 14:31   
    Fixed by commit 1e0025b




    View Issue Details
    417 [mercury] Bug minor have not tried 2016-09-06 16:06 2016-09-06 16:06
    wangp  
     
    normal  
    new  
    open  
    none    
    none  
       
    new_arg_ref may return interior pointer
    new_arg_ref (and perhaps other predicates) may return an interior pointer into an object. If all other references to the base object are lost then the object may be garbage collected, leaving references to its arguments dangling.

    (I did not try to confirm the bug yet)
     
    There are no notes attached to this issue.




    View Issue Details
    416 [mercury] Bug crash always 2016-08-31 17:04 2016-08-31 17:04
    maxime Java backend  
     
    normal  
    new  
    open  
    none    
    none  
       
    mutable thread_local java backend missing initialValue()
    In the java backend, when compiling a thread_local mutable, mmc generates a static field
    static java.lang.ThreadLocal<Type> module__mutable_variable_name_of_mutable = new java.lang.InheritableThreadLocal<Type>();
    which is set via set(...) to the initial value into a initialise declaration (static code block).
    The issue is that the InheritableThreadLocal MUST override the initialValue() method, returning the initial value.
    Why? because in threads may have been created by a container before the static block has executed, leading in the end to a NullPointerException, because a such a thread from a thread-pool is executing code using the mutable, which does not have a parent-child relation with the thread in which the mutable was initialized.
    Create a module with a thread_local mutable, compile to a jar, create a main java, which creates threads before calling anything from the jar, then from multiple threads, use the mutable.

    The generated code should either be
    static java.lang.ThreadLocal<Type> module__mutable_variable_name_of_mutable = new java.lang.InheritableThreadLocal<Type>() {
    protected java.lang.Integer initialValue() {return <VALUE>;}
    };

    Or
    static java.lang.ThreadLocal<Type> module__mutable_variable_name_of_mutable;
    and in the initialization code, instead of doing a set(...), do a
    new java.lang.InheritableThreadLocal<Type>() {
    protected java.lang.Integer initialValue() {return <VALUE>;}
    };
     
    There are no notes attached to this issue.




    View Issue Details
    415 [mercury] Bug minor have not tried 2016-08-30 00:50 2016-08-30 18:39
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Segmentation fault during mode checking
    Attempting to compile the attached module (which provides an inst. preserving version of the list module's chunk/3 predicate), results in a segmentation fault on OS X with rotd-2016-08-26. (This is probably a stack overflow rather than anything else, it's just that the OS X is not very good at reporting them as such.)
    ip_chunk.m (1,831 bytes) 2016-08-30 00:50
    https://bugs.mercurylang.org/file_download.php?file_id=262&type=bug
     
    Notes
    (0000908)
    zs   
    2016-08-30 18:39   
    Fix committed 2016 aug 30.




    View Issue Details
    75 [mercury] Bug minor always 2008-08-12 15:57 2016-08-28 13:31
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    better treatment of absolute pathnames
    The compiler doesn't like absolute pathnames in Mercury.modules files, e.g.

        % mmc -f /tmp/*.m
        % mmc --generate-dependencies foo
        Uncaught Mercury exception:
        Software Error: dir./: second argument is absolute
        Stack dump not available in this grade.
     
    Notes
    (0000905)
    wangp   
    2016-08-28 13:31   
    Can't reproduce any more, probably fixed.




    View Issue Details
    414 [mercury] Bug minor always 2016-07-25 16:53 2016-07-29 03:42
    pbone x86_64  
    zs Linux Mint  
    normal 18  
    resolved  
    fixed  
    none    
    none  
       
    The switch detection fails to detect this switch
    The switch detection code fails to detect the larger switch, and instead detects a can_fail switch within a disjunction.

        Replay = Loader ^ loader_replay_options,
        (
            ( Replay = replay_none
            ; Replay = replay_save(_)
            ),
            Prefix = Loader ^ loader_prefix
        ;
            Replay = replay_load(_),
            Prefix = Loader ^ loader_replay_prefix
        ).

    When I deconstruct Loader outside of the switch and assignment unifications within the switch things work correctly.
    $ mmc --allow-stubs --grade asm_fast.gc --compile-to-c testb.m -Dall -dall
    testb.m:011: Error: invalid determinism for `prefix_locator'(in) = out:
    testb.m:011: the primary mode of a function cannot be `nondet'.
    testb.m:011: In `prefix_locator'(in) = out:
    testb.m:011: error: implicit determinism declaration not satisfied.
    testb.m:011: Declared `det', inferred `nondet'.
    testb.m:034: The switch on Replay does not cover
    testb.m:034: `replay_load'/1.
    testb.m:037: Disjunction has multiple clauses with solutions.
    testb.m:038: Unification of `Replay' and `testb.replay_load(V_7)' can fail.
    For more information, recompile with `-E'.
    Mercury ROTD 2016-07-18
    GCC 5.4.0 20160609
    testb.m (888 bytes) 2016-07-25 16:53
    https://bugs.mercurylang.org/file_download.php?file_id=261&type=bug
     
    Notes
    (0000899)
    zs   
    2016-07-25 19:33   
    The reason why this happens is that this code exhibits a rare
    combination of properties. (a) Both disjuncts of the outer disjunction
    contain deconstruction unifications with both Loader and Prefix.
    (b) Since Loader's first occurrence in the clause comes *before*
    Prefix's first occurrence, it gets the lower variable number,
    so switch detection tests whether the disjunction is a switch on
    Loader first. (c) Because of point a, it finds that the answer is yes,
    with no disjuncts left over. It therefore commits to convertion the
    disjunction into a switch on Loader, not even looking to see whether
    the disjunction is a switch on any other variable.

    Switch detection is inherently incomplete: there will always be switches
    that it cannot find, for the same kinds of reasons why determinism
    analysis (say of a Turing machine simulator) cannot ever prove that
    all det predicates are actually det. Therefore stopping the search
    after we find an apparently-satisfactory switch configuration (such as
    the switch on Loader appears to be in this case) is justifiable, and
    it definitely was the right thing to do in in the 1990s, when this code
    was written. Now that we have computer power to burn, we can choose
    to keep looking. I will look into that.
    (0000900)
    pbone   
    2016-07-25 21:31   
    That's an interesting combination of properties, more complex than I expected, but I did wonder if it had something to do with Loader, and that due to the field access code it is deconstructed in 3 places.

    Anyway, it's pretty rare and also easy enough to work around so there's no hurry at all.

    Cheers.
    (0000901)
    zs   
    2016-07-29 03:42   
    Fix committed 2016 july 27.




    View Issue Details
    196 [mercury] Bug minor sometimes 2011-04-13 23:10 2016-07-17 20:56
    pbone  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Binary compatibility checks in C grades don't work.
    The binary compatibility checks in runtime/mercury_goto.h don't work. I was able to modify the grade string and re-compile the runtime and link it against the standard library and object files that had been generated against an older version of this header file.

    I suspect that the static variable in generated C files that refers to the grade variable is being optimized a way and therefore the linker happily links the mis-matched objects.
     
    Notes
    (0000327)
    juliensf   
    2011-04-13 23:25   
    Does the variable appear amongst the list of exported symbols?

    What version of gcc are you using? (Recent ones do perform some LTO, so maybe
    that's the problem?)
    (0000892)
    juliensf   
    2016-07-07 19:56   
    The problem is that the static variable MR_grade that we emit at the end of every generated .c file is being optimised away (since it is not referenced by anything else). GCC and clang seem quite happy to do this even if the variable is also declared to be volatile. The will however retain the variable if it is declared with
    the variable attribute __attribute__((used)). For other C compilers I'm not yet sure what to do (or even if this is a problem).
    (0000893)
    zs   
    2016-07-07 20:27   
    We could generate an exported function that returns the value of MR_grade.
    Since it could be called from somewhere else, the compiler wouldn't be able
    to optimize away the reference. This should be more portable than __attribute__.
    (0000894)
    juliensf   
    2016-07-07 20:48   
    We can hide __attribute__ behind a macro, just as we already do with other such attributes, e.g.

      #if defined(MR_GNUC) || defined(MR_CLANG)
          #define MR_CONSIDER_USED __attribute__((used))
      #else
          #define MR_CONSIDER_USED volatile /* .. and hope for the best! */
      #endif

    I've implemented this and tested it with clang. (I'm not even sure that this is an issue with
    MSVC; I'll take a look tomorrow when I have access to a machine with that compiler installed.)
    Given that C compilers used with Mercury are nearly always GCC or clang I think this is probably
    good enough.
    (0000898)
    juliensf   
    2016-07-17 20:56   
    Fix in commit 10c210d.




    View Issue Details
    412 [mercury] Bug minor always 2016-07-03 21:12 2016-07-17 18:25
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    compiler does not report some unused imported modules
    The compiler does not report as unused any of the standard library modules imported in the implementation section of the test file.
    unused_imports.m (2,782 bytes) 2016-07-03 21:12
    https://bugs.mercurylang.org/file_download.php?file_id=259&type=bug
     
    Notes
    (0000897)
    zs   
    2016-07-17 18:25   
    Fix committed 2016 July 17.




    View Issue Details
    91 [mercury] Bug major always 2009-03-09 22:32 2016-07-01 10:11
    maclarty  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    compiler throws exception in hlc.gc
    $ tar -xzf bug.tar.gz
    $ mmc --version
    Mercury Compiler, version rotd-2009-03-08, configured for x86_64-unknown-linux-gnu
    Copyright (C) 1993-2009 The University of Melbourne
    $ mmc --grade hlc.gc run.m
    Uncaught Mercury exception:
    Software Error: map.lookup: key not found
        Key Type: parse_tree.prog_data.type_ctor
        Key Value: type_ctor(qualified(unqualified("interpreter"), "value"), 0)
        Value Type: hlds.hlds_data.hlds_type_defn
    Stack dump not available in this grade.

    Error still occurs with -O-1.
    bug.tar.gz (1,657 bytes) 2009-03-09 22:32
    https://bugs.mercurylang.org/file_download.php?file_id=70&type=bug
    bug2.m (97 bytes) 2009-03-11 18:01
    https://bugs.mercurylang.org/file_download.php?file_id=72&type=bug
     
    Notes
    (0000161)
    maclarty   
    2009-03-11 17:59   
    The problem here seems to be that the type interpreter.value/0 is not exported to interpreter.int. It is not exported, because it is only defined in the implementation. It is however used in the interface as the argument of another type's functor. One would expect this to cause an error when compiling interpreter.m.

    I've attached a simpler test case that triggers this bug. In bug2.m type a uses type b in the interface, but type b is only defined in the implementation. This module compiles without error (mmc -C bug2.m).
    (0000162)
    maclarty   
    2009-03-11 18:02   
    Of course this doesn't explain why the original program compiles in asm_fast.gc.
    (0000891)
    juliensf   
    2016-07-01 10:11   
    The fix for 0000017 also resolves this one. The larger of the two test cases still causes an abort in the compiler
    but that's only because the supplied .int files are invalid -- newer versions of the compiler won't allow them to be generated in the first place.




    View Issue Details
    214 [mercury] Bug minor always 2011-09-02 03:41 2016-06-30 17:32
    juliensf  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
      15.11  
    confusing type error
    The attached model produces the following type error:

        bug.m:036: In predicate `solve_mip_cg'/2:
        bug.m:036: type error: unsatisfied typeclass constraint:
        bug.m:036: `bug.linear_expr(int, V_15, int)'
        bug.m:036: The constraint is due to:

    But no constraints are listed; also the type error produced is incidental to the actual error.
    bug.m (4,718 bytes) 2011-09-02 03:41
    https://bugs.mercurylang.org/file_download.php?file_id=126&type=bug
     
    Notes
    (0000890)
    juliensf   
    2016-06-30 17:32   
    Fixed in commit ced4134. (We could still do a better job of localising the error though.)




    View Issue Details
    184 [mercury] Bug crash always 2011-02-03 17:28 2016-06-30 11:46
    mgiuca  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
      15.11  
    Unresolved polymorphism in typeclass crashes mmc
    The following program causes a software error in mmc (I believe I am using the HLC grade -- is there any way to check this?):

    :- module compileerror.

    :- interface.

    :- func test = int.

    :- implementation.

    :- import_module list.

    test = f([]).

    :- typeclass myclass(T) where [
        func f(T) = int
    ].

    :- instance myclass(list(T)) <= myclass(T) where [
        f(_) = 4
    ].

    Uncaught Mercury exception:
    Software Error: map.lookup: key not found
        Key Type: parse_tree.prog_data.prog_constraint
        Key Value: constraint(qualified(unqualified("compileerror"), "myclass"), [type_variable(var(1), kind_star)])
        Value Type: set_ordlist.set_ordlist(hlds.hlds_data.constraint_id)
    Stack dump not available in this grade.

    There are two factors which cause this. First, the instance for list has a constraint on T -- this can be any constraint but it doesn't crash unless there is a constraint on T. Second, I am calling 'f' with a type with unresolved polymorphism (the empty list has type list(T) and I have not bound the type variable T). Had I written f([] : list(int)) and added an instance myclass(int), it would compile successfully.

    What I would have expected is to receive a warning due to unresolved polymorphism, along the lines of:
    compileerror.m:005: In function `test'/0:
    compileerror.m:005: warning: unresolved polymorphism.
    compileerror.m:005: The variable with an unbound type was:
    compileerror.m:005: V_2: list.list(T)
    compileerror.m:005: The unbound type variable will be implicitly bound to the
    compileerror.m:005: builtin type `void'.

    Then I suppose this would cause an error, since `void' is not an instance of myclass:
    compileerror.m:011: In clause for function `test'/0:
    compileerror.m:011: unsatisfiable typeclass constraint:
    compileerror.m:011: `compileerror.myclass(void)'.

    This would then communicate to the user the folly of passing a list with an unspecified type to a method which really needs the list elements to have a concrete instance of myclass.
    It seems as though the problem is that things are happening in the wrong order inside the compiler. With minor changes, I can cause the "unresolved polymorphism" warning to occur, so I think the problem is that mmc is trying to choose a "type dictionary" or "vtable" for the elements-of-the-list type *before* it assigns the type `void'. I figure that if it assigned the type `void' earlier, then it would cause the above more user-friendly error instead.

    For what it's worth, this situation does cause the following error in GHCI for Haskell:
        Ambiguous type variable `a' in the constraint:
          `MyClass a' arising from a use of `f' at compileerror.hs:2:7-10
        Probable fix: add a type signature that fixes these type variable(s)
     
    Notes
    (0000889)
    juliensf   
    2016-06-30 11:46   
    Fixed in commit ced4134.




    View Issue Details
    36 [mercury] Bug major always 2008-01-14 17:15 2016-06-23 14:48
    juliensf  
     
    high  
    new  
    open  
    none    
    none  
       
    another tabling bug with the high-level C backend
    The attached module causes an assertion failure in the compiler when compiled with

    mmc -C --grade hlc.gc -O0 --no-optimize-dead-procs
    The code in question is derived from the FlatZinc interpreter.
    While compiling with --optimize-dead-procs causes the assertion failure to not
    occur we cannot compile the original code in the FlatZinc interpreter with that option
    enabled since that would trigger bug 0000022.
    fzn_table_bug2.m (1,015 bytes) 2008-01-14 17:15
    https://bugs.mercurylang.org/file_download.php?file_id=32&type=bug
     
    Notes
    (0000888)
    juliensf   
    2016-06-23 14:48   
    This is working with rotd-2016-06-23**; there have been a lot of changes over the past eight years, so it isn't clear if the "fix" is intentional or not. I have added the attached test case to the test suite (tests/valid/bug36.m).


    ** it seems to have been passing as far back as 14.01.1.




    View Issue Details
    407 [mercury] Bug minor have not tried 2016-04-12 15:17 2016-06-22 15:41
    wangp  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Exception.getMessage can return null
    io.m assumes java.lang.Exception.getMessage will not return null, but it can.
     
    Notes
    (0000887)
    juliensf   
    2016-06-22 15:41   
    Fix in commit d038639.




    View Issue Details
    326 [mercury] Feature Request feature always 2014-04-23 11:45 2016-04-04 12:07
    wangp  
    wangp  
    low  
    resolved  
    fixed  
    none    
    none  
       
    disable rpath
    It should be possible to disable setting the rpath. Perhaps it should be off by default when statically linking the Mercury standard library and runtime.

    --no-runtime-library-directory does not work.
     
    Notes
    (0000672)
    juliensf   
    2014-05-01 10:31   
    I have no objections to adding an option --no-use-rpath to the compiler to achieve this.
    (Additionally, if it's possible to switch it off completely on Mac OS X, then that would be useful too.)
    (0000698)
    juliensf   
    2014-05-29 13:55   
    Sorry, I accidently closed this one.
    (0000884)
    wangp   
    2016-04-04 12:07   
    Fixed with --no-default-runtime-library-directory.




    View Issue Details
    373 [mercury] Bug minor always 2015-01-13 17:40 2016-02-24 09:44
    wangp  
     
    normal  
    new  
    open  
    none    
    none  
      15.11  
    string.to_float imprecisely specified
    string.to_float does not explicitly describe the literals that it will accept, and may be backend dependent. As it is, it goes beyond Mercury float literals and that accepted by parsing_utils.float_literal_as_string.

    Examples:

    "1" (missing fractional part and exponent)
    "+1" (leading plus)
    ".1" (leading dot)
    "1."
    "1.e"
    "1e"
     
    Notes
    (0000803)
    juliensf   
    2015-01-13 18:12   
    There is no "may" about it. It *is* backend dependent.
    (0000883)
    juliensf   
    2016-02-24 09:44   
    A fix for this issue should also address the question of whether string.to_float("-0") is equal to 0.0 or -0.0?
    The C back-ends** and C#/Java back-ends currently disagree on this.

    ** at least on OS X, with clang and BSD libc etc.




    View Issue Details
    405 [mercury] Bug minor always 2016-02-20 03:04 2016-02-23 03:24
    FlyingJester amd64  
    Windows  
    normal 8.1  
    confirmed  
    open  
    none    
    none  
       
    Compiler Software Exception in Certain Projects
    Trying to build my project MEdit, I run into the following error:

    Uncaught Mercury exception:
    Software Error: check_hlds.cse_detection: predicate `check_hlds.cse_detection.detect_cse_in_proc'/4: Unexpected: mode check fails when repeated

    I had thought this was only an issue with Mercury 14, but it seems to occur with the newest ROTD as well.
    Download the MEdit sources from https://github.com/FlyingJester/medit
    Run either just `make` (which requires yasm) or `make medit_mercury`
    I'm not really sure if this is actually an error in the compiler or in my own code, but if it is in my code the error reporting could be much improved.
     
    Notes
    (0000878)
    mark   
    2016-02-20 10:50   
    (Last edited: 2016-02-20 13:00)
    The code relies on nested unique modes, which are not supported. This is a known limitation. In this case it seems to be compounded by another mode error in your code, in the use of SizeIn+0 as an input parameter. (Edit: disregard that last sentence.)

    The compiler fails to report the problem accurately.

    What is the purpose of writing SizeIn+0 instead of just SizeIn?

    (0000879)
    FlyingJester   
    2016-02-20 11:06   
    (Last edited: 2016-02-20 11:07)
    The purpose is to allow a unique output which is partially composed of a non-unique integer input.

    What do you mean by nested unique modes?

    (0000880)
    mark   
    2016-02-20 12:58   
    By nested unique modes I mean modes for structured terms in which the uniqueness of the subterms is significant. That includes being partially composed of a non-unique term, as is the case in what you are attempting.

    Is the bug report just that the compiler throws an exception instead of giving a spurious mode error, as it says in the reference manual?
    (0000881)
    FlyingJester   
    2016-02-20 13:51   
    (Last edited: 2016-02-23 03:24)
    This bug report is simply that the compiler throws an exception.

    (0000882)
    mark   
    2016-02-20 15:23   
    Confirm that this is a bug. The compiler should give a proper error message when attempting to use nested unique modes.

    Note that the feature itself is officially NYI.




    View Issue Details
    403 [mercury] Bug minor always 2016-02-09 10:02 2016-02-18 14:36
    juliensf  
    juliensf  
    normal  
    assigned  
    open  
    none    
    none  
       
    Normal termination of a program in the Java grade does not flush stdout
    Normal termination of a program compiled in the Java grade does not flush stdout.
    This is leading to the failure of (at least) the following test cases in the Java grade:

        general/duplicate_label
        general/interpreter
        general/prune_switch

    (And probably some others in the hard_coded directory.)
     
    Notes
    (0000877)
    juliensf   
    2016-02-18 14:36   
    (Last edited: 2016-02-18 14:36)
    Workaround committed in commit f56b11d. The workaround inserts calls to flush stdout and stderr
    before System.exit() is called. The affected test cases all now pass (or fail for other non-related reasons).





    View Issue Details
    402 [mercury] Bug minor always 2016-01-02 03:51 2016-01-10 01:00
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    state variables not supported in require_complete_switch scope heads
    Referring to the current state of a a state variable in a require_complete_switch scope results in syntax error. For example,

         require_complete_switch [!.Value] (
              ...
          )

    results in:

         bug402.m:014: Expected a variable, got `(!. Value)'.

    bug402.m (370 bytes) 2016-01-02 03:51
    https://bugs.mercurylang.org/file_download.php?file_id=255&type=bug
     
    Notes
    (0000874)
    zs   
    2016-01-10 01:00   
    Fixed 2016 jan 2.




    View Issue Details
    400 [mercury] Bug minor always 2015-12-16 23:13 2015-12-16 23:13
    juliensf  
     
    normal  
    new  
    open  
    none    
    none  
       
    ROTDs can no longer compile extras/trailed_update
    Attempting to compile the trailed_update library in the extras results in a mode error in the var module.
    The module compiles successfully with Mercury 14.01.X.

    A cut down test case is attached.
    bug400.m (514 bytes) 2015-12-16 23:13
    https://bugs.mercurylang.org/file_download.php?file_id=252&type=bug
     
    There are no notes attached to this issue.




    View Issue Details
    388 [mercury] Bug minor have not tried 2015-07-10 13:50 2015-12-14 10:31
    juliensf  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
      15.11  
    Inconsistent permissions on library jar files
    The Java archives for the standard libraries are installed in such a way that they only user readable and writeable. Aside from not being very useful in multi-user environments, this is also inconsistent with the permissions on the library files in other grades (which are group readable and writeable and world readable.)
    fix-java-jar-index.diff (1,733 bytes) 2015-07-10 14:16
    https://bugs.mercurylang.org/file_download.php?file_id=246&type=bug
    fix-java-jar-index.log (986 bytes) 2015-07-10 14:16
    https://bugs.mercurylang.org/file_download.php?file_id=247&type=bug
     
    Notes
    (0000840)
    juliensf   
    2015-07-10 14:07   
    This is occurring on a CentOS 7 system. Thing are ok on OS X system.
    (0000841)
    sebgod   
    2015-07-10 14:15   
    Hello Julien. I have the same problem on Fedora as well. This is a problem introduced by Java 7+, where temporary files get only 0600 permissions.
    This happens when the Mercury compiler invokes the Java index option, which is currently used in a wrong fashion any way, since the jar index only works for multiple referenced jar files, but Mercury only references the jar file itself, which is not needed.
    I've added a patch to make that point clearer.
    (0000871)
    juliensf   
    2015-12-14 10:31   
    Fixed in commit 2d01e41. (The race condition on Windows has been moved into bug 0000399.)




    View Issue Details
    399 [mercury] Bug minor have not tried 2015-12-14 10:27 2015-12-14 10:28
    juliensf  
    juliensf  
    normal  
    assigned  
    open  
    none    
    none  
       
    race condition on Windows when comparing a file to itself.
    The attached patch fixes a race condition on Windows when comparing a file to itself.
    fix-java-jar-index.diff (1,733 bytes) 2015-07-10 14:16
    https://bugs.mercurylang.org/file_download.php?file_id=250&type=bug
    fix-java-jar-index.log (986 bytes) 2015-07-10 14:16
    https://bugs.mercurylang.org/file_download.php?file_id=251&type=bug
     
    Notes
    (0000870)
    juliensf   
    2015-12-14 10:28   
    The parts of the patch that deal with 0000388 have been handled separately.




    View Issue Details
    115 [mercury] Bug minor always 2009-11-05 21:50 2015-11-30 16:50
    petdr  
    juliensf  
    low  
    resolved  
    fixed  
    none    
    none  
       
    segfault for predicate names containing multibyte utf8 char
    If you don't quote a predicate name which contains a multibyte utf8 character the compiler segfaults.

    eg
      :- pred dèja(int::int) is semidet.
    seg faults while
      :- pred 'dèja'(int::int) is semidet.

    compiles fine.
    test.m (98 bytes) 2009-11-05 21:50
    https://bugs.mercurylang.org/file_download.php?file_id=88&type=bug
     
    Notes
    (0000227)
    wangp   
    2009-12-03 11:19   
    This is "only" a problem on 64-bit machines installing from the generated .c files targeted at 32-bit architectures. It has something to do with the number of tag bits. A stage2 compiler does not crash.
    (0000270)
    juliensf   
    2010-06-29 18:27   
    Building the source distribution with --no-smart-indexing makes this problem go away.
    I strongly suspect that some of the code generation approaches we use for switches
    are not respecting the --cross-compiling option. (Most probably, it is the ones that
    call int.bits_per_int/0 somewhere along the way.)
    (0000869)
    juliensf   
    2015-11-30 16:50   
    Fixed when we transitioned to Unicode.




    View Issue Details
    10 [mercury] Bug minor always 2007-09-28 11:31 2015-11-29 16:08
    maclarty  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    :- pragma source_file ignored for warnings about unused imports in the interface.
    A :- pragma source_file directive at the top of a mercury file is ignored for warnings about unused imports in the interface.

    Compiling the attached file with:

    mmc sc

    gives:

    sc.m:001: In module `sc':
    sc.m:001: warning: module `list' is imported in the interface, but is not
    sc.m:001: used in the interface.
    x:013: In clause for predicate `main'/2:
    x:013: error: undefined predicate `foo'/2.

    The warning has the wrong context.
    sc.m (200 bytes) 2007-09-28 11:31
    https://bugs.mercurylang.org/file_download.php?file_id=7&type=bug
     
    Notes
    (0000007)
    juliensf   
    2007-10-01 12:19   
    I don't think there is any point in dealing with this one until the
    parse tree is restructured.
    (0000868)
    juliensf   
    2015-11-29 16:08   
    Fixed, although I'm not sure when, presumably as part of the parse tree restructure.
    Regression test has been added.




    View Issue Details
    50 [mercury] Bug minor always 2008-03-04 01:48 2015-11-15 23:15
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    another compiler abort when using debug grades
    The attached program causes the compiler to abort with:

    Uncaught Mercury exception:
    Software Error: continuation_info.m: Unexpected: find_typeinfos_for_tvars: can't find rval for type_info var V_59

    when compiled in a debug grade. It compiles successfully in non-debug grades.
    fzn_missing_rval.m (7,333 bytes) 2008-03-04 01:48
    https://bugs.mercurylang.org/file_download.php?file_id=43&type=bug
     
    Notes
    (0000867)
    zs   
    2015-11-15 23:15   
    Fix committed 2015 nov 15.




    View Issue Details
    17 [mercury] Bug minor always 2007-10-11 12:18 2015-11-11 19:00
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
      15.11  
    no error for unknown types in interface if defined in implementation
    The compiler does not issue an error for unknown types in the interface if the type is later defined in the implementation.

    This may be the same bug as 0000011.
    not_abstract.m (138 bytes) 2007-10-11 12:18
    https://bugs.mercurylang.org/file_download.php?file_id=9&type=bug
     
    Notes
    (0000866)
    zs   
    2015-11-11 19:00   
    Fix committed 2015 nov 11.




    View Issue Details
    264 [mercury] Bug minor always 2012-10-02 22:55 2015-11-02 16:55
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    function mode lost without warning
    It's possible to place a function with non-default mode into a ground term then extract it back out, now with the default mode assumed.

    According to the manual this should be forbidden:

       As a consequence of this, it is a mode error to pass a higher-order
    function term that does not match this standard mode to somewhere where
    its higher-order inst information may be lost[...]

    which was apparently implemented:
    http://www.mercury.csse.unimelb.edu.au/mailing-lists/mercury-users/mercury-users.0308/0013.html
    default_ho_inst.m (482 bytes) 2012-10-02 22:55
    https://bugs.mercurylang.org/file_download.php?file_id=161&type=bug
     
    Notes
    (0000865)
    zs   
    2015-11-02 16:55   
    Fix committed 2015 nov 2.




    View Issue Details
    232 [mercury] Bug minor always 2011-11-24 11:16 2015-11-02 16:07
    pbone  
    pbone  
    normal  
    resolved  
    won't fix  
    none    
    none  
       
    The thread pinning code in the parallel runtime doesn't work on older Linux systems.

    There are two alternatives for the thread pinning code in Mercury's Parallel low-level C runtime. hwloc() and sched_setaffinity(). When libhwloc is not available sched_setaffinity will be used. Later versions of glibc provide several
    macros to manipulate bitsets for use with sched_setaffinity, some or all of these macros may be unavailable on some systems. Currently mercury expects all the macros to be available whenever sched_setaffinity is available - which is not the case on older versions of glibc (such as on RHEL 5).

    Furthermore, Non-linux OSs that support sched_setaffinity may also have problems.

    To work-around this issue install libhwloc.
     
    There are no notes attached to this issue.




    View Issue Details
    86 [mercury] Bug minor always 2008-09-29 11:05 2015-11-02 13:08
    user90  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Uncaught mode error leads to crash in codegen.m
    The following program:

    %-----------------------------------------------------------------------------%
    :- module hello.
    :- interface.
    :- import_module io.

    :- pred main(io::di, io::uo) is det.

    :- implementation.
    :- import_module string.

    :- type abc ---> a ; b ; c.
    :- inst ab ---> a ; b.

    :- func abc2ab(abc::in) = (abc::out(ab)) is det.

    abc2ab(X) = X.

    main(!IO) :-
        X = abc2ab(c),
        io.write_string("X = " ++ X^string, !IO).
    %-----------------------------------------------------------------------------%

    Makes the compiler abort:

      Uncaught Mercury exception:
      Software Error: code_gen.m: Unexpected: semidet model in det context
      Stack dump not available in this grade.

    A similar case: if I change 'main' to this:

    main(!IO) :-
        X = abc2ab(c),
        ( X = a,
            io.write_string("X = a: " ++ X^string, !IO)
        ;
            X = b,
            io.write_string("X = b: " ++ X^string, !IO)
        ;
            X = c,
            io.write_string("X = c: " ++ X^string, !IO)
        ).

    I get a compiler warning:

      hello.m:029: In clause for `main(di, uo)':
      hello.m:029: warning: unification of `X' and hello.c cannot succeed
      hello.m:029: `X' has instantiatedness `bound((hello.a) ; (hello.b))'.

    and then codegen.m aborts again -- I guess the 'X=c' branch is removed as
    dead code.
     
    Notes
    (0000860)
    juliensf   
    2015-11-02 13:08   
    This was fixed in commit 491bb0a.




    View Issue Details
    191 [mercury] Bug minor always 2011-03-22 13:52 2015-11-02 11:10
    colanderman  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    indirect instance implementations ignore special insts
    If a typeclass requires a predicate of a specific inst, but an instance indirectly defines that predicate (using "is"), the inst is not properly checked and an implementation with a more general inst (e.g. in or out) can be used. Result is a software error during compile, below.
    Software Error: code_gen.m: Unexpected: semidet model in det context
    instbug.m (507 bytes) 2011-03-22 13:52
    https://bugs.mercurylang.org/file_download.php?file_id=116&type=bug
    inst_match.patch (526 bytes) 2011-04-05 12:21
    https://bugs.mercurylang.org/file_download.php?file_id=119&type=bug
    inst_match2.patch (14,424 bytes) 2011-04-07 13:37
    https://bugs.mercurylang.org/file_download.php?file_id=120&type=bug
     
    Notes
    (0000321)
    colanderman   
    2011-03-22 14:18   
    (Last edited: 2011-03-22 14:25)
    This seems to be part of a more general problem of complex insts not being propagated through predicate calls. Am I misunderstanding the semantics of the language?

    Edit: seems to be related to bugs # 86 and 117.

    (0000322)
    colanderman   
    2011-04-05 12:22   
    Squashed it, was a one-line fix in compiler/inst_match.m. Also fixes bugs 86 and 117. See attached patch.
    (0000323)
    juliensf   
    2011-04-07 03:22   
    The above patch breaks compilation of the stage 2 standard library. (That doesn't necessarily
    mean it is incorrect, since at least some the library code that breaks looks suspicious -- we
    will need to look into this further before applying the above patch.)
    (0000326)
    colanderman   
    2011-04-07 13:41   
    That's what I get for being sneaky and skipping the install phase :)

    Attached is a (much larger) patch that fixes *most* of the library issues. It involved some mode additions to the list module (there really should be lots more), generalizing the mode of cc_multi_equal, and specializing cc_multi_equal in exception.m (this is due to the fact that the compiler chooses the di/uo mode of cc_multi_equal as "best" and doesn't try the other mode when it fails).

    term_to_xml.m still doesn't compile, and I believe it is due to a possible bug I mentioned on the users mailing list, concerning predicates which refine nested insts. The error I'm getting is:

    term_to_xml.m:1348: In clause for `'__Unify__'(in, (unique(list.'[|]'(free,
    term_to_xml.m:1348: unique((list.[])))) >> bound(list.'[|]'(ground,
    term_to_xml.m:1348: bound((list.[]))))), (ground >>
    bound(list.'[|]'(ground,
    term_to_xml.m:1348: bound((list.[]))))))':
    term_to_xml.m:1348: mode error: argument 3 did not get sufficiently
    term_to_xml.m:1348: instantiated.
    term_to_xml.m:1348: Final instantiatedness of `HeadVar__2' was
    term_to_xml.m:1348: `bound(list.'[|]'(ground, ground))',
    term_to_xml.m:1348: expected final instantiatedness was
    term_to_xml.m:1348: `bound(list.'[|]'(ground, bound((list.[]))))'.

    which looks suspiciously similar to the issue I mentioned. I will focus my efforts on trying to track down that bug, and will hope that it's as simple as this one was to fix.
    (0000859)
    juliensf   
    2015-11-02 11:10   
    This was fixed in commit 491bb0a.




    View Issue Details
    187 [mercury] Bug minor always 2011-03-06 17:12 2015-10-31 21:00
    colanderman  
    juliensf  
    normal  
    confirmed  
    open  
    none    
    none  
      15.11  
    Strange error with disjunctive definitions returning existential typeclass instance
    I don't know how to describe this but with code. Compile it and observe the error. Now uncomment the last line, and comment out the two preceding (to use an equivalent definition of the function f). Recompile and it works as expected.
    test.m (265 bytes) 2011-03-06 17:12
    https://bugs.mercurylang.org/file_download.php?file_id=113&type=bug
     
    Notes
    (0000546)
    juliensf   
    2013-06-28 14:55   
    (Last edited: 2013-06-28 14:57)
    The problem here is that polymorphism transforms the multi-clause version into the following:

    % Clause 1.
    test.f(TypeClassInfo_for_foo_3, HeadVar__1_1) = HeadVar__2_2 :-
      (
        ( HeadVar__1_1 = test.x,
          HeadVar__2_2 = test.a
        ),
        TypeClassInfo_for_foo_4 = typeclass_info_const(0),
        TypeClassInfo_for_foo_3 = TypeClassInfo_for_foo_4
      ).

    % Clause 2
    test.f(TypeClassInfo_for_foo_3, HeadVar__1_1) = HeadVar__2_2 :-
      (
        (
          HeadVar__1_1 = test.y,
          HeadVar__2_2 = test.b
        ),
        TypeClassInfo_for_foo_3 = TypeClassInfo_for_foo_4
      ).

    In the second clause TypeClassInfo_for_foo_4 is free. It should presumably have been pointed
    at typeclass_info_const(0) as in the first clause, but that hasn't happened for some reason.
    (Possibly, the mapping of typeclass_infos to static data is being maintained across clauses, so it thinks
    that it has already introduced the unification with the constant when it processes the second clause.)

    (A workaround here is to re-write the predicate with a single clause -- as mentioned in the original bug report -- since polymorphism will process that in one go and the issue won't arise.)

    (0000548)
    pbone   
    2013-06-28 15:45   
    Possibly related to bug 0000271. When fixing this consider the fix for 0000271 and also retest 0000271.




    View Issue Details
    117 [mercury] Bug minor always 2009-11-28 02:36 2015-10-31 19:04
    pjrm  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    No error message for false non_empty_list declaration; runtime segfault
    (The available "Severity" values aren't quite right for a compiler. I chose "minor" on the grounds that it affects only incorrect programs, though it's among the more serious of this class, in that it still compiles, but the resulting executable segfaults.)

    I have a program where a function's output variable's mode is declared as out(non_empty_list), but where in fact the result can be empty. The program compiles with no warnings (whether with --debug or --grade=hlc.gc), but segfaults when it generates an empty list for a caller that assumes non-emptiness. (I have a feeling that in some cases the executable silently produces wrong results rather than segfaulting, though I'm not certain.)

    I haven't yet made a minimal example, but can do so on request.

    Tested with rotd-2009-02-26 and a 2007 version.
    nonempty12.m (230 bytes) 2009-12-01 03:02
    https://bugs.mercurylang.org/file_download.php?file_id=89&type=bug
    call_nonempty12.m (269 bytes) 2009-12-01 03:03
    https://bugs.mercurylang.org/file_download.php?file_id=90&type=bug
     
    Notes
    (0000220)
    wangp   
    2009-12-01 01:53   
    Can you post a test case?
    (0000222)
    pjrm   
    2009-12-01 03:13   
    I've attached two files, nonempty12.m and call_nonempty12.m. The first is the one of interest, in that it compiles without error. The second is the obvious corresponding `main' predicate that segfaults when trying to access the first element of the list.

    The test case is remarkably simple, not at all the highly specific circumstances I'd usually have for a Mercury compiler bug; I suppose then that it must be related to one of the several already-known limitations in the current mode system implementation.

    I've tested with rotd-2009-02-26 on i686-pc-linux-gnu (Debian), with mgnuc=gcc-3.4.6, with both
    `mmc --make --debug call_nonempty12 && ./call_nonempty12' and
    `mmc --make --grade=hlc.gc call_nonempty12 && ./call_nonempty12'.
    (Also tested with rotd-2007-12-16, so it's fairly long-standing.)
    (0000223)
    wangp   
    2009-12-01 21:35   
    The problem is the following XXX.

    inst_matches_final_3(ground(UniqA, HOInstInfoA), bound(UniqB, ListB),
            MaybeType, !Info) :-
        ModuleInfo = !.Info ^ imi_module_info,
        \+ ho_inst_info_is_nonstandard_func_mode(ModuleInfo, HOInstInfoA),
        unique_matches_final(UniqA, UniqB),
        bound_inst_list_is_ground(ListB, MaybeType, ModuleInfo),
        uniq_matches_bound_inst_list(UniqA, ListB, ModuleInfo),
        (
            MaybeType = yes(Type),
            % We can only do this check if the type is known.
            bound_inst_list_is_complete_for_type(set.init, ModuleInfo, ListB, Type)
        ;
            true
            % XXX enabling the check for bound_inst_list_is_complete
            % for type makes the mode checker too conservative in
            % the absence of alias tracking, so we currently always
            % succeed, even if this check fails.
        ).
    (0000858)
    juliensf   
    2015-10-31 19:04   
    This was fixed in commit 491bb0a.
    (I have added a test case for it.)




    View Issue Details
    318 [mercury] Bug minor always 2014-02-13 11:31 2015-10-29 15:23
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    pragma foreign_type depends on item order
    An error is reported for a pragma foreign_type if the type name is not declared earlier.
    foreign.m (135 bytes) 2014-02-13 11:31
    https://bugs.mercurylang.org/file_download.php?file_id=203&type=bug
     
    Notes
    (0000646)
    juliensf   
    2014-02-13 14:41   
    That happens because type declarations and pragmas are added to the HLDS during the same pass.
    One solution would be to add all the type declarations before adding all the pragmas; the disadvantage of that approach is that it would require another traversal of the parse tree during parse tree -> hlds conversion.
    (0000647)
    juliensf   
    2014-02-13 19:31   
    Actually, there's another solution to this, we could allow foreign_type pragmas to act as type declarations.
    (0000653)
    zs   
    2014-03-03 14:13   
    I think the right solution is to away with the notion of "passes" over the item list altogether.

    I think the one and only pass over the item list should construct a set of cords; one cord for type declarations, one for inst declarations, one for mode declarations, one for pred declarations and so on. Once those cords have been converted to lists, the rest of the code should then process those lists
    in the order that their dependencies dictate. One of those dictates would be the need to process type declarations before processing foreign type pragmas.

    The main complication is that at the moment, the import status of each item is effectively implicit in the position of the item with respect to status markers in the item list, and the exact details of that dependence are not well documented. Most of those details are obvious, but some are not.
    (0000857)
    zs   
    2015-10-29 15:23   
    Fix committed 2015 oct 29.




    View Issue Details
    278 [mercury] Bug minor always 2013-04-04 23:16 2015-10-29 14:47
    pbone x86_64  
    zs Debian Linux  
    normal 7.0  
    resolved  
    fixed  
    none    
    none  
      15.11  
    Compiler crash from bad state variable use.
    If I refer to the wrong state variable in the head of a lambda expression, I can reliably crash the compiler. I have a test case.
    Attached in the testcase It crashes when I compile it with 'mmc --make' It also crashes in the Java grade.

    mmc -V prints out the following just before the crash.
    % Converting parse tree to hlds...
    % Processing clause 1 for predicate `bug.main/2'...
    % Processing clause 1 for predicate `bug.build_map/5'...

    The exception thrown is:
    Uncaught Mercury exception:
    Software Error: hlds.make_hlds.state_var: predicate `hlds.make_hlds.state_var.svar_find_final_renames_and_copy_goals'/7: Unexpected: readonly status
    Stack dump not available in this grade.
    ** Error making `Mercury/cs/bug.c'.

    I'm using the 12.08 beta (The release MCit is using)
    bug278.m (841 bytes) 2013-04-04 23:19
    https://bugs.mercurylang.org/file_download.php?file_id=173&type=bug
     
    Notes
    (0000502)
    juliensf   
    2013-04-10 16:06   
    In principle this is easy to fix, just replace the relevant call to unexpected/2 in compiler/state_var.m
    with something that generates a proper error message. The issue is: what should that error message
    be? (Probably, before zs rewrote the state var transformation this would have been picked up
    later by mode checking ...)
    (0000503)
    juliensf   
    2013-04-10 16:07   
    It (hopefully) goes without saying, that this has nothing do with what backend is being used!
    (0000532)
    juliensf   
    2013-05-29 00:43   
    Actually, with Mercury 10.04.2, lots of phases picked up the error:


    bug278.m:023: In clause for predicate `build_map'/5:
    bug278.m:023: in argument 1 of call to predicate `list.foldl2'/6:
    bug278.m:023: type error: argument has type `pred(tree234.tree234(K, V), V,
    bug278.m:023: tree234.tree234(K, V), V_11, V_9)',
    bug278.m:023: expected type was `pred(L, A, A, Z, Z)'.
    bug278.m:023: In clause for predicate `bug278.build_map'/5:
    bug278.m:023: warning: variable `STATE_VARIABLE_MemoTable' occurs only once
    bug278.m:023: in this scope.
    bug278.m:028: In clause for predicate `build_map'/5:
    bug278.m:028: in argument 1 (i.e. the predicate term) of higher-order
    bug278.m:028: predicate call:
    bug278.m:028: type error: variable `KeyToValue' has type `(some [K, V]
    bug278.m:028: pred(K, V))',
    bug278.m:028: expected type was `pred(V_13, V_12, V_11, V_10)'.
    bug278.m:030: In clause for predicate `build_map'/5:
    bug278.m:030: in implicit state variable unification:
    bug278.m:030: type error in unification of variable `STATE_VARIABLE_M_1'
    bug278.m:030: and variable `STATE_VARIABLE_M_0'.
    bug278.m:030: `STATE_VARIABLE_M_1' has type `tree234.tree234(K, V)',
    bug278.m:030: `STATE_VARIABLE_M_0' has type `V'.

    The issue here is: what is an appropriate error message to generate during the state var transformation?
    (0000856)
    zs   
    2015-10-22 06:49   
    fix committed 2015 oct 22.




    View Issue Details
    397 [mercury] Bug minor always 2015-10-13 17:43 2015-10-20 18:00
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Clang fails to deal with -R command line parameter
    Not necessarily our bug, but clang 3.4 does not like -R/foo:

    clang -R/foo --version
    clang: error: unknown argument: '-R/foo'
    FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
    Target: i386-unknown-freebsd10.1
    Thread model: posix

    https://llvm.org/bugs/show_bug.cgi?id=18164
     
    Notes
    (0000851)
    juliensf   
    2015-10-14 10:08   
    Presumably it is happy with -Wl,-rpath though? We may need to make the definitions of SHLIB_RPATH_OPT etc in the configure script dependent on the C compiler type on the affected platforms.
    (0000853)
    wangp   
    2015-10-14 12:38   
    Yes, all of these work. The linker is GNU ld.

    -Wl,-R
    -Wl,-rpath
    -rpath

    so we can probably just remove lines in configure.ac that force "-R" for FreeBSD.
    (0000854)
    juliensf   
    2015-10-14 15:14   
    Yep, that would work for GCC as well. I assume you have a FreeBSD system set up to test this on?




    View Issue Details
    395 [mercury] Bug minor have not tried 2015-10-12 14:46 2015-10-20 18:00
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    non tail recursion in lexer.m
    In lexer.m, execute_get_token_action calls skip_to_eol which calls get_token_2 which calls execute_get_token_action.

    I believe this is the cause of a C stack overflow on FreeBSD/i386/gcc48/hlc.gc.
     
    There are no notes attached to this issue.




    View Issue Details
    396 [mercury] Bug minor always 2015-10-12 15:44 2015-10-20 18:00
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    non tail recursion in prog_io.m
    read_items_loop calls read_items_loop_2 which calls read_items_loop

    In high-level C grades this can overflow the C stack when reading a module with a large number of items.
     
    Notes
    (0000855)
    wangp   
    2015-10-20 18:00   
    This particular problem was already fixed on the master branch when I submitted the report. There were some other similar problems, which have now been fixed.




    View Issue Details
    394 [mercury] Bug minor have not tried 2015-09-20 01:43 2015-10-14 10:12
    juliensf  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Building compiler with --use-mmc-make broken (rotd-2015-09-18)
    Building the compiler in the hlc.gc or java grade using rotd-2015-09-18 and --use-mmc-make results in the following error:

    Making Mercury/cs/hlds.passes_aux.c
    Making Mercury/cs/hlds.pred_table.c
    Making Mercury/cs/hlds.quantification.c
    Error opening file `Mercury/opts/hlds.quantification.opt.tmp' for output: can't append to file: No such file or directory** Error making `Mercury/cs/hlds.quantification.c'.
    /var/folders/pd/5lypc6_j3vnf65q9x5y9s3p40000gn/T//mmake.D1F8M2:1421: recipe for target 'top_level' failed
    gmake[1]: *** [top_level] Error 1
    gmake[1]: Leaving directory '/Users/jfischer/Mercury-Workspaces/mercury.local-5/compiler'
    /var/folders/pd/5lypc6_j3vnf65q9x5y9s3p40000gn/T//mmake.cjoMVE:1073: recipe for target 'compiler' failed
    gmake: *** [compiler] Error 2
    Commenting the line that enables --optimize-unused-args for the hlds.quantification module in compiler/Mercury.options is a workaround.
     
    Notes
    (0000852)
    juliensf   
    2015-10-14 10:12   
    This was fixed by commit 4eab5db.




    View Issue Details
    389 [mercury] Feature Request minor have not tried 2015-07-21 10:45 2015-09-30 15:31
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    aligned_pointer foreign type assertion
    This is a proposal for a foreign type assertion. The user promises that values of this type would be clear in the tag bits (most likely a word-aligned pointer). The compiler would therefore be able to apply the direct arg optimisation to functors with a single argument of that foreign type.

    (just writing it down for now, I won't be implementing it soon)
     
    Notes
    (0000850)
    wangp   
    2015-09-30 15:31   
    Added in commit 62db25b




    View Issue Details
    391 [mercury] Bug minor always 2015-08-14 16:56 2015-09-18 17:33
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    trace conditions lost in .opt files
    Conditions on trace goals are not written out to .opt files, thus trace goals may be executed when their conditions are not met.

    The .opt file for the attached module includes:

    require_lt.require_lt(A_3, B_4) :-
        (
          % trace
          % compiletime(flag(checks))
          % quantified vars
          require_lt.require_lt0(A_3, B_4)
        ).
    require_lt.m (398 bytes) 2015-08-14 16:56
    https://bugs.mercurylang.org/file_download.php?file_id=248&type=bug
     
    Notes
    (0000849)
    zs   
    2015-09-18 17:33   
    Fix was committed 14 aug 2015.




    View Issue Details
    393 [mercury] Bug minor always 2015-09-15 10:40 2015-09-18 06:57
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    #line directives in .mh cause unnecessary recompilations
    This is a source of mysterious recompilations that I was experiencing in debug grades. I had a mutable declaration near the *end* of a file:

    :- mutable(debug_num, int, 0, ground, [untrailed, attach_to_io_state]).

    resulting in a #line directive in the .mh file:

    #ifndef WRITEPDF__RASTER_DECL_GUARD
    #define WRITEPDF__RASTER_DECL_GUARD
    #line 1400 "../writepdf/raster.m"
    #ifdef MR_HIGHLEVEL_CODE
        extern MR_Integer writepdf__raster__mutable_variable_debug_num;
    #else
        extern MR_Word writepdf__raster__mutable_variable_debug_num;
    #endif
    #ifdef MR_THREAD_SAFE
        extern MercuryLock writepdf__raster__mutable_variable_debug_num_lock;
    #endif

    Adding or removing blank lines would be enough to triggering recompilation of seemingly unrelated .c files.
     
    Notes
    (0000848)
    zs   
    2015-09-18 06:57   
    Fixed 18 sep 2015 by commit 410c75c81f47d0a1f5620f1f41f4e7afe87c665d.




    View Issue Details
    363 [mercury] Bug minor always 2014-09-17 17:22 2015-08-23 14:50
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    misleading error message for missing comma in foreign_proc attribute list
    The attached program causes the following error message.

    foo.m:009: Error: invalid `:- pragma foreign_proc' declaration: invalid second
    foo.m:009: argument: expecting a foreign proc attribute or list of
    foo.m:009: attributes.

    The invalid argument is the *third* argument, not the second.
    foo.m (249 bytes) 2014-09-17 17:22
    https://bugs.mercurylang.org/file_download.php?file_id=227&type=bug
     
    Notes
    (0000847)
    zs   
    2015-08-23 14:50   
    Fix committed 2015 aug 23.




    View Issue Details
    392 [mercury] Bug minor always 2015-08-17 14:13 2015-08-17 15:38
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    compiler abort with deforestation
    Reproduceable with 14.01 and master.

    % mmc -O0 --deforestation -C deforest_bug.m

    Uncaught Mercury exception:
    Software Error: ll_backend.code_gen: predicate `ll_backend.code_gen.generate_goal'/7: Unexpected: nondet model in det/semidet context
    Stack dump follows:
       0 pred exception.throw/1-0 (erroneous) (exception.m:289)
       1 pred require.error/1-0 (erroneous) (require.m:172)
       2 pred require.unexpected/3-0 (erroneous) (require.m:210)
       3 pred ll_backend.code_gen.generate_goal/7-0 (det) (code_gen.m:123)
       4 pred ll_backend.proc_gen.generate_category_code/11-0 (det) (proc_gen.m:786)
       5 pred ll_backend.proc_gen.generate_proc_code/9-0 (det) (proc_gen.m:405)
       6 pred top_level.mercury_compile_llds_back_end.llds_backend_pass_for_proc/12-0 (det) (mercury_compile_llds_back_end.m:396)
       7 pred top_level.mercury_compile_llds_back_end.llds_backend_pass_for_pred/11-0 (det) (mercury_compile_llds_back_end.m:296)
       8 3* pred top_level.mercury_compile_llds_back_end.llds_backend_pass_by_preds_loop_over_preds/11-0 (det) (mercury_compile_llds_back_end.m:264 and others)
      11 pred top_level.mercury_compile_llds_back_end.llds_backend_pass_by_preds/7-0 (det) (mercury_compile_llds_back_end.m:211)
      12 pred top_level.mercury_compile_llds_back_end.llds_backend_pass/8-0 (det) (mercury_compile_llds_back_end.m:138)
      13 pred top_level.mercury_compile.mercury_compile_after_front_end/11-0 (det) (mercury_compile.m:1706)
      14 pred top_level.mercury_compile.mercury_compile/11-0 (det) (mercury_compile.m:1537)
      15 pred top_level.mercury_compile.compile/13-0 (det) (mercury_compile.m:1462)
      16 pred list.map_foldl2/7-2 (det) (list.m:2835)
      17 pred top_level.mercury_compile.compile_all_submodules/13-0 (det) (mercury_compile.m:1281)
      18 pred top_level.mercury_compile.process_module_2/9-0 (det) (mercury_compile.m:1254)
      19 pred top_level.mercury_compile.process_module/7-0 (det) (mercury_compile.m:1144)
      20 pred top_level.mercury_compile.process_arg_2/7-0 (det) (mercury_compile.m:850)
      21 pred top_level.mercury_compile.process_arg_build/9-0 (det) (mercury_compile.m:812)
      22 pred make.util.build_with_module_options_args_invoked/13-0 (det) (make.util.m:1064)
      23 pred make.util.build_with_module_options_args/12-0 (det) (make.util.m:1016)
      24 pred top_level.mercury_compile.process_arg/9-0 (det) (mercury_compile.m:785)
      25 pred top_level.mercury_compile.process_arg_list/11-0 (det) (mercury_compile.m:756)
      26 pred top_level.mercury_compile.process_args/9-0 (det) (mercury_compile.m:707)
      27 pred top_level.mercury_compile.process_all_args/9-0 (det) (mercury_compile.m:613)
      28 pred top_level.mercury_compile.main_after_setup/8-0 (det) (mercury_compile.m:514)
      29 pred top_level.mercury_compile.real_main_after_expansion/3-0 (det) (mercury_compile.m:341)
      30 pred top_level.mercury_compile.real_main/2-0 (det) (mercury_compile.m:126)
      31 pred top_level.main/2-0 (det) (top_level.m:56)
    deforest_bug.m (750 bytes) 2015-08-17 14:13
    https://bugs.mercurylang.org/file_download.php?file_id=249&type=bug
     
    Notes
    (0000846)
    zs   
    2015-08-17 15:38   
    Fix committed 17 aug 2015.




    View Issue Details
    390 [mercury] Bug minor always 2015-08-05 17:11 2015-08-05 17:11
    wangp  
     
    normal  
    new  
    open  
    none    
    none  
       
    MR_ALLOC_ID visibility
    In non-memprof grades a MR_ALLOC_ID symbol is visible outside foreign_proc bodies, unlike in memprof grades. It is easy to move code from a foreign_proc to a foreign_code block and have it compile, only to find out much later that it is broken in memprof grades.
     
    There are no notes attached to this issue.




    View Issue Details
    385 [mercury] Bug minor always 2015-04-06 18:47 2015-07-22 09:08
    dirkz MinGW/MSYS 32bit rotd-2015-03-10  
    juliensf Windows 7 Professional 64 bit  
    normal Win 7 64 bit  
    resolved  
    fixed  
    none    
    none  
       
    mercury_compile.exe crashes during compilation of large fact table on MinGW/MSYS
    mercury_compile.exe crashes without giving any error message at all.

    It seems that the crash occurs where Mercury normally makes the .int3-file.

    The same module compiles without any problems on Mac OS X version 10.10.

    Mercury-Version: rotd-2015-03-10
    mmc --make --grade none.gc contextOfDataPoints
    As a workaround, I can use pragma fact_table.
    contextOfDataPoints.m.gz (138,275 bytes) 2015-04-06 18:47
    https://bugs.mercurylang.org/file_download.php?file_id=243&type=bug
     
    Notes
    (0000824)
    juliensf   
    2015-04-07 13:56   
    The compiler built from the source distribution (for 32-bit MinGW/MSYS) is aborting with error status
    0XC0000FD (i.e. STATUS_STACK_OVERFLOW).
    (0000845)
    zs   
    2015-07-22 09:08   
    As discussed on the mailing list, the problem was stack exhaustion while parsing a very long item list.

    Fixed by commit f2043fc9bd58b084701fc8e7618e0a5ccbf83d7f. It should be in the next release of the day. (It is NOT in the rotd for july 20.)




    View Issue Details
    381 [mercury] Bug major always 2015-03-01 00:09 2015-07-15 12:07
    ttmrichter Some Lenovo i5 laptop or other  
    Linux Mint  
    normal 15  
    new  
    open  
    none    
    none  
       
    Compiler deals poorly with '.' character constants.
    Unifying variables with '.' causes compiler to fail with "operator precedence error".
    Compile attached code. If line 10 is not commented out (as uploaded) the compiler will explode. If line 10 is commented out, the compiler is happy.
    Mercury Compiler, version rotd-2015-02-20, on x86_64-unknown-linux-gnu
    bug.m (401 bytes) 2015-03-01 00:09
    https://bugs.mercurylang.org/file_download.php?file_id=238&type=bug
     
    Notes
    (0000844)
    mark   
    2015-07-15 12:07   
    Mercury has no specific lexical syntax for character literals - they are just terms with arity 0, whose identifiers have length 1.

    Single lower case characters are valid identifiers, and so are all operators defined in the operator table. Any other character needs to be enclosed in single-quotes to be a valid identifier, otherwise it won't be treated as a character literal.

    Single-character operators in the operator table don't need the quotes, as they are already valid identifiers. However, operators in this table never have arity zero, so they won't be treated as character literals anyway, unless parentheses are used to override the operator table in the usual way. That is the problem in bug.m.

    Hence this issue is not a bug, it is intended behaviour. However, it is a common problem for users, and if Mercury had specific syntax for character literals this common problem would be avoided. So perhaps this issue should be considered a feature request for character literal syntax?




    View Issue Details
    339 [mercury] Bug major always 2014-06-22 07:19 2015-07-14 17:30
    sebgod Windows NT 6.3 x86_64  
    juliensf Windows  
    normal 8.1  
    resolved  
    fixed  
    none    
    none  
       
    mmc --java with Oracle Java 1.8.0 fails on Windows
    Making Java class files
    An exception has occurred in the compiler (1.8.0). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
    java.lang.AssertionError: the -J flag should be caught by the launcher.
            at com.sun.tools.javac.main.Option$20.process(Option.java:330)
            at com.sun.tools.javac.main.Main.processArgs(Main.java:260)
            at com.sun.tools.javac.main.Main.compile(Main.java:414)
            at com.sun.tools.javac.main.Main.compile(Main.java:381)
            at com.sun.tools.javac.main.Main.compile(Main.java:370)
            at com.sun.tools.javac.main.Main.compile(Main.java:361)
            at com.sun.tools.javac.Main.compile(Main.java:56)
            at com.sun.tools.javac.Main.main(Main.java:42)
    Compile any program using the Java grade
    Break resulted only from installation of the Java JDK 8.0;
    recompilation of the Mercury compiler did work but did not change the given output.
    Using the latest MinGW with gcc 4.7 for 32bit
    Java 1.8.0
    .NET 4.5.1
    Bootstrapped (with ROTD from June 2014) Mercury-dev
    fix-java8-flag-reorder.diff (1,247 bytes) 2014-12-16 02:54
    https://bugs.mercurylang.org/file_download.php?file_id=229&type=bug
     
    Notes
    (0000711)
    juliensf   
    2014-06-25 16:59   
    Do you know if this occurred / occurs with older versions of Java on the same system?
    (0000713)
    sebgod   
    2014-06-26 23:46   
    On the same machine, I had Java 1.7.5x installed,
    Mercury was working fine with that version.
    Then I upgraded Java to 1.8.0_05,
    When using the command line:
    mercury --use-grade-subdirs -s java -m libmercury_misc (e.g.)
    then I received the aforementioned error.
    Rebuilding the compiler did not resolve that issue.
    I could reproduce the error with Mercury 14_01 MinGW32 on Windows XP SP3
    with Java 1.8.0 (okay that is not supported but still I got the same error)
    (0000717)
    wangp   
    2014-06-27 11:13   
    (Last edited: 2014-06-27 11:13)
    Can you try editing your lib/mercury/conf/Mercury.config file

    This line has the wrong quoting

    --java-flags "-J"-Xmx1024m""

    Try fixing the quoting to

    --java-flags "-J-Xmx1024m"

    Or perhaps removing the line completely. It may not be needed any more.

    (0000719)
    sebgod   
    2014-06-27 17:21   
    Fixing the quoting to --java-flags "-J-Xmx1024m"
    still resulted to the complain from the Java compiler,
    removing on the other hand resulted in a successful compilation.
    (0000720)
    juliensf   
    2014-06-27 17:29   
    I believe that the quoting on Windows needs to be something like:

       --java-flags "-J\"-Xmx1024m\""

    That seems to be what I've done in the binary packages for Windows at any rate.
    (0000721)
    sebgod   
    2014-06-28 04:00   
    Using (in the .config)
    --java-flags "-J\"-Xmx1024m\""
    yields the same error, I suppose this is a JDK bug.
    I'll have to do some tests with "normal" Java programs
    and will check the http://java.sun.com/webapps/bugreport
    the javac compiler kindly provides.
    (0000735)
    sebgod   
    2014-07-05 21:09   
    (Last edited: 2014-07-05 21:11)
    I've tracked down the bug,
    Using the mmc -V option I received the content of the "javac @tempfile"
    % Args placed in @C:\Users\SEBAST~1\AppData\Local\Temp\mtmp000.3D2: `-classpath <snip> -sourcepath <snip> -d <snip> -J-Xmx1024m Mercury\\java\\i686-pc-mingw32\\Mercury\\javas\\jmercury\\fmt_bug.java'
    When invoking javac + the arg string directly on the command line, the compilation is successful.
    On a side note, the -J flag is correctly escaped.

    Now if I create that @tempfile manually, and running javac @tempfile myself,
    I do get the original error with the -J flag not being captured.
    Checking the Oracle online documentation for javac:
    http://docs.oracle.com/javase/7/docs/technotes/tools/solaris/javac.html
    revleas that:
      @argfiles One or more files that lists options and source files.
    The -J options are not allowed in these files.

    I suspect that the assertion in the javac compiler was added in Java 8.0,
    such that the -J flag passed via the @options-file was previously unnoticed (and most probably dysfunctional)

    (0000823)
    juliensf   
    2015-04-05 15:18   
    This was fixed in commit 9c85673.
    (0000825)
    juliensf   
    2015-04-08 13:51   
    Actually, commit 9c85673 only fixed the quoting issue. I'll look into fixing the issue with the -J
    option being placed in the @options file.
    (0000842)
    juliensf   
    2015-07-14 17:30   
    Fixed (hopefully, for good) in commit d7857cf.




    View Issue Details
    293 [mercury] Bug minor always 2013-07-10 13:55 2015-07-08 13:19
    juliensf x86-64  
    juliensf Linux  
    normal Fedora 19  
    resolved  
    fixed  
    none    
    none  
       
    asm_fast grades do not work with GCC 4.8
    The asm_fast grades do not work with GCC 4.8 on Fedora 19 x86-64 (and probably elsewhere).
    (The configure test for gcc labels is failing due to a segmentation fault on my system.)
    This was with Mercury 13.05.

     
    Notes
    (0000551)
    juliensf   
    2013-07-10 16:19   
    This seems to be caused by the option -ftree-dominator-opts.
    (0000555)
    juliensf   
    2013-07-12 01:37   
    I've committed a fix for this (i.e. compile with -fno-tree-dominator-opts). I would also not that
    compiling with -fno-omit-frame-pointer is also a possible fix. I'll keep this bug open until I've decided
    what the best fix is.
    (0000839)
    juliensf   
    2015-07-08 13:19   
    We compile with -fno-tree-dominator-opts in this case. (Also affects GCC 4.9 and 5.)




    View Issue Details
    348 [mercury] Bug minor have not tried 2014-07-18 15:07 2015-07-08 13:15
    juliensf  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Failure of tests/general/string_format_special_floats with MSVC
    When using MSVC as a C compiler, the test case tests/general/string_format_special_float fails as the MS libc doesn't appear to
    implement the C99 behaviour for printing nan, inf etc.

    With VS2012 we get:

    Plus Infinity:
                      %e: failure '1.#INF00
                      %f: failure '1.#INF00
                      %g: failure '1.#INF'
                      %E: failure '1.#INF00
                      %F: failure ''
                      %G: failure '1.#INF'
    Minus Infinity:
                      %e: failure '-1.#INF0
                      %f: failure '-1.#INF0
                      %g: failure '-1.#INF'
                      %E: failure '-1.#INF0
                      %F: failure ''
                      %G: failure '-1.#INF'
    Not a number:
                      %e: failure '-1.#IND0
                      %f: failure '-1.#IND0
                      %g: failure '-1.#IND'
                      %E: failure '-1.#IND0
                      %F: failure ''
                      %G: failure '-1.#IND'

    We should probably check for special float values before calling sprintf
    and just handle them directly using Mercury. (This would also avoid some
    inconsistencies in the output of these tests due to do differences in C
    libraries.)
     
    Notes
    (0000747)
    juliensf   
    2014-07-18 15:46   
    The same problem also affects tests/hard_coded/write_float_special.
    (0000748)
    wangp   
    2014-07-18 16:23   
    For what it's worth, NaNs were printed on AIX as "NaNQ", where 'Q' stands for quiet.
    (0000750)
    juliensf   
    2014-07-18 17:01   
    C99 says they should be printed as: nan, -nan, nan(...) or -nan(...) where "..." is an implementation-defined sequence of letters, digits or underscores. (Or in uppercase if %F is used.)
    (0000755)
    juliensf   
    2014-08-06 10:37   
    I intend to address this one by checking for, and handling, inf and nan (although nan should really cause an exception to be thrown) in Mercury rather than relying on sprintf. Even with C99 there are too many annoying little differences in how inf and nan are handled. Dealing with Java and C# just complicates things further.
    (0000838)
    juliensf   
    2015-07-08 13:15   
    Fixed in commit 4e15777.




    View Issue Details
    280 [mercury] Bug minor always 2013-04-11 14:06 2015-07-07 15:23
    juliensf  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Parser stack overflow with MSVC
    Attempting to compile compiler/options.c (from the rote-2012-04-10 srcdist) with MSVC
    results in:

        fatal error C1026: parser stack overflow, program too complex

    It looks as though the C code we generate for the predicate long_option/2 is too
    heavily nested; I'll try to separate it out a bit and see if that avoids the limitation.
     
    Notes
    (0000505)
    juliensf   
    2013-04-11 14:09   
    Actually, the problem may be that the source distribution is built with --no-smart-indexing.
    (The other approaches for string switches shouldn't bump into these sort of limitations.)
    (0000506)
    juliensf   
    2013-04-11 16:34   
    It's fine if you rebuild the .c files with --smart-indexing. In the long term, I would like to be able
    to compile the MSVC version of Mercury directly from the source distribution. Some options here are:

    (1) Work out whether --smart-indexing is still causing problems with the source distribution.

    (2) Manually, break long_options/2 into smaller chunks.

    (3) If compiling with --no-smart-indexing then change the MLDS code generator so that
    it breaks deeply nested if-then-else chains into separate C functions -- i.e. get the code generator
    to do (2).
    (0000837)
    juliensf   
    2015-07-07 15:23   
    The source distribution C files are now built with --smart-indexing enabled (option 1 above).




    View Issue Details
    387 [mercury] Bug major always 2015-07-06 12:50 2015-07-07 14:58
    pbone x86_64  
    Debian  
    normal stretch  
    new  
    open  
    none    
    none  
       
    Polymorphism pass miscompiles some try goals.
    I get the following error:

    polymorphism_try_bug.m:031: In clause for `test(in, di, uo)':
    polymorphism_try_bug.m:031: mode mismatch in disjunction.
    polymorphism_try_bug.m:031: The variable `TypeInfo_25' has these
    polymorphism_try_bug.m:031: instantiation states:
    polymorphism_try_bug.m:031: line 26: free
    polymorphism_try_bug.m:031: line 26: ground

    My predicate contains a try goal with a catch_any block. The TypeInfo in question is the type info for the exception, which passed out of the try goal in a maybe_error type and named-appart.
    mmc --use-grade-subdirs -O3 --allow-stubs --no-warn-stubs --compile-to-c test_bdd_bug.m
    polymorphism_try_bug.m (1,608 bytes) 2015-07-06 12:50
    https://bugs.mercurylang.org/file_download.php?file_id=244&type=bug
    bug387.m (597 bytes) 2015-07-06 17:30
    https://bugs.mercurylang.org/file_download.php?file_id=245&type=bug
     
    Notes
    (0000831)
    mark   
    2015-07-06 17:28   
    How do you think this ought to be compiled? What type should MaybeBDD have, for example?

    The error message can be improved: you had to figure out what TypeInfo_25 was, and both line numbers refer to the containing disjunction instead of the disjuncts. Also, it's a try goal not a disjunction. But I think the general idea is right, in that the type was bound in one branch and not in another.

    This issue applies to an existential type escaping from any form of disjunct. I'll upload a simplified case.
    (0000832)
    pbone   
    2015-07-06 19:28   
    I think that this can be compiled correctly, if unintuitive. If MaybeBDD is typed as some [E] maybe_error(bdd(V), {string, E}).

    It will become unintuitive if the exception type appears in the head of the clause, that will require the predicate to be existentially typed.
    (0000833)
    mark   
    2015-07-06 23:42   
    To put the question another way, what would be the output of calling io.write(type_desc.type_of(MaybeBDD), !IO)? What's in the type_desc for E?

    For the error branch, the type_desc is obviously meant to be whatever type_desc the exception value had. But for the ok branch, the type_desc is not provided anywhere. That's more or less what the compiler error message is trying to say.

    Note that a similar idiom to those documented in the Existential Types chapter also applies here, namely, wrap ExpPrime in a univ:

    catch_any ExpPrime ->
        MaybeBDD = error({"My message", univ(ExpPrime)})
    (0000834)
    pbone   
    2015-07-07 10:29   
    I tried breaking the predicate into two parts so that I can put the try goal in a predicate that explicitly returns an existential type. (My idea is that the types should be named apart and the type of the exception should be set when MaybeBDD is unified with error and deconstructed.

        :- some [E] pred test_try(bexpr(V)::in, maybe_error(bdd(V), {string, E})::out)
            is det.

        test_try(BooleanExpression, MaybeBDD) :-
            promise_equivalent_solutions [MaybeBDD] (
            ( try []
                BDDPrime = make_bdd(BooleanExpression)
              then
                MaybeBDD = ok(BDDPrime)
              catch_any ExpPrime ->
                MaybeBDD = error({"My error message", ExpPrime})
            )).

        test2(BooleanExpression, !IO) :-
            test_try(BooleanExpression, MaybeBDD),
            ( MaybeBDD = ok(BDD)
            ; MaybeBDD = error({ErrMessage, _}),
                % This deconstructon should determine the type of the error.
                write_string(ErrMessage, !IO),
                sorry($pred, "Error")
            ),
            io.write(BDD, !IO).

    But this doesn't work. and using `new error` doesn't work because error is not existentially typed itself. (I'm learning more about existential types BTW.)

        :- type maybe_error(T)
            ---> ok(T)
            ; some [E] error(string, E).

        test2(BooleanExpression, !IO) :-
            promise_equivalent_solutions [MaybeBDD] (
            ( try []
                BDDPrime = make_bdd(BooleanExpression)
              then
                MaybeBDD = ok(BDDPrime)
              catch_any ExpPrime ->
                MaybeBDD = 'new error'("My error message", ExpPrime)
            )),
            ( MaybeBDD = ok(BDD)
            ; MaybeBDD = error(ErrMessage, _),
                % This deconstructon should determine the type of the error.
                write_string(ErrMessage, !IO),
                sorry($pred, "Error")
            ),
            io.write(BDD, !IO).

    This works, it solves the problem in the same way as your use of univ. I've learnt that if I want the type of the error to be determined when error is deconstructed, then I need error to have the existential type applied to it. (Or univ, if I want it a little later).

    We can make it a type error for the type of an exception to escape the catch_any branch. Or indeed any branching structure, this will allow us to produce a better error message. Do you agree? is a type error the way to go here? (My reasoning is that the program is incorrectly typed.)
    (0000835)
    pbone   
    2015-07-07 10:29   
    Thank you.
    (0000836)
    mark   
    2015-07-07 14:58   
    Breaking it into two parts better illustrates why this is a program error, not just a compiler bug. The signature says that there is "some" type, which means that this predicate is responsible for producing that type (see "Semantics of type quantifiers" in the reference manual). But the programmer only provides that type in the catch_any clause, not in the then clause, hence the "mode" mismatch.

    The compiler could fill in the type as 'void', like in other circumstances, but this doesn't seem a good idea. If the programmer has provided a type in at least one branch of a branched structure, they ought to do so in all branches. In any case the compiler's use of 'void' would generate a warning.

    Which brings us to a different problem: there is no way to give different types in different branches anyway, because that would be a type error. So the following won't work:

        ( X = 1 ; X = "foo" ), io.write(X, !IO)

    Instead you must push the polymorphic calls inside the branches:

        ( X = 1, io.write(X, !IO) ; X = "foo", io.write(X, !IO) )

    or else you can "box" the existential type:

        ( X = 1, UX = univ(X) ; X = "foo", UX = univ(X) ),
        io.write(univ_value(UX), !IO)

    So, regarding your last question, if the programmer does address the "mode" error by providing a type for every branch (or none), then with the current language they will already necessarily receive a "type" error, as the existential type in one branch is opaque and cannot be referred to in the other branches.

    I don't think it matters much whether these are called mode errors or type errors. Given that the type quantifier determines where a type is produced, the two concepts amount to the same thing as far as checking the quantifiers is concerned.




    View Issue Details
    386 [mercury] Bug major always 2015-06-29 01:37 2015-07-01 01:36
    juliensf  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    rotd-2015-03-24 and following broken
    rotd-2015-03-24 and the following rotds break when installing from the source distribution.
    During the install_grades step, compiling library/array.m to C results in:

    Uncaught Mercury exception:
    Software Error: map.lookup: key not found
            Key Type: term.var(parse_tree.prog_data.prog_var_type)
            Key Value: var(32)
            Value Type: ll_backend.var_locn.var_state

     
    Notes
    (0000826)
    juliensf   
    2015-06-29 01:41   
    This has been confirmed on x86_64 Linux (gcc 4.7 and 4.9) and x86_64 Darwin (gcc 4.9).
    It occurs with both --no-smart-indexing and --smart-indexing.
    (0000827)
    juliensf   
    2015-06-29 11:05   
    Also, on x86_64 Darwin while building array.c in none.gc (Apple clang 600.0.56).
    (0000828)
    juliensf   
    2015-06-29 11:46   
    On i686 Darwin systems things are fine.
    (0000829)
    juliensf   
    2015-06-29 15:25   
    The problem was introduced in commit 6e3e60f.
    https://github.com/Mercury-Language/mercury/commit/6e3e60fae083d9c216dfa4249fae0f3fee33ebd6
    (0000830)
    juliensf   
    2015-07-01 01:36   
    Fix in commit b915b25.




    View Issue Details
    384 [mercury] Bug minor always 2015-03-31 11:22 2015-04-02 12:13
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Stage 1 compiler directory fails in hlc.gc grade with syntax errors in optimisation interfaces
    Build the current git HEAD with rotd-2015-03-30 in hlc.gc with -O5 --intermodule-optimization
    fails in the compiler directory due to:

    gmake[1]: Entering directory '/Users/jfischer/Mercury-Workspaces/mercury.local-4/compiler'
    /Users/jfischer/Mercury-Install/mercury-rotd-2015-03-30/bin//mmc --compile-to-c --grade hlc.gc -O5 --intermodule-optimization --flags COMP_FLAGS --no-common-struct analysis > analysis.err 2>&1
    /var/folders/pd/5lypc6_j3vnf65q9x5y9s3p40000gn/T//mmake.MygSwR:1973876: recipe for target 'analysis.c_date' failed
    gmake[1]: *** [analysis.c_date] Error 1
    gmake[1]: Leaving directory '/Users/jfischer/Mercury-Workspaces/mercury.local-4/compiler'

    The contents of analysis.err are:

    hlds.passes_aux.opt:003: Error: syntax error in inst body at bound/1.
    hlds.passes_aux.opt:004: Error: syntax error in inst body at bound/1.

    Looking at hlds.passes_aux.opt, the insts in question are:

    :- inst (hlds.passes_aux.par_proc_task) == bound((hlds.passes_aux).update_proc($typed_inst(pred(hlds.hlds_module.module_info, hlds.hlds_pred.proc_info, hlds.hlds_pred.proc_info), ((hlds.passes_aux).proc_task))) ; (hlds.passes_aux).update_proc_ids($typed_inst(pred(hlds.hlds_module.module_info, hlds.hlds_pred.pred_proc_id, hlds.hlds_pred.proc_info, hlds.hlds_pred.proc_info), ((hlds.passes_aux).proc_ids_task))) ; (hlds.passes_aux).update_proc_ids_pred($typed_inst(pred(hlds.hlds_module.module_info, hlds.hlds_pred.pred_proc_id, hlds.hlds_pred.pred_info, hlds.hlds_pred.proc_info, hlds.hlds_pred.proc_info), ((hlds.passes_aux).proc_ids_pred_task)))).
    :- inst (hlds.passes_aux.seq_proc_task) == bound((hlds.passes_aux).update_module($typed_inst(pred(hlds.hlds_pred.pred_proc_id, hlds.hlds_pred.proc_info, hlds.hlds_pred.proc_info, hlds.hlds_module.module_info, hlds.hlds_module.module_info), ((hlds.passes_aux).module_task))) ; (hlds.passes_aux).update_module_cookie($typed_inst(pred(hlds.hlds_pred.pred_proc_id, hlds.hlds_pred.proc_info, hlds.hlds_pred.proc_info, hlds.hlds_module.module_info, hlds.hlds_module.module_info, univ.univ, univ.univ), ((hlds.passes_aux).module_cookie_task)), ground) ; (hlds.passes_aux).update_module_pred($typed_inst(pred(hlds.hlds_pred.pred_proc_id, hlds.hlds_pred.pred_info, hlds.hlds_pred.proc_info, hlds.hlds_pred.proc_info, hlds.hlds_module.module_info, hlds.hlds_module.module_info), ((hlds.passes_aux).module_pred_task))) ; (hlds.passes_aux).update_module_pred_cookie($typed_inst(pred(hlds.hlds_pred.pred_proc_id, hlds.hlds_pred.pred_info, hlds.hlds_pred.proc_info, hlds.hlds_pred.proc_info, hlds.hlds_module.module_info, hlds.hlds_module.module_info, univ.univ, univ.univ), ((hlds.passes_aux).module_pred_cookie_task)), ground)).

    I would guess the issue here is the appearance of $typed_inst in the inst which isn't valid Mercury syntax.


     
    Notes
    (0000821)
    zs   
    2015-03-31 14:08   
    I am pretty sure the change that lead to this is the change I committed on march 5, which pre-propagated types into the insts of the inst table. However, the right fix is not to undo that, but to fix the code that outputs insts so that it doesn't output typed insts into interface files. (We do still want to output them for debugging.)

    I will fix this later today.
    (0000822)
    zs   
    2015-04-02 12:13   
    Fix committed 2 april 2015.




    View Issue Details
    383 [mercury] Bug minor always 2015-03-25 13:59 2015-03-25 19:53
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Program behaviour changes when trie string switches are used
    The behaviour of the attached program with the attached input differs depending on
    whether the predicate cadmium_op_table/2 is compiled into a trie string switch or not.
      $ mmc --make bug
      $ ./bug < bug.inp

    yields:

    error("Syntax error at token \'main\': operator precedence error", 5)

      $ mmc --no-smart-indexing --make bug
      $ ./bug < bug.inp

    yields:

    term(varset(var_supply(0), empty, empty), functor(atom("transform"), [functor(atom("="), [functor(atom("main"), [], context("<standard input>", 5)), functor(atom("."), [functor(atom("zinc2merc"), [], context("<standard input>", 5)), functor(atom("high_level"), [], context("<standard input>", 5))], context("<standard input>", 5))], context("<standard input>", 5))], context("<standard input>", 5)))

    The latter is the expected output for this program.

    The problem did not exist in rotd-2015-02-20. It exists in rotd-2015-02-27 onwards.
    (The change that added trie string switches was committed on 2015-02-24; the next
    rotd build was 2015-02-27.)
    bug.m (7,737 bytes) 2015-03-25 14:00
    https://bugs.mercurylang.org/file_download.php?file_id=241&type=bug
    bug.inp (435 bytes) 2015-03-25 14:00
    https://bugs.mercurylang.org/file_download.php?file_id=242&type=bug
     
    Notes
    (0000820)
    zs   
    2015-03-25 19:53   
    Fix committed in commit c1e0499140ec5c38369b0cacb546618f56061ed2.




    View Issue Details
    382 [mercury] Bug crash always 2015-03-15 00:22 2015-03-16 03:15
    pbone x86_64  
    zs Debian  
    normal 8.0  
    resolved  
    fixed  
    none    
    none  
       
    arg-pack-bits optimisation broken with foreign_enums.

    The arg-pack-bits optimisation is incorrectly applied to members of structures which are foreign enums. In this example I have two types each has two fields and therefore could be stored in 1 bit each. However they are foreign enums and in this case may contain values that may use an arbitrary number of bits. Mercury incorrectly assumes that they use fewer bits and attempts to pack them.

    Code that uses the following structure is mis-compiled. I'm attaching a full example. Note that the 3rd field is necessary to trigger the crash.

    :- type addrinfo
        ---> addrinfo(
                    ai_family :: family,
                    ai_socktype :: socktype,
                    ai_protocol :: protocol_num
                ).

    :- type family
        ---> fam_inet
        ; fam_inet6.

    :- type socktype
        ---> sock_stream
        ; sock_dgram.

    :- pragma foreign_enum("C", family/0,
        [fam_inet - "AF_INET",
         fam_inet6 - "AF_INET6"]).

    :- pragma foreign_enum("C", socktype/0,
        [sock_stream - "SOCK_STREAM",
         sock_dgram - "SOCK_DGRAM"]).

    The error goes away when I set --arg-pack-bits=0
    Note that the solution will need to be aware of cases where the foreign enum is in the implementation section of a different module.
    bug_pack_bits.m (2,542 bytes) 2015-03-15 00:22
    https://bugs.mercurylang.org/file_download.php?file_id=239&type=bug
     
    Notes
    (0000817)
    zs   
    2015-03-15 04:31   
    I know what is causing the problem. The code in du_type_layout.m that decides on whether
    and how the arguments in a memory cell will be packed is invoked at the end of pass 2
    in the making of the HLDS, but the foreign_enum pragma is processed only in pass 3.
    This means that while du_type_layout.m does the right thing, it is given wrong data.
    Since it thinks that family and socktype are Mercury enums that are NOT exported to
    other languages, it believes it is safe to compress them in fields.

    I am working on a change to move the processing of those pragmas to pass 2.
    Getting rid of the pass system would be even better, but that would conflict with
    my work on the item list structure.
    (0000818)
    pbone   
    2015-03-15 10:06   
    Thanks Zoltan.

    Just a quick note regarding "Mercury enums that are NOT exported to
    other languages," These enums aren't exported from Mercury, they're imported to Mercury.

    Cheers.
    (0000819)
    zs   
    2015-03-16 03:15   
    Fixed in commit 6dd74cad6471b9c1db11575034d7a866c8429a87, 2015 march 16.




    View Issue Details
    380 [mercury] Bug minor always 2015-02-25 15:55 2015-02-28 14:18
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    mercury_string.h not always included in high-level C grades
    mercury_string.h is not always included by the generated C file unless the module imports the string module, but the compiler may generate references to macros defined in that file. The easiest fix would be to include mercury_string.h in mercury.h

    % mmc -s hlc.gc -c words
    words.m: In function ‘words__word_1_p_0’:
    words.m:12:7: warning: implicit declaration of function ‘MR_nth_code_unit’ [-Wimplicit-function-declaration]
     word("aback").
           ^
    words.m:12:17: warning: implicit declaration of function ‘MR_offset_streq’ [-Wimplicit-function-declaration]
     word("aback").
    words.m (603 bytes) 2015-02-25 15:55
    https://bugs.mercurylang.org/file_download.php?file_id=237&type=bug
     
    Notes
    (0000816)
    zs   
    2015-02-28 14:18   
    Fix committed 2015 feb 27.




    View Issue Details
    366 [mercury] Bug minor always 2014-10-27 16:15 2015-02-20 15:20
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    enable inst_matches_final_bug and ho_default_func_4
    The aforementioned test cases can now be enabled after the hack in inst_matches_final was removed.
     
    There are no notes attached to this issue.




    View Issue Details
    377 [mercury] Bug minor always 2015-02-18 01:46 2015-02-19 01:46
    mvd23jsdf4 x86_64  
    juliensf Fedora  
    normal 21  
    feedback  
    open  
    none    
    none  
       
    Debugger doesn't have help installed.
    After building and installing the debugger, mdb doesn't have any help files.
    ./configure --prefix=$HOME/.local --enable-minimal-install --enable-additional-libgrades=asm_fast.gc.debug,asm_fast.gc.decldebug
    make PARALLEL=-j2
    make PARALLEL=-j2 install
     
    Notes
    (0000815)
    juliensf   
    2015-02-19 01:46   
    Do you mean that the 'help' command in mdb is not displaying anything, or something different?
    Can you please check that the file $HOME/.local/lib/mercury/mdb/mdb_doc is present and non-empty.
    (That file should contain the help documentation for mdb.)




    View Issue Details
    378 [mercury] Bug minor have not tried 2015-02-18 01:52 2015-02-19 01:42
    mvd23jsdf4 x86_64  
    Fedora  
    normal 21  
    new  
    open  
    none    
    none  
       
    Cannot access library source files when debugging
    When debugging an application and the code enters a library file, you are unable to view that source. see attached source file.
    ./configure --prefix=$HOME/.local --disable-most-grades --enable-additional-libgrades=reg.gc.debug,reg.gc.decldebug
    make PARALLEL=-j2
    make PARALLEL=-j2 install
    mmc --make --debug fib2
    mdb ./fib2

    [mercuryuser@localhost fib2]$ mdb ./fib2
    Melbourne Mercury Debugger, mdb version 14.01.1.
    Copyright 1998-2014 The University of Melbourne.
    mdb is free software, covered by the GNU General Public License.
    There is absolutely no warranty for mdb.
           1: 1 1 CALL pred fib2.main/2-0 (det) fib2.m:16
    /home/mercuryuser/.local/lib/mercury/mdb/mdb_doc: No such file or directory.
    mdb> list
                else fib(N - 1) + fib(N - 2)).
      
    > main(!IO) :-
           io.read_line_as_string(Result, !IO),
           (if
    mdb> next

           4: 1 1 COND pred fib2.main/2-0 (det) c2;?; fib2.m:19
    mdb> list
           io.read_line_as_string(Result, !IO),
           (if
    > Result = ok(String),
               string.to_int(string.strip(String), N)
            then
    mdb> step
           5: 3 2 CALL func string.strip/1-0 (det) string.m:6331 (fib2.m:20)
    mdb> list
    mdb: cannot find file string.m
    mdb>
    fib2.m (546 bytes) 2015-02-18 01:52
    https://bugs.mercurylang.org/file_download.php?file_id=235&type=bug
     
    Notes
    (0000814)
    juliensf   
    2015-02-19 01:42   
    You need to point the debugger to wherever the library source files are using the 'list_path' command.




    View Issue Details
    379 [mercury] Bug minor always 2015-02-18 02:06 2015-02-19 01:38
    mvd23jsdf4 x86_64  
    juliensf Fedora  
    normal 21  
    resolved  
    fixed  
    none    
    none  
       
    GCC 4.9.2 Giving Error
    The GCC (version 4.9.2) on Fedora 21 is showing warnings on compile. See the attached file crypt.m.
        [mercuryuser@localhost crypt]$ mmc --make --debug crypt
        Making Mercury/int3s/crypt.int3
        Making Mercury/ints/crypt.int
        Making Mercury/cs/crypt.c
        Making Mercury/os/crypt.o
        Making crypt
        In file included from /usr/include/stdlib.h:24:0,
                         from /home/mercuryuser/local/lib/mercury/inc/mercury_std.h:23,
                         from /home/mercuryuser/local/lib/mercury/inc/mercury_goto.h:13,
                         from /home/mercuryuser/local/lib/mercury/inc/mercury_init.h:84,
                         from Mercury/cs/crypt_init.c:18:
        /usr/include/features.h:148:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
         # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
           ^
        In file included from /usr/include/stdlib.h:24:0,
                         from /home/mercuryuser/local/lib/mercury/inc/mercury_std.h:23,
                         from /home/mercuryuser/local/lib/mercury/inc/mercury_goto.h:13,
                         from /home/mercuryuser/local/lib/mercury/inc/mercury_init.h:84,
                         from Mercury/cs/crypt_init.c:18:
        /usr/include/features.h:148:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
         # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
        ... error log truncated, see `crypt.err' for the complete log.

    crypt.m (1,147 bytes) 2015-02-18 02:06
    https://bugs.mercurylang.org/file_download.php?file_id=236&type=bug
     
    Notes
    (0000812)
    juliensf   
    2015-02-19 01:18   
    The generated _init.c files define _BSD_SOURCE for some reason.
    (0000813)
    juliensf   
    2015-02-19 01:38   
    Fixed in commit b70619d.




    View Issue Details
    376 [mercury] Bug minor always 2015-02-06 15:25 2015-02-17 12:35
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    base_string_to_int ignores overflow unless base 10
    base_string_to_int should always check for under/overflow despite the faulty reasoning in commit 51b8f76. The fix should be easy enough but I will leave this bug report for a bit in case there are dissenting opinions.
     
    Notes
    (0000807)
    zs   
    2015-02-06 15:51   
    No dissent from me.
    (0000809)
    wangp   
    2015-02-10 15:03   
    Does anyone require the undocumented behaviour of allowing (and truncating) oversized binary/octal/hexadecimal literals in Mercury source? Maintaining the behaviour requires more work and potentially breaking changes in the library.
    (0000810)
    juliensf   
    2015-02-10 15:30   
    No and given that the behaviour is undocumented you should feel free to break it.
    (0000811)
    wangp   
    2015-02-17 12:35   
    Fixed in commit 6a267a8




    View Issue Details
    368 [mercury] Bug minor always 2014-12-02 22:19 2015-02-08 12:18
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Table reset predicates not generated in Erlang grade
    The module compiler/ctgc.selector contains a number of predicates that are the subject of memo pragmas and that have the reset attribute specified. The reset predicates are called by other predicates
    in this module. Although tabling is not supported by the Erlang backend, we still need to generate
    dummy versions of the reset predicates where there are references to them. This is the cause
    of the errors from the Erlang compiler about undefined functions in the build output below.
    Build the Mercury compiler in the erlang grade.
    Making Mercury/int3s/transform_hlds.ctgc.selector.int3
    Making Mercury/ints/transform_hlds.ctgc.selector.int
    Making Mercury/erls/transform_hlds__ctgc__selector.erl
    ctgc.selector.m:066: Ignoring the pragma memo for predicate
    ctgc.selector.m:066: `transform_hlds.ctgc.selector.normalize_selector_with_type_information'/4
    ctgc.selector.m:066: mode 0 due to lack of support on this back end.
    ctgc.selector.m:288: Ignoring the pragma memo for predicate
    ctgc.selector.m:288: `transform_hlds.ctgc.selector.type_contains_subtype_1'/4
    ctgc.selector.m:288: mode 0 due to lack of support on this back end.
    ctgc.selector.m:330: Ignoring the pragma memo for predicate
    ctgc.selector.m:330: `transform_hlds.ctgc.selector.type_arg_types'/3 mode 0
    ctgc.selector.m:330: due to lack of support on this back end.
    Making Mercury/beams/transform_hlds__ctgc__selector.beam
    ctgc.selector.m:295: syntax error before: ','
    ctgc.selector.m:334: syntax error before: ','
    Mercury/erls/transform_hlds__ctgc__selector.erl:354: function table_reset_for_type_contains_subtype_1_4_2_p_0/0 undefined
    Mercury/erls/transform_hlds__ctgc__selector.erl:355: function table_reset_for_type_arg_types_3_2_p_0/0 undefined
    ** Error making `Mercury/beams/transform_hlds__ctgc__selector.beam'.
    /var/folders/pd/5lypc6_j3vnf65q9x5y9s3p40000gn/T//mmake.YQsUfH:1400: recipe for target 'top_level' failed
    gmake[1]: *** [top_level] Error 1
    gmake[1]: Leaving directory '/Users/jfischer/Mercury-Workspaces/mercury.local-4/compiler'
    /var/folders/pd/5lypc6_j3vnf65q9x5y9s3p40000gn/T//mmake.nCDJA5:1066: recipe for target 'compiler' failed
    gmake: *** [compiler] Error 2
     
    Notes
    (0000808)
    zs   
    2015-02-08 12:18   
    Fix committed 2015 feb 5.




    View Issue Details
    375 [mercury] Bug major always 2015-01-19 14:52 2015-01-21 01:07
    lpimmes OSx 10.9  
     
    urgent  
    new  
    open  
    none    
    none  
       
    io.seek_binary_output(Stream, set, 32, Out3, Out4), % rec1 NOT working
    Seeking to an offset, the second record, in binTest file and then writing new results only writes a single record.
    Initially three records present; now only a single record remains.
    Any ideas? Thanks.
    This invites the question: overwrite record at position, versus insert new record at seek position.
    Change true/false switches in main/2 to achieve results for test:
    1 write binTest, true, false
    2 false, true read binTest at offset, record 2, OK
    3 false, false write to binTest at offset, record 2; fails.

                                    % ioBinFile 522>which mmc
                    % /usr/local/mercury-14.01/bin/mmc

                    % ioBinFile 511>./ioBinFile
                    % Opened 'binTest' successfully.
                    % Offsets rec0: 0, rec1: 32, rec2: 62.
                    % ioBinFile 513>cat binTest
                    % rec("The man ran home.", 3092).
                    % rec("The girl saw me.", 312).
                    % rec("Each person saw you.", 532).

                    % set to false, recompile main/2
                    % ioBinFile 517>./ioBinFile
                    % Opened 'binTest' successfully.
                    % Offset after seek: 32.
                    % Read record: rec('The girl saw me.', 312)

                    % Not working, just record output; first and third one removed.
                    % false, false; default last term in if / then / else
                    % ioBinFile 521>./ioBinFile
                    % Opened 'binTest' successfully for seek writing.
                    % Stream name: binTest; seek to position: 32.
                    % ioBinFile 521>cat binTest
                    % rec("Dr. Smith", 3).
    ioBinFile.m (4,993 bytes) 2015-01-19 14:52
    https://bugs.mercurylang.org/file_download.php?file_id=234&type=bug
     
    Notes
    (0000805)
    juliensf   
    2015-01-20 12:33   
    The call to io.open_binary_output/4 in the predicate writeSeek/3 will truncate the file.
    You probably meant to call io.open_binary_append/4.
    (0000806)
    lpimmes   
    2015-01-21 01:07   
    Yes, I agree, and testing shows that o.open_binary_append/4 in writeSeek/3 will (not surprisingly)
    append new text to end of existing text. Code and example shown below.
    But, how do overwrite/insert at a particular seek position in this file?
    Reading from a position after seek works fine.
    Thanks.

    :- pred writeSeek(string::in, io::di, io::uo) is det.
    writeSeek(Fname, In, Out) :-
        io.open_binary_append(Fname, Result, In, Out2), % file may / may not exist

        (if Result = ok(Stream)
                    % Offsets rec0: 0, rec1: 32, rec2: 62.
        then
        io.format("Opened '%s' successfully for seek writing.\n", [s(Fname) ], Out2, Out3),
         io.seek_binary_output(Stream, set, 32, Out3, Out4), % rec1
         io.binary_output_stream_offset(Stream, Offset, Out4, Out5),
         io.binary_output_stream_name(Stream, Name, Out5, Out6),
         io.format("Stream name: %s; seek to position: %i.\n",
               [s(Name), i(Offset) ], Out6, Out7), % should be 32, OK
         Rec0 = rec("Dr. Smith", 3),
         io.write_binary(Stream, Rec0, Out7, Out8),
         io.close_binary_output(Stream, Out8, Out)
        
        else if
        Result = io.error(Code)
        
        then
        io.format("Failed to open %s because of: %s.\n",
              [ s(Fname), s(io.error_message(Code)) ], Out2, Out)
        
        else
        io.format( "Fail to unify io.error(Code).\n", [], Out2, Out)
        ).

    -----
    ioBinFile 508>./ioBinFile
    Opened 'binTest' successfully for seek writing.
    Stream name: binTest; seek to position: 32.

    ioBinFile 509>cat binTest
    rec("The man ran home.", 3092).
    rec("The girl saw me.", 312).
    rec("Each person saw you.", 532).
    rec("Dr. Smith", 3).




    View Issue Details
    374 [mercury] Bug crash always 2015-01-14 15:34 2015-01-15 14:04
    juliensf x86_64-w64-mingw32  
    juliensf Windows  
    normal 7  
    assigned  
    open  
    none    
    none  
       
    rotd-2015-01-13 fails to install with mingw64
    Building from the source distribution with the mingw-builds x86_64-4.9.2-posix-rseh t_v3-rev1 compiler
    aborts during 'make install' when building the optimisation interface for library.m in grade asm_fast.gc.
    The abort occurs during expansion of equivalence types. I strongly suspect this is down to C stack
    exhaustion but haven't confirmed this yet.
    The same occurs with the mingw-builds x86_4.8.1-posix-seh-rev5 compiler.

    32-bit builds of the same rotd using the standard mingw32 compiler are unaffected.
     
    Notes
    (0000804)
    juliensf   
    2015-01-15 14:04   
    Actually, the stack overflow occurs during the conversion of clauses during the initial construction
    of the HLDS. The actual problem here is that I forgot to pass --host=x86_64-w64-mingw32 to configure
    and so the stack limit on mercury_compile.exe was ridiculously small.

    This *is* all documented in README.MinGW, but I think we need a better way of ensuring that *if* we
    are using a MinGW64 under msys or cygwin that the host architecture is set correctly. I'll keep this
    bug open until I find a better way ...




    View Issue Details
    372 [mercury] Bug minor have not tried 2015-01-05 13:16 2015-01-05 13:16
    pbone x86_64  
    Debian Linux  
    normal  
    new  
    open  
    none    
    none  
       
    Finalisers run after main/2 throws an exception.
    We have decided that module finalisers should not run if main/2 throws an exception. The C# backend always runs finalisers. It does not implement the correct behaviour.
     
    There are no notes attached to this issue.




    View Issue Details
    370 [mercury] Bug minor always 2014-12-22 11:54 2015-01-03 21:07
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    unused module imports and string.format
    The compiler reports unused module import warnings after string.format is specialised.

    % lmc --warn-unused-imports f.m
    f.m:001: In module `f':
    f.m:001: warning: modules `stream', `string.format' and `string.parse_util'
    f.m:001: are imported, but are not used.
    f.m (275 bytes) 2014-12-22 11:54
    https://bugs.mercurylang.org/file_download.php?file_id=232&type=bug
     
    Notes
    (0000802)
    zs   
    2015-01-03 21:07   
    Fix f0a1701bc8afb70f5133a11a0e75ab88a735fdd5 committed 2014 dec 30.




    View Issue Details
    371 [mercury] Bug major always 2014-12-22 12:18 2014-12-23 00:45
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    can't locate string.format.format_signed_int_component_nowidth_noprec/3
    % mmc -C f2.m
    Uncaught Mercury exception:
    Software Error: hlds.pred_table: predicate `hlds.pred_table.lookup_builtin_pred_proc_id'/8: Unexpected: can't locate string.format.format_signed_int_component_nowidth_noprec/3
    f2.m (391 bytes) 2014-12-22 12:18
    https://bugs.mercurylang.org/file_download.php?file_id=233&type=bug
     
    Notes
    (0000801)
    zs   
    2014-12-23 00:45   
    Fix committed in change ebc10c087efa453357590053303c8082af28cc13
    on 23 dec 2014.




    View Issue Details
    369 [mercury] Bug crash always 2014-12-16 03:17 2014-12-16 10:18
    sebgod Windows NT 6.3 x86_64  
    zs Windows  
    normal 8.1  
    resolved  
    fixed  
    none    
    none  
       
    Software Error: hlds.pred_table: predicate `hlds.pred_table.lookup_builtin_pred_proc_id'/8: Unexpected: can't locate put/5
    Using the latest Mercury compiler (git commit fd822d712a8f1170a9fab3d9a1d05dd5e404106b)
    Compiling the attached example module yields following exception:
    Making Mercury\int3s\stream_put5_bug.int3
    Making Mercury\ints\stream_put5_bug.int
    Making Mercury\asm_fast.gc\i686-pc-mingw32\Mercury\cs\stream_put5_bug.c
    Uncaught Mercury exception:
    Software Error: hlds.pred_table: predicate `hlds.pred_table.lookup_builtin_pred_proc_id'/8: Unexpected: can't locate stream.put/5
    Stack dump not available in this grade.
    Error: system command received signal 1.
    ** Error making `Mercury\asm_fast.gc\i686-pc-mingw32\Mercury\cs\stream_put5_bug.c'.
    mmc -m stream_put5_bug
    Unfortunately I'm not sure when this bug exactly appeared (the program I used to compile was working fine for a while).
    An educated guess is that this appeared after the string.format changes in the compiler.
    Using the latest MinGW with gcc 4.7 for 32bit
    Java 1.8.0
    .NET 4.5.1
    Bootstrapped (with ROTD from June 2014) Mercury-dev
    stream_put5_bug.m (352 bytes) 2014-12-16 03:17
    https://bugs.mercurylang.org/file_download.php?file_id=230&type=bug
    pred_table_fix_lookup_builtin_pred_proc_id.diff (1,552 bytes) 2014-12-16 03:18
    https://bugs.mercurylang.org/file_download.php?file_id=231&type=bug
     
    Notes
    (0000799)
    sebgod   
    2014-12-16 03:20   
    (Last edited: 2014-12-16 03:21)
    To pinpoint the bug, I've modified the hlds.pred_table.lookup_builtin_pred_proc_id/8 procedure (see attached diff) to also output the module name in the error message, not sure if that is generally useful.
    Just thought that put/5 was a little bit too generic.

    (0000800)
    zs   
    2014-12-16 10:18   
    Fix add253af9fa0d396034004bef2e36a4512eb8b1a committed 2014 dec 16.




    View Issue Details
    367 [mercury] Bug minor have not tried 2014-11-27 14:27 2014-12-03 18:23
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    array binary search predicates use builtin.compare
    approx_binary_search_2 implicitly calls builtin.compare (@<) instead of the supplied ordering function.
     
    Notes
    (0000798)
    zs   
    2014-12-03 18:23   
    Fixed by commit 35fe4814ce28699f79c98b757d545ee7faac48d8 on 2014 dec 3.




    View Issue Details
    181 [mercury] Bug minor always 2011-02-02 13:49 2014-12-02 22:20
    pbone  
    pbone  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Feedback framework uses partial instationation which is not well supported.
    mdbcomp/feedback.m uses partial instantiation to retrieve feedback information from the feedback_info structure. This is not well supported in all grades, for instance it prevents the erlang grade from building the compiler.
     
    Notes
    (0000797)
    juliensf   
    2014-12-02 22:20   
    This issue was resolved by commit f7237359ae7281168fa19b321c2b2881a405a05e which
    removed the use of partial instantiation from the feedback framework.




    View Issue Details
    365 [mercury] Bug minor sometimes 2014-10-20 11:40 2014-10-20 11:40
    pbone x86_64  
    Linux  
    low Debian testing  
    new  
    open  
    none    
    none  
       
    hard_coded/parse test failes in asm_fast.gc.par.stseg with libhwloc
    The hard_coded/parse test failes in asm_fast.gc.par.stseg. The test fails to compile because it cannot find libnuma during linking. This test unlike others uses static linking and lubnuma is a dependency of libhwloc. It looks like a static version of libnuma is not provided on Debian. The fix is pretty clear, configure should test if we can use libhwloc is usable for dynamic and static linking and if it fails in either it should be disabled in that case.
     
    There are no notes attached to this issue.




    View Issue Details
    231 [mercury] Bug trivial always 2011-11-22 16:30 2014-10-09 12:48
    colanderman  
     
    normal  
    new  
    open  
    none    
    none  
       
    No way to specify instantiatedness of char type
    There is currently no way to specify the instantiatedness of a char type, e.g.:

    :- inst whitespace ---> ' '; '\t'; '\n'.

    The above instantiatednesses are represented as atoms, but since instantiatednesses of character values are internally represented as type char_const(), this leads to mode errors such as:

    Final instantiatedness of `HeadVar__1' was `bound('\t' ; '\n' ; ' ')',
    expected final instantiatedness was `bound('\t' ; '\n' ; ' ')'.

    Attached is a patch which fixes this bug.
    char_inst.m (222 bytes) 2011-11-22 16:30
    https://bugs.mercurylang.org/file_download.php?file_id=138&type=bug
    mercury-compiler-char-inst.patch (1,974 bytes) 2011-11-22 16:31
    https://bugs.mercurylang.org/file_download.php?file_id=139&type=bug
     
    Notes
    (0000795)
    wangp   
    2014-10-09 12:48   
    Applying the patch as-is would be unsafe. If you try to switch on the variable following the call to is_whitespace, e.g.

    is_whitespace(C),
    ( C = (' '), ...
    ; C = ('\t'), ...
    ; C = ('\n'), ...
    )

    The inst of C is represented as a list of cons/3 functors and the cases as `char_const' functors. Switch detection does not see them as equivalent so replaces the disjunction by `fail'. I assume other parts of the compiler may have similar problems.




    View Issue Details
    364 [mercury] Bug minor sometimes 2014-10-01 16:25 2014-10-07 11:37
    pbone x86_64  
    pbone Linux  
    normal Debian jessie  
    resolved  
    fixed  
    none    
    none  
       
    Autoparallelisation analysis crashes on nondet disjunctions.
    Matthias Guedemann submitted this bug via e-mail users@mercurylang.org in September 2014.

    > mdprof_create_feedback chokes on the created Deep.data file. I always
    > get the error:
    >
    > ,----
    > | Uncaught Mercury exception:
    > | Software Error: measurements: predicate `measurements.check_total_calls'/3: Unexpected: TotalCalls \= CallsA + CallsB
    > | Stack dump not available in this grade.
    > `----
    >
    > when using
    >
    > % mdprof_create_feedback --implicit-parallelism Deep.data feedback.data

    MCFLAGS:
      --deep-profiling --profile-for-feedback

    mdprof_create_feedback --implicit-parallelism Deep.data feedback.data
    I'd like to attempt to explain what's happening, this may be pretty detailed
    so feel free to ignore it, I'm mostly explaining this to myself :-).

    The autoparallelisation analysis scans your whole program for places where
    parallelism could help (it skips parts of the program where it's obvious
    that it won't help). It crashes when it looks in
    euler_81_82_83_problem_set.euler_edge_81/4 which is nondeterminisic. It
    tries to calculate the cost of every goal including the disjunction as a
    whole, however it assumes that the disjunction is either a switch or a
    "semidet disjunction" which is another special case. This incorrect
    assumption causes the analysis to crash (because a consistency check fails).
    It might be possible to comment out the consistency check, but then I'd be
    concerned that something else would crash because of the same faulty
    assumption. I'll see if I can fix the bug in the next week or so.
    euler.tgz (1,145,111 bytes) 2014-10-01 16:25
    https://bugs.mercurylang.org/file_download.php?file_id=228&type=bug
     
    Notes
    (0000792)
    pbone   
    2014-10-07 11:37   
    Fixed in revision: 4a431556b5b63e2f04de272684dd5abca18e86e0

    https://github.com/Mercury-Language/mercury/commit/4a431556b5b63e2f04de272684dd5abca18e86e0




    View Issue Details
    296 [mercury] Bug minor always 2013-07-31 12:58 2014-10-05 17:33
    wangp  
     
    normal  
    new  
    open  
    none    
    none  
       
    ui mode and multiple clauses
    from Michael:

    This code triggers a mode error:

    :- mode get_text_content0(in, out, ui) is det.

    get_text_content0([], [], _IO).
    get_text_content0([Node|Nodes], [Text|Texts], IO) :-
         get_text_content_from_node(Node, Text, IO), % <-- error here for IO
         get_text_content0(Nodes, Texts, IO).

    However if I write the switch explicitly, it's fine:

    get_text_content0(Nodes, Texts, IO) :-
         (
             Nodes = [],
             Texts = []
         ;
             Nodes = [Node|Nodes0],
             get_text_content_from_node(Node, Text, IO),
             get_text_content0(Nodes0, Texts0, IO),
             Texts = [Text|Texts0]
         ).
     
    Notes
    (0000791)
    mark   
    2014-10-05 17:33   
    The explanation for this is that the introduction of HeadVars introduces extra unifications, and these cause the ui term to lose its uniqueness according to the mode analyser.

    HeadVars are always introduced, but in some cases (such as when a predicate is defined in a single clause) this introduction is reversed in order to retain meaningful variables names in the debugger. A side effect of this reversal is that the mode analyser no longer always chokes.

    Using a single clause seems to be an effective workaround for the real bug, which is that the mode analyser doesn't properly keep track of uniqueness.




    View Issue Details
    361 [mercury] Bug minor always 2014-09-15 14:59 2014-09-16 13:22
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Compiler abort with loose determinism decl. and pragma loop_check
    The attached program causes a compiler abort in both C backends.

    Uncaught Mercury exception:
    Software Error: ll_backend.code_gen: predicate `ll_backend.code_gen.generate_goal'/5: Unexpected: nondet model in det/semidet context
    Stack dump not available in this grade.

    Uncaught Mercury exception:
    Software Error: ml_backend.ml_code_gen: predicate `ml_backend.ml_code_gen.ml_gen_maybe_convert_goal_code_model'/7: Unexpected: nondet in semi
    Stack dump not available in this grade.


    bug361.m (793 bytes) 2014-09-15 14:59
    https://bugs.mercurylang.org/file_download.php?file_id=225&type=bug
     
    Notes
    (0000788)
    zs   
    2014-09-16 13:22   
    Fix committed sep 16.




    View Issue Details
    362 [mercury] Bug minor always 2014-09-15 15:10 2014-09-16 11:10
    juliensf  
     
    normal  
    new  
    open  
    none    
    none  
       
    Program cause compiler to abort in mmos grades (but not mmsc)
    The attached program causes the following abort in the compiler when compiled with:

       $ mmc --grade asm_fast.gc.mmos

    Uncaught Mercury exception:
    Software Error: map.lookup: key not found
        Key Type: int
        Key Value: 0
        Value Type: hlds.hlds_pred.proc_info
    Stack dump not available in this grade.

    The program compiles and works correctly in the mmsc grades.
    The test program is similar, but not identical, to that of bug 0000360 and bug 0000361.
    bug362.m (860 bytes) 2014-09-15 15:10
    https://bugs.mercurylang.org/file_download.php?file_id=226&type=bug
     
    Notes
    (0000786)
    zs   
    2014-09-16 07:23   
    That is not surprising. The mmos grades were never finished. They should not be used by anyone who is not in the process of finishing that implementation :-) They should not even be mentioned in any user-facing documentation.
    (0000787)
    juliensf   
    2014-09-16 11:10   
    I know they were never finished -- I was recording the test case for the benefit anyone who is working on them. To the test of my knowledge they are *not* mentioned in any user-facing documentation.




    View Issue Details
    41 [mercury] Bug minor always 2008-02-01 20:57 2014-09-02 12:27
    bvn  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    unclear error message in case the end_module declaration differs from the :- module description
    The compiler bails out this message:

    Making Mercury/ints/rdfStore_support.int
    Uncaught Mercury exception:
    Software Error: modules.m: Unexpected: standardize_impl_items: unexpected items
    Stack dump not available in this grade.
    make: *** [nim_tcp_xml_server] Error 1

    The situation to reproduce: compile a module MX. Then make a copy of MX to become MY. Change in MY the :- module mx. :- module my. and then recompile.

     
    Notes
    (0000075)
    juliensf   
    2008-02-08 17:27   
    IIRC, this actually quite difficult to detect at the moment.
    We are intending to restructure the frontend of the compiler in such a way that
    things like this will be easier to detect; that work has not been completed yet however.

    I'll take a look and see if anything can be done in the interim; at the very least the
    exception could mention the possibility that the :- module and :- end_module declarations
    disagree.
    (0000778)
    zs   
    2014-09-02 12:27   
    Fix committed 2014 sep 2.




    View Issue Details
    352 [mercury] Bug minor always 2014-08-18 17:41 2014-09-01 18:14
    wangp  
    zs  
    normal  
    assigned  
    open  
    none    
    none  
       
    tabled_for_io with Mercury descendants
    In the example, p has attributes may_call_mercury and tabled_for_io. At the end of p, table_io stats prints that the I/O counter = 2. If you retry over p, then at the end, table_io stats prints that counter = 1. Obviously this leads to problems later.

    I see that there is an undocumented attribute tabled_for_io_unitize. Perhaps that should be implied if tabled_for_io and may_call_mercury are used together?
    table_io_callback.m (845 bytes) 2014-08-18 17:41
    https://bugs.mercurylang.org/file_download.php?file_id=221&type=bug
     
    Notes
    (0000762)
    zs   
    2014-08-18 21:10   
    The table_for_io attribute was intended for PRIMITIVE I/O operations, which do not call Mercury. Having it misbehave with may_call_mercury is not a surprise.
    There should be a check for the conflict.

    I don't remember for sure, but I think the table_for_io_unitize attribute wasn't documented because it was not yet ready for prime time. I don't remember whether there was some situation I knew I still had to code to cover, but I do remember that the testing was only superficial; thorough testing still remained to be done.

    Once it HAS been done, then yes, turning tabled_for_io into tabled_for_io_unitize in the presence of may_call_mercury would be a good idea.

    I won't have much time to look into this for a few days. If this is not urgent, assign the bug to me, and I will have a look at this, probably sometime next week.
    (0000777)
    juliensf   
    2014-09-01 18:14   
    There approximately 76 procedures in the standard library that currently have both tabled_for_io and may_call_mercury enabled. The great majority of those seem to make calls back to Mercury in order
    to construct some data structure that describes an error condition (or other such return value).




    View Issue Details
    146 [mercury] Bug minor always 2010-05-24 11:18 2014-09-01 12:46
    juliensf  
    juliensf  
    normal  
    assigned  
    open  
    none    
    none  
       
    inf and Nan
    The following is from the BUGS file in the Mercury distribution.

    --------

    Subject: bug report - Inf and NaN
    Date: Wed, 4 Oct 1995 02:48:19 +1000 (EST)

    The following module causes an "undefined variable Inf" error in the
    generated C code, because 1E400 == Infinity, which gets printed as `Inf'.

    :- module hello.
    :- interface.
    :- import_module io.

    :- pred main(io__state::di, io__state::uo) is det.

    :- implementation.

    main -->
            io__write_float(1E400),
            io__write_string("\n").
     
    Notes
    (0000776)
    juliensf   
    2014-09-01 12:46   
    The upcoming change to better support infinities in the standard library should allow us to fix this.
    The idea is to check whether float constants are infinity and if so replace them with a call to float.infinity or -float.infinity (as appropriate).




    View Issue Details
    356 [mercury] Bug crash always 2014-08-30 10:30 2014-08-31 11:11
    C4Cypher x86_64-pc-linux-gnu  
    Ubuntu  
    normal 14.04 'Trusty'  
    new  
    open  
    none    
    none  
       
    mmc exception thrown from instmap.m line 600
    Okay, I'm still going through it all, I'm just floored that I got mmc to spit out a runtime error.

    Making Mercury/asm_fast.gc.trseg.debug.stseg/x86_64-pc-linux-gnu/Mercury/cs/luaMR.state.c
    Uncaught Mercury exception:
    Software Error: hlds.instmap: predicate `hlds.instmap.instmapping_set_vars_corresponding'/4: Unexpected: not_reached

    Here's a pastebin of the source I was working on: http://pastebin.com/Z6Fau9b3

    The lines that I was editing (trying to get the switch to infer as det) when mmc started to throw exceptions are 682 - 684. The entire clause is pasted for convenience.

    lua_pcall(L, A) = R :-
        impure Result = lua_pcall(L, A, 0),
        ( Result = returned(R) % line 682
        ; Result = returned_error(Error), throw(Error)
        ; unexpected($module, $pred, "Invalid result value. (WTF?)") % line 684
        ).

    Using if-> calls rather than raw disjuncts originally triggered this. I'm going to be focusing on trying to re-arrange this clause in a manner that does not cause mmc to toss cookies.

    I've located the exception I've triggered in the source, instmap.m line 600, although I don't know the inner workings of the compiler to begin knowing how to interpret it.

    expect(negate(unify(Inst, not_reached)), $module, $pred, "not_reached"),


    Note: I also compiled the same code under asm_fast.gc.trseg and got the same response.
    I've created a branch from my project with my code in the exact state it was in when I produced this issue:

    https://github.com/C4Cypher/Apollo-lander/tree/mmc-exception-thrown-from-instmap.m-line-600

    I was able to produce this with the line

    mmc --make testluaMR

    with both asm_fast.gc.trseg.debug.stseg and asm_fast.gc.trseg

    emphasis placed on the options I'm using in Mercury.options
    I'm at a loss. This library is in mid-development, and as such, it's very unstable ... I'm a long way from making a stable release. Please let me know if there's any kind of information that might help provide more light on this.
     
    Notes
    (0000769)
    C4Cypher   
    2014-08-30 10:39   
    I forgot to mention that this was all on mercury 14.01

    These are the availible grades I have installed are:

    asm_fast.gc asm_fast.gc.trseg.debug.stseg
    asm_fast.gc.debug.stseg asm_fast.par.gc.stseg
    asm_fast.gc.decldebug.stseg hlc.gc
    asm_fast.gc.memprof hlc.gc.pregen
    asm_fast.gc.prof hlc.gc.trseg
    asm_fast.gc.profdeep hlc.par.gc
    asm_fast.gc.trseg libgc.a
    (0000770)
    C4Cypher   
    2014-08-30 11:23   
    (Last edited: 2014-08-30 11:27)
    I think I found my mistake in api.m

    line 251: :- impure func lua_pcall(lua, int) = int.
    should be: :- impure func lua_pcall(lua, int) = lua_result.

    I'm not experienced with C ... but C's laziness as to true type safety is making me lazy as to casts between equivalent C types.

    the actual lua.h's lua_pcall returns an int, and I've defined several DU types related to the output of lua_pcall:

    :- type lua_result
        ---> returned(int)
        ; returned_error(lua_error).

    :- type lua_error
        ---> lua_error(error_type, string).

    :- type error_type
        ---> no_error
        ; runtime_error
        ; syntax_error
        ; memory_error
        ; unhandled_error.

    :- pragma foreign_enum("C", error_type/0,
    [
        no_error - "0",
        runtime_error - "LUA_ERRRUN",
        syntax_error - "LUA_ERRSYNTAX",
        memory_error - "LUA_ERRMEM",
        unhandled_error - "LUA_ERRERR"
    ]).

    I'm still not sure what's exactly is causing the runtime error, but my code, in terms of what I've linked in the branch in the reproduction section, treats mercury code type safety as if it were C type safety (with certain implicit casts assumed).

    To be specific, I beleive that the runtime error was produced by my inadvertant attempt to implicitly cast int.int to luaMR.api.lua_result.

    (0000771)
    C4Cypher   
    2014-08-30 11:52   
    Okay, I've corrected the type saftey issue I've found in api.m, but I'm still producing the same runtime error from mmc.

    Here's the corrected branch: https://github.com/C4Cypher/Apollo-lander/tree/mmc_exception_thrown_instmap2
    (0000772)
    zs   
    2014-08-30 12:16   
    The compiler abort is actually coming when the compiler is mode checking trail_to_func in state.m; specifically, when it is mode checking the unification that binds F to the lambda goal on line 236 of state.m. As far as I can tell, it has nothing to do with the code in api.m.

    The call that leads to the compiler abort is in modecheck_unify.m at line 440.
    The not_reached inst belongs to R (var6), which is a nonlocal of the lambda expression.
    (0000773)
    wangp   
    2014-08-30 12:20   
    trail_to_func is the function causing the compiler to abort. Changing the code in any number of ways will work around the issue.
    (0000774)
    C4Cypher   
    2014-08-30 12:59   
    Interesting, and yeah, looking at this now, I failed at logic in a strange manner

    trail_to_func(Trail) = Func :- % Trail := discriminated union
     ( wtf_goal(Trail, Func) ) -> Func = ( lambada_goal ) ; unexpected($module, $pred, "derp").

    What I actually intended was to bind Func to lambada_goal, iff wtf_goal fails to bind Func to a ho value.

    What my pred actually did was, on some branches, bind Func to a ho value of type impure func(lua::in) = (int::out), and then on success, unify Func again with another lambada of that same type.

    I can correct this, thanks both of you for pointing out where things were going pear shaped. Thanks again for what has otherwise been an absolutely awsome compiler.
    `
    (0000775)
    C4Cypher   
    2014-08-31 11:09   
    (Last edited: 2014-08-31 11:11)
    I'd like to thank the team for the quick response and the assistance.

    I'm not certain what caused the runtime error, but I was able to rewrite my code in a manner that the compiler likes.

    trail_to_func(unique_state(L, _, T)) = F :-
        require_complete_switch [T] some [R]
        ( T = lua_func(F0) -> F = F0
        ; T = empty_trail ->
            F = ( impure func(_::in) = (0::out) is det :- true )
        ; T = c_function(C) ->
            impure lua_pushcfunction(L, C),
            semipure R = lua_toref(L, index(-1)),
            impure lua_pop(L, 1),
            F = ref_to_func(R)
        ; T = ref(R) ->
            F = ref_to_func(R)
        ; unexpected($module, $pred,
                "Unknown lua_trail value provided.")
        ).

    Given that I've found something that works, from my end, I consider the matter closed, however, if there's any way I can assist, please let me know.





    View Issue Details
    354 [mercury] Bug minor always 2014-08-24 09:16 2014-08-30 08:55
    chemoelectric AMD64  
    zs Gentoo Linux  
    normal not applicable  
    resolved  
    fixed  
    none    
    none  
       
    Building mercury_cairo fails in version 14.01
    Whenever I attempt to build mercury_cairo with Mercury 14.01 I get a failure as follows:

    Installing grade reg.gc.decldebug.stseg
    Making Mercury/reg.gc.decldebug.stseg/x86_64-unknown-linux-gnu/Mercury/cs/cairo.c
    Uncaught Mercury exception:
    Software Error: transform_hlds.table_gen: predicate `transform_hlds.table_gen.type_save_category'/2: Unexpected: unexpected category
    ** Error making `Mercury/reg.gc.decldebug.stseg/x86_64-unknown-linux-gnu/Mercury/cs/cairo.c'.
    mmc --make libmercury_cairo.install
    I have tried both gcc-4.8.3 and gcc-4.9.1. My C library is glibc 2.19. My Cairo is version 1.12.16 and is located in /usr. (I adjusted Cairo.options to suit.)
    bug354.m (2,632 bytes) 2014-08-24 23:14
    https://bugs.mercurylang.org/file_download.php?file_id=222&type=bug
     
    Notes
    (0000763)
    juliensf   
    2014-08-24 23:15   
    The problem also occurs on the current master branch. I have uploaded a minimal test case for it.
    Affected grades seem to be all those containing a debug or decldebug component.
    (0000764)
    zs   
    2014-08-25 02:45   
    I/O tabling has two main purposes. The first and more important is to allow the debugger to replay parts of the program execution for the programmer, which requires making I/O operations idempotent (so that we get the same results on the second, third etc "execution" as on the first). The second purpose is to let the person using the debugger actually see a list of the I/O actions, and their results.

    I believe that the root of the problem here is that the compiler can do the second part only if it has access to the type_infos describing the types of the arguments of the I/O action. With the current infrastructure for representing typeclass information, this is not always possible in the presence of typeclass constraints on I/O action predicates. The reason is that polymorphism.m can hide the typeinfo for a type variable that is subject to a typeclass constraint arbitrarily deep inside the typeclass_info for that constraint, but the RTTI can encode such locations only up to a fixed depth (currently only the shallowest embedded is encodable). Rather than allow I/O tabling for SOME typeclass-constrained predicates but not others, the current system consistently does not allow it for any. Of course, the error indication could be better.

    When I designed the I/O tabling system, I did NOT design it for I/O actions whose types include typeclass constraints. There were two reasons for this. First, none of the I/O actions in the Mercury standard library have typeclass constraints; second, I/O actions are written in languages like C, which themselves have no class system.

    While fully fixing this limitation would be desirable, it would also be a huge amount of work. However, there are two possible short term fixes.

    The first fix is actually a simple workaround. I haven't tested it with mercury_cairo, but it works with bug354.m: simply compile the module with the mmc flag --trace-table-io-only-retry. This tells the compiler to generate I/O tabling code that serves only the first purpose I mentioned above (making I/O actions idempotent in mdb), but not the second (printing those actions in mdb).
    chemoelectric, please enable this flag for all the modules of mercury_cairo, and tell us what happens.

    The second possible fix, which I will look into in the next few days, would make this unnecessary by automatically imposing the effect of --trace-table-io-only-retry on any I/O predicates that have typeclass constraints on them.
    (0000765)
    juliensf   
    2014-08-25 03:30   
    The first workaround also works for the full mercury_cairo library. I'll add that workaround to the 14.01 branch.
    (0000767)
    chemoelectric   
    2014-08-26 04:00   
    The workaround works for me, too.
    (0000768)
    zs   
    2014-08-30 08:55   
    Fix committed 2014 aug 30.




    View Issue Details
    355 [mercury] Feature Request minor have not tried 2014-08-29 03:20 2014-08-29 03:20
    zs  
     
    none  
    new  
    open  
    none    
    none  
       
    it would be nice to be able to defer type errors till runtime
    This page shows how it can be done: https://www.haskell.org/ghc/docs/latest/html/users_guide/defer-type-errors.html

    The basic idea is: report a warning instead of an error, and replace the code that has the type error with code that throws an exception.
     
    There are no notes attached to this issue.




    View Issue Details
    350 [mercury] Bug minor always 2014-08-05 17:36 2014-08-25 14:39
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    winpthreads support
    Currently threaded grades are unsafe if using winpthreads with mingw-w64, which is different from pthreads-win32. We build Boehm GC with -DGC_WIN32_THREADS (i.e. Win32 API) but the Mercury runtime still creates threads using the pthread API without registering them with the GC.

    A (tiny) change will allow building Boehm GC with winpthreads. We'll try to get that upstream, and then we should upgrade.
     
    Notes
    (0000752)
    juliensf   
    2014-08-05 18:15   
    Can we make the tiny change to the 14.01 branch ourselves, since we won't be upgrading the GC on that?
    (0000753)
    wangp   
    2014-08-06 10:28   
    We can do that.
    (0000754)
    juliensf   
    2014-08-06 10:34   
    Incidentally, I think Paul was looking at upgrading the GC on the master branch. I'm not sure how far he got with that though.
    (0000766)
    wangp   
    2014-08-25 14:39   
    Winpthreads support exists upstream and in our branch.




    View Issue Details
    353 [mercury] Bug minor always 2014-08-19 11:11 2014-08-19 11:11
    wangp  
    wangp  
    normal  
    assigned  
    open  
    none    
    none  
       
    misuse of tabled_for_io in the standard library
    dir.open_2 is tabled_for_io but is a non-primitive I/O operation as it directly calls dir.read_first_entry. It should leave that to the Mercury code in dir.open to do.

    Foreign procs marked tabled_for_io should not throw exceptions. The throws should be deferred until back in Mercury code.
     
    There are no notes attached to this issue.




    View Issue Details
    351 [mercury] Bug minor always 2014-08-08 17:47 2014-08-12 19:50
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    abort compiling integer.m with parallel conjunction
    The master branch fails to bootcheck for me at -O5 --intermod-opt in asm_fast.gc, after the commit[1] which introduces a parallel conjunction to integer.m. The error log is attached.

    The 14.01 branch seems fine.

    [1] cb161d615520c277a90a74de3a13682b20cc0a7e
    integer.err (5,322 bytes) 2014-08-08 17:47
    https://bugs.mercurylang.org/file_download.php?file_id=220&type=bug
     
    Notes
    (0000756)
    juliensf   
    2014-08-08 19:53   
    For the moment you can just replace the parallel conjunction with a sequential one -- Paul was going to take a look further look at that parallel conjunction anyway, so I guess this is just something else for him to do as well ;-)
    (0000757)
    zs   
    2014-08-08 20:42   
    The error message indicates a problem in the LLDS code generator, or in the HLDS being fed into it. I will take a look.
    (0000759)
    zs   
    2014-08-12 19:49   
    Fix committed aug 11.
    (0000760)
    zs   
    2014-08-12 19:50   
    Fix committed aug 11.




    View Issue Details
    349 [mercury] Bug minor always 2014-07-22 15:44 2014-07-28 15:48
    wangp  
     
    normal  
    new  
    open  
    none    
    none  
       
    io stream predicates thread-safe or not
    Programs which use different streams in different threads should not be unnecessarily serialised on the global lock. But I think it's also quite likely that users write to the same stream, stdout or stderr, from different threads without explicit synchronisation. This can produce garbled output but it basically works, at least for testing, so I think it needs to be allowed.

    The underlying I/O routines (probably) have their own locking, but we also perform our own bookkeeping, like line counts, with the protection of the global lock. To safely mark the io procedures as `thread_safe' then requires per-stream locks or perhaps the use of atomic operations.
     
    Notes
    (0000751)
    wangp   
    2014-07-28 15:48   
    In POSIX and Windows, the stdio stream functions are thread-safe, protected by per-stream locks. The only extra book-keeping we actually do is the line number tracking. We do stuff like MR_line_number(*mf)++; without any synchronisation sometimes, which could be a problem but I think unlikely.

    To solve it, we could acquire the stream lock manually with flockfile, call the *_unlocked function (where possible), update the line number while holding the stream lock, then call funlockfile.

    MSVC has *_nolock functions but I don't see any functions to manually acquire the stream lock. We would probably need our own locks there.

    It's probably not worth the effort.




    View Issue Details
    345 [mercury] Bug minor always 2014-07-11 17:14 2014-07-14 10:20
    wangp  
     
    low  
    new  
    open  
    none    
    none  
       
    name mangling produces very long symbols
    gcc 4.2.0 on on AIX 7.1 happens to crash on very long symbols. I suspect there is a fixed size buffer somewhere about 256 bytes long.

    While this is not a bug in Mercury, we may want to use a different name mangling algorithm which produces shorter and, preferably, more readable symbols, e.g. only escaping the characters which are not allowed in C identifiers.
     
    Notes
    (0000740)
    juliensf   
    2014-07-11 20:13   
    Is that a limitation of that version of GCC (which is quite old), or is it a more fundamental restriction (e.g. the linker only accepts symbol names of a certain length)?
    (0000741)
    wangp   
    2014-07-14 10:15   
    That version of gcc crashes during compilation. xlc deals with it fine, and so does the linker.
    (0000742)
    juliensf   
    2014-07-14 10:20   
    Can you not just use a more recent version of GCC (i.e one that isn't eight years old)?

    In relation to name mangling, we should probably revisit this anyway since there are a series of bugs
    with the other backends in relation to it as well.




    View Issue Details
    125 [mercury] Bug minor always 2010-01-06 15:40 2014-07-10 17:28
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    thread.spawn should spawn OS thread in low-level C grades
    In low-level C grades, thread.spawn creates a new context but not a OS thread. The idea was to multiplex contexts onto OS threads, but this isn't implemented and won't work unless you use non-blocking I/O everywhere, including in user-defined foreign procs. We should just create a new OS thread, as we do in high-level C grades.
     
    Notes
    (0000238)
    pbone   
    2010-01-06 16:02   
    This will be non-trivial to implement.

    In many recent changes to the runtime we've assumed that engines can only be created at initialization time and that the number of engines running will always be constant. I don't see this going away anytime soon, In particular some optimizations I'd like to make to work stealing rely on this assumption.

    GHC handles this differently, when code makes any foreign call the engine that it was using becomes 'freed' while the foreign call is in progress, then the existing engine can pick up other available work. This allows them to do concurrent IO without the programmer having to wrap their head around asynchronous system calls. More performance is probably available by using asynchronous system calls though. This will also be non-trivial for us to implement but it won't harm any assumptions that I (personally) like.

    I would like to see our runtime handle asynchronous IO nicely while isolating the C foreign procedure writer from worrying about this. I'd also like to see Mercury and other pure languages use mmap() for reading and writing files more often, hopefully we can worry about buffering less and let the kernel handle this - Manipulating buffers in a pure language is not pretty. Of course this would become difficult when using network sockets as I don't think they support mmap().
    (0000239)
    wangp   
    2010-01-06 16:26   
    If it comes down to it, could we not distinguish parallel-conjunction-capable engines/threads from the threads created by thread.spawn? Eventually spawned threads should be capable of running code containing parallel conjunctions, but right now one feature is a research project, the other is practical, and the two don't have to meet just yet. It's the last resort, though.
    (0000240)
    pbone   
    2010-01-06 16:44   
    What should the runtime behavior be when a non parallel conjunction capable engine executes a parallel conjunction?

    It sounds like this is just a work around for asynchronous IO, which is the real problem here. Fixing asynchronous IO is the better long-term solution.
    (0000241)
    wangp   
    2010-01-06 17:16   
    Abort?

    Asynchronous IO might be fine when you can get it (I don't know), but outside of the standard library there are a lot of functions that you might want to call which have no asynchronous equivalent.
    (0000738)
    wangp   
    2014-07-10 17:28   
    Added thread.spawn_native.




    View Issue Details
    3 [mercury] Bug minor always 2007-09-27 23:33 2014-07-10 14:01
    anonymous  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    deep profiler bug with unify/compare for tuples
    The following was orginally reported by Peter Wang on the mercury-bugs list.
    -----------------------------------------------------------------

    Hi,

    Here's a test case for a bug in the deep profiler. I think the problem
    is in the unification or comparison of a type T which contains a
    (non-singleton) tuple which contains T, e.g.

        :- type node
            ---> node(
                        set({node, resource})
                    ).

    You need to enable this line in mercury_deep_call_port_body.h to
    make the bug more obvious:

      #ifdef MR_DEEP_PROFILING_LOWLEVEL_DEBUG
        /* After we copy it, MR_next_call_site_dynamic is not meaningful; */
        /* zeroing it makes debugging output less cluttered. */
        MR_next_call_site_dynamic = NULL;
      #endif

    Unification or comparison involving values of that type will then
    segfault, as it tries to dereference MR_next_call_site_dynamic when it
    is NULL.

    I think what happens is that mercury_unify_compare_body.h merges
    together the code for for call and exit ports, with the assumption that
    no further calls will be made. However, in the MR_TYPECTOR_REP_TUPLE
    case MR_generic_compare/unify will be called for each of the arguments,
    thereby entering call/exit ports with the deep profiler invariants been
    broken. Uncommenting that line above makes it obvious when that
    happens, as MR_next_call_site_dynamic will be clobbered after comparing
    the first subtype of the tuple, and not setting it up before comparing
    the next argument.

    The strange thing is, if the tuple is replaced by a d.u. type then
    things seem to work, although the code for tuples and du's seem pretty
    much the same. So I may be wrong.

    Peter

    %-----------------------------------------------------------------------------%

    :- module cc.
    :- interface.

    :- import_module io.

    :- pred main(io::di, io::uo) is det.

    %-----------------------------------------------------------------------------%
    %-----------------------------------------------------------------------------%

    :- implementation.

    :- import_module set.

    %-----------------------------------------------------------------------------%

    :- type resource
        ---> uri(string).

    :- type tuple(T, U) == {T, U}.
    %:- type tuple(T, U) ---> tuple(T, U).

    :- func mk(T, U) = tuple(T, U).

    mk(T, U) = {T, U}.
    %mk(T, U) = tuple(T, U).

    :- type node
        ---> node(
                    set(tuple(node, resource))
                ).

    %-----------------------------------------------------------------------------%

    main(!IO) :-
        Child = node(
            set.init
        ),
        A = node(
            set.make_singleton_set(mk(Child, uri("foo")))
        ),
        B = node(
            set.make_singleton_set(mk(Child, uri("bar")))
        ),
        write_string("#################\n", !IO),

    % ( unify(A, B) ->
    % io.write_string("unify\n", !IO)
    % ;
    % io.write_string("not unify\n", !IO)
    % ),

        compare(R, A, B),
        io.print(R, !IO),
        io.nl(!IO),

        write_string("################# done\n", !IO).


    %-----------------------------------------------------------------------------%
    % vim: ft=mercury ts=8 sw=4 et wm=0 tw=0
     
    Notes
    (0000731)
    wangp   
    2014-07-02 11:26   
    In mercury_unify_compare_body.h, for case MR_TYPECTOR_REP_TUPLE: there are calls to MR_generic_compare and MR_generic_unify inside a loop (for each type argument). For the first argument, MR_next_call_site_dynamic was set up by the caller. For the second and subsequent arguments, the equivalent of prepare_for_special_call is never called, and so MR_next_call_site_dynamic is either stale or nulled out.

    Does that make sense?
    (0000732)
    pbone   
    2014-07-02 11:48   
    From what I remember about the deep profiler (it's been a while) Yes, that makes sense.
    (0000733)
    wangp   
    2014-07-03 12:35   
    More notes.

    mercury_builtin_types.c has this comment:

    ** The generic unify, compare and compare_rep predicates do different things
    ** for different kinds of type constructors, but these things all fall into
    ** one of two categories: either the implementation is entirely in C code,
    ** or the implementation is a tailcall to a Mercury predicate. In neither
    ** case do the generic predicates allocate a stack frame, which is why
    ** the stack traversal component of the procedure layouts won't ever be
    ** referenced.

    The first part is not true for tuple types, I think. (There are also recursive calls to MR_generic_compare/etc. in the compare_representation paths.)

    In mercury_unify_compare_body.h the return_unify_answer and return_compare_answer macros call special_pred_call_leave_code which merges together the deep profiling "callcode" and "exitcode", which seems to be another instance of that same assumption. The MR_TYPECTOR_REP_TUPLE case would need to avoid doing that as well.

    Since that file is already so hairy, another option I considered is to write the tuple unify/compare predicates in Mercury, and let the compiler transform the predicates in deep profiling grades (seems to work in my test). However that introduces a dependency from the runtime into the library.
    (0000737)
    wangp   
    2014-07-10 14:01   
    Finally.




    View Issue Details
    344 [mercury] Bug minor always 2014-07-05 02:09 2014-07-05 02:30
    nx2059123 x86_64  
    CentOS Linux  
    normal 5  
    new  
    open  
    none    
    none  
       
    Cannot find files when compiling with --debug option
    When you try to compile a file with the --debug option you get an error.
    Various files are not found when compiling with the --debug option

    [mercury-user@localhost mercury]$ mmc --debug ./hello.m
    mkinit: error opening file `/home/mercury-user/local/lib/mercury/modules/asm_fast.gc.debug/mer_rt.init': No such file or directory
    mkinit: error opening file `/home/mercury-user/local/lib/mercury/modules/asm_fast.gc.debug/mer_std.init': No such file or directory
    mkinit: error opening file `/home/mercury-user/local/lib/mercury/modules/asm_fast.gc.debug/mer_browser.init': No such file or directory
    mkinit: error opening file `/home/mercury-user/local/lib/mercury/modules/asm_fast.gc.debug/mer_mdbcomp.init': No such file or directory
    [mercury-user@localhost mercury-srcdist-14.01]$ pwd
    /home/mercury-user/local/src/mercury-srcdist-14.01

    [mercury-user@localhost mercury-srcdist-14.01]$ uname -a
    Linux localhost.localdomain 2.6.32-431.20.3.el6.x86_64 0000001 SMP Thu Jun 19 21:14:45 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

    [mercury-user@localhost mercury-srcdist-14.01]$ gcc --version
    gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4)
    Copyright (C) 2010 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    [mercury-user@localhost mercury-srcdist-14.01]$ ./configure --prefix=$HOME/local

    config.status: executing default commands

    the set of library grades to install will be
       asm_fast.gc
       asm_fast.gc.debug.stseg
       asm_fast.gc.decldebug.stseg
       asm_fast.gc.memprof
       asm_fast.gc.prof
       asm_fast.gc.profdeep
       asm_fast.gc.trseg
       asm_fast.gc.trseg.debug.stseg
       asm_fast.par.gc.stseg
       hlc.gc
       hlc.gc.trseg
       hlc.par.gc

    Configuring to install 12 grades.
    This will likely take 2 to 6 hours.
    You can make the install faster by installing fewer grades
    as shown by the fine-tuning section of the INSTALL file or by
    compiling the files of each grade in parallel which you can do
    via a command such as make PARALLEL=-j2 install.
    [mercury-user@localhost mercury-srcdist-14.01]$


    [mercury-user@localhost mercury-srcdist-14.01]$ make
    [mercury-user@localhost mercury-srcdist-14.01]$ make install

    -- Installation complete.

    -- Don't forget to add /home/mercury-user/local/bin to your PATH,
    -- /home/mercury-user/local/man to your MANPATH,
    -- and /home/mercury-user/local/info to your INFOPATH,
    -- to copy deep_profiler/mdprof_cgi to /usr/lib/cgi-bin,
    -- and to add the following lines to the `.emacs' file
    -- in your home directory:
        (add-to-list 'load-path
            "/home/mercury-user/local/lib/mercury/elisp")
        (autoload 'mdb "gud" "Invoke the Mercury debugger" t)
    gmake[1]: Leaving directory `/home/mercury-user/local/src/mercury-srcdist-14.01'
    [mercury-user@localhost mercury-srcdist-14.01]$

    [mercury-user@localhost mercury]$ mmc --debug ./hello.m
    mkinit: error opening file `/home/mercury-user/local/lib/mercury/modules/asm_fast.gc.debug/mer_rt.init': No such file or directory
    mkinit: error opening file `/home/mercury-user/local/lib/mercury/modules/asm_fast.gc.debug/mer_std.init': No such file or directory
    mkinit: error opening file `/home/mercury-user/local/lib/mercury/modules/asm_fast.gc.debug/mer_browser.init': No such file or directory
    mkinit: error opening file `/home/mercury-user/local/lib/mercury/modules/asm_fast.gc.debug/mer_mdbcomp.init': No such file or directory

    % hello.m
    :- module hello.
    :- interface.
    :- import_module io.
    :- pred main(io::di, io::uo) is det.
     
    :- implementation.
    main(!IO) :-
         io.write_string("Hello, World!\n", !IO).
     
    Notes
    (0000734)
    juliensf   
    2014-07-05 02:30   
    The --debug option just adds the debug grade component to the currently selected grade, so it's looking for the grade asm_fast.gc.debug which isn't one of the ones installed on your system. Do:

        mmc --grade asm_fast.gc.debug.stseg hello.m

    or:

        mmc --debug --stack-segments hello.m

    to select the asm_fast.gc.debug.stseg grade (which is installed).




    View Issue Details
    334 [mercury] Bug major sometimes 2014-06-16 12:10 2014-06-30 15:06
    pbone x86_64  
    pbone Debian Linux  
    high jessie or sid  
    resolved  
    fixed  
    none    
    none  
       
    Low level C parallel grades crash with libc6 > 2.19.x and newer Intel processors
    Intel's latest processors include some transactional memory support instructions (TSX). These can be used to implement lock free data structures and can also be used to implement more traditional locking primitives such as mutexes. Specifically new versions of eglibc use this to implement lock elision for pthreads mutexes: http://lwn.net/Articles/534758/ If you have a supported processor eglibc will use this by default.

    There has been a dormant bug in Mercury (or possibly Boehm GC) that now shows up since I upgraded to libc6 2.19.1, I use a Intel i7-4770 which has the TSX feature and now some parallel Mercury programs crash. A GP fault is thrown by some code in the pthreads library.
    Using an Intel i7-4770 processor (without a K suffix), and eglibc 2.19.1 build Mercury with GRADE=asm_fast.gc.par.stseg in the Mmake.params file (I was doing this to test parallel profiling). The resulting compiler will intermittently crash.
    Mercury is not the only program to have a bug like this show up with the new libc. libtirpc has a similar problem. If you use Debian testing and NFS (or anything with portmap), then upgrading libtirpc from sid will fix this.
     
    Notes
    (0000722)
    pbone   
    2014-06-30 15:06   
    Committed a workaround.




    View Issue Details
    340 [mercury] Bug minor always 2014-06-23 16:17 2014-06-25 17:36
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    strerror not thread-safe
    io.m uses strerror in a couple of cases as if it is thread-safe when it is not, and probably there are other cases in the runtime. An alternative is strerror_r, or strerror_s on Windows. I think we should create a wrapper MR_strerror around both, and forget about trying to lock around uses of strerror().
     
    Notes
    (0000703)
    juliensf   
    2014-06-23 16:22   
    Agreed.




    View Issue Details
    338 [mercury] Bug minor always 2014-06-20 17:58 2014-06-25 17:35
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    asm_fast.par.gc programs crash on Windows
    Strangely enough it works as long as I set MERCURY_OPTIONS=-Pn so it's probably something with the CPU detection. Filing this so I don't forget.
     
    There are no notes attached to this issue.




    View Issue Details
    342 [mercury] Bug major always 2014-06-24 16:03 2014-06-25 16:39
    juliensf  
    juliensf  
    urgent  
    resolved  
    fixed  
    none    
    none  
       
    string.format broken in non-C grades
    The attached program should print "16.0"; when using the Mercury implementation of format
    (i.e when using_sprintf returns false), it prints "10.0". This affects all of the non-C backends.
    fmt_bug.m (284 bytes) 2014-06-24 16:03
    https://bugs.mercurylang.org/file_download.php?file_id=217&type=bug
     
    Notes
    (0000706)
    juliensf   
    2014-06-24 16:05   
    This is derived from tests/general/float_test and appears to be the reason for the failure of that
    test with non-C backends.
    (0000707)
    juliensf   
    2014-06-24 16:14   
    The strings above should be "16" and "10" respectively.
    (0000708)
    wangp   
    2014-06-24 16:31   
    At least part of the bug can be attributed to commit b1af59cb29ac31db9fc5b3422fced505facabad1
    where the replacement of string.substring was replaced by string.between incorrectly.
    (0000709)
    juliensf   
    2014-06-24 16:54   
    Yes, that commit introduced an off-by-one error at string.m:4038. Fixing that fixes the problem.
    I'll commit a fix after I run some further tests to see if anything else is broken.
    (0000710)
    juliensf   
    2014-06-25 16:39   
    Fix committed.




    View Issue Details
    341 [mercury] Bug minor always 2014-06-24 05:58 2014-06-24 11:40
    nx2059 MingW32  
    juliensf Windows  
    normal 8.1  
    resolved  
    no change required  
    none    
    none  
       
    MingW32 Build Errors
    Various unknown types cause errors on builds (off64_t, off_t, etc..)
    $ cd mercury-srcdist-14.01

    $ gcc --version
    gcc.exe (GCC) 4.8.1
    Copyright (C) 2013 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    $./configure --disable-most-grades

    $make

    ...

    make[2]: Leaving directory `/src/mercury-srcdist-14.01/robdd'
    /tmp/mmake.YhJAkb:1045: warning: undefined variable `DESTDIR'
    cd library && PATH=../scripts:../util:../mfilterjavac:../../mfilterjavac:$PATH M
    MAKE_VPATH=. MMAKE_DIR=../scripts DESTDIR= ../scripts/mmake
    make[2]: Entering directory `/src/mercury-srcdist-14.01/library'
    ../scripts/mgnuc --grade hlc.gc.pregen -- -c tree234.c -o tree234.o
    In file included from c:\mingw\include\unistd.h:36:0,
                     from ../runtime/mercury_timing.h:23,
                     from benchmarking.m:163,
                     from tree234.c:32:
    c:\mingw\include\io.h:301:1: error: unknown type name 'off64_t'
     __CRT_INLINE off64_t lseek64 (int, off64_t, int);
     ^
    c:\mingw\include\io.h:301:36: error: unknown type name 'off64_t'
     __CRT_INLINE off64_t lseek64 (int, off64_t, int);
                                        ^
    c:\mingw\include\io.h:302:1: error: unknown type name 'off64_t'
     __CRT_INLINE off64_t lseek64 (int fd, off64_t offset, int whence) {
     ^
    c:\mingw\include\io.h:302:39: error: unknown type name 'off64_t'
     __CRT_INLINE off64_t lseek64 (int fd, off64_t offset, int whence) {
                                           ^
    In file included from ../runtime/mercury_timing.h:23:0,
                     from benchmarking.m:163,
                     from tree234.c:32:
    c:\mingw\include\unistd.h:65:20: error: unknown type name 'off_t'
     int ftruncate(int, off_t);
                        ^
    c:\mingw\include\unistd.h:67:38: error: unknown type name 'off_t'
     __CRT_INLINE int ftruncate(int __fd, off_t __length)
                                          ^
    make[2]: *** [tree234.o] Error 1
    make[2]: Leaving directory `/src/mercury-srcdist-14.01/library'
    make[1]: *** [library] Error 2
    make[1]: Leaving directory `/src/mercury-srcdist-14.01'
    make: *** [all] Error 2



     
    Notes
    (0000704)
    juliensf   
    2014-06-24 11:40   
    This has been fixed in the latest 14.01.1 beta release -- the problem is that
    the MinGW headers are broken when compiling with -ansi.




    View Issue Details
    337 [mercury] Bug minor always 2014-06-20 10:58 2014-06-20 10:58
    wangp  
     
    low  
    new  
    open  
    none    
    none  
       
    csharp stream problems
    In the csharp backend (with mono), io.read_char returns immediately after one character instead of waiting for a whole line first. io.read_char returns 0 for some unprintable characters, e.g. backspace, delete. This also makes io.read_line_as_string return an error as soon as you hit backspace while editing a line.

    Maybe we need to switch to buffered streams in csharp.
     
    There are no notes attached to this issue.




    View Issue Details
    330 [mercury] Bug minor always 2014-05-26 10:43 2014-05-27 16:33
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    slice directory does not build in debugging grade
    SLICE_FLAGS contains --force-disable-tracing

    After commit 5254245ae34ab6b3ca0f7dcd3c7fc807e1407f7d "Eliminate some unnecessary labels in low level grades." the modules in the slice directory no longer compile with GRADE=asm_fast.gc.debug, producing errors like:

    mdbcomp.goal_path.c:2847:2: error: label ‘_entry_mercury__fn__mdbcomp__goal_path__goal_path_add_at_end_2_0_i7’ used but not defined
    mdbcomp.goal_path.c (270,554 bytes) 2014-05-27 10:34
    https://bugs.mercurylang.org/file_download.php?file_id=214&type=bug
     
    Notes
    (0000686)
    zs   
    2014-05-26 20:18   
    I cannot reproduce the problem, but this may be because the original report is unclear.

    If I leave the --force-disable-tracing in SLICE_FLAGS, I see neither a use or a definition of_entry_mercury__fn__mdbcomp__goal_path__goal_path_add_at_end_2_0_i7 in mdbcomp.goal_path.c.

    If I remove the --force-disable tracing from SLICE_FLAGS (after mmake depend and before just mmake in the slice directory, with GRADE=asm_fast.gc.debug in ../Mmake.params), I see both a definition and a use of that same label.

    Can you please tell me the exact sequence of actions needed to reproduce the problem?
    (0000687)
    wangp   
    2014-05-27 10:36   
    mmc -v
    Mercury Compiler, version 14.01.1-beta-2014-05-06, configured for x86_64-unknown-linux-gnu

    echo GRADE=asm_fast.gc.debug > Mmake.params
    aclocal -I m4 && autoconf && ./configure
    mmake -j6
    cd slice
    mmake


    I see in the generated C code that there are MR_init_label* lines for labels which were, presumably, eliminated. I have uploaded mdbcomp.goal_path.c
    (0000688)
    juliensf   
    2014-05-27 12:22   
    I don't think commit 8c72b1e5c0c23353770c494bcdf35a450ebf7c85 has been merged on to the 14.01
    branch, so that may be the problem here.
    (0000689)
    wangp   
    2014-05-27 12:43   
    That appears to be it. It cherry-picks cleanly onto the 14.01 branch. Should I do that?
    (0000690)
    wangp   
    2014-05-27 12:55   
    Or revert 5254245ae34ab6b3ca0f7dcd3c7fc807e1407f7d on 14.01 as it should not have been merged in the first place.
    (0000691)
    juliensf   
    2014-05-27 13:14   
    (Last edited: 2014-05-27 13:18)
    Given the length of time the original change has been on the 14.01 branch (mostly without incident!) I would be inclined to leave it there and merge 8c72b1e5c0c23353770c494bcdf35a450ebf7c85 onto the branch.

    (0000692)
    wangp   
    2014-05-27 15:31   
    Ok.

    The no_refs_to_deleted_labels test case is problematic (also on the master branch). It passes -DMR_LOWLEVEL_DEBUG which implies MR_DEBUG_GOTOS, but the runtime may not have been built with MR_DEBUG_GOTOS. There are some undefined symbol errors when linking (e.g. to MR_goto_msg).
    (0000693)
    juliensf   
    2014-05-27 15:39   
    With reference to the last bit, that looks wrong, MR_DEBUG_GOTOS should only be defined if
    MR_LOWLEVEL_DEBUG && MR_USE_GCC_NONLOCAL_GOTOS.

    (I would guess that no-one has used low-level debugging in a non asm_fast grade for a while
    so it's probably just bitrot.)
    (0000694)
    wangp   
    2014-05-27 15:44   
    MR_DEBUG_LABEL_NAMES implies MR_INSERT_LABELS without implying MR_DEBUG_GOTOS.
    (0000695)
    juliensf   
    2014-05-27 15:49   
    Or that.




    View Issue Details
    322 [mercury] Bug minor always 2014-03-24 13:49 2014-05-15 13:28
    wangp  
     
    normal  
    new  
    open  
    none    
    none  
       
    mingw-w64 compiled program crashes
    Mercury 14.01 branch

    Cross-compiling with x86_64-w64-mingw32-gcc from Ubuntu
    gcc version 4.6.3 (GCC)

    For the given (small) test program:

    asm_fast.gc CRASH
    asm_jump.gc OK
    reg.gc OK
    none.gc OK
    hlc.gc OK
    bug.m (204 bytes) 2014-03-24 13:49
    https://bugs.mercurylang.org/file_download.php?file_id=207&type=bug
     
    Notes
    (0000655)
    wangp   
    2014-03-25 11:03   
    I also tried gcc 4.8.2 as built from the MXE project. The results for the same test case are:

    asm_fast.gc OK
    asm_jump.gc CRASH
    reg.gc OK
    none.gc OK

    For a bigger program (prince) the results are:

    asm_fast.gc CRASH
    asm_jump.gc CRASH
    reg.gc OK
    none.gc OK

    I'm not going to chase this any further now, but we should document the problem in the readme.
    (0000683)
    juliensf   
    2014-05-13 15:34   
    Have you tried the native Windows versions of GCC with this, or just the cross-compiler?
    (0000684)
    wangp   
    2014-05-13 15:52   
    I'm pretty sure I did.
    (0000685)
    juliensf   
    2014-05-15 13:28   
    asm_fast.gc is ok with gcc 4.8.1 (mingw-builds package).




    View Issue Details
    329 [mercury] Bug crash always 2014-05-11 14:09 2014-05-13 15:33
    lpimmes Maverick 10.9  
    juliensf OS X  
    urgent  
    resolved  
    duplicate  
    none    
    none  
       
    Uncaught Mercury exception:
    -library-version 1.0.2411.0 --host-env-type posix --target-env-type posix --unboxed-float -O2 --make --fully-strict -E -v -O 6 --use-subdirs --search-lib-files-dir . --init-file stringCut_lib.init --link-object libstringCut_lib.a --compile-to-c --use-subdirs stringCut'
    Uncaught Mercury exception:
    Software Error: map.lookup: key not found
        Key Type: string
        Key Value: "cutInfo"
        Value Type: tree234.tree234(parse_tree.prog_data.type_ctor, hlds.hlds_data.hlds_type_defn)
    % Touching `Mercury/err_dates/stringCut.err_date'... done.
    % Parsing module `stringCut' and imported interfaces...
    % Module qualifying items...
    % done.
    Unzip strgCut.zip
    >make
    ... error appears

    -------
    Any ideas? Help would be appreciated.
    stringCut_lib.m compiles OK
    stringCut.m did compile this morning. Added cutInfo tracking.
    Thanks.
    strgCut.zip (4,568 bytes) 2014-05-11 14:09
    https://bugs.mercurylang.org/file_download.php?file_id=213&type=bug
     
    Notes
    (0000680)
    wangp   
    2014-05-12 18:05   
    The interface of stringCut_lib mentions the type cutInfo but does not export it as an abstract type, i.e.

    :- type cutInfo.

    It is surprising that the compiler does not report an error.
    (0000681)
    lpimmes   
    2014-05-12 21:27   
    Indeed, it works, i.e., compile and links, now!
    Thank so much.




    View Issue Details
    327 [mercury] Bug minor always 2014-04-30 11:05 2014-05-13 15:28
    juliensf  
    juliensf  
    normal  
    resolved  
    no change required  
    none    
    none  
       
    incorrect binutils used with mingw64
    Some MinGW64 installations name include "gcc" in the name of the ranlib executable, as in

      x86_64-w64-mingw32-gcc-ranlib

    When host is set to x86_64-w64-mingw32 the configure script looks for x86_64-w64-mingw32-ranlib, but not the above. (On my system it falls back to using ranlib, which is incorrect since that's the
    32-bit version.)

    Ditto for ar and nm.
    A workaround is to manually specify the names of ar, ranlib and nm to configure using the variables
    AR, RANLIB and NM, for example:

    AR=x86_64-w64-mingw32-gcc-ar RANLIB=x86_64-w64-mingw32-gcc-ranlib NM=x86_64-w64-mingw32-gcc-nm ./configure ... etc
     
    Notes
    (0000666)
    wangp   
    2014-04-30 11:44   
    Seems that gcc-ar/nm/ranlib are relatively new wrappers over ar/nm/ranlib (something about LTO) and not specific to MinGW.
    (0000667)
    juliensf   
    2014-04-30 12:27   
    They are spectacularly not useful on the MinGW64 installation on Windows that I have since all they do is report that "sorry -- this program has been built without plugin support".

    Fortunately, I can build by not setting --host at all and just using the ar, ranlib etc.
    (I have a nasty feeling that this is inconsistent with my other MinGW64 installation.)

    I will update README.MinGW once I work out what current MinGW64 builds / GCC are actually doing here.

    Peter: does this affect the cross compilation stuff?
    (0000668)
    wangp   
    2014-04-30 14:26   
    My mingw cross-compiler installations have the ${host}-ar/nm/ranlib programs, in addition to ${host}-gcc-ar/nm/ranlib. The latter are useless as you say.

    Actually, my Linux installation also does not have the x86_64-slackware-linux-{nm,ar,ranlib} symlinks. Running ./configure --host=x86_64-slackware-linux also falls back to the unprefixed programs. So your native MinGW64 installation is probably normal.
    (0000669)
    juliensf   
    2014-04-30 14:40   
    I have (at least) two native MinGW64 installations; the older one does not have any unprefixed tools,
    the latter has both except that ar/nm/ranlib are not available except in their gcc- prefixed form.
    (0000673)
    juliensf   
    2014-05-01 14:48   
    There are currently spots, for example determining the value of CFLAGS_FOR_THREADS, where
    we assume that x86_64 builds for Windows are configured using --host=x86_64-w64-mingw32.
    (0000674)
    juliensf   
    2014-05-01 15:55   
    (Last edited: 2014-05-01 15:56)
    When compiling under MSYS (the normal MinGW one) with the unprefixed versions of the MinGW64 tools,
    you need invoke configure with --build=x86_64-w64-mingw32.

    If your MinGW64 installation has only the prefixed versions of the tools then you need to invoke configure
    with --host=x86_64-w64-mingw32. (In this case the difference between --build and --host will
    force autoconf to attach the prefix to the tools it looks for.)

    What you must *not* do on a system with unprefixed MinGW64 tools is simply invoke configure.
    That will set MERCURY_TARGET_ARCH to i686-pc-mingw32 which will (most probably) result in
    a broken installation.

    (0000682)
    juliensf   
    2014-05-13 15:28   
    After some experimentation, it's ok to pass just

       --host=x86_64-w64-mingw32

    to configure on MinGW64 systems with unprefixed tools (At least so long as the MinGW64 bin directory
    is in your PATH before the MinGW one).




    View Issue Details
    328 [mercury] Bug tweak always 2014-05-01 17:19 2014-05-01 20:05
    pbone All  
    All  
    low All  
    new  
    open  
    none    
    none  
       
    dir.foldl2 should be called dir.fold2
    The foldl functions and predicates in the dir module do not guarantee any specific order. Therefore the l (indicating left) in their name is a misnomer. The should be deprecated in favor of names without the 'l'.
     
    Notes
    (0000675)
    juliensf   
    2014-05-01 17:49   
    I disagree. An order is guaranteed, it's just not specified what it is since the actual order is OS (and probably in our case target language) dependent. However, there is an order there and foldl2 goes from first to last in that order. (It doesn't, example, go from last to first.)

    Indeed the definition of the C function readdir (which we use to implement foldl2 on POSIX systems) says:

          The type DIR, which is defined in the <dirent.h> header, represents a directory stream, which is an
          ordered sequence of all the directory entries in a particular directory.
          ^^^^^^
    (0000676)
    pbone   
    2014-05-01 17:59   
    I'm not convinced. Given that the order is undefined, I really don't see the point in saying we start at it's beginning.

    I choose to report this because I quickly looked at the docs, and then in my code i wrote "dir.fold2", because that's what makes sense. The compiler prompted me to change it. This suggests to me that "fold2" is the natural way to think about this.
    (0000677)
    juliensf   
    2014-05-01 20:05   
    Undefined is not the same as system dependent, which is what this is. If you think the fold versions would be useful synonyms then feel free to add them, but I think deprecating the foldl versions is just change for the sake of change. (I suggest you also change the documentation to say that the order is OS dependent or words to that effect.)




    View Issue Details
    323 [mercury] Bug minor always 2014-04-02 22:53 2014-04-03 01:21
    bwitkowski Linux  
    Debian  
    normal wheezy (7.0)  
    new  
    open  
    none    
    none  
       
    Matching on adts makes and instantiation state subtyping is impossible.
    Matching on a subtype doesn't carry the information about the inst of the subtype which makes using pattern matching and instantiation state subtyping impossible to use. See the attached file for details.
    $ mmc --version
    Mercury Compiler, version 13.05.2, configured for x86_64-unknown-linux-gnu
    Copyright (C) 1993-2013 The University of Melbourne

    $ mmc -E subtyping.m
    subtyping.m:019: In clause for `use_everything(in, out)':
    subtyping.m:019: mode error in conjunction. The next 2 error messages
    subtyping.m:019: indicate possible causes of this error.
    subtyping.m:019: In clause for `use_everything(in, out)':
    subtyping.m:019: in argument 1 of call to predicate `subtyping.use_bar'/2:
    subtyping.m:019: mode error: variable `Bar' has instantiatedness `ground',
    subtyping.m:019: expected instantiatedness was
    subtyping.m:019: `bound(subtyping.bar(ground))'.
    subtyping.m:019: In clause for `use_everything(in, out)':
    subtyping.m:019: in argument 2 of clause head:
    subtyping.m:019: mode error in unification of `HeadVar__2' and `String'.
    subtyping.m:019: Variable `HeadVar__2' has instantiatedness `free',
    subtyping.m:019: variable `String' has instantiatedness `free'.
    subtyping.m (491 bytes) 2014-04-02 22:53
    https://bugs.mercurylang.org/file_download.php?file_id=208&type=bug
     
    Notes
    (0000656)
    juliensf   
    2014-04-03 01:09   
    You can work around the above problem by rewriting the predicate use_everything/2 to use a single clause, for example:

       use_everything(Foo, String) :-
           (
               Foo = bar(_),
               use_bar(Foo, String)
           ;
               Foo = baz(_),
               String = "baz"
           ).
    (0000657)
    bwitkowski   
    2014-04-03 01:17   
    (Last edited: 2014-04-03 01:21)
    Interesting, thank you very much! Paul Bone on #mercury irc also suggested deconstructing and reconstructing bar like:

    use_everything(bar(X), String) :- use_bar(bar(X), String).

    which works too. Still I think that, ideally, this should also work in pattern matching in multiple clauses(?).





    View Issue Details
    303 [mercury] Bug minor always 2013-11-06 17:44 2014-03-04 16:11
    juliensf MinGW  
    juliensf Windows  
    normal 7  
    resolved  
    fixed  
    none    
    none  
       
    Installation of java grade fails on Windows 7 / MinGW for 13.05.2-beta-2013-10-31
    Installation of the java grade fails when building on Windows 7 with MinGW with a compiler abort.
    (The end of the install log is below.) The system was:

    Windows 7
    MinGW/GCC 4.6.2
    javac 1.7.0_09

    The problem does *not* occur on Windows XP, MinGW GCC 4.5.0, javac 1.7.0_01.
    (The Java version is probably irrelevant, since the problem is with the compiler not the
    Java version of the library.)
    - add javac bin directory to MSYS PATH
    - unpack 13.05.2-beta-2013-10-31 tarball
    - ./configure --enable-libgrades=asm_fast.gc,java --prefix=…
    - make PARALLEL=-j2
    - make PARALLEL=-j2 install
    Making Mercury\javas\jmercury\string__builder.java^M
    Making Mercury\javas\jmercury\thread__channel.java^M
    Making Mercury\javas\jmercury\thread__mvar.java^M
    Making Mercury\javas\jmercury\thread__semaphore.java^M
    Making Java class files^M
    Note: Some input files use unchecked or unsafe operations.^M
    Note: Recompile with -Xlint:unchecked for details.^M
    Making mer_std.jar^M
    Uncaught Mercury exception:^M
    Software Error: parse_tree.module_cmds: predicate `parse_tree.module_cmds.list_class_files_for_jar'/6: Unexpected: io.file_type failed: No such file or directory^M
    make[2]: *** [libmer_std.install] Error 1
     
    Notes
    (0000575)
    juliensf   
    2013-11-07 14:23   
    Installation works correctly with the 13.05.1 release.
    (0000576)
    juliensf   
    2013-11-07 17:59   
    Installation also fails when the 13.05.2-beta compiler is rebuilt in the asm_fast.gc grade.
    (0000577)
    juliensf   
    2013-11-18 17:18   
    The call to io.file_type/5 in dir.foldl2_process_entries/4 is aborting with

    PathName = "Mercury\\classs\\jmercury\\fat_sparse_bitset$S_TypeSpecOf__pred_or_func__do_foldl2_pred___T_a484fdff_do_foldl2_pred___T___var_V_2___4_1_6_p_4_env_0.class"

    I'm not sure why though.
    (0000578)
    wangp   
    2013-11-18 17:53   
    Surely not a long path name issue? I don't see any change relating to paths since 13.05.1, unless adding "-beta-xxxx-xx-xx" to the pwd counts...
    (0000579)
    juliensf   
    2013-11-18 18:04   
    (Last edited: 2013-11-18 18:06)
    I don't think so, MAX_PATH is 260 characters (or thereabouts), the above string is 160 chars in length.
    (The above string is exactly what is passed to io.file_type so the "-beta-xxxx-xx-xx" is not present anyway.)

    (0000580)
    juliensf   
    2013-11-18 18:08   
    Interestingly, MSYS (e.g. cp and ls in MSYS) claim that they cannot stat that file either.
    (Although Windows explorer and cmd.exe have no trouble with it.) I don't think should be an
    issue for Mercury since it's calling _wstat and friends directly (i.e. MSYS shouldn't enter into it.)
    (0000581)
    juliensf   
    2013-11-19 03:48   
    I can now reproduce this problem on my Windows XP. It is path length related after all.
    I'll try again on the Windows 7 machine and if it works with a shorter build path then
    I'll add something to README.Java about this.
    (0000654)
    juliensf   
    2014-03-04 16:11   
    README.Java has been updated to describe this problem and how to deal with it.




    View Issue Details
    320 [mercury] Bug minor always 2014-02-19 16:12 2014-02-21 17:09
    pbone  
    juliensf  
    normal  
    feedback  
    open  
    none    
    none  
       
    instantiation states and "unused module import" warnings do not interact properly.
    A Mercury module containing a module import for some other Mercury module and an instantiation state deceleration for a type in that module but nothing else to do with that module generated an unused module import warning.
    Compile the attached module with "mmc -c", it should be warnings-clean but isn't. mmc outputs:

    paul@oxygen> mmc -c unused_import_inst_bug.m
    unused_import_inst_bug.m:001: In module `unused_import_inst_bug':
    unused_import_inst_bug.m:001: warning: module `maybe' is imported in the
    unused_import_inst_bug.m:001: interface, but is not used in the interface.
    unused_import_inst_bug.m (455 bytes) 2014-02-19 16:12
    https://bugs.mercurylang.org/file_download.php?file_id=205&type=bug
     
    Notes
    (0000650)
    juliensf   
    2014-02-21 17:08   
    The underlying problem here is most likely that insts don't have type information associated with them,
    so the unused module checker cannot see that the inst maybe_yes refers to the functor yes/1.
    (This is a much more general problem, see 0000089 for example -- it's also a language design issue, since
    in order to resolve properly we would need to add some mechanism to add type information to insts.)




    View Issue Details
    89 [mercury] Bug minor have not tried 2009-02-18 21:21 2014-02-21 17:04
    juliensf  
    juliensf  
    normal  
    assigned  
    open  
    none    
    none  
       
    existentially quantified data constructors and inst subtyping do not work together
    The attached program reports and error when compiled with mmc -C.
    The appears to be the result of two insts that should unify not unify because
    one of them includes a component that corresponds to an introduced
    type-info.
    inst_subtype_exists.m (1,287 bytes) 2009-02-18 21:21
    https://bugs.mercurylang.org/file_download.php?file_id=68&type=bug
     
    Notes
    (0000538)
    juliensf   
    2013-06-07 16:58   
    There are two approaches to fix this, both of which have problems:

    (1) The polymorphism pass should process the inst table and add type-info related
    arguments into any bound functors that correspond to constructors with existentially quantified type
    variables. This seems like the cleanest approach except for the fact that we cannot always tell whether
    an inst should be transformed like this. Consider:

        :- type foo(T) ---> a(T) ; b(T) ; c(T).
        :- type bar ---> some [T] a(T) ; nil.
        :- inst a ---> a(ground).

    Should the inst 'a' have an extra argument added or not. It depend on the type, which we won't
    know until we try to unify the inst against that of some term. (This is essentially a language design
    issue, at the moment functors in insts do not have types associated with them, so we cannot tell
    whether the above should be transformed or not -- indeed, it may be used with both foo/1 and bar/0,
    in which case having polymorphism transform the insts won't work at all.)

    (2) The second approach is to get the mode check to look at var-functor unifications and if the
    functor has introduced type-info related arguments, to add them to the inst on the LHS.
    I've implemented the fix for the incorrect generation of the error message in this bug and it indeed
    fixes the problem. Unfortunately, a later part of the mode analyser then aborts (for more ore less the
    same reason). The issue with this is approach is that it is likely that we are going to have to replicate
    it in several different places.




    View Issue Details
    317 [mercury] Bug major always 2014-02-07 15:33 2014-02-10 10:38
    lpimmes  
    juliensf OSx 10.9.1  
    high  
    resolved  
    no change required  
    none    
    none  
       
    :- pragma memo(findLngCmnSubsqStck/3). WORKING; not sure how to do static Asymptotic analysis
    Answers for longest common subsequence appear to be correct.
    If pragma commented out, we take forever on longer test cases. Thus pragma is working,
    but how?
    I returned number of calls to findLngCmnSubsqStck/3. Number of calls remains the
    same regardless of pragma or not. I would expect calls to be reduced significantly.
    This is a bug in my understanding. Thank goodness pragma works, because it really speeds things
    up.
    I would like to resolve what other authors have determined:
    'total number of calls is at most 2(m+1)(n+1)+1 and the time is O(mn)'
    See listing for comments of trace run. Perhaps I counted incorrectly.
    Thanks again to the Mercury team, and Mercury!
    Example output:
    % lngCommSubseqStck 495>./lngCommonSubseqStck
    % Input test case 0, 1, 2, 3, 4, ... Output longest common subsequence.
    % ^d to quit.
    % Caching really speeds up execution, but same number of calls.
    % 0
    % LongestCommonSubsequence('a', 'a')='a',
    % a length: 1, b length: 1, findLngCmnSubsqStck calls: 2.
    % 1
    % LongestCommonSubsequence('aa', 'bb')='',
    % a length: 2, b length: 2, findLngCmnSubsqStck calls: 4.
    % 2
    % LongestCommonSubsequence('aaa', 'bbb')='',
    % a length: 3, b length: 3, findLngCmnSubsqStck calls: 7.
    % 3
    % LongestCommonSubsequence('aaaa', 'bbbb')='',
    % a length: 4, b length: 4, findLngCmnSubsqStck calls: 11.
    % 4
    % LongestCommonSubsequence('aaaaa', 'bbbbb')='',
    % a length: 5, b length: 5, findLngCmnSubsqStck calls: 16.
    % 5
    % LongestCommonSubsequence('aaaaaa', 'bbbbbb')='',
    % a length: 6, b length: 6, findLngCmnSubsqStck calls: 22.
    % 6
    % LongestCommonSubsequence('aaaaaaa', 'bbbbbbb')='',
    % a length: 7, b length: 7, findLngCmnSubsqStck calls: 29.
    % 7
    % LongestCommonSubsequence('aaaaaaaa', 'bbbbbbbb')='',
    % a length: 8, b length: 8, findLngCmnSubsqStck calls: 37.
    % 9
    % LongestCommonSubsequence('aaaaaaaaaa', 'bbbbbbbbbb')='',
    % a length: 10, b length: 10, findLngCmnSubsqStck calls: 56.
    lngCommonSubseqStck.m (9,448 bytes) 2014-02-07 15:33
    https://bugs.mercurylang.org/file_download.php?file_id=201&type=bug
    lngCommonSubseqStck_tbl.m (12,434 bytes) 2014-02-07 19:34
    https://bugs.mercurylang.org/file_download.php?file_id=202&type=bug
     
    Notes
    (0000640)
    juliensf   
    2014-02-07 16:39   
    The number of calls are the same because one of the things that the memo table in your
    program caches is the number of calls.

    If you want to examine the the actual number of calls that are made during program execution, you
    will need to either profile the program or use the table statistics mechanism described in the ``Tabled evaluation'' section of the reference manual and the table_statistics module in the standard library.
    (0000641)
    lpimmes   
    2014-02-07 19:36   
    Hopefully, number of duplicate calls will appear on output.
    Compiler problem:
    lngCommonSubseqStck_tbl.m:295: In clause for predicate `mainAux'/2:
    lngCommonSubseqStck_tbl.m:295: in argument 1 of call to predicate
    lngCommonSubseqStck_tbl.m:295: `write_table_stats'/3:
    lngCommonSubseqStck_tbl.m:295: type error: variable `Table' has type
    lngCommonSubseqStck_tbl.m:295: `table_statistics.proc_table_statistics',
    lngCommonSubseqStck_tbl.m:295: expected type was
    lngCommonSubseqStck_tbl.m:295: `table_statistics.table_stats'.
        ;
         Result = io.ok(IndxStr),
         Indx = string.det_to_int(string.strip(IndxStr)), % use det_ so func. is det
         io.format("%s\n", [ s(longestCommonSubsequence(Indx)) ], Out0, Out1),
         table_statistics_for_findLngCmnSubsqStck_3(Table, Out1, Out2),
         write_table_stats(Table, Out2, Out) % compiler error: expected type was `table_statistics.table_stats'
    Casting to that type does not work.
    See lngCommonSubseqStck_tbl.m
    Thanks.
    (0000642)
    juliensf   
    2014-02-07 20:06   
    The output of table_statistics_for_findLngCmnSubsqStck_3 has type proc_table_statistics/0 *not*
    table_stats/0. You need to deconstruct the output in order to extract the tabling statistics you are interested in, for example:

             table_statistics_for_findLngCmnSubsqStck_3(ProcTableStats, Out1, Out2),
             ProcTableStats = proc_table_statistics(CallTableStats, _),
             CallTableStats = table_stats_curr_prev(Stats, _),
             write_table_stats(Stats, Out2, Out)
    (0000643)
    lpimmes   
    2014-02-08 07:26   
    OK, great. It works, i.e., compiles, and shows my output, and statistics output.
    Thanks.
    (0000644)
    ttmrichter   
    2014-02-09 01:45   
    lpimmes: Have you considered signing up to an appropriate mailing list[1] instead of (ab)using a bug tracker for these kinds of issues?

    [1] http://lists.mercurylang.org/listinfo/users
    (0000645)
    juliensf   
    2014-02-10 10:38   
    Not a bug.




    View Issue Details
    316 [mercury] Bug major always 2014-02-05 18:11 2014-02-05 18:33
    lpimmes  
    juliensf OSx 10.9.1  
    high  
    resolved  
    no change required  
    none    
    none  
       
    Declared `det', inferred `semidet'. --- [H|T] first argument input
    This function compiles, except for det error.
    In this case, I really need det, not semidet, otherwise callers including main will not work.

    :- pred charToStrLst(list(char), list(string), list(string)).
    :- mode charToStrLst(in, in, out) is det.
    charToStrLst([H | T], Accum, LstStr) :- % [H|T] can fail
        (if list.is_empty([H|T])
        then
        LstStr = Accum
        else
        format("%c", [c(H)], Str),
         charToStrLst(T, [Str | Accum], LstStr)
        ).

    All I needed to accomplish is convert, e.g., "foo" to ["f", "o", "o"].

    longCommSubseq.m:097: In `charToStrLst'(in, in, out):
    longCommSubseq.m:097: error: determinism declaration not satisfied.
    longCommSubseq.m:097: Declared `det', inferred `semidet'.
    longCommSubseq.m:098: In argument 1 of clause head:
    longCommSubseq.m:098: unification of `HeadVar__1' and `list.[H | T]' can
    longCommSubseq.m:098: fail.
    % Program contains determinism error(s).
     mmc --make --fully-strict -E -v -O 0 --use-subdirs longCommSubseq
    See attached file.
    Thanks.
    longCommSubseq.m (4,585 bytes) 2014-02-05 18:11
    https://bugs.mercurylang.org/file_download.php?file_id=200&type=bug
     
    Notes
    (0000639)
    juliensf   
    2014-02-05 18:32   
    The predicate charToStrLst/3 does not have a clause that matches the case where the first
    argument is the empty list, which it would need in order to be det.

    One way of making the above predicate det is:

    charToStrLst([], Accum, Accum).
    charToStrLst([H | T], Accum, LastStr) :-
         Str = string.from_char(H),
         charToStrLst(T, [Str | Accum], LastStr)

    (Aside: you can use string.from_char/1 to convert characters into strings;
    there's no need to use format/3).

    Alternatively, you the above predicate could be written as the following function:

        :- func charToStrLst(list(char)) = list(string).

        charToStrLst(Chars) = list.map(string.from_char, Chars).

    In short, the error reported by the compiler here is correct and there isn't a bug.




    View Issue Details
    315 [mercury] Bug major always 2014-01-31 14:01 2014-02-01 05:47
    lpimmes  
    OSx  
    high 10.9.1  
    new  
    open  
    none    
    none  
       
    Software Error: detected need for minimal model in pred rodcut.r_n/3
    In another program
    :- pragma memo(fib/3). works OK here, but mode is det.

    Trying memo on mode is multi. Comment out memo on two pred, output runs and is correct.
    Uncomment memo and we get

       Software Error: detected need for minimal model in pred rodcut.r_n/3

    Not sure how to create det function, because I need to make decision for base and recursive cases,
    i.e., multiple output.
    rodcut will be very slow for larger values of N, which is why I want memoization.
    See listing attached file.
    Thanks.
    Partial listing:

    ...
    % Implement rn, bottom of page 362 Dynamic programming, Cormen text.
    % Should be implementing 15.2 rn = max (p_i + r_n-i)
    % 1 <= i <= n, r0=0
    %%%% Cannot use multi mode on functions, use pred, and declare main to be cc_multi.

    :- pred r_n(int, array(int), int).
    :- mode r_n(in, in, out) is multi.
    %:- pragma memo(r_n/3).
    r_n(1, P, Mx) :-
        Mx = getRevenue(1, P).
    r_n(N, P, Mx) :-
        r_nAux(getRevenue(N, P), 1, N-1, P, Mx).

    :- pred r_nAux(int, int, int, array(int), int).
    :- mode r_nAux(in, in, in, in, out) is multi.
    %:- pragma memo(r_nAux/5).
    r_nAux(Mx, LowIndx, HighIndx, P, Max) :-
        (
         if LowIndx > HighIndx then
           Max = Mx
        else
           r_n(LowIndx, P, Lw),
           r_n(HighIndx, P, Hg),
            NewMax = int.max(Mx, Lw + Hg),
            r_nAux(NewMax, LowIndx + 1, HighIndx -1, P, Max)
        ).
    ...
    rodcut.m (3,694 bytes) 2014-01-31 14:01
    https://bugs.mercurylang.org/file_download.php?file_id=197&type=bug
    bug315.m (570 bytes) 2014-01-31 15:15
    https://bugs.mercurylang.org/file_download.php?file_id=198&type=bug
    rodcut2.m (2,654 bytes) 2014-01-31 15:15
    https://bugs.mercurylang.org/file_download.php?file_id=199&type=bug
     
    Notes
    (0000636)
    zs   
    2014-01-31 15:20   
    I have uploaded a cleaned-up version of the original program, and a cut-down version of the test case.

    The problem is that the program

    - calls a memo'd nondet predicate, and gets the first solution,
    - cuts the choice point for any more solutions (using cc_multi code) before printing the first.

    That leaves the memoing data structures in an inconsistent state, believing that the original memo'd call is still active.

    When a later call to the same nondet predicate specifies the same input arguments, the tabling code thinks it is an infinitely-recursive call, and generates the error message.

    This is not a bug. This is a known limitation of memoing nondet predicates. The only problem that needs fixing is that the documentation does not do a good job of explaining this limitation.
    (0000637)
    lpimmes   
    2014-02-01 05:47   
    OK, thanks for the help and the code.




    View Issue Details
    302 [mercury] Bug block always 2013-10-30 12:02 2014-01-31 10:15
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    can't bootcheck in asm_fast.gc.debug.stseg
    Bootcheck in asm_fast.gc.debug.stseg crashes when making dependencies for the standard library, on both 32-bit and 64-bit.

    May or may not be like bug 0000065.
    bug302.m (1,402 bytes) 2014-01-30 18:08
    https://bugs.mercurylang.org/file_download.php?file_id=195&type=bug
     
    Notes
    (0000625)
    juliensf   
    2014-01-29 18:36   
    When bootchecking in that grade on 64-bit linux I get nondet stack overflow while building the
    stage 3 dependencies:

    + /home/jfischer/Mercury-Staging/mercury-srcdist-14.01-beta-2014-01-29/scripts/mmake -k dep_library dep_mdbcomp dep_browser_all dep_ssdb dep_compiler
    cd library && PATH=../scripts:../util:../mfilterjavac:../../mfilterjavac:$PATH MMAKE_VPATH=. MMAKE_DIR=../scripts DESTDIR= ../scripts/mmake depend
    gmake[1]: Entering directory `/home/jfischer/Mercury-Staging/mercury-srcdist-14.01-beta-2014-01-29/stage3/library'
    config.status: creating LIB_FLAGS
    /home/opturion/mercury-14.01-beta-2014-01-29/x86_64/bin//mmc --generate-dependencies --grade asm_fast.gc.debug.stseg --mercury-linkage shared --flags LIB_FLAGS --flags INTER_FLAGS --no-warn-nothing-exported --no-warn-unused-imports mer_std

    Mercury runtime: memory zone nondetstack#2 overflowed
    This may have been caused by a stack overflow, due to unbounded recursion.
    gmake[1]: *** [mer_std.depend] Error 1
    gmake[1]: Target `depend' not remade because of errors.
    gmake[1]: Leaving directory `/home/jfischer/Mercury-Staging/mercury-srcdist-14.01-beta-2014-01-29/stage3/library'
    gmake: *** [library/mer_std.dep] Error 2
    (0000626)
    juliensf   
    2014-01-30 16:42   
    asm_fast.gc.stseg and_fast.gc.debug both both bootcheck successfully on the same machine.
    (0000627)
    zs   
    2014-01-30 17:06   
    Fixed by commit 15cb7cf721ae2d04ce5bcd7702b63a41fd5c7b8c. The problem was --generate-dependencies processing a list of all the items in the library with a nondet loop using the nondet mode of list.member. That procedure is usually tail recursive, and so uses constant nondet stack space, but debugging defeats this.
    (0000628)
    juliensf   
    2014-01-30 17:12   
    Is there still not a problem here? Why did the compiler before this fix succeed with asm_fast.gc.debug
    but fail with asm_fast.gc.debug.stseg? My intuition is that lack of tail recursion should cause problems
    for the former more obviously than the latter.
    (0000629)
    zs   
    2014-01-30 17:46   
    My guess as to why the compiler before this fix succeeded with asm_fast.gc.debug but failed with asm_fast.gc.debug.stseg is that the nondet stack was just big enough without stseg, but the added slots needed for stsegs was enough to push things over the edge.

    But you are right; there is a bug remaining, though the compiler would be a VERY bad test case for fixing it. The problem is that the macro making an ORDINARY nondet stack frame checks whether a new stack segment is needed, the macro making a TEMPORARY nondet stack frame does not.

    Unfortunately, changing that fact would require changing the definitions of temp frames, which would NOT be a trivial thing to do.
    (0000630)
    zs   
    2014-01-30 18:14   
    The file I just attached, bug302.m, is a very small test case for the actual problem. It just creates a list of numbers of specified length, and searches it for a number that is not in the list. On my machine, in asm_fast.gc.debug.stseg grade, it works for "bug302 1012" but fails on "bug302 1013".

    For simple predicates like list.member(out, in), we could compute the total amount of space needed by tmp frames on the nondet stack and include this in the initial check to see whether we should create a new nondet stack segment. However, that wouldn't work in the general case where there are calls to nondet predicates between the initial mkframe and later mktmpframes: having enough space in the current segment when mkframe is called will in that case NOT guarantee that there is enough space in the current segment when mktmpframe is called.
    (0000631)
    juliensf   
    2014-01-30 18:14   
    I suggest separating the latter issue out into a new bug and the reclosing this one.
    (0000632)
    zs   
    2014-01-30 18:26   
    The original symptom is fixed. The underlying problem is now bug 314.
    (0000633)
    pbone   
    2014-01-31 10:15   
    I didn't see the diff for this fix on the mailing list. Did you send it?

    Thanks.




    View Issue Details
    311 [mercury] Bug minor always 2014-01-23 06:09 2014-01-28 16:31
    plsm i686  
    zs Linux Debian  
    normal 3.2.46-1+deb7u1  
    assigned  
    open  
    none    
    none  
       
    Gathering solutions depends on how predicate is programmed
    I have a predicate that has several solutions that I want to collect. Depending on how I program the predicate, either all solutions are correctly collected by predicates in module solutions, or some solutions or even just one are returned by predicates.

    I have tested in mercury compiler 11.07 and 13.05.2
    bugSolutions.m (2,964 bytes) 2014-01-23 06:09
    https://bugs.mercurylang.org/file_download.php?file_id=191&type=bug
    bug311.m (6,251 bytes) 2014-01-28 14:24
    https://bugs.mercurylang.org/file_download.php?file_id=194&type=bug
     
    Notes
    (0000618)
    zs   
    2014-01-28 14:25   
    The file bug311.m I just uploaded is a simplified version of the original test case. It has a comment at the top (a) diagnosing the problem, (b) proposing some solutions, and (c) recommending a workaround that works right now.
    (0000619)
    zs   
    2014-01-28 14:42   
    I have just thought of a better fix.

    Mark every variable which satisfies the conditions that lead to the problem (such as G in the example).
    For every unification which fills in some field(s) of G but does not make G ground, eliminate the unification, but record which fields are filled in, with what values. When we come to a unification that grounds G by filling in its remaining field(s), replace that with a unification that creates G from scratch, filling in all its fields all at once.

    This effectively transforms lattice_bad to lattice_bad_fixes inside the compiler.

    This solution works if all fields of a cell have to be filled in by unifications in the same predicate body, because *calls* are not allowed to fill in fields of preexisting cells. I think we currently impose that restriction (indirectly, via limitations of the mode system), but I am not sure.
    (0000620)
    wangp   
    2014-01-28 15:05   
    The delay_partial_inst.m pass does something like that.
    (0000623)
    zs   
    2014-01-28 16:30   
    Yes, it does try to handle things like that. However, I just checked, and it screws up on this test case in two separate and distinct ways. First, it does not properly handle the two unifications in a row that fill in the xsize and ysize fields of G. Second, while it handles the first disjunct ok, it screws up the second, thinking that the unifications generated in the first disjunct hold in the second as well. (There is already an XXX in the code for disjunctions, but that comment does not consider this scenario.)

    I will look into whether we can modify delay_partial_inst.m to handle this situation.




    View Issue Details
    98 [mercury] Bug minor always 2009-06-12 14:56 2014-01-28 15:55
    juliensf  
     
    normal  
    new  
    open  
    none    
    none  
       
    compiler throws exception with --profile-for-implicit-parallelism
    rotd-2009-06-09 aborts with an exception when compiling the standard library module
    erlang_rtti_implementation.m in grade asm_fast.gc.profdeep with --profile-for-implicit-parallelism
    enabled.

    Uncaught Mercury exception:
    Software Error: llds_out.m: Unexpected: stack var out of range
    Stack dump not available in this grade.

    Compiling with --no-inline-simple acts a workaround.
    erlang_rtti_implementation.m (8,995 bytes) 2009-06-15 01:32
    https://bugs.mercurylang.org/file_download.php?file_id=76&type=bug
     
    Notes
    (0000172)
    pbone   
    2009-06-12 16:26   
    --profile-for-implicit-parallelism enables inlineing which is normally disabled in deep profiling builds. This makes the resulting profile look more like the profile that would be generated by a non-profiling build.

    I believe that this bug might be able to be triggered by enabling inlineing in a deep profiling build without enabling --profile-for-implicit-parallelism.
    (0000173)
    juliensf   
    2009-06-12 16:49   
    Yes, you're right. Compiling without --profile-for-implicit-paralellism but with --profile-optimized
    enabled also triggers the bug.
    (0000175)
    juliensf   
    2009-06-15 01:34   
    (Last edited: 2009-06-15 01:36)
    I've uploaded a cut-down version of erlang_rtti_implemetation that exhibits this bug.
    (Curiosly, the problem goes away if I rename the module, although I can't see anywhere
    in the compiler that treats the module erlang_rtti_implementation specially in C grades;
    the bug is also not present if we rename the module to another stdlib or builtin module.)

    The test case is derived from r1.89 of library/erlang_rtti_implementation.m.

    (0000609)
    zs   
    2014-01-22 15:26   
    The compiler DOES treat standard library modules specially in some places. It does list them by name; it uses mercury_std_library_module/1 in library/library.m.
    (0000622)
    pbone   
    2014-01-28 15:55   
    I cannot reproduce this bug (on a compiler without the 0000309 fix) using the attached file. Perhaps changes have been made to the compiler such that the bug (whatever it was) is no longer being triggered.

    I also can't reproduce this by building Mercury with these options. Unless someone knows how to reproduce this, I propose we close this bug.

    Thanks.




    View Issue Details
    307 [mercury] Bug minor always 2014-01-06 22:32 2014-01-10 15:58
    bacuh  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    internal compiler error in assign_by_spills during make install of mercury
    make install fails with

      mercury_ho_call.c: In function ‘MR_generic_unify’:
      mercury_ho_call.c:721:1: internal compiler error: in assign_by_spills, at lra-assigns.c:1281
       }
       ^

    at my site.

    This happens with 13.05.x and 14.01. I may try more older versions to find the one introducing this behaviour. Just ask if this was helpful. Also if there's some investigation I can do or further information I can provide.
      pkgdir=/tmp # or anything else

      ./configure --prefix=/usr --mandir=/usr/share/man \
                  --infodir=/usr/share/info --disable-debug-grades \
                  --disable-inefficient-grade

      make PARALLEL="$NOMATTERWHAT"

      make INSTALL_PREFIX="$pkgdir"/usr \
           INSTALL_MAN_DIR="$pkgdir"/usr/share/man \
           INSTALL_INFO_DIR="$pkgdir"/usr/share/info \
           MERCURY_COMPILER="$pkgdir"/usr/bin/mercury_compile \
           MERCURY_CONFIG_DIR="$pkgdir"/usr/lib/mercury \
           PARALLEL="$NOMATTERWHAT" install
    messages surrounding above error:

      /var/build/build/mercury-compiler/src/mercury-srcdist-13.05.2/install_grade_dir.asm_fast.gc/scripts/mgnuc --grade asm_fast.gc --c-debug --no-ansi -- -fpic -DMR_PIC \
          -c mercury_hgc.c -o mercury_hgc.pic_o
      /var/build/build/mercury-compiler/src/mercury-srcdist-13.05.2/install_grade_dir.asm_fast.gc/scripts/mgnuc --grade asm_fast.gc --c-debug --no-ansi -- -fpic -DMR_PIC \
          -c mercury_ho_call.c -o mercury_ho_call.pic_o
      mercury_ho_call.c: In function ‘MR_generic_unify’:
      mercury_ho_call.c:721:1: internal compiler error: in assign_by_spills, at lra-assigns.c:1281
       }
       ^
      Please submit a full bug report,
      with preprocessed source if appropriate.
      See <https://bugs.archlinux.org/> for instructions.
      /tmp/mmake.GoLNnI:1599: recipe for target 'mercury_ho_call.pic_o' failed
      make[2]: *** [mercury_ho_call.pic_o] Error 1
      make[2]: Leaving directory '/var/build/build/mercury-compiler/src/mercury-srcdist-13.05.2/install_grade_dir.asm_fast.gc/runtime'
      To clean up from failed install, remove /var/build/build/mercury-compiler/src/mercury-srcdist-13.05.2/install_grade_dir.asm_fast.gc
      /tmp/mmake.GMvojB:1408: recipe for target 'install_grades' failed
      make[1]: *** [install_grades] Error 1
      make[1]: Leaving directory '/var/build/build/mercury-compiler/src/mercury-srcdist-13.05.2'
      Makefile:37: recipe for target 'install' failed
      make: *** [install] Error 2
     
    Notes
    (0000591)
    juliensf   
    2014-01-06 22:36   
    What C compiler, version of the C compiler and platform are you using?
    (0000592)
    bacuh   
    2014-01-06 23:59   
    Sorry, I knew I missed something

    It's i686 GNU/Linux 3.12.6, gcc 4.8.2

    As a distribution I'm using Arch Linux and their build system (makepkg) but yes, I tried to build by hand.
    (0000599)
    juliensf   
    2014-01-08 16:20   
    The underlying issue here is a bug in GCC. (Unfortunately many GCC optimisations have a history of not working terribly well in the presence of the global register variables extension used by Mercury.)

    As a workaround I suggest you configure using the option: --with-llds-base-grade=none
    This will disable the use of any GCC extensions to C.

    We will look into seeing if there is an alternative workaround available.
    (0000600)
    juliensf   
    2014-01-10 15:58   
    Workaround applied in the mgnuc script.




    View Issue Details
    306 [mercury] Bug minor always 2013-12-18 06:12 2014-01-08 16:00
    Pedro Mariano  
    juliensf  
    low  
    confirmed  
    open  
    none    
    none  
       
    Java grade and non alphabetic field name
    If the field name of some type starts with a digit, compiling in the java grade fails. I've attached a simple program to illustrate the bug.

    There is no problem compiling to C.
    javaField.m (1,143 bytes) 2013-12-18 06:12
    https://bugs.mercurylang.org/file_download.php?file_id=186&type=bug
     
    Notes
    (0000598)
    juliensf   
    2014-01-08 16:00   
    This issue is that the Java backend (and indeed C# backend) do not perform name mangling of quoted
    names like the C backends. (One reason for this is that doing so would complicate interfacing with
    the generated Java code.) For the moment you should only use names that don't require quoting.




    View Issue Details
    165 [mercury] Bug minor always 2010-10-04 10:43 2014-01-08 15:59
    wangp  
     
    normal  
    new  
    open  
    none    
    none  
       
    java backend generates invalid code for contrived type
    The Java backend currently generates invalid code for this type:

    :- type '$blah'
        ---> '$blah'(int)
        ; '$blah2'.
     
    There are no notes attached to this issue.




    View Issue Details
    301 [mercury] Bug minor always 2013-10-29 14:37 2013-10-29 17:37
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    incorrect handling of deconstructions in float_reg.m pass
    The compiler aborts on this test case when targeting low-level grades with float registers enabled. (I have a fix, just want a bug number)
    float_reg_deconstruct.m (824 bytes) 2013-10-29 14:37
    https://bugs.mercurylang.org/file_download.php?file_id=184&type=bug
     
    Notes
    (0000574)
    wangp   
    2013-10-29 17:37   
    Fixed in 553a108




    View Issue Details
    299 [mercury] Bug minor always 2013-09-16 16:09 2013-10-29 17:33
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    unaligned memory access for unboxed doubles
    Unaligned memory access instructions occur on 32-bit architectures when an unboxed double begins on an odd-numbered slot, crashing on some architectures (e.g. SPARC).

    I think we can "just" split the dword read/write into two instructions for odd-numbered slots.
    unaligned.m (1,323 bytes) 2013-09-16 16:36
    https://bugs.mercurylang.org/file_download.php?file_id=182&type=bug
     
    Notes
    (0000566)
    wangp   
    2013-09-17 17:53   
    We also have to prevent unaligned doubles on the stack, by allocating aligned stack slots and ensuring the stack pointer is always aligned. Alternatively, split up all reads/writes to double-width stack slots into two instructions.
    (0000567)
    wangp   
    2013-09-18 14:38   
    The nondet stack is complicated by multiple frame types (ordinary, temporary det, temporary nondet). Ordinary frames have 5 fixed slots + temporaries (except for mm grades, with 6 fixed slots). Temporary det frames are exactly 4 words big. Temporary nondet frames are exactly 3 words big. The size is used to recognise the different types.

    Maintaining an invariant that the frame pointer rests on an aligned address (so that we can always allocate aligned double slots) would be tricky and probably not worthwhile.
    (0000572)
    pbone   
    2013-10-03 15:11   
    I would like to see these values aligned on the stack in all cases. However since this will be tricky a short term work around, such as using two read instructions for 64bit values on 32 bit platforms, would be okay.
    (0000573)
    wangp   
    2013-10-29 17:33   
    Fixed in 1094f42




    View Issue Details
    294 [mercury] Bug major always 2013-07-24 18:23 2013-09-29 15:12
    pbone  
    pbone  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    GCC 4.6 and 4.7 break asm_fast.par grades
    The mandelbrot program crashes when compiled with gcc 4.6 or 4.7. I have not tested 4.8. 4.5 works.

    I found that passing -fno-reorder-functions to GCC avoids the problem. I don't yet know why.
    patch (1,741 bytes) 2013-07-24 18:24
    https://bugs.mercurylang.org/file_download.php?file_id=178&type=bug
     
    Notes
    (0000556)
    pbone   
    2013-07-24 18:24   
    I have uploaded a patch that I started working on.
    (0000558)
    juliensf   
    2013-08-23 15:33   
    Hi Paul,

    Some comments on your patch: in the configure script, you should be able to use the value of C_COMPILER_TYPE to tell whether to pass -fno-reorder-functions or not to the C compiler or not. (The value of that variable also encodes the version of the C compiler.)

    For now I would suggest disabling the option for GCC version 4.6 and onwards.

    This bug should be kept open until we know *why* -freorder-functions is breaking the .par grades.
    (0000559)
    pbone   
    2013-09-01 14:43   
    Notes on why this bug may be occurring:

    The program has to use higher order code but doesn't need to contain a
    parallel conjunction.

    The effected grade has to be a low-level C par grade, I've only tested with
    stack segments, so I don't know if disabling them will help. I tested a few
    of the low-level C grades:

        asm_fast.gc: Works
        asm_fast.gc.par.seg: Broken
        asm_fast.gc.seg: Broken
        reg.gc.par.seg: Broken
        none.gc.par.seg: Works

    So, the bug is independent of GC and parallel conjunction. It does require
    higher order code, a parallel grade, and gcc global registers.
    (0000560)
    juliensf   
    2013-09-01 16:07   
    Is this on x86_64, i686 or both? Also, is the test case also broken on reg.gc.steg?
    (0000561)
    pbone   
    2013-09-01 17:46   
    x86_64, I havn't tested the others.

    Also regarding reg.gc.par.stseg, this doesn't work in older versions of GCC 4.6 either, so there are at least two different bugs, and until I understand both of them I can't say if the "reg" grades are affected or not. So I can't tell if this is GCC global registers or some other option.
    (0000563)
    pbone   
    2013-09-03 16:30   
    I've now also tested asm_fast.gc.stseg, which does not have the bug.
    (0000569)
    pbone   
    2013-09-29 15:12   
    Fixed in a8397086be733a27d73fe1b0f14b5aa92487adb4

    I'm leaving the bug open as we still do not know the cause.




    View Issue Details
    298 [mercury] Bug minor always 2013-09-16 15:41 2013-09-16 15:41
    wangp  
     
    normal  
    new  
    open  
    none    
    none  
       
    missing .mh include
    foo1.m calls the C function declared in a (non-local) foreign_decl in foo2.m. In the low-level C grades, foo1.c does not include foo2.mh.

    I think the manual suggests that it should:
    "By default, the contents of `pragma foreign_decl' declarations are
    also visible in the same kinds of declarations in other modules that
    import the module containing the `pragma foreign_decl' declaration."

    In the high-level C grades, foo1.c does include foo2.mih (mih).
    foo1.m (656 bytes) 2013-09-16 15:41
    https://bugs.mercurylang.org/file_download.php?file_id=180&type=bug
    foo2.m (556 bytes) 2013-09-16 15:41
    https://bugs.mercurylang.org/file_download.php?file_id=181&type=bug
     
    There are no notes attached to this issue.




    View Issue Details
    51 [mercury] Bug minor always 2008-03-04 15:03 2013-09-09 16:22
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    abort during liveness detection
    The attached file aborts during liveness detection with these options:

    mmc -O2 --optimise-higher-order --optimise-constant-propagation --no-common-struct -C string2

    (this is just a cut down string.m. The same thing happens with the full file.)


    % Computing liveness in function `string2.foldr'/3 mode 0
    Uncaught Mercury exception:
    Software Error: hlds_llds.m: Unexpected: goal_info_get_post_births: no code_gen_info
    string2.m (2,558 bytes) 2008-03-04 15:03
    https://bugs.mercurylang.org/file_download.php?file_id=44&type=bug
     
    Notes
    (0000565)
    wangp   
    2013-09-09 16:22   
    Fixed (I think) in d67f1f8. The test case is different.




    View Issue Details
    297 [mercury] Bug major always 2013-08-29 13:26 2013-09-04 11:52
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    compile-time evaluation of typed_unify changes behaviour
    The attached program is broken by the compile-time evaluation of typed_unify when --optimise-constant-propagation is enabled (-O3).
    t.m (834 bytes) 2013-08-29 13:26
    https://bugs.mercurylang.org/file_download.php?file_id=179&type=bug
     
    Notes
    (0000562)
    wangp   
    2013-09-03 15:31   
    Rather, it has to do the inst of the static type_info when --const-struct is enabled. That --optimise-constant-propagation (and the predicate const_prop.eval_unify) breaks the program seems to be a symptom.

    I suspect commit ee63cb8d, specifically these lines in polymorphism.m:

                StructType = type_info_type,
                list.length(ArgTypeInfoConstArgs, NumArgs),
                InstConsId = cell_inst_cons_id(Cell, NumArgs),
                StructInst = bound(shared, inst_test_results_fgtc,
                    [bound_functor(InstConsId, StructArgInsts)]),

    the NumArgs argument to cell_inst_cons_id.
    (0000564)
    wangp   
    2013-09-04 11:52   
    Fixed in 06e175d34d82b7dce3870d89f070c1d58e038d87




    View Issue Details
    292 [mercury] Bug major always 2013-07-07 01:39 2013-07-12 01:36
    urilabob linux  
    juliensf fedora  
    normal 19 (kernel 3.9.8  
    resolved  
    no change required  
    none    
    none  
       
    'make install' fails on missing dependency (bryant.h) for robdd.m
    Attempting to install mercury-srcdist-13.05 fails because the make of robdd.m fails to find bryant.h. Doubtless it's a shell variable not set properly environment or something of that sort - but I haven't been able to figure out what. The final part of the transcript is attached.
    sh configure
    make
    make install (which fails)
    make_install_transcript.txt (848 bytes) 2013-07-07 01:39
    https://bugs.mercurylang.org/file_download.php?file_id=177&type=bug
     
    Notes
    (0000550)
    juliensf   
    2013-07-10 13:50   
    I've tried doing the above with 13.05 on a newly created VM with Fedora 19 and cannot reproduce
    the above problem. Are there any non-default settings in your environment or anything like that?
    (0000552)
    urilabob   
    2013-07-11 00:43   
    Hi Julien, thanks for looking at it. I can't think of any environment changes that I am making from the standard one that could possibly affect this. The only non-standard installs I have are JavaBayes, Jess (java expert systems environment), the lptp theorem prover (built on top of swi prolog), and the Vue topic map system. Actually, writing this down made me realise that lptp could have an implementation of robdds that could somehow conflict, but grepping robdd and bryant over it didn't turn up anything. Oh, and I'm using lxde window manager rather than gnome, but it would be pretty weird if there were name clashes there. In case you can see something I can't, I'm appending the printenv output at the bottom.

    I thought it might be a hangover from the first failed attempt to build mercury, so I rolled the system back to before the initial mercury install, and tried again. I got exactly the same failure.

    The only other thought I have is that the mercury sources are on a folder shared from the host. But I'm running the build as root, and root has full permissions on the folder, so I wouldn't have thought that could make a difference. If you think there's any possibility this could be the cause, I could try moving the source to the guest's root disk, just in case. Other than that, I'm stumped.



    XDG_VTNR=1
    XDG_SESSION_ID=105
    HOSTNAME=localhost.localdomain
    SAL_USE_VCLPLUGIN=gtk
    IMSETTINGS_INTEGRATE_DESKTOP=yes
    XDG_MENU_PREFIX=lxde-
    SHELL=/bin/bash
    TERM=xterm
    HISTSIZE=1000
    GNOME_KEYRING_CONTROL=/home/rim/.cache/keyring-2Jnk7U
    QT_GRAPHICSSYSTEM_CHECKED=1
    IMSETTINGS_MODULE=none
    USER=rim
    LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:
    DESKTOP_SESSION=LXDE
    MAIL=/var/spool/mail/rim
    PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/rim/.local/bin:/home/rim/bin
    QT_IM_MODULE=xim
    PWD=/share/SW/LPTP
    XMODIFIERS=@im=none
    LANG=en_US.UTF-8
    GNOME_KEYRING_PID=6118
    HISTCONTROL=ignoredups
    divider=10
    _LXSESSION_PID=6121
    SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
    SHLVL=3
    XDG_SEAT=seat0
    HOME=/root
    BOOT_IMAGE=/vmlinuz-3.9.8-300.fc19.x86_64
    XDG_CONFIG_HOME=/home/rim/.config
    LOGNAME=rim
    DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-0TqbEFGzMQ,guid=9cc6be088e2b649c3aaa305851dd7061
    PREFERRED=/usr/bin/startlxde
    LESSOPEN=||/usr/bin/lesspipe.sh %s
    DISPLAY=:0
    XDG_RUNTIME_DIR=/run/user/1000
    GTK_IM_MODULE=gtk-im-context-simple
    XDG_CURRENT_DESKTOP=LXDE
    XAUTHORITY=/root/.xauthZ65N3X
    _=/bin/printenv
    OLDPWD=/share/SW
    (0000553)
    urilabob   
    2013-07-11 20:45   
    Hi again, Julien. Well blow me down, use of the shared folder was the culprit. I copied the sources onto the guest's system disk (from the shared folder, so it wasn't due to file corruption), and it built correctly. I can't even begin to imagine what could cause this, but it's a near certainty that it's a deeply-buried virtualbox bug, rather than one in Mercury. Sorry for taking your time,
        Best Wishes
        Bob
    (0000554)
    juliensf   
    2013-07-12 01:35   
    That's ok, my time wasn't wasted since it gave me an opportunity to fix a problem with Mercury and GCC 4.8.




    View Issue Details
    291 [mercury] Bug minor always 2013-07-02 01:46 2013-07-02 01:46
    juliensf  
     
    normal  
    new  
    open  
    none    
    none  
       
    HLDS dumps don't contain clauses unless --dump-hlds-options=x is also given
    --dump-hlds-options=C used (IIRC) to cause the clauses to be included in the HLDS dumps.
    It now doesn't unless the 'x' HLDS dump option is also given. I don't recall that this used to be the
    case and since 'x' corresponds to predicate type information it also seems wrong.
     
    There are no notes attached to this issue.




    View Issue Details
    285 [mercury] Bug tweak have not tried 2013-05-22 11:24 2013-06-28 15:54
    pbone  
     
    normal  
    new  
    open  
    none    
    none  
       
    Mode error is misleading
    A mode error can be causes when code is multidet when it is declared as det. In these case the error text uses the phrase "multiple clauses with solutions". Even for single clause predicates.
    Create a single clause predicate declared as det such as:

    update_atom_in_map(Atom, SubstsA, Status, OrigHt, !Map) :-
        (
            ( map.search(!.Map, Atom, EntryPrime) ->
                Entry = EntryPrime
            ; version_hash_table.search(OrigHt, Atom, EntryPrime) ->
                Entry = EntryPrime
            ;
                false
            ), # HERE is the error, this should be a -> rather than a ,
            Entry = memo_table_entry(SubstsB, _),
            Substs = SubstsA `union` SubstsB
        ;
            Substs = SubstsA
        ),
        set(Atom, memo_table_entry(Substs, Status), !Map).
     
    Notes
    (0000525)
    juliensf   
    2013-05-22 13:15   
    The only such error message I can find is:

         "Disjunction has multiple clauses with solutions."

    That seems fairly unambiguous for the example above.
    (0000547)
    pbone   
    2013-06-28 15:36   
    I don't like the confusion with clauses. Could it say something like "Disjunction has multiple parts with solutions?"
    (0000549)
    juliensf   
    2013-06-28 15:54   
    "clause" is a standard term in predicate logic for describing the "parts" of a disjunction. As I said in my original reply, I don't see that the error message has any ambiguity anyway.




    View Issue Details
    288 [mercury] Bug minor always 2013-06-04 03:27 2013-06-24 11:12
    keri  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Some mercury binary files are built without respecting LDFLAGS
    Compiling mercury (on Linux) with 'make EXTRA_LDFLAGS=...' produces a number of binary files which do not respect EXTRA_LDFLAGS:

     * /usr/lib/mercury/lib/libgc.so
     * /usr/lib/mercury/lib/<grade>/libmer_trace.so
     * /usr/lib/mercury/lib/<grade>/libmer_eventspec.so
     * /usr/lib/mercury/lib/<grade>/libmer_rt.so
     * /usr/bin/mfiltercc
     * /usr/bin/info_to_mdb
     * /usr/bin/mkinit_erl
     * /usr/bin/mdemangle
     * /usr/bin/mkinit
    Attached is a patch which passes through ALL_LDFLAGS to targets that currently do not respect user-defined LDFLAGS.
    mercury-linker-flags.patch (5,206 bytes) 2013-06-04 03:27
    https://bugs.mercurylang.org/file_download.php?file_id=175&type=bug
    mercury-linker-flags-v2.patch (5,242 bytes) 2013-06-07 00:19
    https://bugs.mercurylang.org/file_download.php?file_id=176&type=bug
     
    Notes
    (0000535)
    juliensf   
    2013-06-05 16:09   
    EXTRA_LDFLAGS is an mmake variable not a make one; I wouldn't necessarily expect setting it for make would work.

    Does it work if you pass the options in via the MMAKEFLAGS variable, for example:

       make MMAKEFLAGS="EXTRA_LDFLAGS='<whatever linker flags>'"
    (0000537)
    keri   
    2013-06-07 00:20   
    There are two issues at play with LDFLAGS/LD_LIBFLAGS and mmake:

    1. some mercury binaries are built with respecting the LDFLAGS/LD_LIBFLAGS passed to mmake.

    This is caused by some Mmakefile rules ommitting ALL_LDFLAGS/ALL_LD_LIBFLAGS from the linker options. I've uploaded a new mercury-linker-flags-v2.patch that adds:

    * ALL_LDFLAGS to util/Mmakefile rules
    * ALL_LD_LIBFLAGS to {runtime,trace}/Mmakefile rules
    * LD_LIBFLAGS/EXTRA_LD_LIBFLAGS to boehm_gc Makefile. (ALL_LD_LIBFLAGS is not visible from make)

    2. custom MMAKEFLAGS are not passed to mmake from the toplevel Makefile

    The toplevel Makefile explicitly passes MMAKEFLAGS=$(PARALLEL) to mmake, overriding anything set via 'make MMAKEFLAGS="..."'. Patching the toplevel Makefile to use MMAKEFLAGS+=$(PARALLEL) is a possible fix.
    (0000543)
    juliensf   
    2013-06-24 11:12   
    Committed, along with some additions to support the same for .dylib files properly.




    View Issue Details
    287 [mercury] Bug minor always 2013-05-28 12:55 2013-06-05 16:02
    wangp  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    configure requires m4
    The configure script expects m4 to be present:

    m4 -DDEFAULT_MERCURY_DEBUGGER_INIT_DIR=TESTS_MDB_INIT_DIR \
        -DDEFAULT_MERCURY_DEBUGGER_DOC=TESTS_MDB_DOC \
        "`pwd`"/scripts/mdbrc.in > $test_mdbrc.in

     
    Notes
    (0000528)
    juliensf   
    2013-05-28 13:44   
    We could just skip the above if m4 is not present. What it's doing is only critical to running the test suite, so in principle an installation should be able to proceed without it.
    (0000530)
    pbone   
    2013-05-28 15:15   
    Or have this executed from the test suite's Makefile.
    (0000531)
    juliensf   
    2013-05-28 15:21   
    Or what Paul says. This is a fairly recent problem since before we moved to git we would only have
    executed the above if the tests directory was present.
    (0000534)
    juliensf   
    2013-06-05 16:02   
    Fix committed.




    View Issue Details
    259 [mercury] Feature Request minor always 2012-07-08 03:58 2013-06-04 03:41
    ony All  
    All  
    high All  
    new  
    open  
    none    
    none  
       
    Impossible to override /lib dir with /lib64 etc
    To support multilib install we need to have possibility to use /usr/lib64 instead of /usr/lib.
    Appropriate patch based on rotd-2012-07-01 attached
    0001-Allow-usr-lib64-override-required-for-multilib.patch (2,422 bytes) 2012-07-08 03:58
    https://bugs.mercurylang.org/file_download.php?file_id=155&type=bug
    0001-Add-man-info-and-lisp-dirs-configuring.patch (1,869 bytes) 2012-07-08 06:39
    https://bugs.mercurylang.org/file_download.php?file_id=156&type=bug
    0002-Add-man-info-and-lisp-dirs-configuring.patch (1,847 bytes) 2012-07-08 08:54
    https://bugs.mercurylang.org/file_download.php?file_id=157&type=bug
    mercury-13.05-bug259-dirs-overriding.patch (2,680 bytes) 2013-05-19 03:39
    https://bugs.mercurylang.org/file_download.php?file_id=174&type=bug
     
    Notes
    (0000473)
    ony   
    2012-07-08 08:57   
    sorry for 0001-Add-man-info-and-lisp-dirs-configuring.patch
    second should be good (after applying first one).

    I can create another issue for it (actually I'd prefer to edit description for this to make it sounds like "directory overriding for libdir, mandir, infodir etc").
    (0000474)
    pbone   
    2012-07-08 10:59   
    Thanks. Someone will look at this as time permits (I promise!). Don't worry about adding a new issue, they've enough in common that a general issue is fine.
    (0000518)
    ony   
    2013-05-19 03:44   
    both patches now in single mercury-13.05-bug259-dirs-overriding.patch

    please consider using /usr/share/doc/mercury-13.05 etc for documentation rather than /usr/lib/mercury/doc. currently patch changes those folder according to this suggestion
    (0000533)
    keri   
    2013-06-04 03:41   
    This bug is a little more complicated than first meets the eye. In addition to the changes in mercury-13.05-bug259-dirs-overriding.patch there are a few other places in which $(INSTALL_PREFIX)/lib/mercury is referenced:

    * library/Mmakefile:

       260 install_mer_rt: $(RT_LIB_NAME).jar
       261 mkdir -p $(INSTALL_PREFIX)/lib/mercury/lib/$(GRADE)
       262 cp $(RT_LIB_NAME).jar $(INSTALL_PREFIX)/lib/mercury/lib/$(GRADE)

    * the mercury compiler itself

    compiler/file_util.m:

       262 InstallNamePath = InstallPrefix / "lib" / "mercury" / "lib" / GradeDir

    compiler/make.program_target.m:

      1374 LibDir = Prefix/"lib"/"mercury",
      1427 IncDir = Prefix / "lib" / "mercury" / "inc",
      1576 GradeLibDir = Prefix/"lib"/"mercury"/"lib"/GradeDir,
      1581 GradeLibDir = Prefix/"lib"/"mercury"/"lib"/GradeDir,
      1586 GradeLibDir = Prefix/"lib"/"mercury"/"lib"/GradeDir,
      1593 GradeLibDir = Prefix/"lib"/"mercury"/"lib"/GradeDir,
      1624 GradeModulesDir = Prefix / "lib" / "mercury" / "modules" / GradeDir,
      1641 LibDir = Prefix/"lib"/"mercury",
      1788 LibDir = Prefix/"lib"/"mercury",
      1819 LibDir = Prefix/"lib"/"mercury",

    * extras/posix/Mmakefile

        37 cp $(ADDITIONAL_HDRS) $(INSTALL_PREFIX)/lib/mercury/inc




    View Issue Details
    222 [mercury] Bug minor always 2011-10-18 19:14 2013-05-28 13:47
    gloomdemon  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    mmc can't compile csharp grade without --make under mingw
    rotd 2011-10-11, simple hello world program

    command 'mmc --make --grade csharp hello' compiles all
    command 'mmc --grade csharp hello.m':

    $ mmc --grade csharp hello.m
    mkinit: error opening file `hello.c': No such file or directory
    mkinit: error opening file `c:\mingw\mercury\lib\mercury\modules\csharp\mer_rt.init': No such file or directory
    mkinit: error opening file `c:\mingw\mercury\lib\mercury\modules\csharp\mer_std.init': No such file or directory
    Error: system command received signal 1.

    create files: hello.cs, hello.cs_date, hello.d

    mercury compiled with configure options: CFLAGS=-O2 CPPFLAGS=-O2 ./configure --prefix=c:/mingw/mercury --enable-libgrades=asm_fast.gc,asm_fast.gc.debug,asm_fast.gc.decldebug,hlc.gc,hlc.par.gc,reg.gc,csharp --enable-csharp-grade --enable-new-mercuryfile-struct
    hello.m:

    :- module hello.

    :- interface.
    :- import_module io.

    :- pred main(io::di, io::uo) is det.

    :- implementation.
    :- import_module int.

    main(!IO) :-
        io.write_string("hello ", !IO).
     
    Notes
    (0000367)
    juliensf   
    2011-10-18 21:33   
    IIRC, the non-C backends (csharp, java, and erlang) require the use of mmc --make in order
    to work properly.
    (0000529)
    juliensf   
    2013-05-28 13:47   
    The documentation for the non-C backend is now clearer about the requirement for mmc --make.




    View Issue Details
    183 [mercury] Bug minor have not tried 2011-02-03 11:11 2013-05-22 16:16
    pbone  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    --warn-dead-procs should not warn about foreign-exported procs.

    If a predicate, such as handle_event_excp in ssdb.m, is not called from Mercury but is foreign exported for Java and C#, then compiling to C with --warn-dead-procs tells the user that it may safely be deleted.
     
    Notes
    (0000527)
    juliensf   
    2013-05-22 16:16   
    Fix committed.




    View Issue Details
    262 [mercury] Bug minor always 2012-08-27 08:42 2013-05-22 13:42
    vezhlys amd64  
    NetBSD  
    normal 6_RC1  
    new  
    open  
    none    
    none  
       
    Mercury doesn't compile on NetBSD
    Mercury programming language doesn't compile in NetBSD operating system. I tried to compile it using from NetBSD source package management (pkgsrc). It ended up with error:

    os_dep.c:503:9: error: redefinition of 'GC_data_start'
    os_dep.c:454:9: note: previous definition of 'GC_data_start' was here
    gmake[3]: *** [os_dep.o] Error 1
    gmake[3]: Leaving directory `/usr/pkgsrc/lang/mercury/work/mercury-compiler-11.07/boehm_gc'
    gmake[2]: *** [submake] Error 2
    gmake[2]: Leaving directory `/usr/pkgsrc/lang/mercury/work/mercury-compiler-11.07/boehm_gc'
    gmake[1]: *** [boehm_gc] Error 2
    gmake[1]: Leaving directory `/usr/pkgsrc/lang/mercury/work/mercury-compiler-11.07'
    gmake: *** [install] Error 2
    *** Error code 2

    Stop.
    make: stopped in /usr/pkgsrc/lang/mercury
    *** Error code 1

    Stop.
    make: stopped in /usr/pkgsrc/lang/mercury

    It seems that solution is simple. I commented two duplicate definitions GC_data_start and GC_find_limit as they were defined exactly the same a bit earlier in the same file (see lines 454-456). Mercury compiled fine then. I looked into current version of os_dep.c file and it is the same (pkgsrc retrieves mercury-compiler-11.07.tar.gz currently) because of this it should fail too.
    Compile mercury on netbsd.
    --- os_dep.c 2012-08-27 01:08:21.000000000 +0300
    +++ os_dep.c 2012-08-27 01:09:19.000000000 +0300
    @@ -500,8 +500,8 @@
     # endif /* ECOS */
     
     #if defined(NETBSD) && defined(__ELF__)
    - ptr_t GC_data_start = NULL;
    - ptr_t GC_find_limit(ptr_t, GC_bool);
    + //ptr_t GC_data_start = NULL;
    + //ptr_t GC_find_limit(ptr_t, GC_bool);
     
       extern char **environ;
     
    Notes
    (0000526)
    juliensf   
    2013-05-22 13:42   
    I've tried the source distribution for the latest stable release (13.05) on NetBSD 6.1 (i386) and it
    appears to be fine. I'll do some further testing since I also have a patch that enables support for shared libraries on that platform.

    If there are problems with the version in pkgsrc then they are best taken up with the maintainer of that package. (The version of the Boehm GC that is shipped with Mercury has been bumped several times since the 11.07 release; my best guess is that the newer versions probably fix the problems encountered above.)




    View Issue Details
    161 [mercury] Bug major have not tried 2010-09-08 16:45 2013-05-21 16:51
    pbone  
    juliensf  
    normal  
    assigned  
    open  
    none    
    none  
       
    Calling io.seen/2 twice in a row can crash the runtime with a segfault.
    The following program crashes the runtime with a segfault.

    :- module main.
    :- interface.
    :- import_module io.
    :- pred main(io::di, io::uo) is det.

    :- implementation.

    main(!IO) :- seen(!IO), seen(!IO).
     
    This was reported via the #mercury IRC channel on the Freenode IRC network.
    I'm waiting for the user to tell me what version of Mercury they're using and which grade they're using. I havn't attempted to reproduce this myself.

     
    Notes
    (0000514)
    juliensf   
    2013-05-17 16:49   
    With rotd-2013-05-17, in the hlc.gc grade (on Mac OS X 10.8) it gives me:

        Uncaught Mercury exception:
        io_error("error closing file: Bad address")

    which seems fine. Did the original user ever get back to you about what they were using?
    (0000515)
    juliensf   
    2013-05-17 16:51   
    I do however get the seg fault in both asm_fast.gc and hlc.gc grades on x86_64 Linux.
    (Mercury 13.05-beta-2013-05-02)
    (0000516)
    juliensf   
    2013-05-17 17:10   
    The right fix here IMO, is to change mercury_close so that it checks that the file pointer it is attempting
    to close is non-NULL before attempting to close it. (After calling MR_CLOSE the first time, we NULL out
    the file pointer, so this should be enough to fix the multiple io.seen/2 case.)
    (0000517)
    pbone   
    2013-05-18 12:51   
    I don't remember, or was never told what version/grade the user was using. In any case I agree with your conclusion.
    (0000519)
    juliensf   
    2013-05-19 17:59   
    I'll add a fix for this sometime during this week.
    (0000523)
    juliensf   
    2013-05-21 16:51   
    I've committed a fix that avoids the segmentation fault that occurs when closing the same file stream multiple times (the actual issue here). There appears to be in an issue on the asm_fast.gc grades on Linux with handling the exception that now occurs. I am still investigating this.




    View Issue Details
    257 [mercury] Bug minor always 2012-06-22 12:49 2013-05-21 14:04
    wangp  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    require_complete_switch var does not appear in sub-goal
    The compiler doesn't warn if the variable named in a
    require_complete_switch does not appear anywhere in the sub-goal, e.g.

        :- type xyz ---> x ; y ; z.
              
        :- pred oops(xyz::in, int::out) is semidet.
        
        oops(G, N) :-
            require_complete_switch [Gee]
            (
                G = x,
                N = 1
            ;
                G = y,
                fail
            ).
     
    Notes
    (0000520)
    juliensf   
    2013-05-20 16:42   
    Even better, consider what happens (or rather doesn't happen) with:

    oops(G, N) :-
            some [Gee]
            (
                G = x,
                N = 1
            ;
                G = y,
                fail
            ).
    (0000521)
    juliensf   
    2013-05-20 17:48   
    Fix posted for review.
    (0000522)
    juliensf   
    2013-05-21 14:04   
    The compiler now emits a warning in this case.




    View Issue Details
    263 [mercury] Bug crash always 2012-08-29 18:53 2013-05-17 16:16
    lpimmes  
    juliensf  
    normal  
    resolved  
    no change required  
    none    
    none  
       
    Segmentation fault: not enough memory when invoking solutions/2
    Working with mercury language is quiet rewarding.

    But running into a memory problem of some kind, as expected with
    Traveling salesman problem.

    % Using generator length of 7 (see code): [2, 3, 4, 5, 6, 7, 8]
    % tsp2 501>MERCURY_OPTIONS=--solutions-heap-size-kwords=1024000
    % tsp2 501>echo $MERCURY_OPTIONS
    % --solutions-heap-size-kwords=1024000
    % tsp2 501>./tsp2
    % Segmentation fault: 11
    % tsp2 501>

    See attached tsp2.m file. (shows gcc and mmc, darwin versions)
    Any help would be appreciated, thanks.
    Compile, then run uploaded file(tsp2.m).

    tsp2 493>cat tsp2.bash
    #/bin/bash
    mmc --make --fully-strict -E -v -O 0 --use-subdirs tsp2
    gcc 4.2
    mmc 11.7

    Aside: When analyzing mercury programs asymptotically, we can sometimes determine
    implicit for-loops, i.e., O(n), O(n^2), and so on, even n! if using solutions/2. But, I am not so sure if this is sufficient for 'Analysis of Algorithms graduate course'. Unification takes time, and so does resolution theorem proving. In other words, more computations are taking place 'behind the mercury code' so to speak. Any ideas, heuristics or suggestions (sites)?
    tsp2.m (14,014 bytes) 2012-08-29 18:53
    https://bugs.mercurylang.org/file_download.php?file_id=159&type=bug
    tsp2upd.m (15,136 bytes) 2012-09-12 01:12
    https://bugs.mercurylang.org/file_download.php?file_id=160&type=bug
     
    Notes
    (0000478)
    juliensf   
    2012-09-10 01:13   
    The problem is a nondetstack overflow. This can be resolved by either expanding the size of the
    nondetstack using the --nondetstack-size-kwords option with the MERCURY_OPTIONS environment
    variable or by using a stack segments grade (grade component: stseg). (The latter provides a nondetstack that can grow dynamically at runtime.)
    (0000479)
    lpimmes   
    2012-09-12 00:40   
    (Last edited: 2012-09-12 01:51)
    Follow Julian's advice about stseg; tsp2.m is working now.
    Yes, TSP is an np-complete problem; just examining mercury under heavy stress.

    %% cd mercury-compiler-11.07.2/
    %% ./configure --with-cc="gcc -m64" --enable-libgrades=hlc.gc,none.gc,none.gc.stseg,java,erlang
    %% ...
    Unable to delete original file, so:
    Download tsp2upd.m ; mv tsp2upd.m tsp2.m

                    % RUN
    %% ~ 515>cd $MERCURYPROGRAMS
    %% mercuryPrograms 513>cd algor91503/
    %% algor91503 512>cd tsp2

    %% tsp2 489>ulimit -H -s
    %% 65532
    %% Cannot set to a higher value.

    %% Edit code and change generator length, then recompile.
    %% Generator lengths shown are: 10, 9, 8, 7.

    %% tsp2 489>which mmc
    %% /usr/local/mercury-11.07.2/bin/mmc
    %% tsp2 489>mmc --grade none.gc.stseg --fully-strict -E -v -O 0 --use-subdirs tsp2

                    % 10! = 3628800
                    % 430 m ~= 7 hours, most of the time spent swapping in and out of memory, as timer shows.
    %% tsp2 487>time ./tsp2
    %% #Permutations: 3628800, Generator length: 10 using [2 3 4 5 6 7 8 9 10 11 ],
    %% minimum distance 23: 1_8(2) 8_6(2) 6_5(3) 5_4(1) 4_3(3) 3_9(2) 9_7(1) 7_11(1) 11_2(3) 2_10(3) 10_1(2)

    %% real 430m26.708s
    %% user 7m36.750s
    %% sys 12m29.934s

                    % 9! = 362880
    %% tsp2 489>./tsp2
    %% #Permutations: 362880, Generator length: 9 using [2 3 4 5 6 7 8 9 10 ],
    %% minimum distance 23: 1_8(2) 8_6(2) 6_5(3) 5_4(1) 4_3(3) 3_9(2) 9_7(1) 7_2(4) 2_10(3) 10_1(2)

    % % real 0m32.049s
    % % user 0m30.823s
    % % sys 0m1.051s

                    % 8! = 40320
    %% tsp2 489>./tsp2
    %% #Permutations: 40320, Generator length: 8 using [2 3 4 5 6 7 8 9 ],
    %% minimum distance 24: 1_5(4) 5_4(1) 4_3(3) 3_9(2) 9_7(1) 7_2(4) 2_6(5) 6_8(2) 8_1(2)


                    % 7/! = 5040
    %% tsp2 505>./tsp2
    %% #Permutations: 5040, Generator length: 7 using [2 3 4 5 6 7 8 ],
    %% minimum distance 23: 1_3(5) 3_4(3) 4_5(1) 5_7(1) 7_2(4) 2_6(5) 6_8(2) 8_1(2)
    %% tsp2 505>

    (0000513)
    juliensf   
    2013-05-17 16:16   
    The problem can be avoided by increasing the nondet stack size (low-level C backend), C stack size (high-level C backend) or using a stack segments grade.




    View Issue Details
    282 [mercury] Bug minor always 2013-05-06 13:20 2013-05-06 13:20
    juliensf x86_64  
    Mac OS X  
    normal 10.8.3  
    new  
    open  
    none    
    none  
       
    GNU-specific regexps in test filters
    The following fail in grade none.gc.decldebug:

    * debugger/cmd_quote
    * debugger/completion
    * debugger/declarative/builtin_call_rep
    * mmc_make/rebuild

    This appears to be because various regexps used to filter the output of those tests with grep and
    sed are GNU-specific and don't work with the BSD versions of those tools.

    Reported against 13.05-beta-2013-05-06.
     
    There are no notes attached to this issue.




    View Issue Details
    253 [mercury] Feature Request minor N/A 2012-02-15 17:25 2013-04-12 13:43
    juliensf  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    MS C# compiler should be invoked with -nologo
    The MS C# compiler should be invoked with -nologo in order to suppress the banner message.
     
    Notes
    (0000507)
    juliensf   
    2013-04-12 13:43   
    We now pass -nologo the the MS C# compiler




    View Issue Details
    279 [mercury] Bug minor always 2013-04-10 16:45 2013-04-11 03:05
    juliensf  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    make install from stage 2 dir does not work with csharp grade
    Doing make install from the stage 2 directory does not work if one of the grades
    to be installed is the csharp grade because the link to the file containing the strong
    name is incorrect.

    Making Mercury/css/thread.semaphore.cs
    Making mer_std.dll
    ** Error making `mer_std.dll'.
    error CS1548: Error during assembly signing. The specified key file `../mercury.snk' does not exist
    Compilation failed: 1 error(s), 0 warnings
    make[1]: *** [libmer_std.install] Error 1
     
    Notes
    (0000504)
    juliensf   
    2013-04-11 03:05   
    Fixed.




    View Issue Details
    277 [mercury] Bug major always 2013-03-05 10:43 2013-03-20 16:18
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    float bugs on 64-bit if built with pregenerated C sources
    string.format("%f", [f(1.234)])

    In low-level C, 64-bit, using a compiler built from the pregenerated source distribution, that returns "0.000000".

    string.from_float works correctly.
     
    Notes
    (0000501)
    wangp   
    2013-03-20 16:18   
    Fixed by pregen grade component.




    View Issue Details
    203 [mercury] Bug minor always 2011-07-11 14:22 2013-03-18 15:23
    juliensf  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Problem with DESTDIR and Darwin
    Reported by Jeremy Huddleston (jeremyhu@macports.org) on mercury-bugs:

    --------

    And one more bug to report...
                                                                                                                                                                                                                 
    mercury-11.01 fails to make install the first time.
                                                                                                                                                                                                                 
    This looks like some bad logic for making boehm_gc a second time during the make install.
                                                                                                                                                                                                                 
    cp ./libatomic_ops-install/lib/libatomic_ops.a gc.a
    cp: ./libatomic_ops-install/lib/libatomic_ops.a: No such file or directory
    gmake[3]: *** [gc.a] Error 1
    gmake[3]: Leaving directory
    `/opt/local/var/macports/build/_Volumes_Home_jeremy_src_macports_trunk_dports_lang_mercury/mercury/work/mercury-11.01/install_grade_dir.hlc.gc/boehm_gc'
    gmake[2]: *** [submake] Error 2
    gmake[2]: Leaving directory
    `/opt/local/var/macports/build/_Volumes_Home_jeremy_src_macports_trunk_dports_lang_mercury/mercury/work/mercury-11.01/install_grade_dir.hlc.gc/boehm_gc'
    To clean up from failed install, remove
    /opt/local/var/macports/build/_Volumes_Home_jeremy_src_macports_trunk_dports_lang_mercury/mercury/work/mercury-11.01/install_grade_dir.hlc.gc
    gmake[1]: *** [install_grades] Error 1
    gmake[1]: Leaving directory `/opt/local/var/macports/build/_Volumes_Home_jeremy_src_macports_trunk_dports_lang_mercury/mercury/work/mercury-11.01'
    make: *** [install] Error 2
    make: Leaving directory `/opt/local/var/macports/build/_Volumes_Home_jeremy_src_macports_trunk_dports_lang_mercury/mercury/work/mercury-11.01'
    shell command " cd "/opt/local/var/macports/build/_Volumes_Home_jeremy_src_macports_trunk_dports_lang_mercury/mercury/work/mercury-11.01" && /usr/bin/make -w install
    DESTDIR=/opt/local/var/macports/build/_Volumes_Home_jeremy_src_macports_trunk_dports_lang_mercury/mercury/work/destroot " returned error 2
                                                                                                                                                                                                                 
    Here's the full log, but I'm just doing a fairly standard ./configure && make && make install DESTDIR=/path/to/stage
    main.log.gz (131,988 bytes) 2011-07-11 14:24
    https://bugs.mercurylang.org/file_download.php?file_id=123&type=bug
    0001-Fix-for-bug-203-DESTDIR-brokes-installation.patch (2,036 bytes) 2012-07-06 07:22
    https://bugs.mercurylang.org/file_download.php?file_id=154&type=bug
     
    Notes
    (0000337)
    jeremyhu   
    2011-07-12 02:54   
    Adding a note in hopes that it will add me to a CC list, since I don't see any CC UI (I'm not familiar with Mantis).
    (0000340)
    pbone   
    2011-07-28 12:36   
    I can confirm this.
    (0000341)
    pbone   
    2011-07-28 13:01   
    DESTDIR was only ever made to work when building Mercury for a single grade, that's all I needed when I implemented it. It _should_ work for builds with more than one grade but I never implemented that.

    What this means is that this problem probably isn't Darwin specific, It also means that the solution is going to be more difficult since it's now about implementing an incomplete feature rather than fixing a bug.

    Thanks.
    (0000472)
    ony   
    2012-07-06 07:24   
    That 0001-Fix-for-bug-203-DESTDIR-brokes-installation.patch is based on rotd-2012-07-01
    (0000475)
    pbone   
    2012-07-08 11:01   
    Thanks for the patch, I promise to look at it, but I don't have a lot of time at the moment.
    (0000494)
    pbone   
    2013-01-09 00:25   
    Hi ony.

    Before reviewing your patches I want to make check some things with your experience with this bug. I want to ask about how you're using DESTDIR:

    Are you giving a value for DESTDIR during make install?

    Are you using more than one grade? (how is configure invoked?).

    Thanks.
    (0000495)
    ony   
    2013-01-09 04:17   
    Configure was invoked as: ./configure --prefix=/usr --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --docdir=/usr/share/doc/mercury-12.08_beta20120813 --sysconfdir=/etc --localstatedir=/var/lib --disable-dependency-tracking --disable-silent-rules --enable-fast-install --libdir=/usr/lib64 --disable-most-grades

    Library grades was intended to be built: asm_fast.gc, asm_fast.gc.debug, asm_fast.gc.decldebug, hlc.gc

    After succesful reaching "make -j9". There was invoked: make -j9 -j1 DESTDIR=/var/tmp/paludis/build/dev-lang-mercury-12.08_beta20120813/image/ install

    That caused:

    /usr/bin/install -c -m 644 libatomic_ops.a '/var/tmp/paludis/build/dev-lang-mercury-12.08_beta20120813/image//var/tmp/paludis/build/dev-lang-mercury-12.08_beta20120813/work/mercury-compiler-12.08-beta-2012-08-13/install_grade_dir.asm_fast.gc.debug/boehm_gc/libatomic_ops-install/lib'

    And as result:

    cp ./libatomic_ops-install/lib/libatomic_ops.a gc.a
    cp: cannot stat './libatomic_ops-install/lib/libatomic_ops.a': No such file or directory
    make[3]: *** [gc.a] Error 1
    make[3]: Leaving directory `/var/tmp/paludis/build/dev-lang-mercury-12.08_beta20120813/work/mercury-compiler-12.08-beta-2012-08-13/install_grade_dir.asm_fast.gc.debug/boehm_gc'
    make[2]: *** [submake] Error 2
    make[2]: Leaving directory `/var/tmp/paludis/build/dev-lang-mercury-12.08_beta20120813/work/mercury-compiler-12.08-beta-2012-08-13/install_grade_dir.asm_fast.gc.debug/boehm_gc'
    To clean up from failed install, remove /var/tmp/paludis/build/dev-lang-mercury-12.08_beta20120813/work/mercury-compiler-12.08-beta-2012-08-13/install_grade_dir.asm_fast.gc.debug
    make[1]: *** [install_grades] Error 1
    make[1]: Leaving directory `/var/tmp/paludis/build/dev-lang-mercury-12.08_beta20120813/work/mercury-compiler-12.08-beta-2012-08-13'
    make: *** [install] Error 2
    (0000500)
    wangp   
    2013-03-18 15:23   
    I applied a patch based on ony's. Thanks.




    View Issue Details
    276 [mercury] Bug minor always 2013-02-27 15:23 2013-02-27 15:24
    juliensf  
     
    normal  
    new  
    open  
    none    
    none  
       
    io.call_system/4 inconsistency between C and Java grades
    The attached Mercury program calls io.call_system/4 and it calls the C program foo.
    foo exits with exit status 2. In C grades we get:

        ok(2)

    In the Java grade we get:
      
        error(io_error("system command killed by signal number 2"))
    foo.c (70 bytes) 2013-02-27 15:23
    https://bugs.mercurylang.org/file_download.php?file_id=171&type=bug
    syscall_bug.m (209 bytes) 2013-02-27 15:24
    https://bugs.mercurylang.org/file_download.php?file_id=172&type=bug
     
    There are no notes attached to this issue.




    View Issue Details
    275 [mercury] Bug minor always 2013-02-18 11:47 2013-02-20 11:58
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    hidden symbol pthread_atfork
    On Ubuntu 12.04 (at least) the linker spits out an error message when you try to build most programs in a parallel grade, e.g. hlc.par.gc.

    /usr/bin/ld: test: hidden symbol `pthread_atfork' in /usr/lib/i386-linux-gnu/libpthread_nonshared.a(pthread_atfork.oS) is referenced by DSO

    The solution appears to be to pass -pthread at the link step, either in addition to or replacing -lpthread. Actually we should probably pass -pthread for compilation steps as well.
     
    Notes
    (0000496)
    juliensf   
    2013-02-18 13:05   
    You should only pass -pthread for C compilers that actually support that
    option. The (Mercury) compiler should have enough version information about the
    C compiler available in order to determine this.
    (0000497)
    wangp   
    2013-02-18 14:36   
    I'm thinking we just need to update configure.ac near line 2962 for $host = *linux*. The compilers in use there seem to all support -pthread (gcc, clang, icc, does lcc even work?).
    (0000498)
    juliensf   
    2013-02-18 16:02   
    Older versions of gcc (e.g. 4.2 etc) only seem to support it for things
    like IA64, PowerPC and SPARC. (Presumably, it has no effect on other
    things?) So, it should be ok to enable it for all versions of GCC.

    It should be ok to always enable it for clang.

    AFAIK, we don't support icc.

    If some uses lcc and it doesn't work then we'll do something about that.
    (Otherwise, I don't care about it for the time being.)

    Yes, you need to pass -pthread for all compilation steps since on some
    platforms it apparently affects the preprocessor as well.
    (0000499)
    wangp   
    2013-02-20 11:58   
    Fixed the underlying issue.




    View Issue Details
    226 [mercury] Bug tweak N/A 2011-11-03 10:21 2013-01-08 12:33
    colanderman  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    lazy.read_if_val unsound
    lazy.read_if_val is semantically unsound. It should be marked semipure and lazy.force marked impure, or it should be removed.
     
    Notes
    (0000377)
    pbone   
    2011-11-03 11:25   
    I presume you mean that it is unsound in the sense that it could be re-ordered with respect to force and have a different result. For example.

        Y = force(L),
        read_if_val(L, X)

    will succeed, but

        read_if_val(L, X),
        Y = force(L)

    will not.

    I agree that this might be a problem but I can't see the problem ever arising.

    force is pure because the internal state of the lazy value has no effect on any other part of the system (other than read_if_val).

    read_if_val is pure (and force is pure) because I haven't seen a real-life case where the ordering of force and read_if_val matters. I've only used read_if_val once (the deep profiler feedback tool's pretty printer). And in that case the corresponding call to force was in a separate peice of code, and I do not want to have to propagate the impurity throughout all that code to enforce the ordering of force and read_if_val, so making these non-pure would not be useful.

    If anyone can show a non-contrived case where the ordering of these calls is important and should be enforced using the purity system then I'd be happy to reconsider.
    (0000381)
    wangp   
    2011-11-03 12:37   
    Paul, the predicate

    build_var_use_list(Map, Var, !List)

    may produce different output for the same input.
    (0000382)
    pbone   
    2011-11-03 15:39   
    That doesn't matter, build_var_use is only called after the analysis has finished,
    and we're going to write the output into the feedback file. Or from a trace goal.

    It is used to prevent us from forcing the evaluation of results that aren't actually used in the analysis, and only include those that are used in the feedback report or output of trace goals
    (0000383)
    wangp   
    2011-11-03 17:37   
    The point is that it could be *any* predicate since lazy values could be embedded anywhere. The existence of read_if_val breaks referential transparency.
    (0000384)
    juliensf   
    2011-11-04 00:27   
    I agree, read_if_val/2 should be made semipure.
    (0000386)
    zs   
    2011-11-04 00:52   
    I also agree. However, please don't make it semipure just yet. I have an incomplete diff that I expect will remove some uses of read_if_val from the deep profiler directory, and I would like to avoid conflicts.
    (0000387)
    pbone   
    2011-11-04 11:16   
    Okay,

    My remaining concern is that a semipure read_if_val only makes sense if force is impure. However when a programmer never uses read_if_val they still have to work with an impure force.

    If read_if_val didn't exist, then force can be pure, because the impurity can never affect anything.

    Is there a better way to manage this, and still allow read_if_val to exist?

    Thanks.
    (0000388)
    juliensf   
    2011-11-04 12:38   
    I don't follow you: force is (and can remain) pure whatever the purity of read_if_val is.
    (0000389)
    colanderman   
    2011-11-04 12:52   
    Julien: I think you're right, a semipure read_if_val suffices. I think I was understanding impurity backward.
    (0000390)
    pbone   
    2011-11-04 13:26   
    read_if_val doesn't update any memory, so at best it's pure and at worst it's impure.

    force updates memory, so at worst it is impure, but it has a pure interface.

    read_if_val has an impure interface, since calls to force can cause it to not have referential transperency.

    My understanding of impurity is:
       + that pure gaols are allowed to be placed in any order with respect to one
         another, and even be optimized away.

       + that semipure goals are allowed to be placed in any order with respect to
         one another, and in any order with respect to pure goals, since none of
         these goals are side-affecting. (but semipure goals are affected by side
         effects). And that semipure goals can be optimized away.

       + that impure goals must be placed in order with respect to other impure and
         semipure goals. Since they are both side-effecting and side-effected.
         They may not be optimized away since their side effects may be deliberate.

    Please correct me if I am wrong.

    Therefore if read_if_val is semipure and force is pure, different orderings such as:

        read_if_val(L, X),
        Y = force(L)

    and

        Y = force(L),
        read_if_val(L, X)

    are considered equivalent (because the semipure and pure goals may be re-ordered) except that the former may fail and the latter will always succeed. To prevent this re-ordering, force needs to be marked as impure, so that it's side effect is recognized by the compiler, preventing the compiler from re-ordering these goals.

    Again, please correct me if I am mistaken.
    (0000391)
    juliensf   
    2011-11-04 13:39   
    Ok, you will need to use impurity to prevent the compiler (potentially ) reordering code there. I'm not quite sure how you concluded that it is force/1 should be impure though -- the non-referentially transparent
    procedure is read_if_val, so declare that to be impure (rather than semipure).
    (0000392)
    pbone   
    2011-11-04 13:55   
    Because force is the function that has a side-effect. read_if_val does not have a side-effect.

    If force is pure and read_if_val is impure then the compiler will think that it can re-order the two calls, pure and impure calls can be placed in any order. See my points about impurity above.
    (0000393)
    juliensf   
    2011-11-04 14:09   
    From the reference manual, section 15.3 Semantics [of purity levels]

    "Impure goals may not be reordered relative to any other goals; not even “minimal” reordering as implied by the modes is permitted."

    If the compiler does reorder the first goal in the following over the second then that is a bug in
    the compiler.

        Y = force(L),
        impure read_if_val(L, X)

    Making force impure is (1) unnecessary and (2) misses the entire point of the lazy module which is
    to provide a _pure interface_ to lazy evaluation. (It is read_if_val/2 that subverts this pure interface, it is the source of the non-purity here.)
    (0000394)
    pbone   
    2011-11-04 14:22   
    Okay, I didn't realize that impurity was that strong.

    Yes, this is also why I wanted to avoid making force impure, since it and delay provide the pure interface. I find this unintuitive WRT where the side-effects are.
    (0000493)
    juliensf   
    2013-01-08 12:33   
    Fixed.




    View Issue Details
    261 [mercury] Bug major always 2012-07-26 00:38 2013-01-07 16:48
    petdr  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    building mdbcomp in C# grade attempts to link with non-existant mer_rt.dll
    Attempting to build the compiler in the csharp grade leads to the following error


    Making mer_mdbcomp.dll
    ** Error making `mer_mdbcomp.dll'.
    error CS0006: Metadata file `mer_rt.dll' could not be found
    Compilation failed: 1 error(s), 0 warnings
    make[1]: *** [libmer_mdbcomp] Error 1
    make[1]: Leaving directory `/home/MISCRITITCOM/petdr/merc/workspaces/1107.csharp/mdbcomp'
    make: *** [mdbcomp] Error 2

    this is because we are calling the following command

    % Invoking system command `dmcs -nowarn:162,219 -define:MR_HIGHLEVEL_DATA -target:library -out:mer_mdbcomp.dll -lib:../boehm_gc -lib:../runtime -lib:../library -lib:../trace -lib:../mdbcomp -lib:../browser -r:mer_std.dll -r:mer_rt.dll Mercury/css/mdbcomp.cs Mercury/css/mer_mdbcomp.cs Mercury/css/mdbcomp.feedback.cs Mercury/css/mdbcomp.goal_path.cs Mercury/css/mdbcomp.prim_data.cs Mercury/css/mdbcomp.program_representation.cs Mercury/css/mdbcomp.rtti_access.cs Mercury/css/mdbcomp.slice_and_dice.cs Mercury/css/mdbcomp.trace_counts.cs Mercury/css/mdbcomp.feedback.automatic_parallelism.cs'...

    juliensf tells me that it goes wrong at around line 223 of Mmake.workspace

    My quick solution is to create a dummy mer_rt.dll in the runtime directory, as a workaround.



    1. Add GRADE=csharp to Mmake.params
    2. GRADE=csharp mmake --use-mmc-make

     
    Notes
    (0000477)
    juliensf   
    2012-07-26 01:13   
    Step (2) needs to be mmake --use-mmc-make GRADE=csharp

    Adding GRADE=csharp to Mmake.params doesn't work properly since Mmake.workspaces is
    included before Mmake.params and the former makes the relevant settings concerning what
    libraries mdbcomp is linked against.
    (0000486)
    juliensf   
    2012-12-07 17:14   
    I don't think there's much more to be done here. Since compilers built in the non-C grades don't
    work terribly well anyway, I don't think there is much to be gained from improving support
    for building them. (Supporting four different target languages makes things quite convoluted
    anyway.)

    I will add sections to README.CSharp, README.Java etc describing how to build the compiler
    in the corresponding grades (for those that are interested in such experimentation.)
    (0000492)
    juliensf   
    2013-01-07 16:48   
    I have updated the README files for the non-C backends with a description of how to build the compiler.




    View Issue Details
    272 [mercury] Bug major always 2013-01-02 16:55 2013-01-04 11:51
    pbone x86_64  
    Linux  
    normal  
    new  
    open  
    none    
    none  
       
    The polymorphism pass can generate mode-incorrect code.
    When used with typeclasses and existential types it is possible that the polymorphism pass can create code that does not properly instantiate the typeclass variables.
    Use the attached testcase.
    I found this bug while trying to create a test case for bug271, they may be related.
    bug272.m (464 bytes) 2013-01-04 11:51
    https://bugs.mercurylang.org/file_download.php?file_id=168&type=bug
     
    There are no notes attached to this issue.




    View Issue Details
    270 [mercury] Bug crash always 2012-12-30 05:58 2012-12-31 00:22
    maurojh PC Intel Core I7 2.8GHz, 2.9GB m  
    juliensf Ubuntu Linux  
    urgent 10.04  
    confirmed  
    open  
    none    
    none  
       
    When one uses fact_table, the mercury compiler crashes if there is an error in the fact_table.
    Here is a small program without errors:

    % dic.m
    wrd("cat", "catus").
    wrd("dog", "canis").
    wrd("horse", "equus").
    wrd("person","homo sapiens").

    % bug.m
    :- module bug.

    :- interface.
    :- import_module io.
    :- pred main(io::di, io::uo) is cc_multi.

    :- implementation.
    :- import_module string, list, char.
    :- pred wrd( string::in, string::out) is nondet.
    :- pragma fact_table( wrd/2, "dic.m").

    main(!IO) :-
       ( wrd("horse", X) ->
         print(X,!IO), nl(!IO)
       ; true ).


    The command below compiles the above program flawlessly:

    > mmc --infer-all --use-subdirs --rebuild bug


    However, If I introduce an error in the fact_table, the compiler freezes. For example, let us forget the comma between "horses" and "equus":

    % dic.m
    wrd("cat", "catus").
    wrd("dog", "canis").
    wrd("horse" "equus").
    wrd("person","homo sapiens").


    Now, instead of reporting the error, the compiler freezes.
    In the description of the bug, you will find the steps to reproduce the bug. I tried it in different machines, and I always was able to reproduce the freezing of the compiler. Since I am writing large programs that requires fact_tables I would like that the compiler report errors, instead of crashing or freezing.

    % Correct fact_table
    % dic.m
    wrd("cat", "catus").
    wrd("dog", "canis").
    wrd("horse", "equus").
    wrd("person","homo sapiens").

    % Fact_table that freezes the compiler
    % dic.m
    wrd("cat", "catus").
    wrd("dog", "canis").
    wrd("horse" "equus").
    wrd("person","homo sapiens").
    bug.m (317 bytes) 2012-12-30 05:58
    https://bugs.mercurylang.org/file_download.php?file_id=166&type=bug
     
    Notes
    (0000487)
    juliensf   
    2012-12-30 13:47   
    Have you tried compiling the program as without the fact table pragma? Recent versions of the compiler should be able to generate as efficient code for predicates like wrd/2 without the fact_table/1 pragma.
    (IIRC the only difference is that without the fact_table pragma the compiler may not be able to type check
    that predicate as quickly.)
    (0000488)
    juliensf   
    2012-12-30 13:58   
    The problem is that when building the fact table, the compiler tries to keep going when it encounters
    an error in one of the facts. With verbose output enabled:

    % Reading short interface for module `Mercury/int2s/rtti_implementation.int2'... successful parse.
    % Module qualifying items...
    % done.
    % Expanding equivalence types...
    % done.
    % Converting parse tree to hlds...
    % Read fact 0
    dic.m:003: Syntax error at string "equus": expected `,', `)', or operator
    % Invoking system command `cat >>Mercury/cs/dic.m.c, ...

    It is the invocation of cat after something as gone wrong that is causing the compiler to freeze.
    (0000489)
    edu500ac   
    2012-12-31 00:22   
    juliensf said: "Recent versions of the compiler should be able to generate as efficient code for predicates like wrd/2 without the fact_table/1 pragma." Mauro and Junia wrote a vastly simplified program to demonstrate the bug. The actual program generates user guides and manuals for electronic goods. The generated text can be in many language, like Swahili, Spanish, French and Portuguese, and Guarany. The program builds fact tables from dictionaries and model texts. The fact tables are huge. The arity ranges from 10 to 8. The modes vary from module to module. For example, a mode could be xword(out, out, in, out, in, in, out, out, in, out). The program may consult a chain of 8 nondet dictionaries before making a decision.

    My question is: Can Mercury compiler handle such fact-tables without the pragma declaration? If it can, I think that Mauro and Junia should use standard predicates instead, since their Common Lisp PPCRE programs that generate the fact tables often make mistakes, that confuse the Mercury compiler. Another solution would be to fix the Common Lisp programs to make sure that they don't make mistakes, when allocating a generated fact to a given table. However, I am not sure whether this allocation would be easy, since the decision is made by a neural network.




    View Issue Details
    266 [mercury] Bug trivial always 2012-11-26 13:30 2012-12-07 17:11
    wangp  
    juliensf  
    normal  
    assigned  
    open  
    none    
    none  
       
    --no-warn-missing-det-decls doesn't exist
    The documented option --no-warn-missing-det-decls doesn't exist in the implementation.
     
    Notes
    (0000484)
    juliensf   
    2012-12-07 16:40   
    The implementation hasn't existed since at least version 0.7 (and probably) before. The only
    reference to it is in the user's guide. There are two possible fixes:

    (1) Implement it.
    (2) Delete the mention in the user's guide.

    Since no-one has complained about it not working after all these years I'm leaning towards
    (2). I'll make this change shortly unless I hear otherwise.
    (0000485)
    wangp   
    2012-12-07 17:11   
    I'm not objecting particularly, but in _Determinism analysis in the Mercury compiler_ it is written:

      "However, predicates that are local to a module need not have determinism
    declarations. Since these declarations are useful documentation, the compiler issues a warning if a determinism declaration is omitted, but this warning can be switched off."

    Makes sense to me.




    View Issue Details
    269 [mercury] Bug minor always 2012-12-07 06:27 2012-12-07 14:24
    gloomdemon windows  
    wangp windows 32/64  
    normal any  
    resolved  
    fixed  
    none    
    none  
       
    unicode path handling in dir module
    dir.recursive_foldl2 failed on directory with unicode name QQ菜单

    Uncaught Mercury exception:
    Software Error: string.unsafe_index: illegal sequence
    Stack dump not available in this grade.

    This problem is possible in dir.make_path_name function with incorrect work of function string.length or string.unsafe_index
    unpack utf_dir_small.rar with rar, compile and run 'bugu' program in dir with 'yjkj' directory

    :- module bugu.
    :- interface.

    :- import_module io.

    :- pred main(io::di, io::uo) is det.

    :- implementation.

    :- import_module require, dir, list, bool.

    main(!IO) :-
        Ps = (
            pred(DN::in, BN::in, FT::in, C::out, Di::in, Do::out, !.IO::di, !:IO::uo) is det :-
                C = yes,
                io.write_strings([DN, " ", BN, "\n"], !IO),
                Do = Di
        ),
        dir.recursive_foldl2(Ps, ".", no, [], MaybeResult, !IO),
        (
            MaybeResult = error(_, Err),
            error(io.error_message(Err)) % exception
        ;
            MaybeResult = ok(_)
        ).
    utf_dir_small.rar (696,633 bytes) 2012-12-07 06:27
    https://bugs.mercurylang.org/file_download.php?file_id=165&type=bug
     
    Notes
    (0000482)
    gloomdemon   
    2012-12-07 06:35   
    compilers versions:

    $ mmc --version
    Mercury Compiler, version rotd-2012-02-17, configured for i686-pc-mingw32
    Copyright (C) 1993-2012 The University of Melbourne

    $ gcc --version
    gcc.exe (GCC) 4.6.1
    Copyright (C) 2011 Free Software Foundation, Inc.
    (0000483)
    wangp   
    2012-12-07 14:23   
    Thanks, fixed committed.




    View Issue Details
    265 [mercury] Bug minor always 2012-11-15 00:30 2012-12-07 05:44
    gloomdemon windows  
    windows 32/64  
    normal any  
    new  
    open  
    none    
    none  
       
    long path handling in io module
    "io.file_type" uses "_wstat" in C grade, but *stat didn't support long names on Windows OS (> 260)
    http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/3c093ea9-f0aa-446d-b648-2dabe8480430
    It may be fixed by using "FindFirstFileW" with "\\?\" file name prefix instead of "_wstat".

    Also, other functions in io module (open_input -> mercury_open -> _wfopen) may be can't handle long path.
    unpack test_dir.tar, change path to unpacked directory in bugl program, compile and run
    :- module bugl.
    :- interface.

    :- import_module io.

    :- pred main(io::di, io::uo) is det.

    :- implementation.

    :- import_module require, dir, list, bool.

    main(!IO) :-
        Ps = (
            pred(DN::in, BN::in, FT::in, C::out, Di::in, Do::out, !.IO::di, !:IO::uo) is det :-
                C = yes,
                io.write_strings([DN, " ", BN, "\n"], !IO),
                Do = Di
        ),
        dir.recursive_foldl2(Ps, "C:\\5", no, [], MaybeResult, !IO),
        (
            MaybeResult = error(_, Err),
            error(io.error_message(Err)) % exception
        ;
            MaybeResult = ok(_)
        ).
    test_dir.tar (16,896 bytes) 2012-11-15 00:30
    https://bugs.mercurylang.org/file_download.php?file_id=162&type=bug
    dir.diff (8,095 bytes) 2012-12-07 05:44
    https://bugs.mercurylang.org/file_download.php?file_id=164&type=bug
     
    Notes
    (0000481)
    gloomdemon   
    2012-12-07 05:44   
    (Last edited: 2012-12-07 05:54)
    test_dir.tar can be unpacked without errors with with 7-Zip to disk root directory (c:\, d:\ or other).

    Also dir.recursive_foldl2 and dir.foldl2 can fail on inaccessible dir (no rights to read files list). Possible fix is to skip inaccessible file or dir (see dir.diff).





    View Issue Details
    268 [mercury] Bug crash always 2012-12-03 20:55 2012-12-04 18:22
    ttmrichter Toshiba Satellite L512  
    juliensf Linux Mint  
    normal 11  
    resolved  
    duplicate  
    none    
    none  
       
    Typo in :- end_module declaration leads to compiler crash.
    λ junk → cat test.m
    %-----------------------------------------------------------------------------%
    % vi: ft=mercury ts=4 sw=4 et wm=0 tw=0
    %-----------------------------------------------------------------------------%
    :- module test.

    :- interface.

    :- import_module integer.

    :- func identity(integer) = integer.

    :- implementation.

    identity(X) = X.

    :- end_module not_test.
    λ junk → mmc --make test
    Making Mercury/asm_fast.gc/x86_64-unknown-linux-gnu/Mercury/cs/test.c
    Uncaught Mercury exception:
    Software Error: parse_tree.equiv_type: predicate `parse_tree.equiv_type.replace_in_item_list'/13: Unexpected: module start or end
    Stack dump not available in this grade.
    ** Error making `Mercury/asm_fast.gc/x86_64-unknown-linux-gnu/Mercury/cs/test.c'.
    As above.
    This caused me a frustrating divide-and-conquer debugging session as I tried to figure out why a re-factored module was suddenly crashing the compiler. Generally a warning/error would be preferred to crashes. ;)
     
    There are no notes attached to this issue.




    View Issue Details
    193 [mercury] Bug tweak always 2011-03-28 07:56 2012-07-06 11:19
    colanderman  
     
    normal  
    confirmed  
    open  
    none    
    none  
       
    --introduce-accumulators doesn't recognize "promise all" containing type annotation
    See attached program. Accumulator introduction works with the commented-out "promise all", but not when a do-nothing type annotation is added as in the uncommented "promise all".
    accumbug.m (302 bytes) 2011-03-28 07:56
    https://bugs.mercurylang.org/file_download.php?file_id=117&type=bug
     
    Notes
    (0000325)
    juliensf   
    2011-04-07 08:10   
    It also doesn't work if you module qualify the "*" operators on the lhs of the promise,
    instead of type qualifying them.
    (0000332)
    juliensf   
    2011-05-14 02:38   
    The problem here is that processing the type qualification introduces extra unifications to the goals
    generated for the promise but the code in compiler/assertion.m that examines the promise goal
    does cover the situation where extra unifications are present.

    (1) The working case

    For the declaration:

    :- promise all [A, B, C, ABC] (A * B) * C = ABC <=> A * (B * C) = ABC.

    the corresponding "promise" predicate generated by the compiler is:

    accumbug.'promise__10__accumbug.m'(A, B, C, ABC) :-
      \+ (
        ABC = int.(V_5 * C),
        V_5 = int.(A * B),
        \+ (
          ABC = int.(A * V_6),
          V_6 = int.(B * C)
        )
      ),
      \+ (
        ABC = int.(A * V_8),
        V_8 = int.(B * C),
        \+ (
          ABC = int.(V_7 * C),
          V_7 = int.(A * B)
        )
      ).

    (2) The broken case

    For the declaration:

    :- promise all [A, B, C, ABC] (A * B) * C = ABC : int <=> A * (B * C) = ABC.

    the corresponding "promise" predicate generated by the compiler is:


    accumbug.'promise__9__accumbug.m'(A, B, C, ABC) :-
      \+ (
        V_5 = int.(V_6 * C),
        V_6 = int.(A * B),
        V_5 = ABC, (**)
        \+ (
          ABC = int.(A * V_7),
          V_7 = int.(B * C)
        )
      ),
      \+ (
        ABC = int.(A * V_10),
        V_10 = int.(B * C),
        \+ (
          V_8 = int.(V_9 * C),
          V_9 = int.(A * B),
          V_8 = ABC (**)
        )
      ).

    The code in assertion.m does not account for the extra unifications at (**)




    View Issue Details
    258 [mercury] Bug major always 2012-06-22 14:43 2012-06-23 04:05
    juliensf  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    csharp grade is broken with rotd-2012-06-19
    Compilation of the library in the csharp grade fails with rotd-2012-06-19
    due to:

    ** Error making `mer_std.dll'.
    Mercury/css/exception.cs(413,98): error CS0030: Cannot convert type `int' to `object[]'
    Mercury/css/exception.cs(4365,62): error CS0030: Cannot convert type `int' to
    `object[]'

    This occurs with both Mono and the MS C# compiler.

     
    Notes
    (0000470)
    juliensf   
    2012-06-22 14:50   
    Actually, the java grade is broken too,

    Making Java class files
    Mercury/javas/jmercury/exception.java:463 class expected
        MR_scalar_common_3[0] = new exception.Exception_result_1.Succeeded_1(((java.lang.Object) (/* tuple */ java.lang.Object[].K0)));

    Mercury/javas/jmercury/exception.java:5270 class expected
           /* tuple */ java.lang.Object[] V_2_2 = /* tuple */ java.lang.Object[].K0;
    (0000471)
    juliensf   
    2012-06-23 04:05   
    Fixed -- the problem was caused by the recent change to handling of arity-zero tuples in
    compiler/hlds_code_util.m.




    View Issue Details
    255 [mercury] Bug major always 2012-05-19 14:32 2012-06-19 22:48
    qu1j0t3 PowerPC  
    juliensf OS X  
    normal 10.4.11  
    resolved  
    fixed  
    none    
    none  
       
    build fails on OS X 10.4.11 PowerPC
      $ ./configure --disable-most-grades

    pbg4:~/Downloads/mercury-compiler-11.07.1 toby$ make
    MMAKE_DIR=`pwd`/scripts scripts/mmake MMAKEFLAGS= all
    /tmp/mmake.8duPGY:683: warning: undefined variable `DESTDIR'
    scripts/Mmake.vars:683: warning: undefined variable `DESTDIR'
    Mmake.common:121: warning: undefined variable `DESTDIR'
    /tmp/mmake.8duPGY:1017: warning: undefined variable `DESTDIR'
    cd scripts && PATH=../scripts:../util:$PATH MMAKE_VPATH=. MMAKE_DIR=../scripts DESTDIR= ../scripts/mmake
    make[2]: Nothing to be done for `default_target'.
    /tmp/mmake.8duPGY:1009: warning: undefined variable `DESTDIR'
    cd util && PATH=../scripts:../util:$PATH MMAKE_VPATH=. MMAKE_DIR=../scripts DESTDIR= ../scripts/mmake mfiltercc
    make[2]: `mfiltercc' is up to date.
    /tmp/mmake.8duPGY:1021: warning: undefined variable `DESTDIR'
    gc_grade=`scripts/ml --grade reg.gc --print-gc-grade`; \
    cd boehm_gc && PATH=../scripts:../util:$PATH MMAKE_VPATH=. MMAKE_DIR=../scripts DESTDIR= ../scripts/mmake GC_GRADE=$gc_grade
    MAKEFLAGS=""; export MAKEFLAGS; \
    make -j1 GRADE=reg.gc GC_GRADE=gc \
            libgc.a libgc.dylib \
            FINAL_INSTALL_MERC_GC_LIB_DIR=/usr/local/mercury-11.07.1/lib/mercury/lib \
            dylib
    make[3]: `libgc.a' is up to date.
    make[3]: `libgc.dylib' is up to date.
    make[3]: Nothing to be done for `dylib'.
    /tmp/mmake.8duPGY:1026: warning: undefined variable `DESTDIR'
    cd runtime && PATH=../scripts:../util:$PATH MMAKE_VPATH=. MMAKE_DIR=../scripts DESTDIR= ../scripts/mmake
    make[2]: Nothing to be done for `default_target'.
    /tmp/mmake.8duPGY:1013: warning: undefined variable `DESTDIR'
    cd util && PATH=../scripts:../util:$PATH MMAKE_VPATH=. MMAKE_DIR=../scripts DESTDIR= ../scripts/mmake
    make[2]: Nothing to be done for `default_target'.
    /tmp/mmake.8duPGY:1030: warning: undefined variable `DESTDIR'
    cd robdd && PATH=../scripts:../util:$PATH MMAKE_VPATH=. MMAKE_DIR=../scripts DESTDIR= ../scripts/mmake
    make[2]: Nothing to be done for `default_target'.
    /tmp/mmake.8duPGY:1034: warning: undefined variable `DESTDIR'
    cd library && PATH=../scripts:../util:$PATH MMAKE_VPATH=. MMAKE_DIR=../scripts DESTDIR= ../scripts/mmake
    /tmp/mmake.8duPGY:1038: warning: undefined variable `DESTDIR'
    cd mdbcomp && PATH=../scripts:../util:$PATH MMAKE_VPATH=. MMAKE_DIR=../scripts DESTDIR= ../scripts/mmake
    /tmp/mmake.f0C9tK:1097: Extraneous text after `else' directive
    /tmp/mmake.f0C9tK:1102: *** only one `else' per conditional. Stop.
    make[1]: *** [mdbcomp] Error 2
    make: *** [all] Error 2
    $ ./configure --disable-most-grades
    $ make
    mercury-compiler-11.07.1

    $ gcc -v
    Reading specs from /usr/libexec/gcc/darwin/ppc/3.3/specs
    Thread model: posix
    gcc version 3.3 20030304 (Apple Computer, Inc. build 1819)
    configure-log (13,747 bytes) 2012-05-19 15:22
    https://bugs.mercurylang.org/file_download.php?file_id=151&type=bug
    make-log (38,349 bytes) 2012-05-19 15:22
    https://bugs.mercurylang.org/file_download.php?file_id=152&type=bug
    patch-test.log (15,494 bytes) 2012-05-21 16:14
    https://bugs.mercurylang.org/file_download.php?file_id=153&type=bug
     
    Notes
    (0000455)
    qu1j0t3   
    2012-05-19 14:34   
    I also have access to OS X 10.5/PowerPC and 10.6/x86_64 systems for testing if wanted.
    (0000456)
    juliensf   
    2012-05-19 23:28   
    Fix committed. It should be available in the ROTD in a few days and will also
    be included in the next 11.07.2-beta release.
    (0000457)
    qu1j0t3   
    2012-05-21 16:14   
    Sorry, patch (forwarded by PB) seems not to resolve things. Log attached.
    (0000458)
    juliensf   
    2012-05-21 16:20   
    (Last edited: 2012-05-22 00:07)
    That's a different problem, most probably caused by the version of
    autoconf on Mac OS 10.4 being too old. (I'll take a look at the configure
    script to see if it can be worked around, but it may not be possible to
    do anything about it.)

    If you wait until there is an ROTD available containing the patch and
    compile from the source distribution you won't have that problem (since
    you won't need to run autoconf).

    (0000459)
    qu1j0t3   
    2012-05-23 10:59   
    Not out of the woods yet, I'm afraid; I get this during 'sudo make install':

    ranlib -c /usr/local/mercury-rotd-2012-05-20/lib/mercury/lib/hlc.gc/libmer_rt.a
    ../Mmake.common:486: warning: undefined variable `mer_std.mhs'
    ../Mmake.common:489: warning: undefined variable `mer_std.mhs'
    ../Mmake.common:495: warning: undefined variable `mer_std.os'
    /tmp/mmake.26t9a3:987: warning: undefined variable `mer_std.trans_opts'
    /tmp/mmake.26t9a3:991: warning: undefined variable `mer_std.ms'
    /tmp/mmake.26t9a3:1000: warning: undefined variable `mer_std.ms'
    /tmp/mmake.26t9a3:1020: warning: undefined variable `mer_std.os'
    /tmp/mmake.26t9a3:1021: warning: undefined variable `mer_std.cs'
    /tmp/mmake.26t9a3:1022: warning: undefined variable `mer_std.ss'
    /tmp/mmake.26t9a3:1023: warning: undefined variable `mer_std.pic_ss'
    /tmp/mmake.26t9a3:1024: warning: undefined variable `mer_std.ils'
    /tmp/mmake.26t9a3:1025: warning: undefined variable `mer_std.javas'
    /tmp/mmake.26t9a3:1205: warning: undefined variable `mer_std.os'
    mmc --generate-dependencies --grade hlc.gc --mercury-linkage shared --flags LIB_FLAGS --flags INTER_FLAGS --no-warn-nothing-exported --no-warn-unused-imports mer_std
    mercury_compile: `--host-env-type posix` is incompatible with
      `--csharp-compiler-type microsoft'.
    Mercury Compiler, version rotd-2012-05-20, configured for powerpc-apple-darwin8.11.0
    Copyright (C) 1993-2012 The University of Melbourne
    Usage: mmc [<options>] <arguments>
    Use `mmc --help' for more information.
    make[2]: *** [mer_std.depend] Error 1
    To clean up from failed install, remove /Users/toby/Downloads/mercury-compiler-rotd-2012-05-20/install_grade_dir.hlc.gc
    make[1]: *** [install_grades] Error 1
    make: *** [install] Error 2
    (0000460)
    juliensf   
    2012-05-23 14:53   
    Can you check the setting of the variable MERCURY_CSHARP_COMPILER_TYPE
    in scripts/Mercury.config and scripts/Mercury.config.bootstrap. Are
    they set to "microsoft"?
    (0000461)
    qu1j0t3   
    2012-05-25 12:54   
    pbg4:~/Downloads/mercury-compiler-rotd-2012-05-20 toby$ grep -i csharp.*= scripts/Mercury.config*
    scripts/Mercury.config:MERCURY_CSHARP_COMPILER=csc
    scripts/Mercury.config:MERCURY_CSHARP_COMPILER_TYPE=microsoft
    scripts/Mercury.config.bootstrap:MERCURY_CSHARP_COMPILER=csc
    scripts/Mercury.config.bootstrap:MERCURY_CSHARP_COMPILER_TYPE=microsoft
    (0000462)
    juliensf   
    2012-05-25 15:46   
    I'm pretty sure that Microsoft have never ported their C# compiler to
    Mac OS X or to powerpc. What is the csc executable on that system?

    (A workaround for the above problem would be to set MERCURY_CSHARP_COMPILER_TYPE
    to "unknown" in both cases.)
    (0000463)
    qu1j0t3   
    2012-05-25 23:07   
    Aha! There is a csc executable (the Chicken Scheme compiler). Maybe the test needs to be a little more specific? (And which Unix platforms *do* support the C# compiler?)

    (I guess I can also work around this with a --disable-<foo> option to configure?)
    (0000464)
    juliensf   
    2012-05-25 23:12   
    Ok, that would be it - IIRC the current test just looks for an executable named csc.
    (The only C# compiler -- that works with Mercury -- on Unix is mono, but the executable
    for that is usually called gmcs.) I'll put a stronger test into configure, in the meantime you
    will need to edit scripts/Mercury.config and scripts/Mercury.config.bootstrap by hand.
    (I don't think there is a --disable-foo option that will help here.)
    (0000465)
    qu1j0t3   
    2012-05-26 23:17   
    'make install' was successful, thankyou very much for the prompt help. I am trying a tools/bootcheck as suggested by Boney.
    (0000469)
    juliensf   
    2012-06-19 22:48   
    I've added a stronger test for MS C# to the configure script; it should (hopefully) now distinguish
    between that and the Chicken Scheme compiler.

    I don't think anything can be done about not being able to generate configure on Mac OX X 10.4,
    except upgrading to a newer version of autoconf.




    View Issue Details
    250 [mercury] Bug minor always 2012-01-12 14:34 2012-05-10 10:12
    mgiuca  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    GCC warnings: used but never defined
    In Mercury 11.07 (grade: asm_fast.gc), all non-trivial Mercury programs are causing GCC 4.6 to spit out lots and lots of "used but never defined" warnings. These seem to be caused whenever a function or predicate is curried. The simplest complete example I can think of is this:

    :- module gcc_warn.
    :- interface.
    :- import_module io.
    :- pred main(io::di, io::uo) is det.

    :- implementation.
    :- import_module int.

    :- pred add(int::in, int::in, int::out) is det.
    add(X, Y, Z) :-
        Z = X + Y.

    :- func add_wrap(int, int) = int.
    add_wrap(X, Y) = Z :-
        add(X)(Y, Z).

    main(!IO) :-
        io.write(add_wrap(1, 2), !IO),
        io.nl(!IO).

    Running:

    $ mmc gcc_warn.m

    causes GCC to give the warning:

    gcc_warn.c:80:1: warning: ‘mercury__gcc_warn__add_3_0’ used but never defined [enabled by default]

    The warning is generated due to add_wrap, which curries the add predicate. It also happens if add is a function.
    $ gcc --version
    gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1

    Using Mercury 11.07 beta 2011-11-16 / grade asm_fast.gc. This started happening when I upgraded to Mercury 11.07, but I also upgraded to Ubuntu 11.10 at the same time, so I don't know whether Mercury or GCC regressed.

    The specific GCC command that caused this warning was:
    gcc -I/usr/local/mercury-11.07-beta-2011-11-16/lib/mercury/lib/asm_fast.gc/inc -I/usr/local/mercury-11.07-beta-2011-11-16/lib/mercury/conf -I/usr/local/mercury-11.07-beta-2011-11-16/lib/mercury/inc -O2 -fomit-frame-pointer -fno-strict-aliasing -DMR_USE_GCC_GLOBAL_REGISTERS -DMR_USE_GCC_NONLOCAL_GOTOS -DMR_USE_ASM_LABELS -fno-builtin -fno-omit-frame-pointer -fno-defer-pop -fno-function-cse -fno-gcse -fno-move-loop-invariants -DMR_CONSERVATIVE_GC -DMR_BOEHM_GC -DMR_TAGBITS=2 -ansi -Wall -Wwrite-strings -Wshadow -Wmissing-prototypes -Wno-unused -Wno-uninitialized -Wstrict-prototypes -c gcc_warn.c -o gcc_warn.o

    The line of C code in question is:
    MR_decl_static(gcc_warn__add_3_0)
    gcc_warn.m (474 bytes) 2012-01-12 14:34
    https://bugs.mercurylang.org/file_download.php?file_id=149&type=bug
     
    Notes
    (0000444)
    wangp   
    2012-01-12 17:36   
    Is there any gcc option to suppress the warning now? Otherwise it's just a simple change to util/mfiltercc.c
    (0000445)
    mgiuca   
    2012-01-12 18:01   
    If it was "defined but not used" then suppression would be fine. But I'm a bit nervous about suppressing "used but not defined" errors -- it implies that something could possibly go horribly wrong. (I'm not sure if this is the same thing as when you call a function in C that hasn't been declared, and the types might not convert properly.) Since I don't know exactly what all those Mercury macros do, I'll let you decide, but I'd say it's best if Mercury does whatever GCC is asking it to do rather than suppressing the warning.
    (0000446)
    juliensf   
    2012-01-12 18:38   
    Suppressing this warning is fine. The problem here is that the definition is given is assembly language
    and the compiler can't see that it exists. Note that the function that causes the trouble,

    static void mercury__gcc_warn__add_3_0(void) __asm__("_entry_" "mercury__gcc_warn__add_3_0");

    is also mapped to the same name in assembler.

    The problems here are:
    (1) the warning has changed in gcc 4.6 so mfiltercc isn't filtering it properly
    (2) there's no way to disable the warning AFAIK.

    The problem has existed since about gcc 4.3, i.e. it's not specific to 4.6.
    (0000454)
    wangp   
    2012-05-10 10:12   
    Fix committed today.




    View Issue Details
    254 [mercury] Bug minor always 2012-03-02 13:56 2012-03-02 13:58
    aross  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    HTTP download links for 11.07.1 return 403 forbidden error
    The HTTP download links for the compiler, tests and extras tarballs of Mercury 11.07.1 return a 403 forbidden error, presumably due to incorrect permissions or ownership. The FTP links are fine, so the impact is minor.

    aross@imac:~$ for dist in compiler tests extras; do wget http://www.mercury.c.unimelb.edu.au/download/files/mercury-${dist}-11.07.1.tar.gz; done
    --2012-03-02 13:48:16-- http://www.mercury.csse.unimelb.edu.au/download/files/mercury-compiler-11.07.1.tar.gz
    Resolving www.mercury.csse.unimelb.edu.au... 128.250.29.185
    Connecting to www.mercury.csse.unimelb.edu.au|128.250.29.185|:80... connected.
    HTTP request sent, awaiting response... 403 Forbidden
    2012-03-02 13:48:17 ERROR 403: Forbidden.

    --2012-03-02 13:48:17-- http://www.mercury.csse.unimelb.edu.au/download/files/mercury-tests-11.07.1.tar.gz
    Resolving www.mercury.csse.unimelb.edu.au... 128.250.29.185
    Connecting to www.mercury.csse.unimelb.edu.au|128.250.29.185|:80... connected.
    HTTP request sent, awaiting response... 403 Forbidden
    2012-03-02 13:48:17 ERROR 403: Forbidden.

    --2012-03-02 13:48:17-- http://www.mercury.csse.unimelb.edu.au/download/files/mercury-extras-11.07.1.tar.gz
    Resolving www.mercury.csse.unimelb.edu.au... 128.250.29.185
    Connecting to www.mercury.csse.unimelb.edu.au|128.250.29.185|:80... connected.
    HTTP request sent, awaiting response... 403 Forbidden
    2012-03-02 13:48:17 ERROR 403: Forbidden.
     
    Notes
    (0000453)
    juliensf   
    2012-03-02 13:58   
    Sorry, I forgot to make the files world readable.




    View Issue Details
    174 [mercury] Bug minor always 2010-12-13 17:50 2012-02-13 15:28
    juliensf  
    pbone  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    documentation for extras/lazy_evaluation is out-of-date
    The description of the lazy_evaluation package in extras is out-of-date in various
    places, e.g. extras/README.
     
    Notes
    (0000452)
    juliensf   
    2012-02-13 15:28   
    This has been fixed. The lazy_evaluation directory in extras is now empty and its former
    contents are now either in the standard library or in the samples directory.




    View Issue Details
    200 [mercury] Bug minor have not tried 2011-06-10 03:52 2012-02-13 13:56
    juliensf  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    csharp grade does not install on Cygwin with Mono
    From mercury-users:

    >>> Hello. I'm trying to compile Mercury version 11.01 in cygwin inside
    >>> Windows XP. ./configure and make succeed. When I enter:
    >>>
    >>> make install LIBGRADES=csharp
    >>>
    >>> I get the error:
    >>>
    >>> cygwin warning:
    >>> MS-DOS style path detected: ..\runtime\mercury_dotnet.cs
    >>> Preferred POSIX equivalent is: ../runtime/mercury_dotnet.cs
    >>> Making mer_std.dll
    >>> ** Error making `mer_std.dll'.
    >>> error CS2001: Source file `..runtimemercur
    >>> dotnet.cs' could not be found
    >>>
    >>> I can't find the makefile that is using \ instead of /.
    >>
    >> It is library/Mmakefile:378, specifically these line:
    >>
    >> # Don't use Unix style paths with the Microsoft C# compiler.
    >> ifeq ($(CSC),csc)
    >> MLOBJS += ..\runtime\mercury_dotnet.cs
    >> else
    >> MLOBJS += ../runtime/mercury_dotnet.cs
    >>
    >> The above is a workaround for the fact that --link-object does not yet
    >> do any path conversion.
    >
    > Thanks! That worked. I set both lines to:
    > MLOBJS += ../runtime/mercury_dotnet.cs
    >
    > cygwin uses the Mono compiler. Perhaps Mono doesn't have a problem with Unix
    > style paths?
    It appears as though the wrong assignment to MLOBJS in library/Mmakefile
    is being made when we are telling the compiler to include mercury_dotnet.cs
     
    Notes
    (0000451)
    juliensf   
    2012-02-13 13:56   
    Both mono and MS C# now work correctly on Cygwin without requiring
    modifications to Mmakefiles.




    View Issue Details
    252 [mercury] Bug minor always 2012-02-02 10:29 2012-02-13 13:52
    petdr  
    juliensf  
    normal  
    assigned  
    open  
    none    
    none  
       
    mmc --make doesn't respect the -j flag when building the .cs, .javas or .css target
    If you issue the command

    mmc --make -j4 lib.cs

    then each C/Java/C# file is built sequentially, however if you do

    mmc --make -j4 liblib

    then the C/Java/C# files are built in parallel
     
    Notes
    (0000449)
    juliensf   
    2012-02-10 15:19   
    The build_all targets don't invoke foldl2_maybe_stop_at_error rather than
    foldl2_maybe_stop_at_error_maybe_parallel, so the end up ignoring the -j option.
    (I think the fix is to replace the former with the latter -- I am testing that now.)
    (0000450)
    juliensf   
    2012-02-13 13:52   
    I've committed a partial fix for this that works with everything but the standard library,
    for some reason.




    View Issue Details
    251 [mercury] Bug trivial always 2012-01-19 02:51 2012-01-30 18:31
    colanderman  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    eqvclass.ensure_equivalence(X, X) causes exception
    Calling eqvclass.ensure_equivalence(X, X) (where X is ground) causes an exception of the following form:

    Uncaught Mercury exception:
    Software Error: map.det_insert: key already present
        Key Type: int
        Key Value: 0
        Value Type: int

    See attached test case.
    Obviously the simple fix is for eqvclass.ensure_equivalence to check equality before doing anything else.
    eqvclass_bug.m (223 bytes) 2012-01-19 02:51
    https://bugs.mercurylang.org/file_download.php?file_id=150&type=bug
     
    Notes
    (0000448)
    zs   
    2012-01-30 18:31   
    Fix committed Jan 30.




    View Issue Details
    248 [mercury] Bug tweak N/A 2011-12-14 04:18 2012-01-18 02:50
    colanderman  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Inconsistent argument ordering of singleton_set
    The arguments of singleton_set in set_ordlist and set_unordlist are in reverse order of the arguments of singleton_set in set_tree234 and set_ctree234.
     
    Notes
    (0000447)
    juliensf   
    2012-01-18 02:50   
    Fix committed.




    View Issue Details
    249 [mercury] Bug minor always 2011-12-14 23:34 2011-12-14 23:34
    juliensf  
     
    normal  
    new  
    open  
    none    
    none  
       
    --dump-mlds does not work for non-C grades
    The --dump-mlds option causes the compiler to abort when compiling a program
    in a non-C grade.

    This is due to --dump-mlds being implemented by the MLDS->C code generator; the
    use of non-C grades violates some of the assumptions made by that code generator.
     
    There are no notes attached to this issue.




    View Issue Details
    246 [mercury] Bug major always 2011-12-11 17:40 2011-12-14 17:44
    juliensf  
    zs  
    normal  
    assigned  
    open  
    none    
    none  
       
    HLDS->MLDS code generator abort
    The attached program causes the HLDS->MLDS code generator to abort with the following:

    Uncaught Mercury exception:
    Software Error: map.lookup: key not found
            Key Type: term.var(parse_tree.prog_data.prog_var_type)
            Key Value: var(52)
            Value Type: ml_backend.ml_gen_info.ml_ground_term
    gvs-bug.tar.gz (1,427 bytes) 2011-12-11 17:40
    https://bugs.mercurylang.org/file_download.php?file_id=147&type=bug
     
    Notes
    (0000443)
    zs   
    2011-12-14 17:44   
    Proposed workaround posted to mercury-developers on Dec 14.




    View Issue Details
    242 [mercury] Bug minor always 2011-12-05 10:21 2011-12-14 17:00
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    filename encoding
    The predicate that open files, etc. need to take into account that the file name encoding may not be UTF-8.

    _wfopen looks like the way to go for Windows.

    OS X enforces a decomposed UTF-8 representation.
    Precomposed strings will be automatically decomposed.
    The string returned by the filesystem will be decomposed and may not
    match what you passed in, so that's something to be aware of.

    For Linux, I'm not sure another solution is better than what we have
    now.
     
    Notes
    (0000442)
    wangp   
    2011-12-14 17:00   
    Fix committed.




    View Issue Details
    245 [mercury] Bug crash always 2011-12-07 22:19 2011-12-13 03:23
    jfondren  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    [Java, 11.07-beta-2011-12-06] crashes with ClassCastException
    A program as simple as,

    main(!IO) :- io.write_string("Hello, world!\n", !IO).

    which runs fine in --grade=asm_fast.gc , or with 11.01's Java,
    crashes on start with 11.07-beta-2011-12-06's java grade.

    Exception in thread "main" java.lang.ExceptionInInitializerError
        at jmercury.list.MR_init_scalars_0(list.java:328)
        at jmercury.list.<clinit>(list.java:337)
        at jmercury.io.<clinit>(io.java:947)
        at jmercury.hello.main_2_p_0(hello.java:88)
        at jmercury.hello.main(hello.java:50)
    Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to jmercury.runtime.PseudoTypeInfo
        at jmercury.runtime.TypeInfo_Struct.init(TypeInfo_Struct.java:84)
        at jmercury.runtime.TypeInfo_Struct.<init>(TypeInfo_Struct.java:102)
        at jmercury.pretty_printer.MR_init_scalars_0(pretty_printer.java:695)
        at jmercury.pretty_printer.<clinit>(pretty_printer.java:781)
        ... 5 more
    Mercury Compiler, version 11.07-beta-2011-12-06, configured for i686-pc-linux-gnu

    java version "1.6.0_22"
    OpenJDK Runtime Environment (IcedTea6 1.10.4) (fedora-60.1.10.4.fc16-i386)
    OpenJDK Server VM (build 20.0-b11, mixed mode)

    # failed identically with:
    java version "1.7.0_01"
    Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
    Java HotSpot(TM) Server VM (build 21.1-b02, mixed mode)

    # 11.07-beta-2011-12-06 was built with
    configured by ./configure, generated by GNU Autoconf 2.61,
      with options \"'--disable-most-grades' '--enable-libgrades=java' '--with-default-grade=java'\"
    bug245.m (507 bytes) 2011-12-12 02:59
    https://bugs.mercurylang.org/file_download.php?file_id=148&type=bug
     
    Notes
    (0000434)
    juliensf   
    2011-12-07 23:11   
    We appear to be calling the old constructor for the TypeInfo_Struct class (i.e. the one with
    the arity argument) from the initializer for some scalar common data.
    (0000439)
    juliensf   
    2011-12-12 03:03   
    (Last edited: 2011-12-12 05:09)
    I've updated a reduced test case. The problem occurs because we generate the following:

    MR_scalar_common_1[1] = new jmercury.runtime.TypeInfo_Struct(jmercury.runtime.TypeInfo_Struct.maybe_new(builtin.builtin__type_ctor_info_func_0),
                    3,
                    jmercury.runtime.TypeInfo_Struct.maybe_new(univ.univ__type_ctor_info_univ_0),
                    jmercury.runtime.TypeInfo_Struct.maybe_new(bug245.MR_scalar_common_1[0]),
                    jmercury.runtime.TypeInfo_Struct.maybe_new(bug245.bug245__type_ctor_info_doc_0));

    The TypeInfo_Struct no longer takes an arity argument. There seems to be an issue with how
    rtti_to_mlds.m handles pseudo type-infos -- I've fixed that in my workspace and it makes no
    difference to this. (For the Java backend, psuedo type-infos reuse the TypeInfo_Struct class.)

    Does something other than rtti_to_mlds.m generate calls to the TypeInfo_Struct constructor?

    (0000440)
    juliensf   
    2011-12-12 17:21   
    The answer to the above is yes, ml_unify_gen.m also generates them (when processing unifications
    that involve type_info_cell_constructors). I will post a fix for this shortly.
    (0000441)
    juliensf   
    2011-12-13 03:23   
    Fix committed.




    View Issue Details
    247 [mercury] Bug minor have not tried 2011-12-12 04:08 2011-12-12 04:08
    juliensf  
     
    normal  
    new  
    open  
    none    
    none  
       
    declarative debugger aborts
    When attempting to debug the compiler (which is attempting to compile the test case from bug 0000245),
    the declarative debugger aborts with

    Error: missed final event.
    event 19672059
    last event 19672058
    Errno = 17: File exists
    Mercury runtime: Aborting.
    Last trace event was event #19672059.

    when the "track" command is given.

    This is occuring on goliath.
    The sequence of commands is something like:

    table io_start
    break -E1 mld_to_java.output_scalar_init
    continue
    continue
    step
    finish
    dd
    > yes
    > browse
    > track 3
     
    There are no notes attached to this issue.




    View Issue Details
    244 [mercury] Bug minor always 2011-12-07 07:13 2011-12-10 00:28
    colanderman  
    zs  
    normal  
    feedback  
    reopened  
    none    
    none  
       
    Re-entering partially memoized multi/nondet predicate causes spurious loop exception
    If a memoized multi or nondet predicate is called, and after a few (but not all) results have been returned, is called again in a context which requires all of its solutions (e.g. by the solutions module or an all [] goal), then the following spurious runtime error will be produced:

    Uncaught Mercury exception:
    Software Error: detected need for minimal model in XXX
    Stack dump not available in this grade.

    See attached program for example. Comment out the memo pragma to see the expected behavior.
    Possibly related to bug 111.
    nondet_memo_bug.m (343 bytes) 2011-12-07 07:13
    https://bugs.mercurylang.org/file_download.php?file_id=146&type=bug
     
    Notes
    (0000437)
    zs   
    2011-12-09 18:08   
    This is not a bug. In such situations, the expected value of an atom depends on itself. The Mercury system cannot compute that value without minimal model tabling, as the error message says.
    (0000438)
    colanderman   
    2011-12-10 00:28   
    No, it doesn't depend on itself. The example in the attached test case isn't even recursive. Comment out the pragma memo and it runs just fine.




    View Issue Details
    211 [mercury] Bug minor have not tried 2011-08-22 16:58 2011-12-09 10:26
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    single-precision float grades broken on 64-bit
    Both LLDS (and now high-level C grades) generate structures like this for static data.

    struct foo {
      MR_Word f1;
      MR_Float f2;
      MR_Float f3;
    };

    which is then treated as an array of MR_Word. However, if using MR_Float==float on a 64-bit platform, the C compiler will pack the two float members into a single word.

    Two possible solutions are:

    1. use C compiler extensions to force any MR_Float members to be word-aligned

    2. replace the MR_Float members by a union, e.g.

    union MR_Float_Word {
      MR_Float f;
      MR_Word w;
    };

    This requires additional braces in initialiser lists.
     
    Notes
    (0000350)
    juliensf   
    2011-08-22 21:51   
    I don't think (1) is a solution in this context. The source distribution .c files shouldn't
    make assumptions about the availability or otherwise of compiler extensions.
    (0000351)
    wangp   
    2011-08-23 10:31   
    This only affects single-precision grades on 64-bit platforms, which likely no one uses anyway (why would they? Maybe we should just say it's not supported, and make the compiler issue an error.) Compiler extensions only need to be invoked a rare circumstance.

    /* if defined(MR_USE_SINGLE_PRECISION) && sizeof(MR_Float) < sizeof(MR_Word) */
    #if defined(MR_GNUC) || defined(MR_CLANG)
        typedef MR_Float MR_Float_Aligned __attribute__((aligned(sizeof(MR_Word))));
    #elif defined(MR_MSVC)
        typedef _declspec(align(sizeof(MR_Word))) MR_Float MR_Float_Aligned;
    #else
        #error MR_Float_Aligned not defined
    #endif

    /* otherwise */
    typedef MR_Float MR_Float_Aligned;


    (2) is problematic for high-level data grades. Presumably we would need to use union MR_Float_Word in structures where ever MR_Float currently is, so all field references will need an extra .f suffix.
    (0000352)
    juliensf   
    2011-08-23 13:38   
    Given that the relevant extensions are supported by gcc, clang and visual C, I don't have any objections
    to (1).
    (0000436)
    wangp   
    2011-12-09 10:26   
    Fix committed.




    View Issue Details
    240 [mercury] Bug major always 2011-12-02 20:08 2011-12-09 10:26
    maclarty  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    float unboxing issue on MinGW
    The attached program produces incorrect output when compiled on MinGW with rotd-2011-11-29 in grade hlc.gc at -O1 or lower:

    $ mmc bug.m -O1 --grade hlc.gc
    $ ./bug
    0.0
    123.0
    $ mmc bug.m -O2 --grade hlc.gc
    $ ./bug
    123.0
    123.0

    $ uname -a
    MINGW32_NT-6.1 TTT 1.0.17(0.48/3/2) 2011-04-24 23:39 i686 Msys

    $ gcc --version
    gcc.exe (GCC) 4.6.1

    11.07-beta-2011-11-30 works.
    bug.m (474 bytes) 2011-12-02 20:08
    https://bugs.mercurylang.org/file_download.php?file_id=144&type=bug
     
    Notes
    (0000422)
    juliensf   
    2011-12-02 20:53   
    Hi,

    Does the same also occur with the asm_fast.gc grade on MinGW? Does the same occur on other
    non-Windows 32-bit machines.
    (If the problem is not restricted to MinGW then it's probably an issue to related to Peter's changes
    for unboxed doubles, since that didn't go onto the 11.07 branch.)
    (0000423)
    maclarty   
    2011-12-02 21:40   
    The problem does not occur with asm_fast.gc or 32bit Linux. I also compared the c file generated on Linux and Windows and there are no differences. Note that I used a different version of gcc on Linux (4.4.3).
    (0000424)
    juliensf   
    2011-12-02 21:49   
    I have MinGW gcc 4.5.0 on my laptop so I will give that a try. We should try 4.6.1 on Linux or Mac OS X.
    (0000425)
    juliensf   
    2011-12-03 04:58   
    It also occurs with gcc 4.5.0 on MinGW.
    (0000427)
    juliensf   
    2011-12-03 05:03   
    -O[01] --common-struct works

    -O1 --inline-simple causes both values to be printed incorrectly.
    (0000428)
    maclarty   
    2011-12-03 11:59   
    I believe the cause of the problem is some incorrect assumptions about how struct fields are aligned. Consider the following C program:

    #include <stdio.h>
    struct t {
        void *f1;
        double f2;
    };
    int main() {
        printf("%p\n", &((struct t*)0)->f2);
    }

    On MinGW this produces 8, but on 32 bit Linux it produces 4.

    In the C code generated for bug.m there is the following struct:

    struct bug_scalar_cell_group_1 {
      MR_Box f1;
      MR_Float f2;
    };

    Later on we use MR_hl_field to extract the float field. However MR_hl_field casts the struct to an array of pointers and then looks up element 1. That would look at offset 4, but on MinGW, the float field is at offset 8.
    (0000429)
    wangp   
    2011-12-03 12:36   
    That'd be it, thanks.

    See also bug 0000211
    (0000435)
    wangp   
    2011-12-09 10:25   
    Fix committed.




    View Issue Details
    243 [mercury] Bug minor always 2011-12-05 16:44 2011-12-07 22:29
    juliensf  
    juliensf  
    urgent  
    resolved  
    fixed  
    none    
    none  
       
    Memory zone leak on Windows
    This documents a series of problems that Ian has encountered with memory zones on Windows.

    Executables built in the hlc.gc.trseg grade are leaking memory zones on Windows. The immediate
    cause of the problem is that the call to VirtualFree at runtime/mercury_memory_zones.c:212 is failing
    (it doesn't show because the return value is not checked). Looking closer, I think there are a whole
    series of problems with the VirtualAlloc approach to allocation for memory zones:

    (1) it isn't clear that we are allocating memory correctly in the first place, i.e. doesn't the call
         to VirtualAlloc at runtime/mercury_memory_zones.c:177 also have to reserve the memory
         as well as commit it.

    (2) the call to VirtualFree mentioned above doesn't match the API documentation that says that if
         we call VirtualFree with MEM_RELEASE then the size argument must be 0. (Changing this value
         to 0 just resulted in a segmentation fault.) We should also check the return value of any calls
        to VirtualFree.

    (3) MR_protect_pages should probably be calling VirtualProtect, *not* VirtualAlloc.

    (4) When we allocate a zone using VirtualAlloc when using the Boehm GC we call GC_add_roots
    on the range of memory returned. We do not call GC_remove_roots when deallocating the zone.
    (Which wouldn't work on Windows since Boehm doesn't appear to implement GC_remove_roots on
    Windows.)

    In light of the above, I think the approach using VirtualAlloc doesn't work and we should use the
    version of the zone functions that use the Boehm collector on Windows.
     
    Notes
    (0000433)
    juliensf   
    2011-12-07 22:29   
    Fix committed.




    View Issue Details
    235 [mercury] Bug minor always 2011-11-24 17:22 2011-12-05 16:44
    juliensf  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    java grade does not respect --restricted-command-line
    Building the Mercury compiler in the java grade under MSYS (Windows Server 2008 R2) fails
    because the command line is too long. This occurs even when the Mercury compiler is
    invoked with --restricted-command-line.
     
    Notes
    (0000432)
    juliensf   
    2011-12-05 16:44   
    Fix committed.




    View Issue Details
    239 [mercury] Bug minor always 2011-11-30 08:44 2011-12-05 14:18
    colanderman  
     
    normal  
    new  
    open  
    none    
    none  
       
    Aliasing of partially instantiated structures in solutions.* predicates
    If a partially instantiated structure is fully instantiated and output from the generator predicate of one of the solutions.* predicates, then each result generated will point at the same physical structure (see attached example).

    This is because multi/nondet predicates do not deep copy partially instantiated structures when filling them in, and solutions.builtin_aggregate does not deep copy while generating results (except in the case of accurate garbage collection).

    Since changing the former would result in pervasive ABI changes, I believe that changing solutions.builtin_aggregate to always copy generated results is the correct solution (albeit at a performance hit).
    agg_bug.m (416 bytes) 2011-11-30 08:44
    https://bugs.mercurylang.org/file_download.php?file_id=142&type=bug
    solutions_copy.patch (3,685 bytes) 2011-11-30 08:45
    https://bugs.mercurylang.org/file_download.php?file_id=143&type=bug
     
    Notes
    (0000419)
    colanderman   
    2011-11-30 08:49   
    Attached is a proof-of-concept patch against a 11.07 beta (not CVS, sorry) which fixes the bug in asm_fast.gc, hlc.gc, and java. I believe it also fixes the bug in C# grades, but I cannot test this. I am not sure that the bug exists in Erlang grades.

    The attached patch is suboptimal in that it will unnecessarily copy the aggregation result as well. I suppose the changes in the patch should instead create a new predicate similar to partial_deep_copy, but perhaps there is a cleaner method.
    (0000431)
    mark   
    2011-12-05 14:18   
    The "bug" here is just that the current implementation does not support partially instantiated data structures, so if you want to use them you should expect to need some workarounds. I don't want to pay the cost of unnecessary copying to partly support a feature that won't be fully supported anyway.

    In this case a workaround is to perform the necessary copying yourself in the closure that is passed to solutions.*.




    View Issue Details
    241 [mercury] Bug trivial always 2011-12-03 06:01 2011-12-04 00:36
    colanderman  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    require_semidet doesn't parse
    A typo in compiler/prog_io_goal.m (grep for "require_semi") prevents require_semidet from parsing. See attached test case.
    library/ops.m does not have the typo.
    require_bug.m (276 bytes) 2011-12-03 06:01
    https://bugs.mercurylang.org/file_download.php?file_id=145&type=bug
     
    Notes
    (0000430)
    juliensf   
    2011-12-04 00:36   
    Fix committed.




    View Issue Details
    234 [mercury] Bug minor always 2011-11-24 16:29 2011-12-03 04:59
    juliensf  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    java grade does not compile with Java SE 7
    Compilation of the the java grade with javac 1.7.0_01 causes numerous errors of the type
    below. (This is with Windows Server 2008 R2 and Mercury 11.07-beta.)
    Mercury\javas\jmercury\exception.java:2904: error: reference to TypeInfo_Struct is ambiguous, both constructor TypeInfo_Struct(TypeInfo_Struct,int,Obj
    n TypeInfo_Struct and constructor TypeInfo_Struct(TypeInfo_Struct,Object...) in TypeInfo_Struct match
            TypeInfo_25_25 = new jmercury.runtime.TypeInfo_Struct(TypeCtorInfo_23_23, ActualArity_24, TypeInfo_for_T_21, TypeCtorInfo_22_22);
                             ^
    Mercury\javas\jmercury\exception.java:4631: error: reference to TypeInfo_Struct is ambiguous, both constructor TypeInfo_Struct(TypeInfo_Struct,int,Obj
    n TypeInfo_Struct and constructor TypeInfo_Struct(TypeInfo_Struct,Object...) in TypeInfo_Struct match
            TypeInfo_47_47 = new jmercury.runtime.TypeInfo_Struct(TypeCtorInfo_45_45, ActualArity_46, TypeInfo_for_T_36, TypeInfo_44_44);
                             ^
    Mercury\javas\jmercury\exception.java:4697: error: reference to TypeInfo_Struct is ambiguous, both constructor TypeInfo_Struct(TypeInfo_Struct,int,Obj
    n TypeInfo_Struct and constructor TypeInfo_Struct(TypeInfo_Struct,Object...) in TypeInfo_Struct match
            TypeInfo_42_42 = new jmercury.runtime.TypeInfo_Struct(TypeCtorInfo_40_40, ActualArity_41, TypeInfo_for_T_36, TypeInfo_39_39);
                             ^
    Mercury\javas\jmercury\bit_buffer.java:321: error: reference to TypeInfo_Struct is ambiguous, both constructor TypeInfo_Struct(TypeInfo_Struct,int,Obj
    n TypeInfo_Struct and constructor TypeInfo_Struct(TypeInfo_Struct,Object...) in TypeInfo_Struct match
        MR_scalar_common_3[0] = new jmercury.runtime.TypeInfo_Struct(jmercury.runtime.TypeInfo_Struct.maybe_new(builtin.builtin__type_ctor_info_tuple_0),
                                ^
    Mercury\javas\jmercury\dir.java:2352: error: reference to TypeInfo_Struct is ambiguous, both constructor TypeInfo_Struct(TypeInfo_Struct,int,Object...
    Info_Struct and constructor TypeInfo_Struct(TypeInfo_Struct,Object...) in TypeInfo_Struct match
                              TypeInfo_76_76 = new jmercury.runtime.TypeInfo_Struct(TypeCtorInfo_74_74, ActualArity_75, TypeInfo_71_71, TypeCtorInfo_72_72
    rInfo_73_73);
                                               ^
    Mercury\javas\jmercury\erlang_rtti_implementation.java:1174: error: reference to TypeInfo_Struct is ambiguous, both constructor TypeInfo_Struct(TypeIn
    ,int,Object...) in TypeInfo_Struct and constructor TypeInfo_Struct(TypeInfo_Struct,Object...) in TypeInfo_Struct match
        MR_scalar_common_2[2] = new jmercury.runtime.TypeInfo_Struct(jmercury.runtime.TypeInfo_Struct.maybe_new(builtin.builtin__type_ctor_info_tuple_0),
                                ^
    Mercury\javas\jmercury\erlang_rtti_implementation.java:3184: error: reference to TypeInfo_Struct is ambiguous, both constructor TypeInfo_Struct(TypeIn
    ,int,Object...) in TypeInfo_Struct and constructor TypeInfo_Struct(TypeInfo_Struct,Object...) in TypeInfo_Struct match
            TypeInfo_11_11 = new jmercury.runtime.TypeInfo_Struct(TypeCtorInfo_9_9, ActualArity_10, TypeCtorInfo_8_8, TypeInfo_for_T_6);
     
    Notes
    (0000412)
    juliensf   
    2011-11-25 13:07   
    It's fine with 1.6 (SE 6) on the same machine.
    (0000426)
    juliensf   
    2011-12-03 04:59   
    Fix committed.




    View Issue Details
    238 [mercury] Bug crash always 2011-11-28 12:39 2011-12-01 16:06
    colanderman  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Unexpected: determinism errors when compiling with --constraint-propagation
    Various errors relating to promise_equivalent_solutions are obscured by a compiler crash when compiling with --constraint-propagation or --local-constraint-propagation. The attached program, when compiled with no optimization, produces (as expected), the error:

    pes_crash.m:015: Error: call to predicate `solutions.unsorted_solutions'/2 with
    pes_crash.m:015: determinism `cc_multi' occurs in a context which requires
    pes_crash.m:015: all solutions.
    pes_crash.m:015: Unification of V_2 and V_5 can fail.

    but when compiled with --constraint-propagation, produces the crash:

    Uncaught Mercury exception:
    Software Error: transform_hlds.pd_util: predicate `transform_hlds.pd_util.rerun_det_analysis'/4: Unexpected: determinism errors

    Other errors (such as the one produced by bug 0000237) trigger this crash as well.
    pes_crash.m (297 bytes) 2011-11-29 12:46
    https://bugs.mercurylang.org/file_download.php?file_id=141&type=bug
     
    Notes
    (0000416)
    zs   
    2011-11-28 16:59   
    Without access to pes_crash.m, I cannot confirm whether the fix of bug 237 fixes this one as well.
    (0000418)
    colanderman   
    2011-11-29 12:46   
    Sorry, forgot to upload it. Attached now.
    (0000420)
    zs   
    2011-12-01 14:04   
    Strangely, while mmc --constraint-propagation pes_crash generates the compiler abort, we get back to the benign print-message-and-exit behavior if we just add
    a -v to that command line.
    (0000421)
    zs   
    2011-12-01 16:06   
    Fix committed dec 1.




    View Issue Details
    227 [mercury] Bug minor have not tried 2011-11-09 18:18 2011-11-28 17:01
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    det scope unchecked in lambda expression
    The compiler does not emit an error for this code:

            (pred(C::in) is semidet :-
                require_det (
                    C = 'x'
                )
            )
     
    Notes
    (0000417)
    zs   
    2011-11-28 17:01   
    Fix committed nov 14.




    View Issue Details
    237 [mercury] Bug minor always 2011-11-28 12:30 2011-11-28 16:56
    colanderman  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Strange interaction b/w typeclasses and promise_equivalent_solutions
    promise_equivalent_solutions doesn't seem to play well with typeclasses. The attached example, when, compiled, complains that:

    unif_bug2.m:016: Error: the `promise_equivalent_solutions' goal binds a
    unif_bug2.m:016: variable that is not listed: PolyConst1.

    This is not in a context where the typeclass implementations are not deducible at compile time (i.e. there are no existential types).
    unif_bug2.m (376 bytes) 2011-11-28 12:30
    https://bugs.mercurylang.org/file_download.php?file_id=140&type=bug
     
    Notes
    (0000415)
    zs   
    2011-11-28 16:56   
    Fix committed nov 28.




    View Issue Details
    236 [mercury] Bug text N/A 2011-11-28 08:22 2011-11-28 10:39
    colanderman  
     
    normal  
    new  
    open  
    none    
    none  
       
    Documentation for unsorted_aggregate incorrect (trivial)
    solutions.unsorted_aggregate claims to be declaratively identical to calling list.foldl on the output of solutions.unsorted_solutions, when in fact it acts as if list.foldr is called. This is apparent from the definition of unsorted_solutions in solutions.m, which uses list.cons to build the solutions list (hence building it right-to-left).
     
    Notes
    (0000413)
    maclarty   
    2011-11-28 09:28   
    I don't think this is a bug, because declaratively the order of the solutions returned by unsorted_solutions is not defined (in fact all orders are valid in the declarative reading), so whether foldl or foldr is used for the declarative definition is irrelevant. It would be declaratively identical either way.
    (0000414)
    colanderman   
    2011-11-28 10:39   
    In practice, the order of solutions stays constant from run to run. It is useful while testing code to be able to replace unsorted_solutions with unsorted_aggregate (and v.v.) and obtain the same result. That this assumption is unreliable is sufficiently documented by the cc_multi determinism.

    Changing "foldl" to "foldr" in the documentation is at least on some level "more correct", and is not from any perspective that I can think of less correct.




    View Issue Details
    233 [mercury] Bug minor random 2011-11-24 11:19 2011-11-24 23:24
    pbone  
    pbone  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Parallel run-time system crashes.
    Programs compiled in parallel low-level C grades can crash with an error such as:

    sem_post: Invalid argument

    This happens infrequently and the cause is unknown, it's been seen on taura and mungerabah (RHEL 5).
     
    Notes
    (0000411)
    pbone   
    2011-11-24 23:24   
    I've committed a fix for this.




    View Issue Details
    229 [mercury] Bug crash always 2011-11-15 11:22 2011-11-24 11:36
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    problem with static data on high-level C grades
    The high-level C backend crashes on the given test case. It seems to be related to constants in the arms of lookup switches. Writing the switch as if-then-else or setting --no-common-struct both work around the problem.

    % mmc -s hlc.gc -C lookup_switch_const
    Uncaught Mercury exception:
    Software Error: map.lookup: key not found
            Key Type: term.var(parse_tree.prog_data.prog_var_type)
            Key Value: var(4)
            Value Type: ml_backend.ml_gen_info.ml_ground_term
    lookup_switch_const.m (551 bytes) 2011-11-15 11:22
    https://bugs.mercurylang.org/file_download.php?file_id=136&type=bug
     
    Notes
    (0000409)
    wangp   
    2011-11-24 11:36   
    Fix committed yesterday.




    View Issue Details
    230 [mercury] Bug major have not tried 2011-11-21 15:40 2011-11-23 10:08
    juliensf  
    wangp  
    urgent  
    resolved  
    fixed  
    none    
    none  
       
    submodules inconsistently compiled with direct arg functors
    The attached modules exhibit a bug where the direct arg functor optimisation is applied in a submodule
    but not in its parent.

    (I have a change to the Mercury compiler that I will commit shortly that adds an option that
    causes it to print out a summary of what ctors the daf optimisation has been applied to.)
    daf-bug.tar.gz (816 bytes) 2011-11-21 15:40
    https://bugs.mercurylang.org/file_download.php?file_id=137&type=bug
     
    Notes
    (0000407)
    juliensf   
    2011-11-21 15:57   
    I've committed the --debug-type-rep change to the compiler.
    (0000408)
    wangp   
    2011-11-23 10:08   
    Fix committed today.




    View Issue Details
    228 [mercury] Bug major always 2011-11-10 02:50 2011-11-14 01:36
    juliensf  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    library/lexer.c cannot be compiled with MSVC
    In Rotd-2011-11-10 (and for a probably a few months before) we generate C code for
    library/lexer.c in the hlc.gc grade that cannot be compiled with MSVC. (The 11.07 branch is fine.)
    There are two issues:

    lexer.c(171) : error C2133: 'mercury__lexer__lexer__field_locns_token_0_3' : unknown size
    lexer.m(2466) : error C2440: 'type cast' : cannot convert from 'MR_Float' to 'MR_Float-Dword'
    etc etc
    For issue 1 we just need to emit the array size in the forwarding declaration:

    static const MR_DuArgLocn mercury__lexer__lexer__field_locns_token_0_3[];

    (Does anyone know where it's generated?)

    I haven't looked into the second issue yet.
     
    Notes
    (0000395)
    wangp   
    2011-11-10 10:48   
    Probably somewhere in rtti_out.m, where is_array appears.
    (0000396)
    juliensf   
    2011-11-10 13:45   
    I doubt that, given that rtti_out.m is used for LLDS backend. The problem appears to be in mlds_to_c's
    handling of some RTTI defns. It hasn't shown up before because vector_common_data and the arrays
    for alloc_sites are handled specially (i.e. they are written out in a form that is compatible with MSVC.) Arrays of MR_DuArgLocns are written out using the normal output code for declarations.
    (0000397)
    juliensf   
    2011-11-10 15:45   
    I've posted a diff that fixes the first problem.
    (0000398)
    juliensf   
    2011-11-11 01:11   
    The second problem is caused by the macro MR_float_word_bits, defined as follows

    #define MR_float_word_bits(F, I) \
       ((union MR_float_Dword) (MR_Float) (F)).w[(I)])

    MSVC does not appear to allow casts to unions, see
    <http://msdn.microsoft.com/en-us/library/d9f2bsy2.aspx>
    (0000399)
    juliensf   
    2011-11-11 01:56   
    The code in library/lexer.c that causes the trouble is:
    {
      MR_Word base;
      base = (MR_Word) MR_mkword(MR_mktag(3), MR_new_object(MR_Word, ((MR_Integer) 3 * i sizeof(MR_Word)), NULL, NULL));
      *mercury__lexer__Token_4 = base;
      MR_hl_field(MR_mktag(3), base, 0) = ((MR_Box) (MR_Word) ((MR_Integer) 1));
      MR_hl_field(MR_mktag(3), base, 1) = ((MR_Box) (MR_Word) (MR_float_word_bits(mercury__lexer__Float_5, (MR_Integer) 0)));
      MR_hl_field(MR_mktag(3), base, 2) = ((MR_Box) (MR_Word) (MR_float_word_bits(mercury__lexer__Float_5, (MR_Integer) 1)));
    }

    This can be made to work with MSVC by generating slightly different code that does the same thing, e.g.

    {
     MR_Word base;
     union MR_Float_Dword foo;
     base = (MR_Word) MR_mkword(MR_mktag(3), MR_new_object(MR_Word, ((MR_Integer) 3 * sizeof(MR_Word)), NULL, NULL));
     *mercury__lexer__Token_4 = base;
     MR_hl_field(MR_mktag(3), base, 0) = ((MR_Box) (MR_Word) ((MR_Integer) 1));
     foo.f = mercury__lexer__Float_5;
     MR_hl_field(MR_mktag(3), base, 1) = ((MR_Box) (MR_Word) (foo.w[0]));
     MR_hl_field(MR_mktag(3), base, 2) = ((MR_Box) (MR_Word) (foo.w[1]));
    }

    (Manually making the above changes is sufficient to allow lexer.c to compile with MSVC.)
    (0000400)
    wangp   
    2011-11-11 09:51   
    It would be easier just to use an inline function, as for MR_float_from_dword.

    The low-level C backend has special case handling to detect such pairs of assignments, and rewrites it as a single assignment statement. I can make the hlc backend do that as well.
    (0000401)
    juliensf   
    2011-11-11 13:19   
    Hi Peter,

    Either fix is fine by me - if the fix you suggest is easier to implement then we should do that.
    (0000402)
    wangp   
    2011-11-11 13:49   
    Can you do the first part (the inline function)? I don't have a Windows development environment set up.

    I will do the rewriting as a separate change. MR_float_word_bits will still remain for the possibility that the two instructions are separated or reordered.
    (0000403)
    juliensf   
    2011-11-11 14:26   
    Sure. Just so I'm clear, the intention is to add the inline function:

      MR_Word MR_float_word_bit(MR_Float, MR_Integer)

    and then generate:

      MR_hl_field(MR_mktag(3), base, 1) = ((MR_Box) MR_float_word_bit(mercury__lexer__Float_5, 0);
      MR_hl_field(MR_mktag(3), base, 2) = ((MR_Box) MR_float_word_bit(mercury__lexer__Float_5, 1);

    or do you have something else in mind?

    ----------

    I don't see how MR_float_word_bits can remain in its current form -- any use of it will mean the
    C code can't be compiled with MSVC.
    (0000404)
    wangp   
    2011-11-11 14:56   
    Yes. Will this not work?

        MR_EXTERN_INLINE MR_Float
        MR_float_word_bits(MR_Float f, MR_Integer i)
        {
            union MR_Float_Dword dw;
            dw.f = f;
            return dw.w[i];
        }
    (0000405)
    juliensf   
    2011-11-11 16:26   
    I will check later this evening -- while I do have a Windows development environment set up,
    it's at home at the moment and I'm not. (The Windows machines at work have been requisitioned for
    G12 benchmarking.)
    (0000406)
    juliensf   
    2011-11-11 19:25   
    That does the trick; I've retained the existing (macro) definition for MR_float_word_bits if the C compiler is
    GCC or clang. I'll post a diff to mercury-reviews later this evening.




    View Issue Details
    199 [mercury] Bug minor always 2011-05-31 10:48 2011-11-11 13:51
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    unboxed floats for high-level code
    From mercury_conf_param.h:

    /*
    ** MR_HIGHLEVEL_CODE implies MR_BOXED_FLOAT,
    ** since unboxed float is currently not yet implemented for the MLDS back-end.
    ** XXX we really ought to fix that...
    */
     
    There are no notes attached to this issue.




    View Issue Details
    225 [mercury] Bug tweak always 2011-11-03 10:20 2011-11-04 00:33
    colanderman  
     
    normal  
    new  
    open  
    none    
    none  
       
    Module-level mutable with type "semaphore" causes hlc grade compilation to break.
    Compile attached program with -H. It will produce the following error:

    sema_hlc.m:6:25: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token

    Compiling under asm_fast does not produce this error.
    Also appears with --java.

    Compiler version is 11.07-beta-2011-09-30.
    sema_hlc.m (153 bytes) 2011-11-03 10:20
    https://bugs.mercurylang.org/file_download.php?file_id=135&type=bug
     
    Notes
    (0000375)
    wangp   
    2011-11-03 11:04   
    The underlying problem is bug 0000019.

    For now I will work around it for the hlc case. There should be no problem with the Java grades; at least I couldn't reproduce it with 2011-10-23.
    (0000376)
    colanderman   
    2011-11-03 11:18   
    I only see the bug in the Java grade when I compile with --parallel also:

    $ mmc --java --parallel --rebuild sema_hlc.class
    Making Mercury/javas/jmercury/sema_hlc.java
    sema_hlc.m:001: Warning: interface for module `sema_hlc' does not export
    sema_hlc.m:001: anything.
    Making Mercury/classs/jmercury/sema_hlc.class
    Mercury/javas/jmercury/sema_hlc.java:83: cannot find symbol
    symbol : variable thread__semaphore
    location: class jmercury.sema_hlc
            V_1_1 = thread__semaphore.init_1_f_0(V_2_2);
                    ^
    1 error
    ** Error making `Mercury/classs/jmercury/sema_hlc.class'.
    (0000378)
    wangp   
    2011-11-03 11:26   
    Ok, that'd because there is no 'java.par' grade. You *could* install it, but it would be exactly the same as the 'java' grade.
    (0000379)
    colanderman   
    2011-11-03 11:29   
    Ahh gotcha. I never realized that...
    (0000385)
    juliensf   
    2011-11-04 00:33   
    I suspect attempting to install and/or use the grade "java.par" may have some "interesting" effects on
    the compiler and other tools since they probably don't recognise it as a valid combination of grade
    components.




    View Issue Details
    223 [mercury] Bug minor always 2011-10-24 08:02 2011-11-03 12:08
    colanderman  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    thread.mvar.init/0 and thread.semaphore.init/1 should be marked impure
    thread.mvar.init/0 and thread.semaphore.init/1 are obviously impure but are not marked as such, leading to logical inconsistencies such as this:

    main(!IO) :-
        M1 = init, M2 = init,
        put(M1, 1, !IO), take(M2, _, !IO).

    not being equivalent to this:

    main(!IO) :-
        M1 = init, M2 = M1,
        put(M1, 1, !IO), take(M2, _, !IO).

    (The former will block but the latter will not.)

    They should be marked impure or removed from the library.
     
    Notes
    (0000368)
    wangp   
    2011-10-24 09:37   
    That's true. They were added so that mvar and semaphore mutables could be initialised without the I/O state arguments. Before marking them impure, I would like to see either or both:

    - mutables allowed to be initialised by impure functions
    - mutables initialised by a predicate call with access to the I/O state
    (0000371)
    juliensf   
    2011-10-24 16:10   
    (1) mutables allowed to be initialised by impure functions

    This would be fine, for consistency we should allow calls to semipure functions too.
    (Once this is done mvar.init etc can just be made impure.)

    (2) mutables initialised by a predicate call with access to the I/O state

    This is a bit more tricky. The third argument of a mutable declaration is currently a value, not
    a call. In order to have a predicate call in the third argument this will need to change and probably
    in a way that will break quite a bit of code that already uses mutables.
    (0000380)
    wangp   
    2011-11-03 12:08   
    Fix committed.




    View Issue Details
    224 [mercury] Bug minor always 2011-10-24 11:59 2011-10-25 10:42
    colanderman  
     
    normal  
    new  
    open  
    none    
    none  
       
    STM broken without --inline-compound-threshold 10 --loop-invariants
    Attached is a basic mutex implementation using STM primitives. Compile with:

    mmc --parallel -O0 --inline-compound-threshold 10 --loop-invariants --rebuild stm_bug

    And run. Program will behave as expected (uses 200% CPU on a multiproc platform, does not terminate).

    Recompile without either one (or both) of "--inline-compound-threshold 10" or "--loop-invariants":

    mmc --parallel -O0 --rebuild stm_bug

    And run. Program soon terminates due to failed assertion about the state of the lock.

    Behavior is identical under hlc.par grade (-H flag). Building without any optimization flags fails as well, since -O2 (the default) enables "--inline-compound-threshold 10" but not "--loop-invariants".
    stm_bug.m (1,008 bytes) 2011-10-24 11:59
    https://bugs.mercurylang.org/file_download.php?file_id=133&type=bug
    stm.patch (762 bytes) 2011-10-25 10:41
    https://bugs.mercurylang.org/file_download.php?file_id=134&type=bug
     
    Notes
    (0000369)
    colanderman   
    2011-10-24 12:16   
    Note: in more complex programs I see behavior which I believe is triggered by this bug even with these optimizations enabled. I will attach a test case later.
    (0000370)
    zs   
    2011-10-24 14:40   
    The whole STM implementation is experimental and incomplete. It was worked on by two honours students in the past; noone is working on it currently. Bugs in it won't be fixed until we get someone else who wants to work on the STM system.
    (0000373)
    colanderman   
    2011-10-25 10:42   
    There was a race condition in the STM runtime -- reading an STM variable read the physical location multiple times without a lock. Attached is a patch against CVS which fixes this.




    View Issue Details
    212 [mercury] Bug trivial N/A 2011-08-23 10:00 2011-10-25 01:09
    aross  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Documentation of --no-warn-undefined-options-variables is actually for --warn-undefined-options-variables
    Both the Mercury User Guide and the output of mmc --help contain the following:

    [quote]
     --no-warn-undefined-options-variables
                    Warn about references to undefined variables in
                    options files with `--make'.
    [/quote]

    The description should start with "Disable warnings" instead of "Warn", since the warning is enabled by default and the command-line option being documented disables the warning.
    version-rotd-2011-08-21
     
    Notes
    (0000372)
    juliensf   
    2011-10-25 01:09   
    Fixed.




    View Issue Details
    221 [mercury] Bug major always 2011-10-11 10:09 2011-10-24 16:19
    maclarty  
    maclarty  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    ho specialization bug
    The attached program produces the wrong output when compiled with --optimize-higher-order. It should output "ho2", but instead outputs "ho1". In do_stuff it is specializing P to ho1, when it shouldn't. Here is the relevant bit of the hlds dump for stage 135:

    :- mode do_stuff((builtin.in), (builtin.di), (builtin.uo)) is det.
    bug.do_stuff(Maybe, STATE_VARIABLE_IO_0, STATE_VARIABLE_IO) :-
      ( % cannot_fail switch on `Maybe'
        % Maybe has functor maybe.no/0
        P = bug.ho1
      ;
        % Maybe has functor maybe.yes/1
        P = bug.get_ho2
      ),
      bug.ho1(STATE_VARIABLE_IO_0, STATE_VARIABLE_IO).
    bug.m (674 bytes) 2011-10-11 10:09
    https://bugs.mercurylang.org/file_download.php?file_id=132&type=bug
     
    There are no notes attached to this issue.




    View Issue Details
    99 [mercury] Bug minor always 2009-06-15 01:38 2011-10-09 03:12
    serkho  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Incorrect command-line options for Visual Studio
    I have tried to use Mercury with MSVC2005 and found some glitches:

    1) there is a whitespace after /OUT: in command file for lib, lib.exe is not able to handle it
    2) libcmt.lib should be linked in addition to Mercury libraries
    3) also I had to specify /entry:mainCRTStartup after /link option for linker
     
    Notes
    (0000366)
    juliensf   
    2011-10-09 03:12   
    Fix committed in r1.176 of compiler/compile_target_code.m.




    View Issue Details
    220 [mercury] Bug minor always 2011-10-05 14:58 2011-10-05 15:39
    colanderman  
     
    normal  
    new  
    open  
    none    
    none  
       
    Termination analysis produces spurious "termination constant of infinity" errors
    For certain (not all) functions and/or predicates XXX and YYY, where YYY has :- pragma terminates set, termination analysis will report that:

    "Termination of predicate XXX not proven for the following reason:
     It calls predicate YYY which has a termination constant of infinity."

    and that:

    "Termination constant of function YYY set to infinity for the following reason:
     It contains one or more predicates and/or functions imported from another module."

    Expected behavior is that :- pragma terminates(YYY) causes the compiler to assume YYY terminates, regardless of its body.

    This bug is not exhibited by all such predicates or functions; see attached test case.
    11.07-beta-2011-09-30
    termination.m (885 bytes) 2011-10-05 14:58
    https://bugs.mercurylang.org/file_download.php?file_id=130&type=bug
    termination.err (3,389 bytes) 2011-10-05 14:59
    https://bugs.mercurylang.org/file_download.php?file_id=131&type=bug
     
    Notes
    (0000364)
    colanderman   
    2011-10-05 15:17   
    Looking through the compiler source I think I understand why: because the output arguments of a function/predicate are considered as a whole. In the attached example, one output argument (which does decrease) is used, but the other (which is not known to decrease) is not. The compiler does not maintain enough info to distinguish the two, so it necessarily infers the worst case (infinite termination constant).

    Perhaps :- pragma terminates() should allow optional setting of the termination constant for a given mode? Or should set it to 0?

    Either way this is probably a wishlist item and not a bug per se.
    (0000365)
    colanderman   
    2011-10-05 15:39   
    Nevermind. I just found :- pragma termination_info, and --check-term2, which seems to obviate this need entirely. You guys are good at keeping secrets ;)




    View Issue Details
    172 [mercury] Bug minor have not tried 2010-12-02 14:29 2011-10-05 12:16
    juliensf  
    juliensf  
    normal  
    assigned  
    open  
    none    
    none  
       
    Building library in asm_fast.gc.debug aborts on FreeBSD 8.1

    /home/juliensf/ws2/install_grade_dir.asm_fast.gc.debug/scripts/mgnuc --grade asm_fast.gc.debug --no-ansi -- -fPIC -DMR_PIC \
                    -c io.c -o io.pic_o
    io.c: In function 'io_module326':
    io.c:52935: internal compiler error: Segmentation fault: 11
    Please submit a full bug report,
    with preprocessed source if appropriate.
    See <URL:http://gcc.gnu.org/bugs.html> for instructions.
    gmake[1]: *** [io.pic_o] Error 1
    gmake[1]: Leaving directory `/home/juliensf/ws2/install_grade_dir.asm_fast.gc.debug/library'
    To clean up from failed install, remove /home/juliensf/ws2/install_grade_dir.asm_fast.gc.debug
    gmake: *** [install_grades] Error 1
    *** Error code 2
    gcc -v

    Using built-in specs.
    Target: amd64-undermydesk-freebsd
    Configured with: FreeBSD/amd64 system compiler
    Thread model: posix
    gcc version 4.2.1 20070719 [FreeBSD]
     
    Notes
    (0000295)
    juliensf   
    2010-12-02 14:30   
    This is for the x86_64-unknown-freebsd8.1 architecture.
    (0000363)
    pbone   
    2011-10-05 12:16   
    Target: amd64-undermydesk-freebsd

    ?!? This system _is_ kept under my desk, I must have put that value in /etc/make.conf or something. It's strange that it has shown up here.




    View Issue Details
    219 [mercury] Bug minor always 2011-09-26 10:54 2011-09-26 10:55
    maclarty  
    maclarty  
    low  
    assigned  
    open  
    none    
    none  
       
    declarative debugger abort
    Running the attached program through mdb using asm_fast.gc.decldebug with the attached session results in an abort from the declarative debugger:

    An internal error has occurred; diagnosis will be aborted. Debugging
    message follows:
    insert_new_topmost_node: couldn't find event number
    puzzle_solver.m (14,375 bytes) 2011-09-26 10:54
    https://bugs.mercurylang.org/file_download.php?file_id=128&type=bug
    session (104 bytes) 2011-09-26 10:54
    https://bugs.mercurylang.org/file_download.php?file_id=129&type=bug
     
    There are no notes attached to this issue.




    View Issue Details
    218 [mercury] Bug feature have not tried 2011-09-26 08:41 2011-09-26 09:52
    pbone  
     
    low  
    new  
    open  
    none    
    none  
       
    Feature request: mdb commands for working with common data structures.
    Often when using the degger I'd like to know something about a data structure.

    browser> print
    proc_info(context("mandelbrot.m", 279),
      varset(var_supply(10),
        map([(var(1) -> "TypeInfo_for_X"), (var(2) -> "TypeInfo_for_Y"),
          (... -> ...), ...]), map([])),
      map([
        (var(1) ->
          defined_type(qualified(unqualified("private_builtin"), "type_info"), [],
            kind_star)), (var(2) -> defined_type(qualified(...), ...)),
        (var(...) -> ...), ..., ...]), [var(21), var(22), var(...), ...],
      varset(var_supply(0), map([]), map([])),
      yes([(ground(...) -> ...), ..., ...]),
      [user_defined_mode(qualified(...), ...), ..., ...], no, no, ...)
    browser> cd 3
    browser> print
    map([
      (var(1) ->
        defined_type(qualified(unqualified("private_builtin"), "type_info"), [],
          kind_star)),
      (var(2) ->
        defined_type(qualified(unqualified("private_builtin"), "type_info"), [],
          kind_star)),
      (var(3) -> defined_type(qualified(unqualified(...), ...), [], ...)),
      (var(4) -> higher_order_type(...)), (... -> ...), ...])

    What I want to know at this point is var(21) present in this map and what is it's value.

    It'd be nice to have commands to work with maps, sets, lists, and perhaps other commonly-used data-structures to anwser these questions. This should be without
    using the clunky compile a .m file and dynamically load it into the binary being debugged operation.
     
    Notes
    (0000361)
    maclarty   
    2011-09-26 09:32   
    Just wanted to check if you're aware of the 'open' command. This opens a given term in your editor. I generally find this sufficient for checking whether data structures contain particular values.
    (0000362)
    pbone   
    2011-09-26 09:52   
    That's helpful, but not perfect.

    It won't open subterms for me, such as "open 5/6"

    Instead I have to match parens (vim helps) and count.




    View Issue Details
    217 [mercury] Bug major always 2011-09-20 01:52 2011-09-21 17:23
    dkononenko  
    juliensf  
    normal  
    resolved  
    no change required  
    none    
    none  
       
    Can't compile simple program
    cat testlist.m

    :- module testlist.
    :- interface.
    :- import_module io.

    :- pred main(io::di, io::uo) is det.

    :- implementation.
    :- import_module list.

    main(!IO) :- L=[1,2,3], io.write_list(L, "\n", io.write_int, !IO).

    --------

    wc -l testlist.m
          11 testlist.m

    --------

    mmc --make testlist
    Making Mercury/os/testlist.o
    testlist.m:26: error: initializer element is not constant
    testlist.m:26: error: (near initialization for ‘testlist_scalar_common_1[0][1]’)
    ** Error making `Mercury/os/testlist.o'.

    uname -a
    Darwin MacBook-Pro-Denis-Kononenko.local 11.1.0 Darwin Kernel Version 11.1.0: Tue Jul 26 16:07:11 PDT 2011; root:xnu-1699.22.81~1/RELEASE_X86_64 x86_64

    mmc --version
    Mercury Compiler, version 11.01, configured for x86_64-apple-darwin10.8.0
    Copyright (C) 1993-2011 The University of Melbourne

    testlist.m (205 bytes) 2011-09-20 01:52
    https://bugs.mercurylang.org/file_download.php?file_id=127&type=bug
     
    Notes
    (0000360)
    dkononenko   
    2011-09-20 21:10   
    I solved this problem
    I update MacOS from Leopard to Lion - in Lion for default
    ls -l /usr/bin/gcc
    lrwxr-xr-x 1 root wheel 12 19 ??? 06:32 /usr/bin/gcc -> llvm-gcc-4.2
    I rebuild Mercury with parameter CC=gcc-4.2




    View Issue Details
    207 [mercury] Bug major always 2011-07-28 10:49 2011-09-06 10:23
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    tree_bitset.difference bug
    In the following test case tree_bitset.difference produces the wrong result on 32-bit platforms.

    % ./tree_bitset_difference
    set: [532, 32431]
    tree_bitset: []

    This affects the compiler since the recent representation change.
    tree_bitset_difference.m (1,212 bytes) 2011-07-28 10:49
    https://bugs.mercurylang.org/file_download.php?file_id=125&type=bug
     
    Notes
    (0000342)
    zs   
    2011-07-28 14:53   
    Fix committed 28 July.
    (0000343)
    wangp   
    2011-07-29 10:13   
    Unfortunately it was only a partial fix. Here are a few more cases. I don't know if there are significant differences between them.


        test([1, 29424], [1, 2, 3, 35701], !IO),
        test([1], [2, 35701], !IO),
        test([101, 102], [1, 2, 3, 35699, 35700, 35701], !IO),
        test([35696, 35702, 35703, 35704, 35705], [1, 2, 3, 33416, 334283], !IO),
    (0000346)
    wangp   
    2011-08-03 12:07   
    (Last edited: 2011-08-03 12:17)
    Is this the fix? edit: no.

    diff --git a/library/tree_bitset.m b/library/tree_bitset.m
    index e01831c..716416f 100644
    --- a/library/tree_bitset.m
    +++ b/library/tree_bitset.m
    @@ -2130,7 +2130,7 @@ difference(SetA, SetB) = Set :-
     interiornode_difference(LevelA, HeadA, TailA, LevelB, HeadB, TailB,
             Level, List) :-
         ( LevelA < LevelB ->
    - range_of_parent_node(HeadA ^ init_offset, LevelA + 1,
    + range_of_parent_node(HeadA ^ init_offset, LevelA,
                 ParentInitOffsetA, ParentLimitOffsetA),
             (
                 find_containing_node(ParentInitOffsetA, ParentLimitOffsetA,

    (0000347)
    zs   
    2011-08-03 19:16   
    That fixes one bug, but there are others. I have tentative fixes for another two, but I am reconsidering the wisdom of just fixing bugs in the existing code. The code was designed the way it is because it was supposed to be slow but simple, and the bugs show it isn't simple. It looks like getting a faster design correct may not be that much more work than fixing the slow design.

    In the meantime, one possible workaround for the problem is to make set_of_var use sparse_bitset instead of tree_bitset.
    (0000359)
    zs   
    2011-09-06 10:23   
    Fix committed a while ago.




    View Issue Details
    216 [mercury] Bug minor always 2011-09-05 14:56 2011-09-06 10:23
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    hlc grade generates empty structs in static data
    The generated C code for library/char.m in the hlc.gc grade contains an empty struct and also an array of empty structs that is referenced anywhere else within the module. This breaks compilation with Visual C, since it doesn't support empty struct definitions. Since the definition isn't referred to it's
    pointless anyway.

    /* sealed */ struct mercury__char__vector_common_type_2_0_s {
    };


     static /* final */ const struct mercury__char__vector_common_type_2_0_s mercury__char_vector_common_2[103] = {
      /* row 0 */
      {

      },
      /* row 1 */
      {

      },
      /* row 2 */
      {

      },
      /* row 3 */
      {

      },
    This affects a number of other stdlib modules, char.m is just the first one that is compiled.
     
    Notes
    (0000358)
    zs   
    2011-09-06 10:23   
    Fix committed sep 6.




    View Issue Details
    215 [mercury] Bug text N/A 2011-09-05 14:37 2011-09-05 14:50
    aross  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Documentation of assoc_list.filter/4 is missing the TrueList argument
    In the first line of the documentation of assoc_list.filter/4 there is a missing argument, TrueList, which should appear between List and FalseList:

        % assoc_list.filter(Pred, List, FalseList) takes a closure with one
        % input argument and for each member K - V of List X, calls the closure
        % on the key. K - V is included in TrueList iff Pred(K) is true.
        % K - V is included in FalseList iff Pred(K) is false.
        %
    :- pred assoc_list.filter(pred(K)::in(pred(in) is semidet),
        assoc_list(K, V)::in, assoc_list(K, V)::out, assoc_list(K, V)::out) is det.
    rotd-2011-09-03
     
    Notes
    (0000357)
    juliensf   
    2011-09-05 14:50   
    Fixed.




    View Issue Details
    173 [mercury] Bug minor always 2010-12-06 18:18 2011-08-19 03:19
    juliensf  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    man pages for 10.04.2 contain string "Error reading options file"
    from mercury-isers

    I've noticed that after building Mercury 10.04.2, all (?) the Unix man pages contain the string "Error reading options file". From the top of mmc.1:
                                                                                                                                                                              
    .de Vb
    .nf
    .ne \$1
    ..
    .de Ve
                                                                                                                                                                              
    .fi
    ..
    .TH mmc 1 "Fri Nov 19 15:36:47 GMT 2010" "" "Mercury Programmer's Manual"
    .AT 3
    .Vb 2
    Error reading options file
    .SH " `/usr/local/pkg/mercury-10.04.2-i686-1/lib/mercury/conf/Mercury.config'."
                                                                                                                                                                              
    .SH "NAME "
    mmc -- Melbourne Mercury Compiler, version 10.04.2, configured for i686-pc-linux-gnu
                                                                                                                                                                              
    I can't find mention of this in the mailing list archive.
                                                                                                                                                                              
    I'd prefer that the string wasn't there. I could edit it out from all the man page files, of course, but how can I (or you) prevent the string from being there next
    time I build? The build appeared to go well, but I didn't save a log file.
                                                                                                                                                                              
    John A. Murdie
    Department of Computer Science
    University of York
    UK
     
    Notes
    (0000349)
    juliensf   
    2011-08-19 03:19   
    Fixed in r1.56 of doc/Mmakefile.




    View Issue Details
    210 [mercury] Bug text N/A 2011-08-17 13:26 2011-08-19 01:21
    aross  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Language Reference confuses maybeskel and listskel in "Insts, modes, and mode definitions"
    In section 4.1 (Insts, modes, and mode definitions) of the Mercury Language Reference Manual there is the following text:

    [quote]
    For example, the following declaration

         :- inst maybeskel(Inst) ---> no ; yes(Inst).

    defines the inst ‘listskel(Inst)’ to be a list skeleton whose elements have inst ‘Inst’; you can the use insts such as ‘listskel(listskel(free))’, which represents the instantiation state of a list of lists of free variables.
    [/quote]

    The declared inst (maybeskel) doesn't match the description (listskel).

    There is also a typo in the description: "can the use" should be "can then use".
    version rotd-2011-08-15
     
    Notes
    (0000348)
    juliensf   
    2011-08-19 01:21   
    Fixed in r1.469 of doc/reference_manual.texi.




    View Issue Details
    209 [mercury] Bug minor have not tried 2011-08-01 03:05 2011-08-01 13:09
    juliensf  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    java grade broken in rotd-2011-07-31
    The library does not compile in the java grade on goliath (the ROTD host). The last
    working compiler on that machine is rotd-2011-07-23. The relevant part of the build
    log is reproduced below.

    This appears to affect only the trunk, not the 11.07 branch.
    Making Mercury/javas/jmercury/thread__semaphore.java
    Making Java class files
    Mercury/javas/jmercury/array.java:682: incompatible types
    found : jmercury.builtin.Comparison_result_0
    required: int
                    case builtin.Comparison_result_0.K1:
                                                    ^
    Mercury/javas/jmercury/array.java:735: incompatible types
    found : jmercury.builtin.Comparison_result_0
    required: int
                    case builtin.Comparison_result_0.K0:
                                                    ^
    Mercury/javas/jmercury/array.java:743: incompatible types
    found : jmercury.builtin.Comparison_result_0
    required: int
                    case builtin.Comparison_result_0.K2:
                                                    ^
    ... error log truncated, see `mer_std.err' for the complete log.
    make[1]: *** [libmer_std.install] Error 1
    make[1]: Leaving directory `/home/goliath/workspaces/test_mercury_goliath/build.latest.gcc/mercury/stage2/install_grade_dir.java/library'
    To clean up from failed install, remove /home/goliath/workspaces/test_mercury_goliath/build.latest.gcc/mercury/stage2/install_grade_dir.java
    make: *** [install_grades] Error 1
     
    Notes
    (0000344)
    wangp   
    2011-08-01 13:09   
    Fix committed 1 Aug 2011.




    View Issue Details
    205 [mercury] Bug text N/A 2011-07-21 16:07 2011-07-23 18:03
    aross  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Documentation of array.foldr2 references non-existent list.foldr2
    The documentation of array.foldr2 says:

    "array.foldr2(P, Array, !Acc1, !Acc2) is equivalent to list.foldr2(P, array.to_list(Array), !Acc1, !Acc2) but more efficient."

    but list.foldr2 doesn't exist - there's only list.foldr and list.foldl2.

    Perhaps it should instead use the description of list.foldl2 with s/list.foldl/array.foldr/g
     
    Notes
    (0000339)
    juliensf   
    2011-07-23 18:03   
    Fixed in r1.191 of library/array.m.




    View Issue Details
    206 [mercury] Bug text N/A 2011-07-22 09:29 2011-07-23 18:03
    aross  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    User's guide has incorrect short option name for mtc --output-file
    The "Generating trace counts" section of the Mercury User's Guide states:

    ‘mtc’ accepts an ‘-f’ or ‘--output-file’ option

    but the short option is actually '-o'.

    The mtc help/usage message (and hence the man page) lists the correct option name.


    This problem is present in both 11.01 and rotd-2011-07-17
     
    Notes
    (0000338)
    juliensf   
    2011-07-23 18:03   
    Fixed in r1.631 of doc/user_guide.texi.




    View Issue Details
    204 [mercury] Bug minor always 2011-07-12 16:17 2011-07-13 10:42
    juliensf  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Generated code seg faults
    The attached program seg faults when compiled with the current rotd. It is fine with the 11.07-beta
    compiler. I suspect this is to do with the enumeration argument packing optimization since that
    is the only significant difference between the trunk and the branch. (And the test case involves
    a type which has that optimization applied to it.)
    Bug appears on x86_64 Linux in various grades, notably hlc.gc and asm_fast.gc.
    (I haven't looked at what happens on other machines.)
    zinc-pack-bug.tar.gz (1,383 bytes) 2011-07-12 16:17
    https://bugs.mercurylang.org/file_download.php?file_id=124&type=bug
     
    There are no notes attached to this issue.




    View Issue Details
    202 [mercury] Bug minor always 2011-07-04 01:40 2011-07-11 14:20
    juliensf  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Test failures in profdeep grades
    The following test cases are failing on goliath in the asm_fast.gc.profdeep grade:

    FAILED TEST hard_coded/impl_def_literal in grade asm_fast.gc.profdeep
    FAILED TEST hard_coded/special_char in grade asm_fast.gc.profdeep
    FAILED TEST hard_coded/string_class in grade asm_fast.gc.profdeep
    FAILED TEST hard_coded/string_codepoint in grade asm_fast.gc.profdeep
    FAILED TEST hard_coded/string_first_char in grade asm_fast.gc.profdeep
    FAILED TEST hard_coded/string_presuffix in grade asm_fast.gc.profdeep
    FAILED TEST hard_coded/string_set_char in grade asm_fast.gc.profdeep
    FAILED TEST hard_coded/string_strip in grade asm_fast.gc.profdeep
    FAILED TEST hard_coded/string_sub_string_search in grade asm_fast.gc.profdeep
    FAILED TEST hard_coded/test_pretty_printer in grade asm_fast.gc.profdeep
    FAILED TEST hard_coded/unicode_test in grade asm_fast.gc.profdeep
    FAILED TEST hard_coded/utf8_io in grade asm_fast.gc.profdeep
    FAILED TEST hard_coded/words_separator in grade asm_fast.gc.profdeep


    This is due to the following abort in the compiler when writing out the .c file:

    Software Error: string.unsafe_index: illegal sequence
    Stack dump not available in this grade.

    In particular, it occurs when writing out the module strings for a module.
    (At a guess, we aren't handling UTF-8 encoded strings correctly here.)
     
    Notes
    (0000336)
    juliensf   
    2011-07-11 14:20   
    Fix committed by Peter Wang.




    View Issue Details
    136 [mercury] Bug minor always 2010-03-11 04:41 2011-07-04 13:51
    juliensf  
     
    normal  
    confirmed  
    open  
    none    
    none  
       
    hard_coded/impl_def_literal fails with -O5 --intermodule optimization
    The test case hard_coded/impl_def_literal causes the following abort in the compiler:

    Uncaught Mercury exception:
    Software Error: pred_table.m: Unexpected: can't locate stm_from_outer_to_inner/2

    To reproduce:

    mmc -C --grade asm_fast.gc -O5 --intermodule-optimisation impl_def_literal.m
    This was with rotd-2010-03-10
     
    Notes
    (0000335)
    juliensf   
    2011-07-04 13:51   
    --intermodule-optimization is currently disabled for this test. It can be enabled again once
    the STM issue is fixed.




    View Issue Details
    201 [mercury] Bug crash random 2011-06-11 12:31 2011-06-11 12:31
    pbone  
     
    normal  
    new  
    open  
    none    
    none  
       
    tests/par_conj/cosume_wait blocks before exiting.
    tests/par_conj/cosume_wait blocks before exiting.

    This is repeatable (intermittently) on taura running with MERCURY_OPTIONS=-P4
    The test fails sometimes during the nightly tests (the system is doing other work) and when ran in the day time while the system is relatively unused.

    When this locks up it also seems to lock up gdb, making it difficult to diagnose.
    Using MR_DEBUG_THREADS and some reporting from gdb I have determined that all the worker threads finish, the main thread either has finished or is ready to finish but one of Boehm's threads is still running. Therefore I think this may be a problem with the Boehm GC.
    It may be possible to work around this bug by executing it with GC_MARKERS=1
     
    There are no notes attached to this issue.




    View Issue Details
    198 [mercury] Bug text always 2011-05-13 01:15 2011-05-19 17:35
    colanderman  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    event is a keyword but not mentioned in documentation
    As summary: event is a keyword (prog_io_goal.m) but not mentioned in documentation.
     
    Notes
    (0000328)
    juliensf   
    2011-05-13 21:15   
    Event goals are described in the Users's Guide, in the section entitled ``User defined events''.
    (0000329)
    juliensf   
    2011-05-13 21:16   
    I will add something to the reference manual that points to the relevant bit of the user's guide.
    (0000334)
    juliensf   
    2011-05-19 17:35   
    Fix committed as part of r1.462 of doc/reference_manual.texi.




    View Issue Details
    197 [mercury] Bug minor always 2011-05-09 01:01 2011-05-16 15:01
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    abort in state variable transformation
    The attached program causes an abort in the state variable transformation instead of
    a proper error message being emitted.
    svbug.m (727 bytes) 2011-05-09 01:01
    https://bugs.mercurylang.org/file_download.php?file_id=121&type=bug
     
    Notes
    (0000333)
    zs   
    2011-05-16 15:01   
    Fix committed 16 May 2011.




    View Issue Details
    194 [mercury] Bug minor always 2011-03-30 02:42 2011-05-13 21:54
    xonix  
     
    normal  
    confirmed  
    open  
    none    
    none  
       
    Optimizations -O4 to -O6 causing wrong answer
    When compiling the attached program with command line

    >mmc.bat --make --infer-all -s hlc.gc aag12

    The program prints correct output

    1->[]
    2->[]
    3->[]

    But when add option -O4/-O5/-O6:

    >mmc.bat --make --infer-all -s hlc.gc -O5 aag12

    the result is incorrect:

    1->[5379551]
    2->[5379551]
    3->[5379551]
    >mmc.bat
    Mercury Compiler, version 10.04.2, configured for i686-pc-mingw32
    Copyright (C) 1993-2010 The University of Melbourne
    Usage: mmc [<options>] <arguments>
    Use `mmc --help' for more information.
    aag12.m (610 bytes) 2011-03-30 02:42
    https://bugs.mercurylang.org/file_download.php?file_id=118&type=bug
    Mercury.options (274 bytes) 2011-05-13 21:53
    https://bugs.mercurylang.org/file_download.php?file_id=122&type=bug
     
    Notes
    (0000330)
    juliensf   
    2011-05-13 21:53   
    A similar thing occurs with rotd-2011-05-13.
    (0000331)
    juliensf   
    2011-05-13 21:54   
    The attached Mercury.options contains a minimal set of optimisations that exhibit the bug.




    View Issue Details
    188 [mercury] Bug minor always 2011-03-11 12:28 2011-05-03 14:37
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    structure-reuse and intermod-opt breaks type_list_subsumes
    From Michael Day:

    Hi,

    The attached module compiles fine with --structure-reuse, but
    compilation fails when --intermod-opt is also specified:

    $ mmc --make reuse --intermod-opt --structure-reuse
    ...
    Software Error: prog_type.m: Unexpected: type_list_subsumes_det:
    type_list_subsumes failed
    Something changed after mercury-compiler-rotd-2010-10-17. I haven't tried to isolate it further.
    reuse1.m (365 bytes) 2011-03-11 12:28
    https://bugs.mercurylang.org/file_download.php?file_id=114&type=bug
     
    There are no notes attached to this issue.




    View Issue Details
    195 [mercury] Bug tweak always 2011-04-01 13:18 2011-04-07 07:17
    colanderman  
     
    normal  
    confirmed  
    open  
    none    
    none  
       
    mmc --java ignores -o option
    Simply put: "mmc --java -o bar foo.m" always names the executable "foo"; the executable should be named "bar".
     
    Notes
    (0000324)
    juliensf   
    2011-04-07 07:17   
    In the above case, it's because the code that generates the wrapper scripts ignores the
    value of the -o option; that should be fairly trivial.

    For the Java backend in general, it's a little more tricky because for non-trivial programs
    the the use of mmc --make is required and -o is not currently implemented for that.




    View Issue Details
    192 [mercury] Bug feature N/A 2011-03-23 06:17 2011-03-23 06:17
    colanderman  
     
    normal  
    new  
    open  
    none    
    none  
       
    State variable record notation enhancement
    With the coming changes to the library to better support state variable use, I believe that the following notation would be useful:

    foo(..., !X ^ bar)

    would be equivalent to:

    foo(..., !.X ^ bar, X_bar), !X ^ bar := X_bar

    Multiple uses of this notation within one predicate call should probably be disallowed.
     
    There are no notes attached to this issue.




    View Issue Details
    190 [mercury] Bug minor always 2011-03-17 12:40 2011-03-18 15:09
    colanderman  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    solver type constraint_store declaration has trouble unifying imported types
    If a solver type constraint_store declares a mutable of an imported type (say list), it fails trying to unify the unqualified type name with the qualified version (e.g. list(int) with list.list(int)).
    A workaround is to prefix the type name in the mutable declaration.

    The bug does not occur in normal mutable declarations.
    mutable_bug.m (222 bytes) 2011-03-17 12:40
    https://bugs.mercurylang.org/file_download.php?file_id=115&type=bug
     
    Notes
    (0000317)
    juliensf   
    2011-03-17 14:25   
    The problem here is that module qualification skips the constraint_store attribute.
    (0000318)
    colanderman   
    2011-03-17 14:57   
    More info: this seems also to occur with locally defined types and equivalence types (equivalences aren't checked).
    (0000319)
    juliensf   
    2011-03-17 16:39   
    I've committed the a fix for the first problem. The second problem is due to equivalence
    types in the constraint_store attribute not being expanded; I'm presently testing
    a fix for that.
    (0000320)
    juliensf   
    2011-03-18 15:09   
    A fix for the problem with equivalence type expansion in constriant_store atttributes
    has been committed as well.




    View Issue Details
    189 [mercury] Bug minor always 2011-03-16 04:35 2011-03-16 17:10
    colanderman  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    foreign_enum is not 64-bit safe
    The definition of MR_ForeignEnumFunctorDesc in mercury_type_info.h assumes a 32-bit word size. This causes problems with foreign enum values which have bit 31 set, as their Mercury counterparts are incorrectly sign-extended, causing matching to fail.
    As a workaround, one can cast foreign enum values to MR_int_least32_t before passing to Mercury.
     
    Notes
    (0000316)
    juliensf   
    2011-03-16 17:10   
    Fix committed. The field in MR_ForeignEnumFunctorDesc should have had type MR_Integer,
    not MR_int_least32_t.




    View Issue Details
    103 [mercury] Bug minor always 2009-09-14 12:17 2011-03-08 21:33
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    bug in lcmc transformation
    The compiler crashes on the given test case.

    % mmc --optimize-constructor-last-call lco_bug
    Uncaught Mercury exception:
    Software Error: map.lookup: key not found
            Key Type: term.var(parse_tree.prog_data.prog_var_type)
            Key Value: var(2)
            Value Type: ll_backend.var_locn.var_state
    lco_bug.m (1,235 bytes) 2009-09-14 12:17
    https://bugs.mercurylang.org/file_download.php?file_id=79&type=bug
     
    Notes
    (0000315)
    zs   
    2011-03-08 21:33   
    If an argument in a recursive call is both a head variable AND
    is used in a unification that we are trying to move before
    the recursive call, like this:

      rec_call(..., HV2, X),
      HV3 = functor(HV2, X)

    then each call through this recursive call site is next to a
    unification that creates a cell with a field (in this case
    the first field) that needs to be set to the value of HV2
    finally computed by a base case. After the Nth recursive call,
    there will be N cells. There is no way we can pass N addresses
    to the base case without making the transformed code pass a
    LIST of addresses in place of HV2 in the argument list.
    That would be a different transformation than what lco.m does,
    and it is far from clear that that transformation would be a
    good idea, since it doubles the number of loop iterations
    we would need to execute (N recursive calls, and N iterations
    of a loop to fill in the fields).
      
    The fix is to just disable the application of the lco
    transformation to this call.

    Fix committed 8 March 2011.




    View Issue Details
    186 [mercury] Bug minor always 2011-02-22 17:50 2011-02-22 17:58
    juliensf  
     
    normal  
    new  
    open  
    none    
    none  
       
    abort when --infer-all is enabled
    The attached program aborts with

    Uncaught Mercury exception:
    Software Error: unique_modes.m: Unexpected: call to implied mode?

    when compiled with mmc --infer-all.

    This was originally reported on mercury-users, see
    <http://www.mercury.csse.unimelb.edu.au/mailing-lists/mercury-users/mercury-users.201102/0004.html>
    bug186a.m (1,427 bytes) 2011-02-22 17:50
    https://bugs.mercurylang.org/file_download.php?file_id=111&type=bug
    bug186b.m (1,116 bytes) 2011-02-22 17:56
    https://bugs.mercurylang.org/file_download.php?file_id=112&type=bug
     
    Notes
    (0000314)
    juliensf   
    2011-02-22 17:58   
    The second test case results in a different exception being thrown:

    Uncaught Mercury exception:
    Software Error: modes.m: Unexpected: modecheck_queued_proc: found detism error

    For both instances the error occurs when checking for backtracking over uniques modes.




    View Issue Details
    185 [mercury] Bug major always 2011-02-03 17:45 2011-02-16 14:00
    mgiuca  
     
    normal  
    confirmed  
    open  
    none    
    none  
       
    Cannot make typeclass instance for parameterised equivalence type
    It seems that it is impossible to create a typeclass instance for any type that is all of the following:
    1. parameterised, and
    2. declared in another module to the instance declaration, and
    3. declared abstractly and defined in the "implementation" section, and
    4. defined as an equivalence type (==).

    Notably, this includes the 'set' type. I have created a tiny self-contained example:

    In the file foo.m:

    :- module foo.

    :- interface.

    :- type foo(T).

    :- implementation.

    :- type foo(T) == bar(T).

    :- type bar(T) ---> bar.

    In the file problem.m:

    :- module problem.

    :- interface.

    :- typeclass myclass(T) where [
        func f(T) = int
    ].

    :- implementation.

    :- import_module foo.

    :- instance myclass(foo(T)) where [
        f(_) = 4
    ].

    Notice that the type 'foo' is parameterised, abstract, and defined as an equivalence to bar. In the other module, I am attempting to make foo(T) an instance of myclass. 'foo' compiles properly, but compiling 'problem' leads to this nonsensical error:

    problem.m:013: In instance declaration for `problem.myclass(foo.foo(T))':
    problem.m:013: the first arg contains a type variable which is used in
    problem.m:013: another arg

    With -E, it explains, "types in instance declarations must be functors with distinct variables as arguments". If I am reading this correctly, it is telling me that I have used the type variable `T' in multiple arguments to foo, which can't be true because it only has one argument.

    For a real-world example, in 'problem', replace 'foo' with 'set'; the same error arises. I haven't found any way to make 'set' an instance of a typeclass.
    Can anybody suggest a workaround for this issue? I would like to make 'set' a member of a typeclass.

    This isn't a problem for many other standard library types. For example, it doesn't affect 'list' because list is not defined as an equivalence type. It doesn't affect 'map' because map is not abstract (even though it doesn't appear in the documentation, map(K, V) is defined as equivalent to tree234(K, V) under a subsequent "interface" section, so it is not considered abstract).
     
    Notes
    (0000304)
    juliensf   
    2011-02-04 01:07   
    The usual workaround (which has in fact, already been implemented for most of the other
    abstract equivalence types in the standard library) is to use a notag type to wrap the equivalence.
    That is

    :- type set == set_ordlist(T)

    becomes:

    :- type set ---> set(set_ordlist(T)).

    and then modify the code in the set module appropriately. (There's no performance overhead
    to this; such types are optimised so the representation is the argument.)
    (0000305)
    mgiuca   
    2011-02-04 13:23   
    So are you suggesting that the set module be changed this way? I can do it if you want.

    Is this bug a duplicate of another, or was it simply known without having been reported?

    The set module aside, can something at least be done about the error message? Such as "Not supported: Instance of parameterised abstract equivalence type."
    (0000306)
    juliensf   
    2011-02-04 19:02   
    Looking at the set module a bit closer, I don't think we want to do what I suggested.
    It would make the union_list operation, amongst others, more expensive (because
    you would need to make a pass over the list of sets in order to strip the tag -- I'm
    not sure that the compiler is clever enough to realise that such a traversal is redundant.)

    A possible workaround is to simply use the set_ordlist/1 type in place of set/1.
    This is equivalent since the set module just forwards everything to set_ordlist anyway.
    (set_ordlist/1 is wrapped in a notag type and is usable in type class instances.)

    (In the long term, whenever Mercury supports constructor classes, I would expect the
    existing set type to be replaced by a type class and the various set types in the stdlib
    being instances of that.)

    The problem with the error message in the foo.m and problem.m is definitely a bug
    a needs to be looked at. Despite foo/1 being an asbstract type, its definition is exported
    in the interface file for the module foo, so when compiling the module problem the compiler
    can definitely see it!
    (0000308)
    mgiuca   
    2011-02-07 10:47   
    I see the point about union_list. Wouldn't a much simpler and less-destructive workaround be to move "set(T) == set_ordlist(T)" into the interface, making it non-abstract? It would be in the *second* interface section, so the equivalence is not visible in the user documentation. This is the same as the way map is defined.

    I've tried it and it works.

    --- library/set.m 13 Nov 2010 16:49:27 -0000 1.89
    +++ library/set.m 6 Feb 2011 23:45:30 -0000
    @@ -381,8 +381,11 @@
     
     :- interface.
     
    +:- import_module set_ordlist.
     :- import_module term. % for var/1.
     
    +:- type set(T) == set_ordlist(T).
    +
     :- pragma type_spec(set.list_to_set/2, T = var(_)).
     :- pragma type_spec(set.list_to_set/1, T = var(_)).
     
    @@ -409,10 +412,6 @@
     
     :- implementation.
     
    -:- import_module set_ordlist.
    -
    -:- type set(T) == set_ordlist(T).
    -
     set.list_to_set(List, Set) :-
         set_ordlist.list_to_set(List, Set).
    (0000313)
    juliensf   
    2011-02-16 14:00   
    I've made the above change to the definition of set(T).

    The issue with the error message still needs to be resolved.




    View Issue Details
    182 [mercury] Bug minor have not tried 2011-02-02 14:00 2011-02-02 14:00
    pbone  
     
    normal  
    new  
    open  
    none    
    none  
       
    Segfaults could be reported better.

    In low-level C grades it's possible to detect if a segfault is caused by a stack-overrun, in which case the runtime system can report that it is either definitely or definitely-not due to unbounded/deep recursion. There appears to be code to do this but I haven't seen it work.

    If we can fix this then we should fix the default message in low-level C grades.
    The default message says something like.
    "...this is probably due to unbounded tail recursion...",
    we shouldn't suggest this if we know the segfault is not due to a stack overrun since this only confuses users, making them blame Mercury when it's more likely to be a problem with foreign code they're linking with.
     
    There are no notes attached to this issue.




    View Issue Details
    177 [mercury] Bug minor always 2011-01-07 17:23 2011-01-19 11:05
    juliensf  
     
    normal  
    new  
    open  
    none    
    none  
       
    incorrect C# code generated when compiling extras/moose
    Attempting to build moose in the C# grade (rotd-2011-01-07) results in the following:

    Mercury/css/misc.cs(206,8): error CS1519: Unexpected symbol `=' in class, struct, or interface member declaration
    Mercury/css/misc.cs(210,45): error CS0116: A namespace can only contain types and namespace declarations
    Mercury/css/misc.cs(228,22): error CS0116: A namespace can only contain types and namespace declarations
    Mercury/css/misc.cs(245,45): error CS0116: A namespace can only contain types and namespace declarations
    Mercury/css/misc.cs(263,22): error CS0116: A namespace can only contain types and namespace declarations
    Mercury/css/misc.cs(280,45): error CS0116: A namespace can only contain types and namespace declarations
    Mercury/css/misc.cs(289,22): error CS0116: A namespace can only contain types and namespace declarations
    Mercury/css/misc.cs(297,43): error CS0116: A namespace can only contain types and namespace declarations
    Mercury/css/misc.cs(312,43): error CS0116: A namespace can only contain types and namespace declarations
    Mercury/css/misc.cs(327,43): error CS0116: A namespace can only contain types and namespace declarations
    Mercury/css/misc.cs(342,43): error CS0116: A namespace can only contain types and namespace declarations
    Mercury/css/misc.cs(356,43): error CS0116: A namespace can only contain types and namespace declarations
    Mercury/css/misc.cs(375,14): error CS1518: Expected `class', `delegate', `enum', `interface', or `struct'
    Mercury/css/misc.cs(381,1): error CS8025: Parsing error
     
    Notes
    (0000299)
    wangp   
    2011-01-12 16:38   
    :- type '' ---> ''. is just silly and should be banned.

    I believe it is unused anyway.
    (0000301)
    juliensf   
    2011-01-19 00:05   
    I have removed the above type from moose.
    (There is probably still an issue here with name mangling for the C# backend in general?)
    (0000302)
    wangp   
    2011-01-19 11:05   
    Probably, though the C# backend uses the same name mangling algorithm as everything else. '' just happens to work in C grades because everything is prefixed.




    View Issue Details
    179 [mercury] Bug minor have not tried 2011-01-18 12:43 2011-01-18 14:54
    juliensf  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    csharp grade library compilation failure on MinGW / MSYS with MS C# compiler
    Compilation of the standard library in the csharp grade on MinGW / MSYS using the
    Microsoft C# compiler results in:

    Mercury\css\array.cs(12,110: errror CS1578: Filename, single-line comment or end-of-line expected
    ...
    (plus lots more similar messages)


    This C# compiler is:

    Microsoft (R) Visual C# 2010 Compiler version 4.0.30319.1


     
    Notes
    (0000300)
    juliensf   
    2011-01-18 12:46   
    The problem here is that the filename used in a line directive must be quoted, e.g.

    #line 12 "array.m"

    and we don't do that.




    View Issue Details
    178 [mercury] Bug tweak always 2011-01-12 14:55 2011-01-12 14:55
    pbone  
     
    low  
    new  
    open  
    none    
    none  
       
    browser/browser_test.m does not compile.

    Executing 'mmake all' in the browser directory fails to compile browser_test.m
    It loos as though browser_test.m is out of date.
    /home/taura/public/mercury-latest/x86_64-unknown-linux-gnu/bin/mmc --compile-to-c --grade asm_fast.gc.decldebug --profile-for-implicit-parallelism -R/home/taura/workspaces/pbone/par_test.install/lib/mercury/lib/asm_fast.gc.decldebug -R/home/taura/workspaces/pbone/par_test.install/lib/mercury/lib --flags MDB_FLAGS browse_test > browse_test.err 2>&1
    make: *** [browse_test.c_date] Error 1

    pbone@taura:/home/taura/workspaces/pbone/par_test/browser$ less browse_test.err
    browse_test.m:049: In clause for predicate `main'/2:
    browse_test.m:049: error: undefined predicate `browse.browse'/8.
    browse_test.m:052: In clause for predicate `main'/2:
    browse_test.m:052: error: undefined predicate `browse.browse'/8.
    browse_test.m:055: In clause for predicate `main'/2:
    browse_test.m:055: error: undefined predicate `browse.browse'/8.
     
    There are no notes attached to this issue.




    View Issue Details
    176 [mercury] Bug minor have not tried 2010-12-16 01:51 2010-12-20 16:01
    juliensf  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    incorrect install names on Mac OS X with mmake
    The invocation of ml script in a .dep file on Mac OS X is incorrect.
    For libmercury_www in extras the install name is set using the following:

    -install_name "/Users/<etc etc>/libmercury_www.\$(EXT_FOR_SHARED_LIB)"

    The $ sign should *not* be escaped.
     
    Notes
    (0000298)
    juliensf   
    2010-12-20 16:01   
    Fix committed.
    (See r1.5 of compiler/file_util.m for details.)




    View Issue Details
    175 [mercury] Bug minor always 2010-12-13 17:58 2010-12-16 01:47
    juliensf  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    incorrect foreign_decl pragmas in ODBC binding
    The ODBC binding contains function prototypes for functions with static linkage
    in non-local foreign_decl pragmas and various other abuses of the foreign language
    interface.
     
    Notes
    (0000297)
    juliensf   
    2010-12-16 01:47   
    Fixed.




    View Issue Details
    119 [mercury] Bug minor sometimes 2009-12-14 11:29 2010-12-13 17:27
    pbone  
    pbone  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    par_conj/consume_wait test is failing in low-level C parallel grades.

    The par_conj/consume_wait test is failing in low-level C parallel grades. I've tested this on goofy using the current CVS version and gcc 3.4. I don't remember noticing this on taura or goliath.

    { [ -f consume_wait.inp ] && cat consume_wait.inp; } | MERCURY_OPTIONS=-P2 ./consume_wait > consume_wait.out 2>&1 || \
                    { grep . consume_wait.out /dev/null; exit 1; }
    Aborted
    consume_wait.out:consume_wait: par_builtin.m:150: par_builtin_module2: Assertion `Future->MR_fut_signalled' failed.
    consume_wait.out:1
    make[5]: *** [consume_wait.out] Error 1
    make[5]: Target `consume_wait.runtest' not remade because of errors.
    make[5]: Leaving directory `/mnt/g12/goofy-workspaces/pbone/clean/tests/par_conj'
    FAILED TEST par_conj/consume_wait in grade asm_fast.gc.par
     
    Notes
    (0000235)
    pbone   
    2009-12-16 12:37   
    Somehow work-stealing fixes this test case failure. I still want to know why it was failing though, I'll continue investigating.
    (0000296)
    pbone   
    2010-12-13 17:26   
    There was a change some months ago to the dependent parallelism transformation that fixed a problem with the same symptoms. I think it's safe to close this bug and re-open it if the problem reoccurs.




    View Issue Details
    170 [mercury] Bug minor have not tried 2010-11-26 15:40 2010-11-30 17:24
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    stage 2 ssdb build failure on goliath
    Building the stage 2 ssdb library with rotd-2010-11-24 fails on goliath, ssdb.err is:

    Uncaught Mercury exception:
    Software Error: var_locn.m: Unexpected: clobber_lval_in_var_state_map: empty state
    Stack dump not available in this grade.

    This in asm_fast.gc, with -O5 and --intermodule-optimisation.

    The last working compiler on goliath was rotd-2010-10-19 (between then and now the machine
    was down for about a week due to memory troubles).
     
    Notes
    (0000292)
    juliensf   
    2010-11-26 15:51   
    Can be reproduced with:

     mmc --compile-to-c --grade asm_fast.gc -O0 --inline-compound-threshold=100 --flags SSDB_FLAGS ssdb
    (0000293)
    juliensf   
    2010-11-26 16:34   
    I have committed a workaround for this in ssdb/Mercury.options.
    (0000294)
    zs   
    2010-11-30 17:24   
    Fix committed 30 nov 2010.




    View Issue Details
    169 [mercury] Bug minor always 2010-11-15 13:57 2010-11-15 13:57
    mgiuca  
     
    normal  
    new  
    open  
    none    
    none  
       
    Lambda predicates do not allow references to existing variables in the head
    I am not sure if this is a bug, or intentional, and if it is not intentional, I'm not sure whether it is worth "fixing", but I'll report it anyway.

    The terminology I'm using is from section 2.8 (Rules) of the Mercury reference, where a function is defined as "Head = Result :- Body" and a predicate as "Head :- Body".

    There seems to be an inconsistency with the way lambda predicates treat variable scoping. The compiler seems to scope variables with the following rules (for both lambda functions and lambda predicates):
    1. Any name which appears in the Result and/or Body of a lambda term but not at all in the scope outside of the lambda is scoped locally to the lambda term.
    2. Any name which appears in the Head of a lambda term is also scoped locally to the lambda term (and if it also appears in the scope outside the lambda, is treated as a distinct variable, shadowing the one outside).
    3. Any name which does not appear in the Head, but does appear in the scope outside, is scoped to the closure outside the lambda term.

    This basically mirrors the laws of lambda abstraction in the lambda calculus: variables appearing in the head are "bound" to the abstraction (and shadow other variables with the same name outside); variables not appearing in the head are "free" in the abstraction, and depend upon the name existing in an outer scope.

    It means that code like this functions as expected:

    :- pred add_list(int::in, list(int)::in, list(int)::out) is det.
    add_list(X, L0, L) :-
        list.map((pred(A::in, B::out) is det :- B = A + X),
                 L0, L).

    Note the name X, which is scoped to the add_list predicate, appears in the Body of the lambda pred, referring to the same variable X.

    However, rule 0000002 above doesn't make a lot of sense considering the semantics of predicates. Any data term appearing in the body of a predicate should have the same meaning if moved to the predicate's head. So the following definition should be equivalent:

    :- pred add_list(int::in, list(int)::in, list(int)::out) is det.
    add_list(X, L0, L) :-
        list.map((pred(A::in, A + X::out) is det), L0, L).

    All I have done is replace the Head variable B (unified with A + X in the Body) with the expression A + X, directly in the Head. This produces the following compiler error:

    In clause for predicate `lambdahead.add_list2'/3:
      warning: variable `X' occurs only once in this scope.
    In clause for predicate `lambdahead.add_list2'/3:
      warning: variable `X' occurs only once in this scope.
    In clause for `add_list2(in, in, out)':
     in call to function `int.+'/2:
     mode error: arguments `A, X, V_9' have the following insts:
       ground,
       free,
       free
     which does not match any of the modes for function
     `int.+'/2.

    Basically, the fact that X now appears in the lambda's Head makes the lambda predicate treat it as a distinct variable to the outer-scoped variable also called X (as it would in the lambda calculus). The error message tells me that the two separate variables "X" each appear only one time, and that I am trying to do arithmetic on an unbound variable.

    It is difficult to see how to properly "fix" this situation, if indeed it is considered to be broken. I would recommend changing the rule for lambda predicates (but not functions) such that variables appearing in the Head have the same scoping rules as those appearing in the Body -- they do not create a new variable if one already exists in the outer scope. However, this might break some existing code, and would make a new difference between predicates and functions. (The same rule would not make sense applied to functions.) So I acknowledge that it is a pretty difficult situation.

    Although it might break existing code, it would always be possible for new code to be right: simply don't shadow existing variable names in lambda predicates.

    Note that it would help if the reference manual made a mention of this rule. I can't find it in "Rules", "Variable scoping" or "Creating higher-order terms", which are the obvious places to look.
    lambdahead.m (556 bytes) 2010-11-15 13:57
    https://bugs.mercurylang.org/file_download.php?file_id=110&type=bug
     
    There are no notes attached to this issue.




    View Issue Details
    168 [mercury] Bug minor always 2010-11-08 18:25 2010-11-08 18:25
    juliensf  
     
    normal  
    new  
    open  
    none    
    none  
       
    prototypes of C functions used in io module not visible
    The prototypes of various C functions use in the io module are not
    visible when building on goliath (x86-64, Debian 5). (We need to ensure that __USE_XOPEN
    etc is defined on this platform to make them visible.)

    io.m: In function ‘io_module21’:
    io.m:2790: warning: implicit declaration of function ‘fileno’
    io.m: In function ‘io_module175’:
    io.m:9860: warning: implicit declaration of function ‘putenv’
    io.m: In function ‘io_module182’:
    io.m:10590: warning: implicit declaration of function ‘symlink’
    io.m: In function ‘io_module183’:
    io.m:10647: warning: implicit declaration of function ‘readlink’
    io.m: In function ‘io_module185’:
    io.m:3006: warning: implicit declaration of function ‘lstat’
    io.m: In function ‘mercury_init_io’:
    io.m:6289: warning: implicit declaration of function ‘fdopen’
     
    There are no notes attached to this issue.




    View Issue Details
    167 [mercury] Bug minor always 2010-11-04 17:40 2010-11-04 17:40
    mgiuca  
     
    normal  
    new  
    open  
    none    
    none  
       
    bimap.init could be uo
    The mode of bimap.init is:
    :- func bimap.init = bimap(K, V).
    :- pred bimap.init(bimap(K, V)::out) is det.

    Note that the mode of map.init is:
    :- pred map.init(map(_, _)::uo) is det.
    :- func map.init = (map(K, V)::uo) is det.

    For consistency, bimap.init's mode could be upgraded to uo, which shouldn't cause any problems:
    :- func bimap.init = (bimap(K, V)::uo) is det.
    :- pred bimap.init(bimap(K, V)::uo) is det.

    (I've tried it and it compiles fine, as does code which depends on it.)

    This would be useful for programs trying to use uniqueness where possible.
     
    There are no notes attached to this issue.




    View Issue Details
    166 [mercury] Bug minor always 2010-10-27 11:11 2010-10-27 11:11
    wangp  
     
    normal  
    new  
    open  
    none    
    none  
       
    inconsistent treatment of module-specific variables
    mmc --make wants:

    LIBRARIES-module = somelib

    mmake wants:

    # for executables
    EXTRA_LIBRARIES-module = somelib
    # for libraries
    EXTRA_LIBRARIES-libmodule.so = somelib


    Neither recognise "EXTRA_MCFLAGS-module". Both require "MCFLAGS-module". This is not clear in the user's guide.
     
    There are no notes attached to this issue.




    View Issue Details
    150 [mercury] Bug minor have not tried 2010-05-25 13:37 2010-09-15 14:39
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    nit in error msg
    From the BUGS file

    ------------------

    Subject: nit in error msg
    Date: Thu, 16 May 1996 10:25:42 +1000 (EST)

    Here's another small error in an error message. If you comment out
    the [] clause for the functions car/1 or cdr/1, you get this message:

    fntest.m:023: In `car(in) = out':
    fntest.m:023: Error: determinism declaration not satisfied.
    fntest.m:023: Declared `det', inferred `semidet'.
    fntest.m:023: in argument 1 of clause head:
    fntest.m:023: unification of `HeadVar__1' and `[X | V_4]' can fail.

    It says Declared `det', inferred `semidet', but I never declared it at
    all. It's a bit misleading. Certainly not a major problem, and the
    later part of the message makes it quite clear what the problem is,
    but I thought I'd point it out to you before I forgot it.
     
    Notes
    (0000291)
    zs   
    2010-09-15 14:39   
    Fix committed 15 sep 2010.




    View Issue Details
    128 [mercury] Bug minor have not tried 2010-01-14 18:19 2010-09-15 12:29
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    merge_instmapping_delta_2: error merging var 20
    (This was originally reported by Michael Day on the mercury-bugs list; responses from
    zs are included below as well.)

    Hi,
                                                                                                                                                                                                                     
    The attached program triggers a compiler error when building with -O5:
                                                                                                                                                                                                                     
    Making Mercury/int3s/bug.int3
    Making Mercury/ints/bug.int
    Making Mercury/cs/bug.c
    Uncaught Mercury exception:
    Software Error: instmap.m: Unexpected: merge_instmapping_delta_2: error merging var 20
                                                                                                                                                                                                                     
    It succeeds at lower optimisation levels. Tested with rotd-2009-10-08 and rotd-2008-01-30.
                                                                                                                                                                                                                     
    Michael

    ============
    Date: Mon, 9 Nov 2009 17:43:53 +1100
    From: Zoltan Somogyi <zs@csse.unimelb.edu.au>
    To: Michael Day <mikeday@yeslogic.com>
    Cc: mercury-bugs@csse.unimelb.edu.au
    Subject: Re: merge_instmapping_delta_2: error merging var 20
                                                                                                                                                                              
    On 09-Nov-2009, Michael Day <mikeday@yeslogic.com> wrote:
    > The attached program triggers a compiler error when building with -O5:
    >
    > Making Mercury/int3s/bug.int3
    > Making Mercury/ints/bug.int
    > Making Mercury/cs/bug.c
    > Uncaught Mercury exception:
    > Software Error: instmap.m: Unexpected: merge_instmapping_delta_2: error
    > merging var 20
    >
    > It succeeds at lower optimisation levels. Tested with rotd-2009-10-08 and
    > rotd-2008-01-30.
                                                                                                                                                                                                                     
    It also succeeds with -O5 --no-loop-invariants, and the exception is thrown
    *during* the loop invariants pass. I think that makes this Ralph's to fix.
                                                                                                                                                                                                                     
    Zoltan.

    =======
    Hi Zoltan,
                                                                                                                                                                              
    > It also succeeds with -O5 --no-loop-invariants, and the exception is thrown
    > *during* the loop invariants pass. I think that makes this Ralph's to fix.
                                                                                                                                                                                                                     
    Suits me! :)
                                                                                                                                                                                                                     
    The bug can be worked around by creating lots of little helper predicates, although it is a bit tedious.
                                                                                                                                                                                                                     
    We always build with -O5 rather than waiting until just before release, as it's very frustrating to suddenly be hit with an unexpected internal compiler error.
                                                                                                                                                                                                                     
    Best regards,
                                                                                                                                                                                                                     
    Michael
                                                                                                                                                                                                                     
    --
    Print XML with Prince!
    http://www.princexml.com
    bug.m (1,078 bytes) 2010-01-14 18:20
    https://bugs.mercurylang.org/file_download.php?file_id=93&type=bug
     
    Notes
    (0000290)
    zs   
    2010-09-15 12:29   
    Fix committed 15 sep 2010.




    View Issue Details
    159 [mercury] Bug minor have not tried 2010-08-23 12:02 2010-09-14 20:38
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    liveness.m: Unexpected: branches of switch disagree on liveness
    From mercury-bugs

    ----------------

    Dear all,
                                                                                                                                                                                                                     
    having bought a new notebook (the previous one was from 2003), I've also jump-updated everything to the state of the art. The joy of recompiling old things has just
    begun and here are the first fruits:
                                                                                                                                                                                                                     
    rotd-2010-07-19 fails to compile the attached file (could be surely minimized yet a bit) with the following error:
                                                                                                                                                                                                                     
    22:56 bojar-nb src$mmc --make bug.o
    Making Mercury/int3s/bug.int3
    Making Mercury/cs/bug.c
    Uncaught Mercury exception:
    Software Error: liveness.m: Unexpected: branches of switch disagree on liveness
    First: L_3, STATE_VARIABLE_P_4
    Rest: STATE_VARIABLE_P_4
                                                                                                                                                                                                                     
    Stack dump not available in this grade.
    ** Error making `Mercury/cs/bug.c'.
                                                                                                                                                                                                                     
    Could you have a look at it? Disabling memoization solves it, but memoization alone is naturally fine. I guess it's the variable L where only the type and the value
    is needed.
                                                                                                                                                                                                                     
    Cheers and warm greetings to everybody!
      Ondrej.
    bug.m (1,005 bytes) 2010-08-23 12:03
    https://bugs.mercurylang.org/file_download.php?file_id=107&type=bug
     
    Notes
    (0000289)
    zs   
    2010-09-14 20:38   
    Bug fix committed 14 sep 2010.




    View Issue Details
    164 [mercury] Bug minor have not tried 2010-09-14 15:29 2010-09-14 15:29
    juliensf  
     
    normal  
    new  
    open  
    none    
    none  
       
    problem with mmake -j32

    From keri@gentoo.org on mercury-users

    ===================

    Hi folks.
                                                                                                                                                                                                                                                                   
    I've run into a hitch when bootstrapping mercury-10.04.1 on a linux-sparc box.
    I'm attempting to bootstrap with mercury-10.04 where all C files need to be
    rebuilt; I'm running a parallel compile with 32 submakes (it's a fast machine
    :-)). It looks like building mercury_compile is failing due to race between
    mmc generating .mih files and mgnuc compiling .c files that include the .mih
    files.
                                                                                                                                                                                                                                                                   
    >From './configure':
                                                                                                                                                                                                                                                                   
    looking for an already installed Mercury compiler to bootstrap with...
    checking for mmc... /usr/bin/mmc
    checking whether the above mmc works and is sufficiently recent... yes
    ...
    checking whether any C files need to be rebuilt...
    there are no existing Mercury-generated C files
                                                                                                                                                                                                                                                                   
    >From 'make':
                                                                                                                                                                                                                                                                   
    /usr/bin/mmc --compile-to-c --grade hlc.gc --mercury-linkage static --
    flags COMP_FLAGS transform_hlds.term_constr_data >
    transform_hlds.term_constr_data.err 2>&1
    /usr/bin/mmc --compile-to-c --grade hlc.gc --mercury-linkage static --
    flags COMP_FLAGS transform_hlds.term_constr_main >
    transform_hlds.term_constr_main.err 2>&1
    /usr/bin/mmc --compile-to-c --grade hlc.gc --mercury-linkage static --
    flags COMP_FLAGS transform_hlds.term_errors >
    transform_hlds.term_errors.err 2>&1
    ...
    ../scripts/mgnuc --grade hlc.gc -- -c analysis.c -o analysis.o
    analysis.c:116:47: error: transform_hlds.term_constr_data.mih: No such file or
    directory
    analysis.c:118:47: error: transform_hlds.term_constr_main.mih: No such file or
    directory
    analysis.c:119:42: error: transform_hlds.term_errors.mih: No such file or
    directory
    ....
                                                                                                                                                                                                                                                                   
    Without dialing things down to -j1, is there much I can do to workaround this
    problem?
                                                                                                                                                                                                                                                                   
                                                                                                                                                                                                                                                                   
    Thanks
                                                                                                                                                                                                                                                                   
    Keri
     
    There are no notes attached to this issue.




    View Issue Details
    109 [mercury] Bug minor have not tried 2009-10-09 18:28 2010-09-14 12:23
    janicek Darwin  
    zs Mac OS X  
    normal 10.5.8  
    resolved  
    rotd-2009-10-05 fixed  
    none    
    none  
       
    rotd-2009-10-05's library install fails for grade hlc
    I'm installing Mercury rotd-2009-10-05, with libgrade hlc. "make" seems to run without problems, but while in "make install", I get the following message and the install terminates:

    -- BEGIN SNIPPET
    ...
    mmc --compile-to-c --grade hlc --mercury-linkage shared --flags LIB_FLAGS --flags INTER_FLAGS -R/Users/sandius/Developer/mercury-rotd-2009-10-05/lib/mercury/lib/hlc -R/Users/sandius/Developer/mercury-rotd-2009-10-05/lib/mercury/lib bit_buffer.read > bit_buffer.read.err 2>&1
    mmc --make-optimization-interface --grade hlc --mercury-linkage shared --flags LIB_FLAGS --flags INTER_FLAGS -R/Users/sandius/Developer/mercury-rotd-2009-10-05/lib/mercury/lib/hlc -R/Users/sandius/Developer/mercury-rotd-2009-10-05/lib/mercury/lib bit_buffer.write
    mmc --make-transitive-optimization-interface --grade hlc --mercury-linkage shared --flags LIB_FLAGS --flags INTER_FLAGS -R/Users/sandius/Developer/mercury-rotd-2009-10-05/lib/mercury/lib/hlc -R/Users/sandius/Developer/mercury-rotd-2009-10-05/lib/mercury/lib bit_buffer.write
    mmc --compile-to-c --grade hlc --mercury-linkage shared --flags LIB_FLAGS --flags INTER_FLAGS -R/Users/sandius/Developer/mercury-rotd-2009-10-05/lib/mercury/lib/hlc -R/Users/sandius/Developer/mercury-rotd-2009-10-05/lib/mercury/lib bit_buffer.write > bit_buffer.write.err 2>&1
    mmc --compile-to-c --grade hlc --mercury-linkage shared --flags LIB_FLAGS --flags INTER_FLAGS -R/Users/sandius/Developer/mercury-rotd-2009-10-05/lib/mercury/lib/hlc -R/Users/sandius/Developer/mercury-rotd-2009-10-05/lib/mercury/lib --no-warn-insts-without-matching-type --no-erlang-native-code bitmap > bitmap.err 2>&1
    gmake[2]: *** [bitmap.c_date] Error 1
    gmake[2]: Leaving directory `/Users/sandius/tmp/mercury-compiler-rotd-2009-10-05/install_grade_dir.hlc/library'
    To clean up from failed install, remove /Users/sandius/tmp/mercury-compiler-rotd-2009-10-05/install_grade_dir.hlc
    gmake[1]: *** [install_grades] Error 1
    gmake[1]: Leaving directory `/Users/sandius/tmp/mercury-compiler-rotd-2009-10-05'
    make: *** [install] Error 2

    -- END SNIPPET --

    $ cat install_grade_dir.hlc/library/bitmap.err
    Uncaught Mercury exception:
    Software Error: ml_disj_gen.m: Unexpected: ml_gen_disj: single disjunct

    $ gcc --version
    i686-apple-darwin9-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5566)
    Copyright (C) 2007 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    $ uname -a
    Darwin dfki-guestpool8.dfki.uni-sb.de 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386

    Configure command:
    $ ./configure --prefix=$HOME/Developer/mercury-rotd-2009-10-05 --enable-libgrades=hlc

    config.log attached.
    config.log (235,981 bytes) 2009-10-09 18:28
    https://bugs.mercurylang.org/file_download.php?file_id=81&type=bug
    bug109.m (1,611 bytes) 2009-10-12 12:34
    https://bugs.mercurylang.org/file_download.php?file_id=82&type=bug
     
    Notes
    (0000198)
    wangp   
    2009-10-09 21:25   
    (Last edited: 2009-10-09 21:26)
    What about grade "hlc.gc"? It worked for me on Linux. (Nonetheless it does look like a bug.)

    (0000199)
    janicek   
    2009-10-09 21:34   
    hlc.gc works. However, I wanted to suppress garbage collection as it randomly causes SIGBUSes in my code (which is my fault, I suppose, probably some stray pointers caused by sloppy interfacing to C++...)
    (0000200)
    janicek   
    2009-10-09 21:41   
    Is there perhaps a way to *delay* garbage collection as much as possible? That would also be helpful (to me right now, not solving this issue of course).
    (0000201)
    wangp   
    2009-10-09 21:59   
    You can use hlc.gc but set the GC_DONT_GC environment variable to switch it off completely. There are other environment variables (from Boehm GC) which let you set the initial heap size, etc.
    (0000202)
    janicek   
    2009-10-09 22:43   
    That helped, thanks!
    (0000203)
    juliensf   
    2009-10-12 10:23   
    What is the reason you are using the hlc grade? Grades without
    garbage collection are not generally useful. (It should still
    work of course.)
    (0000205)
    juliensf   
    2009-10-12 10:30   
    Sorry, didn't see the above.
    (0000206)
    juliensf   
    2009-10-12 12:34   
    I have uploaded a cut-down test case for this bug.
    It appears to be a problem with --reclaim-heap-on-failure.
    (0000287)
    zs   
    2010-09-14 12:23   
    Fix committed 14 sep 2010.




    View Issue Details
    154 [mercury] Bug minor always 2010-06-29 14:06 2010-08-25 13:58
    wangp  
     
    normal  
    new  
    open  
    none    
    none  
       
    compiler abort with debugging enabled
    Compiler aborts on test case with debugging enabled.
    some_bug.m (3,925 bytes) 2010-06-29 14:06
    https://bugs.mercurylang.org/file_download.php?file_id=101&type=bug
     
    Notes
    (0000269)
    wangp   
    2010-06-29 14:07   
    % mmc --debug --allow-stubs -C some_bug.m
    % Uncaught Mercury exception:
    % Software Error: map.lookup: key not found
    % Key Type: term.var(parse_tree.prog_data.prog_var_type)
    % Key Value: var(10)
    % Value Type: ll_backend.var_locn.var_state
    % Stack dump follows:
    % 0 pred exception.throw/1-0 (erroneous) (exception.m:411)
    % 1 pred require.error/1-0 (erroneous) (require.m:122)
    % 2 pred require.report_lookup_error/3-0 (erroneous) (require.m:98)
    % 3 pred map.lookup/3-0 (det) (map.m:721)
    % 4 pred ll_backend.var_locn.actually_place_var/7-0 (det) (var_locn.m:1380)
    % 5 pred ll_backend.var_locn.var_locn_place_var/6-0 (det) (var_locn.m:1366)
    % 6 4* pred ll_backend.var_locn.actually_place_vars/5-0 (det) (var_locn.m:1361 and others)
    % 10 pred ll_backend.var_locn.var_locn_place_vars/5-0 (det) (var_locn.m:1353)
    % 11 pred ll_backend.code_info.setup_call/6-0 (det) (code_info.m:3981)
    (0000280)
    wangp   
    2010-08-25 13:14   
    The problem goes like this: after switch detection the nested disjunction is converted to a switch, and some of the code is duplicated into the switch arms. Within the duplicated code is a call to get_arg, which is existentially typed, so the type_info output argument is renamed away in one of the switch arms.

    When liveness.m works on the call to get_arg, it needs to complete the argument list with type_info variables. But the type_info_varmap only knows about the original type_info variable, not the renamed one, so the argument list is completed with the wrong type_info variable.
    (0000281)
    zs   
    2010-08-25 13:58   
    When the compiler duplicates code, it should call clone_variables in goal_util to clone the variables local to the goal, and clone_variables should take the rtti_varmaps as a parameter, and should update it as necessary. I think this means that if the typeinfo var (say V1) for a cloned var (say V2) is also duplicated, then the typeinfo var for the clone of V2 should be recorded as the clone of V1. On the other hand, if V2 is cloned but V1 is not (which in this case means that the type of V2 was established before the switch), then the current behavior is what you want.




    View Issue Details
    158 [mercury] Bug minor always 2010-08-18 14:31 2010-08-19 17:36
    colanderman  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    char constants do not unify
    For some reason, this code:

    if det_from_int(255) = '\xFF\' then print("succeed\n", !IO) else print("fail\n", !IO)

    prints "fail". This code however:

    if 255 = to_int('\xFF\') then print("succeed\n", !IO) else print("fail\n", !IO)

    prints "succeed" as expected.
    Mercury 10.04, Debian Linux 32-bit
    charbug.m (326 bytes) 2010-08-18 14:31
    https://bugs.mercurylang.org/file_download.php?file_id=106&type=bug
     
    Notes
    (0000279)
    wangp   
    2010-08-18 15:32   
    Thanks. This bug affects 8-bit character literals in low-level C grades.

    The LLDS doesn't differentiate between integer and character constants, and the 0xff character ends up in the C source code as (MR_Integer)255 instead of (MR_Char)255. MR_Char is signed (depends on the compiler) so we end up comparing 255 with -1.




    View Issue Details
    137 [mercury] Bug minor always 2010-03-11 23:41 2010-07-21 14:37
    juliensf  
     
    normal  
    new  
    open  
    none    
    none  
       
    failing analysis framework tests
    Many of the analysis framework tests abort with:

    Making Mercury/analysiss/ua_m1.analysis
    Uncaught Mercury exception:
    Software Error: quantification.m: Unexpected: unify_rhs_vars_no_lambda: found lambda
    Stack dump not available in this grade.

     
    Notes
    (0000256)
    wangp   
    2010-03-16 17:47   
    Although I can reproduce this with a rotd, I can't seem to reproduce it from a CVS checkout. I have tried these options in Mmake.params (separately, obviously):

    EXTRA_MCFLAGS= --intermodule-optimisation
    EXTRA_MCFLAGS= -O5
    EXTRA_MCFLAGS= -O5 --intermodule-optimisation
    EXTRA_MCFLAGS= --opt-space
    EXTRA_MCFLAGS= -O2 --intermodule-optimisation --opt-space
    (0000257)
    zs   
    2010-03-17 00:52   
    If someone can reproduce this with a compiler that itself was compiled in a debug grade, I can probably fix this in two minutes.
    (0000278)
    wangp   
    2010-07-21 14:37   
    unused_args calls implicitly_quantify_goal_general(ordinary_nonlocals_no_lambda, ...) on exception.try_io_det, which was being opt-exported, despite being marked no_inline.

    I have now made it so that no_inline predicates are not opt-exported, but that's a separate bug.




    View Issue Details
    67 [mercury] Bug minor always 2008-07-08 16:14 2010-07-15 16:56
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    mprof doesn't like duplicate names
    mprof aborts on duplicate names in Prof.Decl. I get the following trying to profile the compiler. Manually differentiating the duplicate mercury__do_call_closure_* names allows mprof to proceed.

    % mprof
    Uncaught Mercury exception:
    Software Error: map.det_insert: key already present
            Key Type: string
            Key Value: "mercury__do_call_closure_3"
            Value Type: int
    Stack dump not available in this grade.
    Sample data attached.
    Prof.tar.bz2 (311,649 bytes) 2008-07-08 16:14
    https://bugs.mercurylang.org/file_download.php?file_id=51&type=bug
     
    There are no notes attached to this issue.




    View Issue Details
    142 [mercury] Bug minor always 2010-04-06 15:07 2010-07-15 15:47
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    problem updating rtti varmaps on inlining
    In the following test case, higher order specialisation creates
    `or__ho1' from of `or'.

    We try to inline `or__ho1' into `orr'. In the call to `or__ho1' the
    same variable `TypeClassInfo_for_dcg_14' appears twice in the argument
    list, corresponding to the formal arguments V_22 and
    TypeClassInfo_for_dcg_18 in the callee.

    Eventually we try to rename the variables in the callee rtti varmap.
    We hit an assertion failure in apply_substs_to_constraint_map
    (hlds_rtti.m:777) as the two callee variables holding typeclass_infos
    map to the same variable in the caller, and supposedly it is for two
    different constraints. They are the same, just with different type
    variables.

    Is the fix to relax the assertion, or something else?

    % mmc --inline-single-use --optimise-higher-order dcg
    Uncaught Mercury exception:
    Software Error: hlds_rtti.m: Unexpected: inconsistent typeclass_infos
    Stack dump follows:
       0 pred exception.throw/1-0 (erroneous) (exception.m:411)
       1 pred require.error/1-0 (erroneous) (require.m:122)
       2 pred libs.compiler_util.unexpected/2-0 (erroneous) (compiler_util.m:88)
       3 pred hlds.hlds_rtti.apply_substs_to_constraint_map/7-0 (det) (hlds_rtti.m:804)
       4 pred tree234.foldl/4-0 (det) (tree234.m:2625)
       5 pred map.foldl/4-0 (det) (map.m:962)
       6 pred hlds.hlds_rtti.apply_substitutions_to_rtti_varmaps/5-0 (det) (hlds_rtti.m:679)
       7 pred transform_hlds.inlining.do_inline_call/13-0 (det) (inlining.m:774)
       8 pred transform_hlds.inlining.inlining_in_call/11-0 (det) (inlining.m:652)
       9 pred transform_hlds.inlining.inlining_in_goal/4-0 (det) (inlining.m:558)
      10 pred transform_hlds.inlining.inlining_in_conj/4-0 (det) (inlining.m:860)
      11 pred transform_hlds.inlining.inlining_in_goal/4-0 (det) (inlining.m:571)
      12 2* pred transform_hlds.inlining.inlining_in_conj/4-0 (det) (inlining.m:860 and others)
      14 pred transform_hlds.inlining.inlining_in_goal/4-0 (det) (inlining.m:571)
      15 pred transform_hlds.inlining.inline_in_proc/5-0 (det) (inlining.m:489)
      16 3* pred transform_hlds.inlining.do_inlining/6-0 (det) (inlining.m:260 and others)
      19 pred transform_hlds.inlining.inlining/2-0 (det) (inlining.m:249)
      20 pred top_level.mercury_compile_middle_passes.maybe_do_inlining/6-0 (det) (mercury_compile_middle_passes.m:941)
      21 pred top_level.mercury_compile_middle_passes.middle_pass/7-0 (det) (mercury_compile_middle_passes.m:189)
      22 pred top_level.mercury_compile.mercury_compile_after_front_end/11-0 (det) (mercury_compile.m:1650)
      23 pred top_level.mercury_compile.mercury_compile/11-0 (det) (mercury_compile.m:1582)
      24 pred top_level.mercury_compile.compile/13-0 (det) (mercury_compile.m:1507)
      25 pred list.map_foldl2/7-2 (det) (list.m:2359)
      26 pred top_level.mercury_compile.compile_all_submodules/13-0 (det) (mercury_compile.m:1296)
      27 pred top_level.mercury_compile.process_module_2/8-0 (det) (mercury_compile.m:1269)
      28 pred top_level.mercury_compile.process_module/8-0 (det) (mercury_compile.m:1186)
      29 pred top_level.mercury_compile.process_arg_2/8-0 (det) (mercury_compile.m:882)
      30 pred top_level.mercury_compile.process_arg_build/10-0 (det) (mercury_compile.m:844)
      31 pred make.util.build_with_module_options_args_invoked/12-0 (det) (make.util.m:987)
      32 pred make.util.build_with_module_options_args/11-0 (det) (make.util.m:940)
      33 pred top_level.mercury_compile.process_arg/8-0 (det) (mercury_compile.m:817)
      34 pred top_level.mercury_compile.process_arg_list/10-0 (det) (mercury_compile.m:788)
      35 pred top_level.mercury_compile.process_args/8-0 (det) (mercury_compile.m:740)
      36 pred top_level.mercury_compile.process_all_args/8-0 (det) (mercury_compile.m:546)
      37 pred top_level.mercury_compile.main_after_setup/7-0 (det) (mercury_compile.m:422)
      38 pred top_level.mercury_compile.real_main_after_expansion/3-0 (det) (mercury_compile.m:308)
      39 pred top_level.mercury_compile.real_main/2-0 (det) (mercury_compile.m:118)
      40 pred top_level.main/2-0 (det) (top_level.m:56)
    dcg.m (1,474 bytes) 2010-04-06 15:07
    https://bugs.mercurylang.org/file_download.php?file_id=99&type=bug
     
    Notes
    (0000263)
    wangp   
    2010-04-21 11:54   
    I think the problem may be this. inlining.get_type_substitution, which is used in a few places, creates a substitution from the callee's head argument types to types in the caller. However, it doesn't account for type variables in the range of functional dependencies, so they never appear in the type substitution.

    So two separate type variables in the calleee remain as two different type variables after inlining, but they should have been unified. Which is why we got the assertion failure above: a single variable is supposedly holding the TypeClassInfo for two "different" constraints, but the two constraints only differ because their type variables weren't unified.

    Does that make sense?
    (0000277)
    wangp   
    2010-07-15 15:47   
    committed a workaround 0000012:0000010 May




    View Issue Details
    155 [mercury] Bug major always 2010-07-07 17:51 2010-07-07 18:01
    pbone  
     
    normal  
    new  
    open  
    none    
    none  
       
    Mode error with impure code.
    I'm writing a failure driven loop that uses impurity to implement a branch and bound solver. The mode checker tells me that a value is 'free' when it should be (and is) 'ground'.

    I will attach two programs that exhibit this error. Note that removing the switch on BestSolutionFinal and changing the type of the predicates output makes the problem go away.
    bug155a.m (2,863 bytes) 2010-07-07 17:58
    https://bugs.mercurylang.org/file_download.php?file_id=103&type=bug
    bug155b.m (2,709 bytes) 2010-07-07 18:01
    https://bugs.mercurylang.org/file_download.php?file_id=104&type=bug
     
    Notes
    (0000275)
    pbone   
    2010-07-07 17:59   
    Test case one:

    pbone@taura:/tmp$ mmc --compile-to-c bug155a
    bug155a.m:060: In clause for `branch_and_bound((pred(in, out) is nondet),
    bug155a.m:060: (func(in) = out is det), out)':
    bug155a.m:060: in argument 2 of call to predicate `float.<'/2:
    bug155a.m:060: mode error: variable `BestObjective' has instantiatedness
    bug155a.m:060: `free',
    bug155a.m:060: expected instantiatedness was `ground'.
    For more information, recompile with `-E'.
    (0000276)
    pbone   
    2010-07-07 18:01   
    Test case two:

    pbone@taura:/tmp$ mmc --compile-to-c bug155b
    bug155b.m:069: In clause for `branch_and_bound((pred(in, out) is nondet),
    bug155b.m:069: (func(in) = out is det), out)':
    bug155b.m:069: in argument 2 of call to predicate `mutvar.set_mutvar'/2:
    bug155b.m:069: mode error: variable `BestSolutions' has instantiatedness
    bug155b.m:069: `free',
    bug155b.m:069: expected instantiatedness was `ground'.
    For more information, recompile with `-E'.




    View Issue Details
    153 [mercury] Bug minor always 2010-06-28 14:06 2010-07-06 23:51
    juliensf  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    toc in pdf user's guide is empty
    The TOC in the pdf version of the user's guide is empty.
    This was reported against rotd-2010-06-23.
     
    Notes
    (0000271)
    pbone   
    2010-07-03 17:59   
    This is caused when the user_guide.pdf make rule is executed
    before the user_guide.dvi_log rule. pdftexi executes tex only once, therefore
    it is not able to generate the TOC. Executing the .dvi_log rule before the
    .pdf rule solves this problem because texinfo (used to create the .dvi) runs
    tex the correct number of times.
    (0000272)
    pbone   
    2010-07-03 18:09   
    Committed fix to CVS.
    (0000273)
    pbone   
    2010-07-03 18:10   
    Julien, can you include this fix in 10.04?
    (0000274)
    juliensf   
    2010-07-06 23:51   
    Merged onto 10.04 branch as well.




    View Issue Details
    152 [mercury] Bug crash always 2010-06-08 16:59 2010-06-08 16:59
    pbone  
     
    low  
    new  
    open  
    none    
    none  
       
    Test cases crash the compiler in mmos grades.
    The debugger/mmos_print test crashes the compiler in mmos grades.


    pbone@taura:/home/taura/workspaces/pbone/stseg_test/tests/debugger$ lmc --grade asm_fast.gc.mmos -O0 -v mmos_print.m
    % Parsing file `mmos_print' and imported interfaces...
    % Module qualifying items...
    % done.
    % Expanding equivalence types...
    % done.
    % Converting parse tree to hlds...
    % done.
    % Writing auto-dependency file `mmos_print.d'... done.
    % Checking typeclasses...
    % Checking instance declaration types...
    % Checking typeclass instances...
    % Checking for cyclic classes...
    % Checking for missing concrete instances...
    % Checking functional dependencies on instances...
    % Checking typeclass constraints...
    % Checking that insts have matching types... done.
    % Type-checking...
    % Type-checking clauses...
    % Program is type-correct.
    % Purity-checking clauses...
    % Program is purity-correct.
    % Substituting implementation-defined literals...
    % done.
    % Transforming polymorphic unifications... done.
    % Mode-checking clauses...
    % Program is mode-correct.
    % Detecting switches...
    % done.
    % Detecting common deconstructions...
    % done.
    % Doing determinism checking...
    % done.
    % Program is determinism-correct.
    % Checking for backtracking over unique modes...
    % Program is unique-mode-correct.
    % Checking stratification...
    % done.
    % Transforming try goals...
    % done.
    % Simplifying goals...
    % done.
    % Transforming tabled predicates...Uncaught Mercury exception:
    Software Error: map.lookup: key not found
            Key Type: int
            Key Value: 0
            Value Type: hlds.hlds_pred.proc_info
    Stack dump not available in this grade.
     
    There are no notes attached to this issue.




    View Issue Details
    149 [mercury] Bug minor have not tried 2010-05-25 13:36 2010-05-25 13:36
    juliensf  
     
    normal  
    new  
    open  
    none    
    none  
       
    inter-module optimization and abstract exported equivalence types.
    From the BUGS file

    -------------------

    Subject: inter-module optimization and abstract exported equivalence types.
    Date: Thu, 19 February 1998

    In some cases the compiler reports spurious ambiguity errors when compiling
    with `--intermodule-optimization'. This is due to the definition of abstract
    exported equivalence types being made visible by inter-module optimization.
    In this example, with `--intermodule-optimization' the compiler sees the
    declaration `:- type var == int' from term.m and then cannot determine whether
    `Elem' has type `int' or `pair(int)'.
    The work-around is to add an explicit type qualification.

    :- module foo.
    :- interface.
    :- import_module list, term.
    :- pred test(list(var)::in) is det.
    :- implementation.
    :- import_module int, std_util.

    test(Args0) :-
            MakeIndex =
                    (pred(Elem0::in, Elem::out, Index0::in, Index::out) is det :-
                            Elem = Elem0 - Index0,
                            Index is Index0 + 1
            ),
            list.map_foldl(MakeIndex, Args0, _, 0, _).
     
    There are no notes attached to this issue.




    View Issue Details
    147 [mercury] Bug minor have not tried 2010-05-25 13:30 2010-05-25 13:30
    juliensf  
     
    normal  
    new  
    open  
    none    
    none  
       
    NaN behaviour
    From the BUGS file:

    -------------------------

    Subject: NaN behaviour
    Date: Mon, 21 Oct 2002 21:02:00 +1000

    The mercury standard library tends to avoid producing NaN (e.g. throwing
    an exception in many places where libc would return NaN), but it's still
    possible from arithmetic functions (e.g. 0.0*Inf, Inf - Inf, Inf + -Inf,
    Inf / Inf), sin,cos,tan when passed infinity, and perhaps other things (I
    haven't done a full search). Presumably it can also arise from using the
    foreign language interface.

    When NaN does arise, we have a problem that `=' (and unification) aren't
    reflexive. From a logical point of view, this is a fairly serious problem.

    A lesser problem is that `<' doesn't induce a total order on floats.
     
    There are no notes attached to this issue.




    View Issue Details
    143 [mercury] Bug feature always 2010-04-09 17:29 2010-05-20 19:02
    rafe  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    ':- initialise' directives not being respected.
    Compile the attached foo.m file and run it. It should output

    map([(1 -> BAZ), (2 -> BAR), (3 -> BAZ)])

    but unless the call to init_foo/2 in main/2 is uncommented out you get this:

    map([(1 -> baz), (2 -> bar), (3 -> baz)])

    The ':- initialise init_foo/2.' directive is not being respected.

    This is a problem since I was hoping to use this functionality to debug the IC solver.
    foo.m (984 bytes) 2010-04-09 17:29
    https://bugs.mercurylang.org/file_download.php?file_id=100&type=bug
     
    Notes
    (0000262)
    juliensf   
    2010-04-09 17:53   
    This is not a bug IMO. The initialiser is being called, you can see this if you get it to print something
    out. The problem is that the pretty-printer stores its state in a set of mutables

    From section 9.6 of the reference manual:

    For the purposes of determining when mutables are assigned their initial values, the expression ‘initial_value’ behaves as though it were a predicate specified in an ‘initialise’ directive.

    From section 9.4 of the reference manual:

    Initialisation predicates within a module are executed in the order in which they are specified, although no order may be assumed between different modules or sub-modules.

    What is happening here, is that your initialiser is being called and the its effects are being
    overwritten by the initialisation of the mutables in the pretty_printer module in the stdlib.
    (0000264)
    juliensf   
    2010-05-20 19:02   
    Fixed.




    View Issue Details
    145 [mercury] Bug major always 2010-04-20 14:56 2010-04-21 14:57
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    loop invariants broken
    I wonder how long this bug has been present.

    % mmc -O0 --loop-invariants ho_solns.m (from tests/hard_coded)
    % ./ho_solns
    4
    4
    4

    should be:

    4
    5
    6


     
    There are no notes attached to this issue.




    View Issue Details
    140 [mercury] Bug text N/A 2010-03-31 12:27 2010-04-01 18:36
    mgiuca  
     
    normal  
    acknowledged  
    open  
    none    
    none  
       
    Manual section 10 doesn't mention existential types
    Section 11 (existential types) mentions type class constraints on a) existential type variables in predicates and functions, and b) existential type variables in data type definitions.

    However, section 10, which specifically details type class constraints, does not mention these at all. I found this particularly confusing when trying to find out how to put a type class constraint on a data type definition.

    Since this is a reference manual, and not intended to be read cover-to-cover, it doesn't need to hide details just because they haven't been mentioned yet. I would recommend at least adding forward references:

    - adding to section 10.5 a paragraph which states "Type constraints can also be applied to existential type variables, with the syntax "=> Typeclass(Type, ...), ...". See section 11.2."
    - adding to section 10 a new section (between 10.7 and 10.8) called "Type class constraints on data type definitions", which simply has the text "Type constraints may also be applied to data type definitions, which may have existentially quantified type variables. See section 11.3."

    For a more substantial rework, I would recommend swapping sections 10 and 11, and moving the type class discussion from the "Existential types" section to the "Type classes" section. This is because you can cover existential types without mentioning type classes, but you can't really cover type classes without mentioning existential types.
     
    There are no notes attached to this issue.




    View Issue Details
    141 [mercury] Bug feature N/A 2010-04-01 15:37 2010-04-01 18:32
    mgiuca  
     
    normal  
    new  
    open  
    none    
    none  
       
    integer has no method for converting to int with wraparound
    The integer.int function converts an integer to an int but aborts if the integer is out of range.

    It is occasionally useful to convert an integer to an int with out-of-range numbers being wrapped (truncated) just like conversion from int to short in C, for example.

    I have attached a patch which adds a function integer.int_with_overflow which does this.
    The patch sort-of relies upon two's complement (it would probably work for one's complement or sign-bit form as well, but does make some bit-level assumptions). I have included an XXX comment to this effect. I assume this is OK since there are other such comments in the same file.
    integer.patch (1,243 bytes) 2010-04-01 15:37
    https://bugs.mercurylang.org/file_download.php?file_id=97&type=bug
    integer-2.patch (1,249 bytes) 2010-04-01 18:09
    https://bugs.mercurylang.org/file_download.php?file_id=98&type=bug
     
    Notes
    (0000258)
    mgiuca   
    2010-04-01 16:05   
    Irk... that patch is wrong. The "Wrapped" value is not necessarily in int range (I thought it worked because conversion to int truncated anyway, but you can't assume that since it's specified as undefined.)

    Positive integers in range 2^31 to 2^32-1 need to become negative, and vice versa for negative integers in range -2^31-1 to -2^32. This is tricky to do with integer bit operations since they specifically *don't* wrap values. I'm thinking it'll be easier to use mod/rem but I'll have to think hard about it. Does anyone have a better mathematical formula for wraparound conversion?

    Also, is there a test suite I need to write test cases for?
    (0000259)
    mgiuca   
    2010-04-01 16:14   
    A valid formula appears to be (at least for 2's complement):

    ((X + int_max + 1) `mod` (int_max+1) * 2) - int_max - 1

    Is this overly complicated?
    (0000260)
    mgiuca   
    2010-04-01 18:10   
    Added a new patch (integer-2.patch) which uses the above formula.

    I'm aware that there is a formal patch review process, and this isn't it. I'm just seeing if anyone is interested first.
    (0000261)
    juliensf   
    2010-04-01 18:32   
    Hi Matt,

    Yes, we're interested - could you please submit your patch to the mercury-reviews list.
    (Or ask one of the developers to do so on your behalf)

    The review process used in the Mercury project is documented here:
    http://www.mercury.csse.unimelb.edu.au/information/doc-latest/reviews.html

    Cheers,
    Julien.




    View Issue Details
    139 [mercury] Bug minor have not tried 2010-03-23 11:25 2010-03-23 11:25
    pbone  
     
    normal  
    new  
    open  
    none    
    none  
       
    If mercury is installed in a directly with a '+' symbol in it's name, then mkinit will not work.

    Using the recent 10.04 beta release I installed Mercury into /usr/local/mercury-10.04+beta1 (or similar). It installed correctly, and I created a symlink /usr/local/mercury to the installation directory because /usr/local/mercury/bin is in my $PATH.

    When I went to use mmc --make to compile a program. mkinit failed to find the .init files for the standard library and runtime (IIRC). Double quotes had been put around the path at some stage, but mkinit was literally trying to open a "/usr/local/mercury-10.04+beta1/..." with the double quotes as part of the file name. The ellipsis represents the actual path which I don't recall.
     
    There are no notes attached to this issue.




    View Issue Details
    138 [mercury] Bug text always 2010-03-15 06:30 2010-03-16 04:42
    Jurassic  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Mistake in Language Reference, section 2.3
    In section 2.3 (Terms) of the Language Reference, paragraph 7, "optionally followed by a vertical bar (i.e. a close_list token)" should probably read "optionally followed by a vertical bar (i.e. a ht_sep token)".
     
    Notes
    (0000255)
    juliensf   
    2010-03-16 04:41   
    Fix committed in r1.438 of doc/reference_manual.texi.




    View Issue Details
    134 [mercury] Bug minor always 2010-03-03 15:45 2010-03-04 12:48
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    abort in MLDS backend with --no-static-ground-terms
    The attached program causes an abort while converting the HLDS -> MLDS.
    See the comments at the head of the test case for details of how to reproduce.
    This is occurring with Mercury rotd-2010-03-01.
    The problem in the test case is masked by dead procedure elimination.
    bug134.m (3,073 bytes) 2010-03-03 15:45
    https://bugs.mercurylang.org/file_download.php?file_id=96&type=bug
     
    Notes
    (0000254)
    zs   
    2010-03-04 12:48   
    fix committed mar 4.




    View Issue Details
    121 [mercury] Bug major always 2009-12-18 11:57 2010-02-27 18:22
    juliensf  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    parallel grades do not build on Mac OS 10.6
    The .par grades do not build on Mac 0S 10.6 due to the GC not building.

    darwin_stop_world.c: In function 'GC_push_all_stacks':
    darwin_stop_world.c:105: error: 'i386_thread_state_t' has no member named 'esp'
    darwin_stop_world.c:107: error: 'i386_thread_state_t' has no member named 'eax'
    darwin_stop_world.c:108: error: 'i386_thread_state_t' has no member named 'ebx'
    darwin_stop_world.c:109: error: 'i386_thread_state_t' has no member named 'ecx'
    darwin_stop_world.c:110: error: 'i386_thread_state_t' has no member named 'edx'
    darwin_stop_world.c:111: error: 'i386_thread_state_t' has no member named 'edi'
    darwin_stop_world.c:112: error: 'i386_thread_state_t' has no member named 'esi'
    darwin_stop_world.c:113: error: 'i386_thread_state_t' has no member named 'ebp'
    make[2]: *** [darwin_stop_world.o] Error 1
    make[1]: *** [submake] Error 2
    make: *** [boehm_gc] Error 2
     
    Notes
    (0000252)
    juliensf   
    2010-02-27 18:22   
    This was fixed by the upgrading the Boehm GC to version 7.2alpha4.




    View Issue Details
    133 [mercury] Bug major always 2010-02-12 16:10 2010-02-15 12:49
    petdr  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Software Error: try_expand.m: Unexpected: find_subparts: unexpected goal form
    The attached program throws the exception:

    Software Error: try_expand.m: Unexpected: find_subparts: unexpected goal form

    The problem is something to do with the duplicate call to q(X, !IO) once outside the try goal and once inside.
    try_test.m (326 bytes) 2010-02-12 16:10
    https://bugs.mercurylang.org/file_download.php?file_id=95&type=bug
     
    There are no notes attached to this issue.




    View Issue Details
    20 [mercury] Bug minor always 2007-10-19 09:30 2010-02-05 15:43
    maclarty  
    maclarty  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    declarative debugger going up search tree when initial node trusted.
    If the declarative debugger is started on a trusted node, all of whose children are trusted too, then it will start searching up the call tree. This is because it is assuming the node must be inadmissible (the node cannot be erroneous, because it is trusted, also it cannot be correct, because then why would the user have started the declarative debugger at that node in the first place?)

    This behaviour can seem unintuitive.

    There is an example of this behaviour in the following test:
    tests/debugger/declarative/io_read_bug

    Zoltan and I discussed the issue and agreed that the fix was to allow the user to assert whether the node was erroneous or inadmissible when they enter the dd command.

    I now think a better solution is simply for the declarative debugger to say that it is searching up the call tree, because the node is trusted, so it is assuming it is inadmissible. A message like:

      The call to io.read/3 and all its descendents are trusted, searching up the
      call tree for an untrusted node..

    This way you get the behaviour you want if you start the dd at a call to error and if you accidentally start it at a trusted node, you know immediately that the node is trusted, so you can then type "quit", untrust the predicate, and start again.

    Zoltan, how does this sound to you?
     
    Notes
    (0000035)
    maclarty   
    2007-10-19 09:32   
    (Last edited: 2007-10-19 09:32)
    See bug description.

    (0000126)
    pbone   
    2008-08-12 11:42   
    This tricked me yesterday. I agree with the proposed solution of informing the user that the node is trusted and that the debugger will begin to search up the call tree.
    (0000251)
    maclarty   
    2010-02-05 15:43   
    See r1.77 of browser/declarative_debugger.m.




    View Issue Details
    127 [mercury] Bug minor always 2010-01-14 13:15 2010-02-05 14:13
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    implementation defined constants don't work with try goals
    The compiler aborts if the module contains a try goal that uses an implementation defined constant:

    Software Error: hlds_code_util.m: Unexpected: cons_id_to_tag: implementation_defined_const
     
    There are no notes attached to this issue.




    View Issue Details
    132 [mercury] Bug text always 2010-02-02 14:52 2010-02-02 16:30
    mgiuca  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Typo in make_hlds_warn ("ccur")
    Small typo in a warning message in make_hlds_warn.

    It prints "warning: variables `A, B' ccur more than once in this scope."
    "ccur" should read "occur".

    Attached & pasted below is a tiny patch.

    --- compiler/make_hlds_warn.m 2009-09-08 18:14:40.000000000 +1000
    +++ compiler/make_hlds_warn.m 2010-02-02 14:49:38.000000000 +1100
    @@ -386,7 +386,7 @@
                     words("occurs more than once in this scope."), nl]
             ;
                 MultiPieces = [words("warning: variables"), MultiVarsPiece,
    - words("ccur more than once in this scope."), nl]
    + words("occur more than once in this scope."), nl]
             ),
             MultiMsg = simple_msg(goal_info_get_context(GoalInfo),
                 [option_is_set(warn_singleton_vars, yes,
    make_hlds_warn.m.patch (567 bytes) 2010-02-02 14:52
    https://bugs.mercurylang.org/file_download.php?file_id=94&type=bug
     
    Notes
    (0000250)
    juliensf   
    2010-02-02 16:30   
    Fix committed - thanks for that.




    View Issue Details
    40 [mercury] Bug minor always 2008-02-01 15:15 2010-02-02 16:23
    juliensf  
     
    normal  
    confirmed  
    open  
    none    
    none  
       
    RTTI looks for the name of a solver value return repn. type name
    type_name(type_of(X)) where X is a solver type returns the name of the representation type
    not the solver type itself. This will occurs even if the solver type is imported from another
    module.

    The attached test case demonstrates this problem.
    solver_type_name.m (467 bytes) 2008-02-01 15:15
    https://bugs.mercurylang.org/file_download.php?file_id=34&type=bug
     
    Notes
    (0000073)
    juliensf   
    2008-02-01 17:24   
    (Last edited: 2008-02-03 16:45)
    I think this is occurring because the implementation of type_of/1 calls MR_collapse_equivalences
    and (for some reason) solver types are being treated as equivalences in this respect.

    Unfortunately, there is nothing in the current RTTI data structures that would allow us
    to distinguish that a type_info is for a solver type and avoid collapsing the equivalences.
    (Actually, for solver types and solver type equivalences you would need to collapse equivalences,
    but only as far back as the last solver type.)

    In order to fix this I think we will need to add something to type_infos that distinguishes solver
    types from non-solver types.





    View Issue Details
    100 [mercury] Bug minor always 2009-06-26 16:22 2010-02-02 16:21
    petdr  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    incorrect report that a module is unused
    If you have a typeclass

    :- typeclass tc(T) <= tc2(T) where [...].
    :- instance tc(unit).

    Then the system needs to prove that tc2(unit) holds as well.

    If you import a module which holds that fact and that is all the module is used for then the system incorrectly reports that module is unused.
    interface_import_bug.tar.bz2 (407 bytes) 2009-06-26 16:22
    https://bugs.mercurylang.org/file_download.php?file_id=77&type=bug
     
    Notes
    (0000177)
    petdr   
    2009-06-26 16:25   
    I can fix this bug if someone can tell me where to find that we've used the instance tc2(unit) coming from an import.
    (0000249)
    juliensf   
    2010-02-02 16:21   
    Fixed - see r1.176 of compiler/module_qual.m.




    View Issue Details
    131 [mercury] Bug minor sometimes 2010-01-28 16:16 2010-01-28 16:16
    pbone  
     
    low  
    new  
    open  
    none    
    none  
       
    Compilation fails when the same variable is used in two trace goals but not outside the trace goals.

    The following code fails to compile

            trace [compile_time(flag("debug-dep-par-conj")), io(!IO)] (
                OutInfo = init_hlds_out_info(Globals),
                proc_info_get_varset(!.ProcInfo, VarSet),
                format("Pred/Proc: %s/%s before dep-par-conj:\n",
                    [s(string(PredId)), s(string(ProcId))], !IO),
                write_goal(OutInfo, !.Goal, !.ModuleInfo, VarSet,
                    yes, 0, "", !IO),
                nl(!IO)
            ),
            !:SyncInfo = sync_info(!.ModuleInfo, IgnoreVars, AllowSomePathsOnly,
                !.VarSet, !.VarTypes, proc(PredId, ProcId)),
            sync_dep_par_conjs_in_goal(!Goal, InstMap0, _, !SyncInfo),
            !.SyncInfo = sync_info(_, _, _, !:VarSet, !:VarTypes, _),
            % XXX RTTI varmaps may need to be updated

            trace [compile_time(flag("debug-dep-par-conj")), io(!IO)] (
                OutInfo = init_hlds_out_info(Globals),
                proc_info_get_varset(!.ProcInfo, VarSet),
                format("Pred/Proc: %s/%s after dep-par-conj:\n",
                    [s(string(PredId)), s(string(ProcId))], !IO),
                write_goal(OutInfo, !.Goal, !.ModuleInfo, VarSet,
                    yes, 0, "", !IO),
                nl(!IO)
            ),

    With a confusing error message because the compiler doesn't understand that VarSet in each trace goal is local to that trace goal only. The compiler complains about a variable introduced in the state variable notation of !IO - which is incorrect.

    The following code works as VarSet is produced outside of both trace goals.

            OutInfo = init_hlds_out_info(Globals),
            proc_info_get_varset(!.ProcInfo, VarSet),
            trace [compile_time(flag("debug-dep-par-conj")), io(!IO)] (
                format("Pred/Proc: %s/%s before dep-par-conj:\n",
                    [s(string(PredId)), s(string(ProcId))], !IO),
                write_goal(OutInfo, !.Goal, !.ModuleInfo, VarSet,
                    yes, 0, "", !IO),
                nl(!IO)
            ),
            !:SyncInfo = sync_info(!.ModuleInfo, IgnoreVars, AllowSomePathsOnly,
                !.VarSet, !.VarTypes, proc(PredId, ProcId)),
            sync_dep_par_conjs_in_goal(!Goal, InstMap0, _, !SyncInfo),
            !.SyncInfo = sync_info(_, _, _, !:VarSet, !:VarTypes, _),
            % XXX RTTI varmaps may need to be updated

            trace [compile_time(flag("debug-dep-par-conj")), io(!IO)] (
                format("Pred/Proc: %s/%s after dep-par-conj:\n",
                    [s(string(PredId)), s(string(ProcId))], !IO),
                write_goal(OutInfo, !.Goal, !.ModuleInfo, VarSet,
                    yes, 0, "", !IO),
                nl(!IO)
            ),
     
    There are no notes attached to this issue.




    View Issue Details
    96 [mercury] Bug text always 2009-05-28 12:14 2010-01-27 17:06
    pbone  
    rafe  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    some predicates parsing_utils are documented with arguments in an incorrect order.

    Some documentation comments in parsing_utils don't match the actual order of the aguments of the predicate.

    For example:

        % keyword(Src, IdChars, Keyword, _, !PS) matches Keyword exactly (i.e., it
        % must not be followed by any character in IdChars) and any subsequent
        % whitespace.
        %
      :- pred keyword(string::in, string::in, src::in, unit::out,
           ps::in, ps::out) is semidet.

    Above the src argument has the third place in the type declaration (which is correct making this easy to use as a curried higher order argument to other predicates), while the documentation places this argument in the first place.
     
    Notes
    (0000167)
    pbone   
    2009-05-28 12:21   
    It seems that the set module has the same problem.
    (0000168)
    juliensf   
    2009-06-01 18:43   
    For the sake of uniformity in the parsing_utils module it would be better if the
    Src argument was always first (when present) -- that's what half of the predicates
    in the interface of that module do anyway.

    Which predicates in the set module had inconsistent documentation? I looked but
    couldn't see any.
    (0000170)
    pbone   
    2009-06-02 17:00   
    Julien:

    When accepting more than the four arguments (src::in, T::out, ps::in, ps::out) a predicate must put the extra arguments before the source argument. Many predicates in this module take a higher order argument with these four arguments that is semidet. Predicates who's argument lists end in exactly these four arguments can be easily curried to create higher order arguments.
    (0000171)
    pbone   
    2009-06-02 17:14   
    Disregard my comments about the set module with regard to this bug.
    (0000248)
    juliensf   
    2010-01-27 17:06   
    Fix committed, see r1.5 of library/parsing_utils.m.




    View Issue Details
    126 [mercury] Bug major always 2010-01-12 11:10 2010-01-25 17:08
    petdr  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    unable to build asm_fast.gc.stseg grade under cygwin
    mgnuc --grade asm_fast.gc.stseg --c-debug --no-ansi -- -c mercury_stacks.c -o mercury_stacks.o
    mercury_stacks.c: In function `MR_rewind_nondetstack_segments':
    mercury_stacks.c:330: error: structure has no member named `MR_zone_redzone'
    make[2]: *** [mercury_stacks.o] Error 1

    The problem is that MR_zone_redzone is only defined if one can use mprotect to check for overflow, which one cannot do on cygwin.
     
    There are no notes attached to this issue.




    View Issue Details
    129 [mercury] Bug minor always 2010-01-18 11:50 2010-01-25 16:29
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    java grade generates uncompilable code for some uses of typeclasses
    From Max:

    "For your information,
    I have a bug in the Java BE of Mercury.
    It all compiles at the Mercury level (it even works in the asm grade),
    but the java compilers complains of:
                                                                                                                                                                                       
    Making Java class files
    Mercury/java/x86_64-unknown-linux-gnu/Mercury/javas/jmercury/sewol.java:5471: inconvertible types
    found : jmercury.runtime.TypeCtorInfo_Struct
    required: java.lang.Object[]
          TypeClassInfo_for_workflow_case_238 = (/* typeclass_info */ java.lang.Object[]) unit.unit__type_ctor_info_unit_0;
                                                                                              ^
    "
    I haven't been able to pull a small test case from our tangled web of proprietary code yet.
     
    Notes
    (0000247)
    wangp   
    2010-01-22 12:53   
    I think I know where the bug is.

    `interpret_typeclass_info_manipulator' in higher_order.m tries to evaluate
    `private_builtin.superclass_from_typeclass_info' at compile time, but the
    Index calculation is wrong.

    `private_builtin.superclass_from_typeclass_info' calls
    `MR_typeclass_info_superclass_info', defined in mercury_type_info.h:

      #define MR_typeclass_info_superclass_info(tci, n) \
        (((MR_Word *)(tci))[MR_typeclass_info_num_extra_instance_args(tci) + (n)])

    where: "MR_typeclass_info_num_extra_instance_args gives the sum of
    MR_typeclass_info_num_instance_type_vars and
    MR_typeclass_info_num_instance_constraints".

    But `interpret_typeclass_info_manipulator' only adds NumConstraints. I'm not
    sure how to get MR_typeclass_info_num_instance_type_vars at compile time.
    Somewhere in hlds_instance_defn?

    The bug also affects type_info_from_typeclass_info.




    View Issue Details
    122 [mercury] Bug minor always 2009-12-18 20:18 2010-01-18 18:33
    mva  
    mark  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Functional dependency typeclass instance in module with sub-module int0 error
    I experience a bug in the Mercury compiler to do with int0 and typeclass instances.

    If you have an abstract typeclass instance in a module which has a sub-module, the int0 file has two instances declaration, which can lead to a self-conflicting declaration.


    Mercury/int0s/tcin.int0:011: Inconsistent instance declaration for typeclass
    Mercury/int0s/tcin.int0:011: `tc.tc'/2 with functional dependency `(A -> B)'.
    Mercury/int0s/tcin.int0:008: Here is the conflicting instance.
    ** Error making `Mercury/cs/tcin.sub.c'.


    While there is no conflicting typeclass instance.

    You can find attached a small test case exposing this bug.

    Commenting the include_module tcin.sub in tcin.m is sufficient to make it compile properly.
    tcinsub.zip (975 bytes) 2009-12-18 20:18
    https://bugs.mercurylang.org/file_download.php?file_id=91&type=bug
     
    Notes
    (0000237)
    wangp   
    2010-01-04 17:40   
    check_consistency_pair_2 in check_typeclass.m looks suspicious, specifically the RangeA = RangeB test.
    (0000243)
    mark   
    2010-01-12 17:22   
    The check_consistency_pair_2 predicate is doing what it's meant to: it checks the "consistency" condition, namely that any unifier for the domain of a functional dependency is also a unifier of the range.

    The problem is that this doesn't work nicely with the weakened form of the "coverage" condition. The full coverage condition says that any type variables appearing in the range of a functional dependency must also appear in the domain, where they will be bound by the above unifier. The weakened coverage condition says merely that they should either appear in the domain or be captured by some functional dependency derived from the instance constraints, but in the latter case they will not be bound by the above unifier. The paper [1] does not seem to say anything about the issue, so it's going to need further investigation.

    One thing that is exacerbating the problem is that duplicate abstract instances end up in the .int0 file, which is what triggers the problem in this case. Same thing arises if an abstract instances is duplicated in a .m file.

    [1] M. Sulzmann, G. Duck, S. Peyton-Jones, P. Stuckey, "Understanding Functional Dependencies via Constraint Handling Rules", JFP 2006.
    (0000246)
    mark   
    2010-01-18 18:33   
    On further investigation, the issue with the "weakened coverage" condition is not actually a problem. In this case it is intended that instances may be found to be inconsistent even if identical. (It is analogous to a disjunction being considered multi/nondet even if the disjuncts are identical.)

    The problem has been fixed by not performing the consistency check on pairs of instances that are imported from the same module. The proper check will be done when that module is itself compiled.




    View Issue Details
    123 [mercury] Bug minor always 2009-12-18 20:25 2010-01-12 14:12
    mva  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    typeclass instance clause type mix.
    In a typeclass instance, when the clause of a predicate is defined
    directly in the instance, qualifying certain types result in the compiler mixing up types.

    See the attached example, where simply adding :_ to a type makes the compiler
    complain about wrong typing;
    while doing the same but with the predicate defined outside the instance (via pred(...) is) works perfectly fine.
    test1.m (640 bytes) 2009-12-18 20:25
    https://bugs.mercurylang.org/file_download.php?file_id=92&type=bug
     
    Notes
    (0000242)
    wangp   
    2010-01-12 14:12   
    fix committed 2010-01-12




    View Issue Details
    102 [mercury] Bug minor always 2009-07-28 13:23 2009-12-17 00:52
    user185  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Inconsistent behaviour (error vs. warning) when compiling with --make
    The attached source file contains a simple "hello world" application.
    It specifies a module "mprojects" which is different from the name of the source file "mproject".

    The following behaviour results when compiling directly:
    13:17 dharabor@armitage build>mmc mproject.m
    mproject.m:001: Warning: source file `mproject.m' contains module named
    mproject.m:001: `mprojects'.

    However, compiling with "mmc --make":
    13:20 dharabor@armitage build>mmc --make mproject
    Making Mercury/cs/mproject.c
    Error: file `mproject.m' contains the wrong module.
      Expected module `mproject', found module `mprojects'.
    mproject.m:001: Warning: source file `mproject.m' contains module named
    mproject.m:001: `mprojects'.
    ** Error making `Mercury/cs/mproject.c'.

    Which is correct? Is this an error or a warning?

    mproject.m (181 bytes) 2009-07-28 13:23
    https://bugs.mercurylang.org/file_download.php?file_id=78&type=bug
     
    Notes
    (0000186)
    juliensf   
    2009-09-22 02:19   
    It as an error when the compiler is invoked with --make and a warning when it
    is invoked as just mmc.

    Invoking mmc by itself can only be used to build single-module programs. In that
    case it is possible to produce an executable even though the module name is "wrong".
    (Typically, the compiler is only used this way with small things and aborting with an
    error message would just be annoying - hence it is only warning.)

    mmc --make is intended for building multi-module programs. WIth them it is simply
    not possible for the compiler to build the program if the module and file names cannot
    be resolved - hence it is an error in this case. (It probably shouldn't also be printing out
    the warning in though.)

    You can tell the compiler to allow non-matching module / filename combinations by
    building a source file mapping, e.g. by using mmc's -f option.
    (0000236)
    juliensf   
    2009-12-17 00:52   
    Recent changes to the compiler mean that it no longer emits a warning in this case.




    View Issue Details
    118 [mercury] Bug minor always 2009-12-04 17:10 2009-12-16 09:18
    wangp  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    table_reset predicates omitted in non-tabling grades
    Table reset predicates are not generated in grades that don't support tabling, causing problems for code that must be portable to other grades. The solution is probably to generate dummy predicates when tabling is not supported.
     
    Notes
    (0000234)
    juliensf   
    2009-12-16 09:18   
    The compiler now generates dummy reset predicates for target languages
    which do not (yet) support tabling.




    View Issue Details
    15 [mercury] Bug major always 2007-10-05 13:25 2009-12-11 06:46
    pjrm  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    wrong variable scoping in `if ( some[X] p(X) ) then q(X) ...'
    :- module ifsome.
    :- interface.
    :- import_module io.
    :- pred main(io::di, io::uo) is det.
    :- implementation.
    :- import_module string.
    main(!IO):-
            X = "outer",
            ( if ( some[X] X = "inner" ) then
                    io.write_string(X, !IO),
                    io.nl(!IO)
             else
                    true
            ).

    This prints "inner", but one would expect it to print "outer" (both from one's expectations from standard predicate logic notation and from the point of view of the Mercury reference manual: "some Vars Goal ... The variables in Vars are local to the goal Goal", and the definition of if-then-else says nothing to contradict that: its statement about the declarative semantics of if-then-else is false for this example, or at least (if we want an example that still compiles after the transformation) for similar examples not involving I/O in the then/else goals).

    Fixing this bug is made harder by the fact that an example program in mercury_faq.texi depends on this behaviour (at least in absence of parens around the `some' goal): search for `if some'.

    In the example I've given, the severity of the bug is reduced by the fact that we get an `unused variable' warning (or a `shadowed variable' warning if we add another use of X). However, it is possible to construct examples that don't produce warnings by not having X outside of the if-then-else but where the behaviour differs according to whether X is bound or free on entry to the `then' goal (e.g. if the if-then-else is in semidet context and the `then' goal is `generate(X), test(X)'; and a similar generate(X),test(X) construct in the condition to avoid appears-only-once warning/objection). (I can send a 40-line example if that's useful, it's just not as succinct as the above.)

    This bug doesn't arise all that often, but is nevertheless a "psychologically" important bug, in that it results in a program that gives a wrong result rather than abort; it attacks Mercury's claim to logical consistency and ease of reasoning about program behaviour.

    pjrm.
    I haven't checked a current ROTD.
     
    Notes
    (0000219)
    pjrm   
    2009-11-28 02:23   
    Can someone please at least comment on what they think is the best course of action, e.g. whether to introduce an `ifsome' keyword, whether to change the behaviour of `if (some[VARS] GOAL(VARS))' to match the documentation [and, more importantly, to match what I believe to be programmer/logician expectations], whether to change the documentation to match the current behaviour, etc.?

    FWIW, I think the right things would be:

    First of all, change mercury_faq.texi (near the end of the Programming node) so as not to use this construct, e.g. simply comment out the `if some' version of the example and its following `The explicit existential quantifier...' comment, leaving the implicit-quantifier version (and add a link to this bug report). This takes about one minute; please, if you have commit rights then do it now.

    As to the appropriate behaviour of `if some[VARS]' or `if (some[VARS]...)':
    The contradictions in the documentation on this point is evidence of contradictory expectations. I believe most people would expect the parenthesized version to have VARS local to the parenthesized expression. For `if some', I could accept either behaviour, so long as the documentation is changed to explicitly describe the behaviour for this case that evidently has contradictory expectations.

    The question of whether to introduce an `ifsome' keyword depends in part on how `if some' and `if (some...)' are resolved. If both are changed to match the language reference manual documentation, or if both are made to produce a warning, then there's a strong case for adding an ifsome keyword. Otherwise, the decision is harder, and I suspect that different people will answer differently according to how they see Mercury being used; FWIW, I currently lean towards still introducing one.
    (0000224)
    wangp   
    2009-12-02 20:57   
    I agree that `if (some ...) then' is misleading, but the scoping behaviour is useful to keep. I think the best course of action is to make the compiler distinguish between `if (some ...)' and `if some ...', in line with our intuition.

    The problem does not warrant a new keyword. I don't think I've ever seen it in practice -- the quantifier is optional, so the shorter and clearer code would leave it out.
    (0000225)
    pbone   
    2009-12-02 21:08   
    isn't this a Prolog compatibility feature?

    I believe the work around is:

    (
       some [X] cond(X),
       true
    ->
       then
    ;
       else
    ).

    This makes the condition a conjunction rather than an existentially quantified goal. I seem to recall having this conversation with Julian.
    (0000226)
    wangp   
    2009-12-02 22:36   
    Here is one relevant thread:
    http://thread.gmane.org/gmane.comp.lang.mercury.devel/1151
    (0000228)
    juliensf   
    2009-12-04 00:30   
    The current behaviour is intended (although not documented properly), i.e.
    if the top-level goal of the condition of an if-then-else is an existential quantification
    then the quantified variables are quantified over both the condition and the then branch.
    The rationale for this behaviour is that there is no other way to write an existential quantification
    over both the condition and then branch in Mercury otherwise.

    Note that the proposed "if some [Vars]" or "( some [Vars if ...") syntax does not extend
    to the ( c-> t ; e) syntax. In any case, I think that introducing new syntax to deal with what
    is a very rare usage is not worth it.

    IMO, the appropriate resolution to this is just to document that conditions whose top-level
    goal is an existential quantification are scoped over both the condition and then then branch.
    (Indeed, I have a diff somewhere that changes the reference manual to say precisely this.)
    (0000229)
    juliensf   
    2009-12-04 00:35   
    (Last edited: 2009-12-04 02:33)
    Hi Paul,

    The difference between:

    ( some [X] C, true -> T ; G)

    and

    ( some [X] C -> T ; G)

    is that the in the latter X is quantified over C and T because the top-level goal of the condition
    is an existential quantification; in the former case the top-level goal is a conjunction, so here
    X is only quantified over C.

    (0000230)
    pbone   
    2009-12-04 09:26   
    Julien:

    This has jogged my memory, I remember discussing this with you now. The thing that I forgot was that in the latter example that the existential quantification covered T, I knew it did something unexpected but couldn't remember what.

    Cheers.
    (0000233)
    juliensf   
    2009-12-11 06:45   
    I have committed a change to the reference manual that documents the behaviour
    of i.t.e conditions that are explicit existential quantifiers.
    (See r1.436 of doc/reference_manual.texi.)

    The confusing example in the FAQ has been deleted.

    Any further discussion about alternative syntax for existentially quantifying over
    the condition and then branch can take place on mercury-developers. (IMO, adding
    such syntax is not worth it however.)




    View Issue Details
    77 [mercury] Bug crash always 2008-08-16 05:06 2009-12-01 01:57
    michael_george_hart  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    make install issues with mercury-compiler-rotd-2008-08-14
    Since I really don't know I report this as major

    make install always end in failure

    on OpenSUSe 10.3

    [ -d /usr/local/mercury-rotd-2008-08-14/lib/mercury/conf ] || mkdir -p /usr/local/mercury-rotd-2008-08-14/lib/mercury/conf
    [ -d /usr/local/mercury-rotd-2008-08-14/lib/mercury/reconf/runtime ] || \
                    mkdir -p /usr/local/mercury-rotd-2008-08-14/lib/mercury/reconf/runtime
    cat `vpath_find mercury.c mercury_accurate_gc.c mercury_agc_debug.c mercury_atomic_ops.c mercury_backjump.c mercury_bootstrap.c mercury_builtin_types.c mercury_bitmap.c mercury_construct.c mercury_context.c mercury_debug.c mercury_deconstruct.c mercury_deep_copy.c mercury_deep_profiling.c mercury_dlist.c mercury_dummy.c mercury_engine.c mercury_file.c mercury_float.c mercury_getopt1.c mercury_getopt.c mercury_grade.c mercury_hash_table.c mercury_heap_profile.c mercury_ho_call.c mercury_label.c mercury_layout_util.c mercury_memory.c mercury_memory_handlers.c mercury_memory_zones.c mercury_minimal_model.c mercury_misc.c mercury_mm_own_stacks.c mercury_prof.c mercury_profiling_builtin.c mercury_prof_mem.c mercury_prof_time.c mercury_region.c mercury_regs.c mercury_reg_workarounds.c mercury_runtime_util.c mercury_signal.c mercury_stacks.c mercury_stack_layout.c mercury_stack_trace.c mercury_stm.c mercury_string.c mercury_tabling.c mercury_term_size.c mercury_thread.c mercury_timing.c mercury_trace_base.c mercury_trace_term.c mercury_trail.c mercury_type_desc.c mercury_type_info.c mercury_type_tables.c mercury_wrapper.c mercury_wsdeque.c` | grep '^INIT ' > mer_rt.init
    cp `vpath_find mer_rt.init` /usr/local/mercury-rotd-2008-08-14/lib/mercury/modules/hlc.gc
    cp `vpath_find libmer_rt.a \
                    libmer_rt.so` \
                    /usr/local/mercury-rotd-2008-08-14/lib/mercury/lib/hlc.gc
    ranlib /usr/local/mercury-rotd-2008-08-14/lib/mercury/lib/hlc.gc/libmer_rt.a
    gmake[2]: Leaving directory `/mnt/sde/home/XMan/Projects/Mecury/mercury-compiler-rotd-2008-08-14/install_grade_dir.hlc.gc/runtime'
    gmake[2]: Entering directory `/mnt/sde/home/XMan/Projects/Mecury/mercury-compiler-rotd-2008-08-14/install_grade_dir.hlc.gc/library'
    ../Mmake.common:455: warning: undefined variable `mer_std.mhs'
    ../Mmake.common:458: warning: undefined variable `mer_std.mhs'
    ../Mmake.common:464: warning: undefined variable `mer_std.os'
    /tmp/mmake.p15309:964: warning: undefined variable `mer_std.trans_opts'
    /tmp/mmake.p15309:968: warning: undefined variable `mer_std.ms'
    /tmp/mmake.p15309:976: warning: undefined variable `mer_std.ms'
    /tmp/mmake.p15309:996: warning: undefined variable `mer_std.os'
    /tmp/mmake.p15309:997: warning: undefined variable `mer_std.cs'
    /tmp/mmake.p15309:998: warning: undefined variable `mer_std.ss'
    /tmp/mmake.p15309:999: warning: undefined variable `mer_std.pic_ss'
    /tmp/mmake.p15309:1000: warning: undefined variable `mer_std.ils'
    /tmp/mmake.p15309:1001: warning: undefined variable `mer_std.javas'
    /tmp/mmake.p15309:1157: warning: undefined variable `mer_std.os'
    mmc --generate-dependencies --grade hlc.gc --mercury-linkage shared --flags LIB_FLAGS --flags INTER_FLAGS -R/usr/local/mercury-rotd-2008-08-14/lib/mercury/lib/hlc.gc -R/usr/local/mercury-rotd-2008-08-14/lib/mercury/lib --no-warn-nothing-exported --no-warn-unused-imports mer_std

    *** Mercury runtime: caught segmentation violation ***
    cause: address not mapped to object
    address involved: (nil)
    This may have been caused by a stack overflow, due to unbounded recursion.
    exiting from signal handler
    gmake[2]: *** [mer_std.depend] Error 1
    gmake[2]: Leaving directory `/mnt/sde/home/XMan/Projects/Mecury/mercury-compiler-rotd-2008-08-14/install_grade_dir.hlc.gc/library'
    To clean up from failed install, remove /mnt/sde/home/XMan/Projects/Mecury/mercury-compiler-rotd-2008-08-14/install_grade_dir.hlc.gc
    gmake[1]: *** [install_grades] Error 1
    gmake[1]: Leaving directory `/mnt/sde/home/XMan/Projects/Mecury/mercury-compiler-rotd-2008-08-14'
    make: *** [install] Error 2
     
    Notes
    (0000128)
    juliensf   
    2008-08-18 18:41   
    The problem here is that OpenSUSE 10.3 uses gcc 4.2 as its default C compiler
    and that particular version of gcc is causing problems with the asm_fast grades.
    (This is already the subject of bug 0000066).

    As a workaround invoke configure with the following additional options:

        --with-llds-base-grade=reg
        --with-default-grade=hlc.gc

    I've tried this and the installation process continues beyond the point reached above.
    (Note that this results in a somewhat slower version of the Mercury compiler, so
    you may wish to re-compile the entire system in the hlc.gc grade if that becomes
    important.)
    (0000129)
    michael_george_hart   
    2008-08-19 02:23   
    I did as was recommended,

    ./configure --with-llds-base-grade=reg --with-default-grade=hlc.gc


    but this time with this time with "mercury-compiler-rotd-2008-08-16"

    then I did
    >make
    ...
    >su
    ...
    >make install
    ..
    and got the following; which looks like what I was getting before
    cp `vpath_find mer_rt.init` /usr/local/mercury-rotd-2008-08-16/lib/mercury/modules/hlc.gc
    cp `vpath_find libmer_rt.a \
                    libmer_rt.so` \
                    /usr/local/mercury-rotd-2008-08-16/lib/mercury/lib/hlc.gc
    ranlib /usr/local/mercury-rotd-2008-08-16/lib/mercury/lib/hlc.gc/libmer_rt.a
    gmake[2]: Leaving directory `/mnt/sde/home/XMan/Projects/Mecury/mercury-compiler-rotd-2008-08-16/install_grade_dir.hlc.gc/runtime'
    gmake[2]: Entering directory `/mnt/sde/home/XMan/Projects/Mecury/mercury-compiler-rotd-2008-08-16/install_grade_dir.hlc.gc/library'
    ../Mmake.common:455: warning: undefined variable `mer_std.mhs'
    ../Mmake.common:458: warning: undefined variable `mer_std.mhs'
    ../Mmake.common:464: warning: undefined variable `mer_std.os'
    /tmp/mmake.L24133:964: warning: undefined variable `mer_std.trans_opts'
    /tmp/mmake.L24133:968: warning: undefined variable `mer_std.ms'
    /tmp/mmake.L24133:976: warning: undefined variable `mer_std.ms'
    /tmp/mmake.L24133:996: warning: undefined variable `mer_std.os'
    /tmp/mmake.L24133:997: warning: undefined variable `mer_std.cs'
    /tmp/mmake.L24133:998: warning: undefined variable `mer_std.ss'
    /tmp/mmake.L24133:999: warning: undefined variable `mer_std.pic_ss'
    /tmp/mmake.L24133:1000: warning: undefined variable `mer_std.ils'
    /tmp/mmake.L24133:1001: warning: undefined variable `mer_std.javas'
    /tmp/mmake.L24133:1157: warning: undefined variable `mer_std.os'
    mmc --generate-dependencies --grade hlc.gc --mercury-linkage shared --flags LIB_FLAGS --flags INTER_FLAGS -R/usr/local/mercury-rotd-2008-08-16/lib/mercury/lib/hlc.gc -R/usr/local/mercury-rotd-2008-08-16/lib/mercury/lib --no-warn-nothing-exported --no-warn-unused-imports mer_std
    GC Warning: Out of Memory! Returning NIL!

    *** Mercury runtime: caught segmentation violation ***
    cause: address not mapped to object
    address involved: (nil)
    This may have been caused by a stack overflow, due to unbounded recursion.
    exiting from signal handler
    gmake[2]: *** [mer_std.depend] Error 1
    gmake[2]: Leaving directory `/mnt/sde/home/XMan/Projects/Mecury/mercury-compiler-rotd-2008-08-16/install_grade_dir.hlc.gc/library'
    To clean up from failed install, remove /mnt/sde/home/XMan/Projects/Mecury/mercury-compiler-rotd-2008-08-16/install_grade_dir.hlc.gc
    gmake[1]: *** [install_grades] Error 1
    gmake[1]: Leaving directory `/mnt/sde/home/XMan/Projects/Mecury/mercury-compiler-rotd-2008-08-16'
    make: *** [install] Error 2
    (0000130)
    juliensf   
    2008-08-19 02:36   
    Could you please send us the file config.log from the top-level of the source tree.
    (0000131)
    michael_george_hart   
    2008-08-19 07:30   
    config.log
    This file contains any messages produced by compilers while
    running configure, to aid debugging if configure makes a mistake.

    It was created by configure, which was
    generated by GNU Autoconf 2.59. Invocation command line was

      $ ./configure --with-llds-base-grade=reg --with-default-grade=hlc.gc

    ## --------- ##
    ## Platform. ##
    ## --------- ##

    hostname = XMan-3
    uname -m = x86_64
    uname -r = 2.6.22.18-0.2-default
    uname -s = Linux
    uname -v = 0000001 SMP 2008-06-09 13:53:20 +0200

    /usr/bin/uname -p = unknown
    /bin/uname -X = unknown

    /bin/arch = x86_64
    /usr/bin/arch -k = unknown
    /usr/convex/getsysinfo = unknown
    hostinfo = unknown
    /bin/machine = unknown
    /usr/bin/oslevel = unknown
    /bin/universe = unknown

    PATH: /usr/local/mercury-rotd-2008-08-16/bin
    PATH: /opt/kde3/bin
    PATH: /usr/local/mercury-rotd-2008-08-14/bin
    PATH: /home/XMan/bin
    PATH: /usr/local/bin
    PATH: /usr/bin
    PATH: /bin
    PATH: /usr/bin/X11
    PATH: /usr/X11R6/bin
    PATH: /usr/games
    PATH: /usr/lib/mit/bin
    PATH: /usr/lib/mit/sbin
    PATH: /usr/lib/qt3/bin


    ## ----------- ##
    ## Core tests. ##
    ## ----------- ##

    configure:1489: checking build system type
    configure:1507: result: x86_64-unknown-linux-gnu
    configure:1515: checking host system type
    configure:1529: result: x86_64-unknown-linux-gnu
    configure:1579: checking for cygpath
    configure:1606: result: echo
    configure:1615: checking for cygpath
    configure:1642: result: echo
    configure:1741: checking for mmc
    configure:1759: found /usr/local/mercury-rotd-2008-08-16/bin/mmc
    configure:1771: result: /usr/local/mercury-rotd-2008-08-16/bin/mmc
    configure:1779: checking whether the above mmc works and is sufficiently recent
    /usr/local/mercury-rotd-2008-08-16/bin/mmc conftest

    *** Mercury runtime: caught segmentation violation ***
    cause: address not mapped to object
    address involved: (nil)
    This may have been caused by a stack overflow, due to unbounded recursion.
    exiting from signal handler
    configure:1938: result: no
    configure:2009: checking whether to enable large heaps when using conservative GC
    configure:2013: result: yes
    configure:2045: checking whether to enable unmapping of unused pages when using Boehm GC
    configure:2055: result: no
    configure:2083: checking for GCC source directory
    configure:2117: result: not_found
    configure:2119: checking whether to enable the GCC back-end interface
    configure:2162: result: no
    configure:2176: checking for gmake
    configure:2192: found /usr/bin/gmake
    configure:2202: result: gmake
    configure:2239: checking for mkfifo
    configure:2257: found /usr/bin/mkfifo
    configure:2269: result: /usr/bin/mkfifo
    configure:2363: checking for mktemp
    configure:2381: found /bin/mktemp
    configure:2393: result: /bin/mktemp
    configure:2422: checking for install-info
    configure:2440: found /usr/bin/install-info
    configure:2452: result: /usr/bin/install-info
    configure:2472: checking for texi2dvi
    configure:2490: found /usr/bin/texi2dvi
    configure:2502: result: /usr/bin/texi2dvi
    configure:2515: checking for pdftex
    configure:2533: found /usr/bin/pdftex
    configure:2545: result: /usr/bin/pdftex
    configure:2556: checking for lynx
    configure:2589: result: no
    configure:2597: checking for dvips
    configure:2615: found /usr/bin/dvips
    configure:2627: result: /usr/bin/dvips
    configure:2638: checking for makeinfo
    configure:2656: found /usr/bin/makeinfo
    configure:2668: result: /usr/bin/makeinfo
    configure:2679: checking for info
    configure:2697: found /usr/bin/info
    configure:2709: result: /usr/bin/info
    configure:2720: checking for perl
    configure:2738: found /usr/bin/perl
    configure:2750: result: /usr/bin/perl
    configure:2761: checking for hostname
    configure:2779: found /bin/hostname
    configure:2791: result: /bin/hostname
    configure:2866: checking for gcc
    configure:2882: found /usr/bin/gcc
    configure:2892: result: gcc
    configure:3136: checking for C compiler version
    configure:3139: gcc --version </dev/null >&5
    gcc (GCC) 4.2.1 (SUSE Linux)
    Copyright (C) 2007 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    configure:3142: $? = 0
    configure:3144: gcc -v </dev/null >&5
    Using built-in specs.
    Target: x86_64-suse-linux
    Configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-languages=c,c++,objc,fortran,obj-c++,java,ada --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.2.1 --enable-ssp --disable-libssp --disable-libgcj --with-slibdir=/lib64 --with-system-zlib --enable-shared --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --program-suffix=-4.2 --enable-version-specific-runtime-libs --without-system-libunwind --with-cpu=generic --host=x86_64-suse-linux
    Thread model: posix
    gcc version 4.2.1 (SUSE Linux)
    configure:3147: $? = 0
    configure:3149: gcc -V </dev/null >&5
    gcc: '-V' option must have argument
    configure:3152: $? = 1
    configure:3175: checking for C compiler default output file name
    configure:3178: gcc conftest.c >&5
    configure:3181: $? = 0
    configure:3227: result: a.out
    configure:3232: checking whether the C compiler works
    configure:3238: ./a.out
    configure:3241: $? = 0
    configure:3258: result: yes
    configure:3265: checking whether we are cross compiling
    configure:3267: result: no
    configure:3270: checking for suffix of executables
    configure:3272: gcc -o conftest conftest.c >&5
    configure:3275: $? = 0
    configure:3300: result:
    configure:3306: checking for suffix of object files
    configure:3327: gcc -c conftest.c >&5
    configure:3330: $? = 0
    configure:3352: result: o
    configure:3356: checking whether we are using the GNU C compiler
    configure:3380: gcc -c conftest.c >&5
    configure:3386: $? = 0
    configure:3389: test -z || test ! -s conftest.err
    configure:3392: $? = 0
    configure:3395: test -s conftest.o
    configure:3398: $? = 0
    configure:3411: result: yes
    configure:3417: checking whether gcc accepts -g
    configure:3438: gcc -c -g conftest.c >&5
    configure:3444: $? = 0
    configure:3447: test -z || test ! -s conftest.err
    configure:3450: $? = 0
    configure:3453: test -s conftest.o
    configure:3456: $? = 0
    configure:3467: result: yes
    configure:3484: checking for gcc option to accept ANSI C
    configure:3554: gcc -c -g -O2 conftest.c >&5
    configure:3560: $? = 0
    configure:3563: test -z || test ! -s conftest.err
    configure:3566: $? = 0
    configure:3569: test -s conftest.o
    configure:3572: $? = 0
    configure:3590: result: none needed
    configure:3608: gcc -c -g -O2 conftest.c >&5
    conftest.c:2: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'me'
    configure:3614: $? = 1
    configure: failed program was:
    | #ifndef __cplusplus
    | choke me
    | #endif
    configure:3746: checking whether C compiler needs -no-cpp-precomp
    configure:3764: result: no
    configure:3871: checking whether we can use -fno-strict-aliasing
    configure:3876: result: yes
    configure:3879: checking whether we need to use -fno-strict-aliasing
    configure:3890: result: yes
    configure:3916: checking whether to pass -I/usr/local/include to C compiler
    configure:3925: result: no
    configure:3945: checking whether to pass -L/usr/local/lib to the linker
    configure:3955: result: no
    configure:3975: checking how to run the C preprocessor
    configure:4010: gcc -E -Iruntime -Iruntime/machdeps -Itrace conftest.c
    configure:4016: $? = 0
    configure:4048: gcc -E -Iruntime -Iruntime/machdeps -Itrace conftest.c
    conftest.c:13:28: error: ac_nonexistent.h: No such file or directory
    configure:4054: $? = 1
    configure: failed program was:
    | /* confdefs.h. */
    |
    | #define PACKAGE_NAME ""
    | #define PACKAGE_TARNAME ""
    | #define PACKAGE_VERSION ""
    | #define PACKAGE_STRING ""
    | #define PACKAGE_BUGREPORT ""
    | #define MR_FULLARCH "x86_64-unknown-linux-gnu"
    | #define MR_VERSION "rotd-2008-08-16"
    | #define MR_MKFIFO "/usr/bin/mkfifo"
    | #define MR_HOSTNAMECMD "/bin/hostname -f"
    | /* end confdefs.h. */
    | #include <ac_nonexistent.h>
    configure:4093: result: gcc -E
    configure:4117: gcc -E -Iruntime -Iruntime/machdeps -Itrace conftest.c
    configure:4123: $? = 0
    configure:4155: gcc -E -Iruntime -Iruntime/machdeps -Itrace conftest.c
    conftest.c:13:28: error: ac_nonexistent.h: No such file or directory
    configure:4161: $? = 1
    configure: failed program was:
    | /* confdefs.h. */
    |
    | #define PACKAGE_NAME ""
    | #define PACKAGE_TARNAME ""
    | #define PACKAGE_VERSION ""
    | #define PACKAGE_STRING ""
    | #define PACKAGE_BUGREPORT ""
    | #define MR_FULLARCH "x86_64-unknown-linux-gnu"
    | #define MR_VERSION "rotd-2008-08-16"
    | #define MR_MKFIFO "/usr/bin/mkfifo"
    | #define MR_HOSTNAMECMD "/bin/hostname -f"
    | /* end confdefs.h. */
    | #include <ac_nonexistent.h>
    configure:4207: checking for egrep
    configure:4217: result: grep -E
    configure:4222: checking for use of a Microsoft C compiler
    configure:4252: result: no
    configure:4388: checking for ranlib
    configure:4404: found /usr/bin/ranlib
    configure:4415: result: ranlib
    configure:4466: checking for sin in -lm
    configure:4496: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c -lm >&5
    conftest.c:20: warning: conflicting types for built-in function 'sin'
    configure:4502: $? = 0
    configure:4505: test -z || test ! -s conftest.err
    configure:4508: $? = 0
    configure:4511: test -s conftest
    configure:4514: $? = 0
    configure:4527: result: yes
    configure:4584: checking for ilasm
    configure:4602: found /usr/bin/ilasm
    configure:4614: result: /usr/bin/ilasm
    configure:4623: checking for gacutil
    configure:4641: found /usr/bin/gacutil
    configure:4653: result: /usr/bin/gacutil
    configure:4661: checking for Microsoft.NET Framework SDK
    configure:4679: result: yes
    configure:4690: checking for csc
    configure:4723: result: no
    configure:4690: checking for cscc
    configure:4723: result: no
    configure:4783: checking for al
    configure:4801: found /usr/bin/al
    configure:4813: result: /usr/bin/al
    configure:4846: checking for jikes
    configure:4879: result: no
    configure:4846: checking for javac
    configure:4864: found /usr/bin/javac
    configure:4876: result: /usr/bin/javac
    configure:4891: checking for java
    configure:4924: result: no
    configure:4930: checking for jar
    configure:4948: found /usr/bin/jar
    configure:4960: result: /usr/bin/jar
    configure:5096: checking for erlc
    configure:5129: result: no
    configure:5191: checking for erl
    configure:5224: result: no
    configure:5253: checking for sysconf
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for getpagesize
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for gethostname
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for mprotect
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for memalign
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for posix_memalign
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for memmove
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    conftest.c:43: warning: conflicting types for built-in function 'memmove'
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for sigaction
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for siginterrupt
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for setitimer
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for snprintf
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    conftest.c:47: warning: conflicting types for built-in function 'snprintf'
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for _snprintf
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    /tmp/cce9PdSY.o: In function `main':
    conftest.c:(.text+0x7): undefined reference to `_snprintf'
    /tmp/cce9PdSY.o:(.data+0x0): undefined reference to `_snprintf'
    collect2: ld returned 1 exit status
    configure:5316: $? = 1
    configure: failed program was:
    | /* confdefs.h. */
    |
    | #define PACKAGE_NAME ""
    | #define PACKAGE_TARNAME ""
    | #define PACKAGE_VERSION ""
    | #define PACKAGE_STRING ""
    | #define PACKAGE_BUGREPORT ""
    | #define MR_FULLARCH "x86_64-unknown-linux-gnu"
    | #define MR_VERSION "rotd-2008-08-16"
    | #define MR_MKFIFO "/usr/bin/mkfifo"
    | #define MR_HOSTNAMECMD "/bin/hostname -f"
    | #define MR_HAVE_SYSCONF 1
    | #define MR_HAVE_GETPAGESIZE 1
    | #define MR_HAVE_GETHOSTNAME 1
    | #define MR_HAVE_MPROTECT 1
    | #define MR_HAVE_MEMALIGN 1
    | #define MR_HAVE_POSIX_MEMALIGN 1
    | #define MR_HAVE_MEMMOVE 1
    | #define MR_HAVE_SIGACTION 1
    | #define MR_HAVE_SIGINTERRUPT 1
    | #define MR_HAVE_SETITIMER 1
    | #define MR_HAVE_SNPRINTF 1
    | /* end confdefs.h. */
    | /* Define _snprintf to an innocuous variant, in case <limits.h> declares _snprintf.
    | For example, HP-UX 11i <limits.h> declares gettimeofday. */
    | #define _snprintf innocuous__snprintf
    |
    | /* System header to define __stub macros and hopefully few prototypes,
    | which can conflict with char _snprintf (); below.
    | Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
    | <limits.h> exists even on freestanding compilers. */
    |
    | #ifdef __STDC__
    | # include <limits.h>
    | #else
    | # include <assert.h>
    | #endif
    |
    | #undef _snprintf
    |
    | /* Override any gcc2 internal prototype to avoid an error. */
    | #ifdef __cplusplus
    | extern "C"
    | {
    | #endif
    | /* We use char because int might match the return type of a gcc2
    | builtin and then its argument prototype would still apply. */
    | char _snprintf ();
    | /* The GNU C library defines this for functions which it implements
    | to always fail with ENOSYS. Some functions are actually named
    | something starting with __ and the normal name is an alias. */
    | #if defined (__stub__snprintf) || defined (__stub____snprintf)
    | choke me
    | #else
    | char (*f) () = _snprintf;
    | #endif
    | #ifdef __cplusplus
    | }
    | #endif
    |
    | int
    | main ()
    | {
    | return f != _snprintf;
    | ;
    | return 0;
    | }
    configure:5340: result: no
    configure:5253: checking for vsnprintf
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    conftest.c:48: warning: conflicting types for built-in function 'vsnprintf'
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for _vsnprintf
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    /tmp/ccCZIMib.o: In function `main':
    conftest.c:(.text+0x7): undefined reference to `_vsnprintf'
    /tmp/ccCZIMib.o:(.data+0x0): undefined reference to `_vsnprintf'
    collect2: ld returned 1 exit status
    configure:5316: $? = 1
    configure: failed program was:
    | /* confdefs.h. */
    |
    | #define PACKAGE_NAME ""
    | #define PACKAGE_TARNAME ""
    | #define PACKAGE_VERSION ""
    | #define PACKAGE_STRING ""
    | #define PACKAGE_BUGREPORT ""
    | #define MR_FULLARCH "x86_64-unknown-linux-gnu"
    | #define MR_VERSION "rotd-2008-08-16"
    | #define MR_MKFIFO "/usr/bin/mkfifo"
    | #define MR_HOSTNAMECMD "/bin/hostname -f"
    | #define MR_HAVE_SYSCONF 1
    | #define MR_HAVE_GETPAGESIZE 1
    | #define MR_HAVE_GETHOSTNAME 1
    | #define MR_HAVE_MPROTECT 1
    | #define MR_HAVE_MEMALIGN 1
    | #define MR_HAVE_POSIX_MEMALIGN 1
    | #define MR_HAVE_MEMMOVE 1
    | #define MR_HAVE_SIGACTION 1
    | #define MR_HAVE_SIGINTERRUPT 1
    | #define MR_HAVE_SETITIMER 1
    | #define MR_HAVE_SNPRINTF 1
    | #define MR_HAVE_VSNPRINTF 1
    | /* end confdefs.h. */
    | /* Define _vsnprintf to an innocuous variant, in case <limits.h> declares _vsnprintf.
    | For example, HP-UX 11i <limits.h> declares gettimeofday. */
    | #define _vsnprintf innocuous__vsnprintf
    |
    | /* System header to define __stub macros and hopefully few prototypes,
    | which can conflict with char _vsnprintf (); below.
    | Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
    | <limits.h> exists even on freestanding compilers. */
    |
    | #ifdef __STDC__
    | # include <limits.h>
    | #else
    | # include <assert.h>
    | #endif
    |
    | #undef _vsnprintf
    |
    | /* Override any gcc2 internal prototype to avoid an error. */
    | #ifdef __cplusplus
    | extern "C"
    | {
    | #endif
    | /* We use char because int might match the return type of a gcc2
    | builtin and then its argument prototype would still apply. */
    | char _vsnprintf ();
    | /* The GNU C library defines this for functions which it implements
    | to always fail with ENOSYS. Some functions are actually named
    | something starting with __ and the normal name is an alias. */
    | #if defined (__stub__vsnprintf) || defined (__stub____vsnprintf)
    | choke me
    | #else
    | char (*f) () = _vsnprintf;
    | #endif
    | #ifdef __cplusplus
    | }
    | #endif
    |
    | int
    | main ()
    | {
    | return f != _vsnprintf;
    | ;
    | return 0;
    | }
    configure:5340: result: no
    configure:5253: checking for strerror
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for open
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for close
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for dup
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for dup2
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for fdopen
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for fileno
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for fstat
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for stat
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for lstat
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for isatty
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for getpid
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for setpgid
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for fork
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    conftest.c:62: warning: conflicting types for built-in function 'fork'
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for execlp
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    conftest.c:63: warning: conflicting types for built-in function 'execlp'
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for wait
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for kill
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for grantpt
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for unlockpt
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for ptsname
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for tcgetattr
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for tcsetattr
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for ioctl
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for access
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for sleep
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for opendir
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for readdir
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for closedir
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for mkdir
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for symlink
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for readlink
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for gettimeofday
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for setenv
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for putenv
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5253: checking for _putenv
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    /tmp/ccs20b76.o: In function `main':
    conftest.c:(.text+0x7): undefined reference to `_putenv'
    /tmp/ccs20b76.o:(.data+0x0): undefined reference to `_putenv'
    collect2: ld returned 1 exit status
    configure:5316: $? = 1
    configure: failed program was:
    | /* confdefs.h. */
    |
    | #define PACKAGE_NAME ""
    | #define PACKAGE_TARNAME ""
    | #define PACKAGE_VERSION ""
    | #define PACKAGE_STRING ""
    | #define PACKAGE_BUGREPORT ""
    | #define MR_FULLARCH "x86_64-unknown-linux-gnu"
    | #define MR_VERSION "rotd-2008-08-16"
    | #define MR_MKFIFO "/usr/bin/mkfifo"
    | #define MR_HOSTNAMECMD "/bin/hostname -f"
    | #define MR_HAVE_SYSCONF 1
    | #define MR_HAVE_GETPAGESIZE 1
    | #define MR_HAVE_GETHOSTNAME 1
    | #define MR_HAVE_MPROTECT 1
    | #define MR_HAVE_MEMALIGN 1
    | #define MR_HAVE_POSIX_MEMALIGN 1
    | #define MR_HAVE_MEMMOVE 1
    | #define MR_HAVE_SIGACTION 1
    | #define MR_HAVE_SIGINTERRUPT 1
    | #define MR_HAVE_SETITIMER 1
    | #define MR_HAVE_SNPRINTF 1
    | #define MR_HAVE_VSNPRINTF 1
    | #define MR_HAVE_STRERROR 1
    | #define MR_HAVE_OPEN 1
    | #define MR_HAVE_CLOSE 1
    | #define MR_HAVE_DUP 1
    | #define MR_HAVE_DUP2 1
    | #define MR_HAVE_FDOPEN 1
    | #define MR_HAVE_FILENO 1
    | #define MR_HAVE_FSTAT 1
    | #define MR_HAVE_STAT 1
    | #define MR_HAVE_LSTAT 1
    | #define MR_HAVE_ISATTY 1
    | #define MR_HAVE_GETPID 1
    | #define MR_HAVE_SETPGID 1
    | #define MR_HAVE_FORK 1
    | #define MR_HAVE_EXECLP 1
    | #define MR_HAVE_WAIT 1
    | #define MR_HAVE_KILL 1
    | #define MR_HAVE_GRANTPT 1
    | #define MR_HAVE_UNLOCKPT 1
    | #define MR_HAVE_PTSNAME 1
    | #define MR_HAVE_TCGETATTR 1
    | #define MR_HAVE_TCSETATTR 1
    | #define MR_HAVE_IOCTL 1
    | #define MR_HAVE_ACCESS 1
    | #define MR_HAVE_SLEEP 1
    | #define MR_HAVE_OPENDIR 1
    | #define MR_HAVE_READDIR 1
    | #define MR_HAVE_CLOSEDIR 1
    | #define MR_HAVE_MKDIR 1
    | #define MR_HAVE_SYMLINK 1
    | #define MR_HAVE_READLINK 1
    | #define MR_HAVE_GETTIMEOFDAY 1
    | #define MR_HAVE_SETENV 1
    | #define MR_HAVE_PUTENV 1
    | /* end confdefs.h. */
    | /* Define _putenv to an innocuous variant, in case <limits.h> declares _putenv.
    | For example, HP-UX 11i <limits.h> declares gettimeofday. */
    | #define _putenv innocuous__putenv
    |
    | /* System header to define __stub macros and hopefully few prototypes,
    | which can conflict with char _putenv (); below.
    | Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
    | <limits.h> exists even on freestanding compilers. */
    |
    | #ifdef __STDC__
    | # include <limits.h>
    | #else
    | # include <assert.h>
    | #endif
    |
    | #undef _putenv
    |
    | /* Override any gcc2 internal prototype to avoid an error. */
    | #ifdef __cplusplus
    | extern "C"
    | {
    | #endif
    | /* We use char because int might match the return type of a gcc2
    | builtin and then its argument prototype would still apply. */
    | char _putenv ();
    | /* The GNU C library defines this for functions which it implements
    | to always fail with ENOSYS. Some functions are actually named
    | something starting with __ and the normal name is an alias. */
    | #if defined (__stub__putenv) || defined (__stub____putenv)
    | choke me
    | #else
    | char (*f) () = _putenv;
    | #endif
    | #ifdef __cplusplus
    | }
    | #endif
    |
    | int
    | main ()
    | {
    | return f != _putenv;
    | ;
    | return 0;
    | }
    configure:5340: result: no
    configure:5253: checking for posix_spawn
    configure:5310: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5316: $? = 0
    configure:5319: test -z || test ! -s conftest.err
    configure:5322: $? = 0
    configure:5325: test -s conftest
    configure:5328: $? = 0
    configure:5340: result: yes
    configure:5378: checking for ANSI C header files
    configure:5403: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5409: $? = 0
    configure:5412: test -z || test ! -s conftest.err
    configure:5415: $? = 0
    configure:5418: test -s conftest.o
    configure:5421: $? = 0
    configure:5510: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    conftest.c: In function 'main':
    conftest.c:77: warning: incompatible implicit declaration of built-in function 'exit'
    configure:5513: $? = 0
    configure:5515: ./conftest
    configure:5518: $? = 0
    configure:5533: result: yes
    configure:5557: checking for sys/types.h
    configure:5573: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5579: $? = 0
    configure:5582: test -z || test ! -s conftest.err
    configure:5585: $? = 0
    configure:5588: test -s conftest.o
    configure:5591: $? = 0
    configure:5602: result: yes
    configure:5557: checking for sys/stat.h
    configure:5573: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5579: $? = 0
    configure:5582: test -z || test ! -s conftest.err
    configure:5585: $? = 0
    configure:5588: test -s conftest.o
    configure:5591: $? = 0
    configure:5602: result: yes
    configure:5557: checking for stdlib.h
    configure:5573: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5579: $? = 0
    configure:5582: test -z || test ! -s conftest.err
    configure:5585: $? = 0
    configure:5588: test -s conftest.o
    configure:5591: $? = 0
    configure:5602: result: yes
    configure:5557: checking for string.h
    configure:5573: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5579: $? = 0
    configure:5582: test -z || test ! -s conftest.err
    configure:5585: $? = 0
    configure:5588: test -s conftest.o
    configure:5591: $? = 0
    configure:5602: result: yes
    configure:5557: checking for memory.h
    configure:5573: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5579: $? = 0
    configure:5582: test -z || test ! -s conftest.err
    configure:5585: $? = 0
    configure:5588: test -s conftest.o
    configure:5591: $? = 0
    configure:5602: result: yes
    configure:5557: checking for strings.h
    configure:5573: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5579: $? = 0
    configure:5582: test -z || test ! -s conftest.err
    configure:5585: $? = 0
    configure:5588: test -s conftest.o
    configure:5591: $? = 0
    configure:5602: result: yes
    configure:5557: checking for inttypes.h
    configure:5573: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5579: $? = 0
    configure:5582: test -z || test ! -s conftest.err
    configure:5585: $? = 0
    configure:5588: test -s conftest.o
    configure:5591: $? = 0
    configure:5602: result: yes
    configure:5557: checking for stdint.h
    configure:5573: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5579: $? = 0
    configure:5582: test -z || test ! -s conftest.err
    configure:5585: $? = 0
    configure:5588: test -s conftest.o
    configure:5591: $? = 0
    configure:5602: result: yes
    configure:5557: checking for unistd.h
    configure:5573: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5579: $? = 0
    configure:5582: test -z || test ! -s conftest.err
    configure:5585: $? = 0
    configure:5588: test -s conftest.o
    configure:5591: $? = 0
    configure:5602: result: yes
    configure:5625: checking for unistd.h
    configure:5630: result: yes
    configure:5634: checking sys/wait.h usability
    configure:5646: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5652: $? = 0
    configure:5655: test -z || test ! -s conftest.err
    configure:5658: $? = 0
    configure:5661: test -s conftest.o
    configure:5664: $? = 0
    configure:5674: result: yes
    configure:5678: checking sys/wait.h presence
    configure:5688: gcc -E -Iruntime -Iruntime/machdeps -Itrace conftest.c
    configure:5694: $? = 0
    configure:5714: result: yes
    configure:5749: checking for sys/wait.h
    configure:5756: result: yes
    configure:5634: checking sys/siginfo.h usability
    configure:5646: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    conftest.c:106:25: error: sys/siginfo.h: No such file or directory
    configure:5652: $? = 1
    configure: failed program was:
    | /* confdefs.h. */
    |
    | #define PACKAGE_NAME ""
    | #define PACKAGE_TARNAME ""
    | #define PACKAGE_VERSION ""
    | #define PACKAGE_STRING ""
    | #define PACKAGE_BUGREPORT ""
    | #define MR_FULLARCH "x86_64-unknown-linux-gnu"
    | #define MR_VERSION "rotd-2008-08-16"
    | #define MR_MKFIFO "/usr/bin/mkfifo"
    | #define MR_HOSTNAMECMD "/bin/hostname -f"
    | #define MR_HAVE_SYSCONF 1
    | #define MR_HAVE_GETPAGESIZE 1
    | #define MR_HAVE_GETHOSTNAME 1
    | #define MR_HAVE_MPROTECT 1
    | #define MR_HAVE_MEMALIGN 1
    | #define MR_HAVE_POSIX_MEMALIGN 1
    | #define MR_HAVE_MEMMOVE 1
    | #define MR_HAVE_SIGACTION 1
    | #define MR_HAVE_SIGINTERRUPT 1
    | #define MR_HAVE_SETITIMER 1
    | #define MR_HAVE_SNPRINTF 1
    | #define MR_HAVE_VSNPRINTF 1
    | #define MR_HAVE_STRERROR 1
    | #define MR_HAVE_OPEN 1
    | #define MR_HAVE_CLOSE 1
    | #define MR_HAVE_DUP 1
    | #define MR_HAVE_DUP2 1
    | #define MR_HAVE_FDOPEN 1
    | #define MR_HAVE_FILENO 1
    | #define MR_HAVE_FSTAT 1
    | #define MR_HAVE_STAT 1
    | #define MR_HAVE_LSTAT 1
    | #define MR_HAVE_ISATTY 1
    | #define MR_HAVE_GETPID 1
    | #define MR_HAVE_SETPGID 1
    | #define MR_HAVE_FORK 1
    | #define MR_HAVE_EXECLP 1
    | #define MR_HAVE_WAIT 1
    | #define MR_HAVE_KILL 1
    | #define MR_HAVE_GRANTPT 1
    | #define MR_HAVE_UNLOCKPT 1
    | #define MR_HAVE_PTSNAME 1
    | #define MR_HAVE_TCGETATTR 1
    | #define MR_HAVE_TCSETATTR 1
    | #define MR_HAVE_IOCTL 1
    | #define MR_HAVE_ACCESS 1
    | #define MR_HAVE_SLEEP 1
    | #define MR_HAVE_OPENDIR 1
    | #define MR_HAVE_READDIR 1
    | #define MR_HAVE_CLOSEDIR 1
    | #define MR_HAVE_MKDIR 1
    | #define MR_HAVE_SYMLINK 1
    | #define MR_HAVE_READLINK 1
    | #define MR_HAVE_GETTIMEOFDAY 1
    | #define MR_HAVE_SETENV 1
    | #define MR_HAVE_PUTENV 1
    | #define MR_HAVE_POSIX_SPAWN 1
    | #define STDC_HEADERS 1
    | #define HAVE_SYS_TYPES_H 1
    | #define HAVE_SYS_STAT_H 1
    | #define HAVE_STDLIB_H 1
    | #define HAVE_STRING_H 1
    | #define HAVE_MEMORY_H 1
    | #define HAVE_STRINGS_H 1
    | #define HAVE_INTTYPES_H 1
    | #define HAVE_STDINT_H 1
    | #define HAVE_UNISTD_H 1
    | #define MR_HAVE_UNISTD_H 1
    | #define MR_HAVE_SYS_WAIT_H 1
    | /* end confdefs.h. */
    | #include <stdio.h>
    | #if HAVE_SYS_TYPES_H
    | # include <sys/types.h>
    | #endif
    | #if HAVE_SYS_STAT_H
    | # include <sys/stat.h>
    | #endif
    | #if STDC_HEADERS
    | # include <stdlib.h>
    | # include <stddef.h>
    | #else
    | # if HAVE_STDLIB_H
    | # include <stdlib.h>
    | # endif
    | #endif
    | #if HAVE_STRING_H
    | # if !STDC_HEADERS && HAVE_MEMORY_H
    | # include <memory.h>
    | # endif
    | # include <string.h>
    | #endif
    | #if HAVE_STRINGS_H
    | # include <strings.h>
    | #endif
    | #if HAVE_INTTYPES_H
    | # include <inttypes.h>
    | #else
    | # if HAVE_STDINT_H
    | # include <stdint.h>
    | # endif
    | #endif
    | #if HAVE_UNISTD_H
    | # include <unistd.h>
    | #endif
    | #include <sys/siginfo.h>
    configure:5674: result: no
    configure:5678: checking sys/siginfo.h presence
    configure:5688: gcc -E -Iruntime -Iruntime/machdeps -Itrace conftest.c
    conftest.c:72:25: error: sys/siginfo.h: No such file or directory
    configure:5694: $? = 1
    configure: failed program was:
    | /* confdefs.h. */
    |
    | #define PACKAGE_NAME ""
    | #define PACKAGE_TARNAME ""
    | #define PACKAGE_VERSION ""
    | #define PACKAGE_STRING ""
    | #define PACKAGE_BUGREPORT ""
    | #define MR_FULLARCH "x86_64-unknown-linux-gnu"
    | #define MR_VERSION "rotd-2008-08-16"
    | #define MR_MKFIFO "/usr/bin/mkfifo"
    | #define MR_HOSTNAMECMD "/bin/hostname -f"
    | #define MR_HAVE_SYSCONF 1
    | #define MR_HAVE_GETPAGESIZE 1
    | #define MR_HAVE_GETHOSTNAME 1
    | #define MR_HAVE_MPROTECT 1
    | #define MR_HAVE_MEMALIGN 1
    | #define MR_HAVE_POSIX_MEMALIGN 1
    | #define MR_HAVE_MEMMOVE 1
    | #define MR_HAVE_SIGACTION 1
    | #define MR_HAVE_SIGINTERRUPT 1
    | #define MR_HAVE_SETITIMER 1
    | #define MR_HAVE_SNPRINTF 1
    | #define MR_HAVE_VSNPRINTF 1
    | #define MR_HAVE_STRERROR 1
    | #define MR_HAVE_OPEN 1
    | #define MR_HAVE_CLOSE 1
    | #define MR_HAVE_DUP 1
    | #define MR_HAVE_DUP2 1
    | #define MR_HAVE_FDOPEN 1
    | #define MR_HAVE_FILENO 1
    | #define MR_HAVE_FSTAT 1
    | #define MR_HAVE_STAT 1
    | #define MR_HAVE_LSTAT 1
    | #define MR_HAVE_ISATTY 1
    | #define MR_HAVE_GETPID 1
    | #define MR_HAVE_SETPGID 1
    | #define MR_HAVE_FORK 1
    | #define MR_HAVE_EXECLP 1
    | #define MR_HAVE_WAIT 1
    | #define MR_HAVE_KILL 1
    | #define MR_HAVE_GRANTPT 1
    | #define MR_HAVE_UNLOCKPT 1
    | #define MR_HAVE_PTSNAME 1
    | #define MR_HAVE_TCGETATTR 1
    | #define MR_HAVE_TCSETATTR 1
    | #define MR_HAVE_IOCTL 1
    | #define MR_HAVE_ACCESS 1
    | #define MR_HAVE_SLEEP 1
    | #define MR_HAVE_OPENDIR 1
    | #define MR_HAVE_READDIR 1
    | #define MR_HAVE_CLOSEDIR 1
    | #define MR_HAVE_MKDIR 1
    | #define MR_HAVE_SYMLINK 1
    | #define MR_HAVE_READLINK 1
    | #define MR_HAVE_GETTIMEOFDAY 1
    | #define MR_HAVE_SETENV 1
    | #define MR_HAVE_PUTENV 1
    | #define MR_HAVE_POSIX_SPAWN 1
    | #define STDC_HEADERS 1
    | #define HAVE_SYS_TYPES_H 1
    | #define HAVE_SYS_STAT_H 1
    | #define HAVE_STDLIB_H 1
    | #define HAVE_STRING_H 1
    | #define HAVE_MEMORY_H 1
    | #define HAVE_STRINGS_H 1
    | #define HAVE_INTTYPES_H 1
    | #define HAVE_STDINT_H 1
    | #define HAVE_UNISTD_H 1
    | #define MR_HAVE_UNISTD_H 1
    | #define MR_HAVE_SYS_WAIT_H 1
    | /* end confdefs.h. */
    | #include <sys/siginfo.h>
    configure:5714: result: no
    configure:5749: checking for sys/siginfo.h
    configure:5756: result: no
    configure:5634: checking sys/signal.h usability
    configure:5646: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5652: $? = 0
    configure:5655: test -z || test ! -s conftest.err
    configure:5658: $? = 0
    configure:5661: test -s conftest.o
    configure:5664: $? = 0
    configure:5674: result: yes
    configure:5678: checking sys/signal.h presence
    configure:5688: gcc -E -Iruntime -Iruntime/machdeps -Itrace conftest.c
    configure:5694: $? = 0
    configure:5714: result: yes
    configure:5749: checking for sys/signal.h
    configure:5756: result: yes
    configure:5634: checking ucontext.h usability
    configure:5646: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5652: $? = 0
    configure:5655: test -z || test ! -s conftest.err
    configure:5658: $? = 0
    configure:5661: test -s conftest.o
    configure:5664: $? = 0
    configure:5674: result: yes
    configure:5678: checking ucontext.h presence
    configure:5688: gcc -E -Iruntime -Iruntime/machdeps -Itrace conftest.c
    configure:5694: $? = 0
    configure:5714: result: yes
    configure:5749: checking for ucontext.h
    configure:5756: result: yes
    configure:5634: checking asm/sigcontext.h usability
    configure:5646: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5652: $? = 0
    configure:5655: test -z || test ! -s conftest.err
    configure:5658: $? = 0
    configure:5661: test -s conftest.o
    configure:5664: $? = 0
    configure:5674: result: yes
    configure:5678: checking asm/sigcontext.h presence
    configure:5688: gcc -E -Iruntime -Iruntime/machdeps -Itrace conftest.c
    configure:5694: $? = 0
    configure:5714: result: yes
    configure:5749: checking for asm/sigcontext.h
    configure:5756: result: yes
    configure:5634: checking sys/param.h usability
    configure:5646: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5652: $? = 0
    configure:5655: test -z || test ! -s conftest.err
    configure:5658: $? = 0
    configure:5661: test -s conftest.o
    configure:5664: $? = 0
    configure:5674: result: yes
    configure:5678: checking sys/param.h presence
    configure:5688: gcc -E -Iruntime -Iruntime/machdeps -Itrace conftest.c
    configure:5694: $? = 0
    configure:5714: result: yes
    configure:5749: checking for sys/param.h
    configure:5756: result: yes
    configure:5634: checking sys/time.h usability
    configure:5646: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5652: $? = 0
    configure:5655: test -z || test ! -s conftest.err
    configure:5658: $? = 0
    configure:5661: test -s conftest.o
    configure:5664: $? = 0
    configure:5674: result: yes
    configure:5678: checking sys/time.h presence
    configure:5688: gcc -E -Iruntime -Iruntime/machdeps -Itrace conftest.c
    configure:5694: $? = 0
    configure:5714: result: yes
    configure:5749: checking for sys/time.h
    configure:5756: result: yes
    configure:5634: checking sys/times.h usability
    configure:5646: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5652: $? = 0
    configure:5655: test -z || test ! -s conftest.err
    configure:5658: $? = 0
    configure:5661: test -s conftest.o
    configure:5664: $? = 0
    configure:5674: result: yes
    configure:5678: checking sys/times.h presence
    configure:5688: gcc -E -Iruntime -Iruntime/machdeps -Itrace conftest.c
    configure:5694: $? = 0
    configure:5714: result: yes
    configure:5749: checking for sys/times.h
    configure:5756: result: yes
    configure:5625: checking for sys/types.h
    configure:5630: result: yes
    configure:5625: checking for sys/stat.h
    configure:5630: result: yes
    configure:5634: checking fcntl.h usability
    configure:5646: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5652: $? = 0
    configure:5655: test -z || test ! -s conftest.err
    configure:5658: $? = 0
    configure:5661: test -s conftest.o
    configure:5664: $? = 0
    configure:5674: result: yes
    configure:5678: checking fcntl.h presence
    configure:5688: gcc -E -Iruntime -Iruntime/machdeps -Itrace conftest.c
    configure:5694: $? = 0
    configure:5714: result: yes
    configure:5749: checking for fcntl.h
    configure:5756: result: yes
    configure:5634: checking termios.h usability
    configure:5646: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5652: $? = 0
    configure:5655: test -z || test ! -s conftest.err
    configure:5658: $? = 0
    configure:5661: test -s conftest.o
    configure:5664: $? = 0
    configure:5674: result: yes
    configure:5678: checking termios.h presence
    configure:5688: gcc -E -Iruntime -Iruntime/machdeps -Itrace conftest.c
    configure:5694: $? = 0
    configure:5714: result: yes
    configure:5749: checking for termios.h
    configure:5756: result: yes
    configure:5634: checking sys/ioctl.h usability
    configure:5646: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5652: $? = 0
    configure:5655: test -z || test ! -s conftest.err
    configure:5658: $? = 0
    configure:5661: test -s conftest.o
    configure:5664: $? = 0
    configure:5674: result: yes
    configure:5678: checking sys/ioctl.h presence
    configure:5688: gcc -E -Iruntime -Iruntime/machdeps -Itrace conftest.c
    configure:5694: $? = 0
    configure:5714: result: yes
    configure:5749: checking for sys/ioctl.h
    configure:5756: result: yes
    configure:5634: checking sys/stropts.h usability
    configure:5646: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5652: $? = 0
    configure:5655: test -z || test ! -s conftest.err
    configure:5658: $? = 0
    configure:5661: test -s conftest.o
    configure:5664: $? = 0
    configure:5674: result: yes
    configure:5678: checking sys/stropts.h presence
    configure:5688: gcc -E -Iruntime -Iruntime/machdeps -Itrace conftest.c
    configure:5694: $? = 0
    configure:5714: result: yes
    configure:5749: checking for sys/stropts.h
    configure:5756: result: yes
    configure:5634: checking windows.h usability
    configure:5646: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    conftest.c:118:21: error: windows.h: No such file or directory
    configure:5652: $? = 1
    configure: failed program was:
    | /* confdefs.h. */
    |
    | #define PACKAGE_NAME ""
    | #define PACKAGE_TARNAME ""
    | #define PACKAGE_VERSION ""
    | #define PACKAGE_STRING ""
    | #define PACKAGE_BUGREPORT ""
    | #define MR_FULLARCH "x86_64-unknown-linux-gnu"
    | #define MR_VERSION "rotd-2008-08-16"
    | #define MR_MKFIFO "/usr/bin/mkfifo"
    | #define MR_HOSTNAMECMD "/bin/hostname -f"
    | #define MR_HAVE_SYSCONF 1
    | #define MR_HAVE_GETPAGESIZE 1
    | #define MR_HAVE_GETHOSTNAME 1
    | #define MR_HAVE_MPROTECT 1
    | #define MR_HAVE_MEMALIGN 1
    | #define MR_HAVE_POSIX_MEMALIGN 1
    | #define MR_HAVE_MEMMOVE 1
    | #define MR_HAVE_SIGACTION 1
    | #define MR_HAVE_SIGINTERRUPT 1
    | #define MR_HAVE_SETITIMER 1
    | #define MR_HAVE_SNPRINTF 1
    | #define MR_HAVE_VSNPRINTF 1
    | #define MR_HAVE_STRERROR 1
    | #define MR_HAVE_OPEN 1
    | #define MR_HAVE_CLOSE 1
    | #define MR_HAVE_DUP 1
    | #define MR_HAVE_DUP2 1
    | #define MR_HAVE_FDOPEN 1
    | #define MR_HAVE_FILENO 1
    | #define MR_HAVE_FSTAT 1
    | #define MR_HAVE_STAT 1
    | #define MR_HAVE_LSTAT 1
    | #define MR_HAVE_ISATTY 1
    | #define MR_HAVE_GETPID 1
    | #define MR_HAVE_SETPGID 1
    | #define MR_HAVE_FORK 1
    | #define MR_HAVE_EXECLP 1
    | #define MR_HAVE_WAIT 1
    | #define MR_HAVE_KILL 1
    | #define MR_HAVE_GRANTPT 1
    | #define MR_HAVE_UNLOCKPT 1
    | #define MR_HAVE_PTSNAME 1
    | #define MR_HAVE_TCGETATTR 1
    | #define MR_HAVE_TCSETATTR 1
    | #define MR_HAVE_IOCTL 1
    | #define MR_HAVE_ACCESS 1
    | #define MR_HAVE_SLEEP 1
    | #define MR_HAVE_OPENDIR 1
    | #define MR_HAVE_READDIR 1
    | #define MR_HAVE_CLOSEDIR 1
    | #define MR_HAVE_MKDIR 1
    | #define MR_HAVE_SYMLINK 1
    | #define MR_HAVE_READLINK 1
    | #define MR_HAVE_GETTIMEOFDAY 1
    | #define MR_HAVE_SETENV 1
    | #define MR_HAVE_PUTENV 1
    | #define MR_HAVE_POSIX_SPAWN 1
    | #define STDC_HEADERS 1
    | #define HAVE_SYS_TYPES_H 1
    | #define HAVE_SYS_STAT_H 1
    | #define HAVE_STDLIB_H 1
    | #define HAVE_STRING_H 1
    | #define HAVE_MEMORY_H 1
    | #define HAVE_STRINGS_H 1
    | #define HAVE_INTTYPES_H 1
    | #define HAVE_STDINT_H 1
    | #define HAVE_UNISTD_H 1
    | #define MR_HAVE_UNISTD_H 1
    | #define MR_HAVE_SYS_WAIT_H 1
    | #define MR_HAVE_SYS_SIGNAL_H 1
    | #define MR_HAVE_UCONTEXT_H 1
    | #define MR_HAVE_ASM_SIGCONTEXT_H 1
    | #define MR_HAVE_SYS_PARAM_H 1
    | #define MR_HAVE_SYS_TIME_H 1
    | #define MR_HAVE_SYS_TIMES_H 1
    | #define MR_HAVE_SYS_TYPES_H 1
    | #define MR_HAVE_SYS_STAT_H 1
    | #define MR_HAVE_FCNTL_H 1
    | #define MR_HAVE_TERMIOS_H 1
    | #define MR_HAVE_SYS_IOCTL_H 1
    | #define MR_HAVE_SYS_STROPTS_H 1
    | /* end confdefs.h. */
    | #include <stdio.h>
    | #if HAVE_SYS_TYPES_H
    | # include <sys/types.h>
    | #endif
    | #if HAVE_SYS_STAT_H
    | # include <sys/stat.h>
    | #endif
    | #if STDC_HEADERS
    | # include <stdlib.h>
    | # include <stddef.h>
    | #else
    | # if HAVE_STDLIB_H
    | # include <stdlib.h>
    | # endif
    | #endif
    | #if HAVE_STRING_H
    | # if !STDC_HEADERS && HAVE_MEMORY_H
    | # include <memory.h>
    | # endif
    | # include <string.h>
    | #endif
    | #if HAVE_STRINGS_H
    | # include <strings.h>
    | #endif
    | #if HAVE_INTTYPES_H
    | # include <inttypes.h>
    | #else
    | # if HAVE_STDINT_H
    | # include <stdint.h>
    | # endif
    | #endif
    | #if HAVE_UNISTD_H
    | # include <unistd.h>
    | #endif
    | #include <windows.h>
    configure:5674: result: no
    configure:5678: checking windows.h presence
    configure:5688: gcc -E -Iruntime -Iruntime/machdeps -Itrace conftest.c
    conftest.c:84:21: error: windows.h: No such file or directory
    configure:5694: $? = 1
    configure: failed program was:
    | /* confdefs.h. */
    |
    | #define PACKAGE_NAME ""
    | #define PACKAGE_TARNAME ""
    | #define PACKAGE_VERSION ""
    | #define PACKAGE_STRING ""
    | #define PACKAGE_BUGREPORT ""
    | #define MR_FULLARCH "x86_64-unknown-linux-gnu"
    | #define MR_VERSION "rotd-2008-08-16"
    | #define MR_MKFIFO "/usr/bin/mkfifo"
    | #define MR_HOSTNAMECMD "/bin/hostname -f"
    | #define MR_HAVE_SYSCONF 1
    | #define MR_HAVE_GETPAGESIZE 1
    | #define MR_HAVE_GETHOSTNAME 1
    | #define MR_HAVE_MPROTECT 1
    | #define MR_HAVE_MEMALIGN 1
    | #define MR_HAVE_POSIX_MEMALIGN 1
    | #define MR_HAVE_MEMMOVE 1
    | #define MR_HAVE_SIGACTION 1
    | #define MR_HAVE_SIGINTERRUPT 1
    | #define MR_HAVE_SETITIMER 1
    | #define MR_HAVE_SNPRINTF 1
    | #define MR_HAVE_VSNPRINTF 1
    | #define MR_HAVE_STRERROR 1
    | #define MR_HAVE_OPEN 1
    | #define MR_HAVE_CLOSE 1
    | #define MR_HAVE_DUP 1
    | #define MR_HAVE_DUP2 1
    | #define MR_HAVE_FDOPEN 1
    | #define MR_HAVE_FILENO 1
    | #define MR_HAVE_FSTAT 1
    | #define MR_HAVE_STAT 1
    | #define MR_HAVE_LSTAT 1
    | #define MR_HAVE_ISATTY 1
    | #define MR_HAVE_GETPID 1
    | #define MR_HAVE_SETPGID 1
    | #define MR_HAVE_FORK 1
    | #define MR_HAVE_EXECLP 1
    | #define MR_HAVE_WAIT 1
    | #define MR_HAVE_KILL 1
    | #define MR_HAVE_GRANTPT 1
    | #define MR_HAVE_UNLOCKPT 1
    | #define MR_HAVE_PTSNAME 1
    | #define MR_HAVE_TCGETATTR 1
    | #define MR_HAVE_TCSETATTR 1
    | #define MR_HAVE_IOCTL 1
    | #define MR_HAVE_ACCESS 1
    | #define MR_HAVE_SLEEP 1
    | #define MR_HAVE_OPENDIR 1
    | #define MR_HAVE_READDIR 1
    | #define MR_HAVE_CLOSEDIR 1
    | #define MR_HAVE_MKDIR 1
    | #define MR_HAVE_SYMLINK 1
    | #define MR_HAVE_READLINK 1
    | #define MR_HAVE_GETTIMEOFDAY 1
    | #define MR_HAVE_SETENV 1
    | #define MR_HAVE_PUTENV 1
    | #define MR_HAVE_POSIX_SPAWN 1
    | #define STDC_HEADERS 1
    | #define HAVE_SYS_TYPES_H 1
    | #define HAVE_SYS_STAT_H 1
    | #define HAVE_STDLIB_H 1
    | #define HAVE_STRING_H 1
    | #define HAVE_MEMORY_H 1
    | #define HAVE_STRINGS_H 1
    | #define HAVE_INTTYPES_H 1
    | #define HAVE_STDINT_H 1
    | #define HAVE_UNISTD_H 1
    | #define MR_HAVE_UNISTD_H 1
    | #define MR_HAVE_SYS_WAIT_H 1
    | #define MR_HAVE_SYS_SIGNAL_H 1
    | #define MR_HAVE_UCONTEXT_H 1
    | #define MR_HAVE_ASM_SIGCONTEXT_H 1
    | #define MR_HAVE_SYS_PARAM_H 1
    | #define MR_HAVE_SYS_TIME_H 1
    | #define MR_HAVE_SYS_TIMES_H 1
    | #define MR_HAVE_SYS_TYPES_H 1
    | #define MR_HAVE_SYS_STAT_H 1
    | #define MR_HAVE_FCNTL_H 1
    | #define MR_HAVE_TERMIOS_H 1
    | #define MR_HAVE_SYS_IOCTL_H 1
    | #define MR_HAVE_SYS_STROPTS_H 1
    | /* end confdefs.h. */
    | #include <windows.h>
    configure:5714: result: no
    configure:5749: checking for windows.h
    configure:5756: result: no
    configure:5634: checking dirent.h usability
    configure:5646: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5652: $? = 0
    configure:5655: test -z || test ! -s conftest.err
    configure:5658: $? = 0
    configure:5661: test -s conftest.o
    configure:5664: $? = 0
    configure:5674: result: yes
    configure:5678: checking dirent.h presence
    configure:5688: gcc -E -Iruntime -Iruntime/machdeps -Itrace conftest.c
    configure:5694: $? = 0
    configure:5714: result: yes
    configure:5749: checking for dirent.h
    configure:5756: result: yes
    configure:5634: checking getopt.h usability
    configure:5646: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5652: $? = 0
    configure:5655: test -z || test ! -s conftest.err
    configure:5658: $? = 0
    configure:5661: test -s conftest.o
    configure:5664: $? = 0
    configure:5674: result: yes
    configure:5678: checking getopt.h presence
    configure:5688: gcc -E -Iruntime -Iruntime/machdeps -Itrace conftest.c
    configure:5694: $? = 0
    configure:5714: result: yes
    configure:5749: checking for getopt.h
    configure:5756: result: yes
    configure:5634: checking malloc.h usability
    configure:5646: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5652: $? = 0
    configure:5655: test -z || test ! -s conftest.err
    configure:5658: $? = 0
    configure:5661: test -s conftest.o
    configure:5664: $? = 0
    configure:5674: result: yes
    configure:5678: checking malloc.h presence
    configure:5688: gcc -E -Iruntime -Iruntime/machdeps -Itrace conftest.c
    configure:5694: $? = 0
    configure:5714: result: yes
    configure:5749: checking for malloc.h
    configure:5756: result: yes
    configure:5634: checking semaphore.h usability
    configure:5646: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5652: $? = 0
    configure:5655: test -z || test ! -s conftest.err
    configure:5658: $? = 0
    configure:5661: test -s conftest.o
    configure:5664: $? = 0
    configure:5674: result: yes
    configure:5678: checking semaphore.h presence
    configure:5688: gcc -E -Iruntime -Iruntime/machdeps -Itrace conftest.c
    configure:5694: $? = 0
    configure:5714: result: yes
    configure:5749: checking for semaphore.h
    configure:5756: result: yes
    configure:5634: checking pthread.h usability
    configure:5646: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5652: $? = 0
    configure:5655: test -z || test ! -s conftest.err
    configure:5658: $? = 0
    configure:5661: test -s conftest.o
    configure:5664: $? = 0
    configure:5674: result: yes
    configure:5678: checking pthread.h presence
    configure:5688: gcc -E -Iruntime -Iruntime/machdeps -Itrace conftest.c
    configure:5694: $? = 0
    configure:5714: result: yes
    configure:5749: checking for pthread.h
    configure:5756: result: yes
    configure:5634: checking time.h usability
    configure:5646: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5652: $? = 0
    configure:5655: test -z || test ! -s conftest.err
    configure:5658: $? = 0
    configure:5661: test -s conftest.o
    configure:5664: $? = 0
    configure:5674: result: yes
    configure:5678: checking time.h presence
    configure:5688: gcc -E -Iruntime -Iruntime/machdeps -Itrace conftest.c
    configure:5694: $? = 0
    configure:5714: result: yes
    configure:5749: checking for time.h
    configure:5756: result: yes
    configure:5634: checking spawn.h usability
    configure:5646: gcc -c -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5652: $? = 0
    configure:5655: test -z || test ! -s conftest.err
    configure:5658: $? = 0
    configure:5661: test -s conftest.o
    configure:5664: $? = 0
    configure:5674: result: yes
    configure:5678: checking spawn.h presence
    configure:5688: gcc -E -Iruntime -Iruntime/machdeps -Itrace conftest.c
    configure:5694: $? = 0
    configure:5714: result: yes
    configure:5749: checking for spawn.h
    configure:5756: result: yes
    configure:5944: checking for `sigaction' field name
    configure:5993: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    configure:5996: $? = 0
    configure:5998: ./conftest
    configure:6001: $? = 0
    configure:6016: result: sa_sigaction
    configure:6035: checking for working `sigcontext_struct' in second arg
    configure:6091: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    In file included from /usr/include/asm/sigcontext.h:5,
                     from conftest.c:103:
    /usr/include/asm-x86_64/sigcontext.h:9: error: redefinition of 'struct _fpstate'
    /usr/include/asm-x86_64/sigcontext.h:23: error: redefinition of 'struct sigcontext'
    conftest.c: In function 'main':
    conftest.c:120: warning: incompatible implicit declaration of built-in function 'exit'
    conftest.c: In function 'handler':
    conftest.c:125: warning: cast to pointer from integer of different size
    conftest.c:127: warning: incompatible implicit declaration of built-in function 'exit'
    conftest.c:129: warning: incompatible implicit declaration of built-in function 'exit'
    configure:6094: $? = 1
    configure: program exited with status 1
    configure: failed program was:
    | /* confdefs.h. */
    |
    | #define PACKAGE_NAME ""
    | #define PACKAGE_TARNAME ""
    | #define PACKAGE_VERSION ""
    | #define PACKAGE_STRING ""
    | #define PACKAGE_BUGREPORT ""
    | #define MR_FULLARCH "x86_64-unknown-linux-gnu"
    | #define MR_VERSION "rotd-2008-08-16"
    | #define MR_MKFIFO "/usr/bin/mkfifo"
    | #define MR_HOSTNAMECMD "/bin/hostname -f"
    | #define MR_HAVE_SYSCONF 1
    | #define MR_HAVE_GETPAGESIZE 1
    | #define MR_HAVE_GETHOSTNAME 1
    | #define MR_HAVE_MPROTECT 1
    | #define MR_HAVE_MEMALIGN 1
    | #define MR_HAVE_POSIX_MEMALIGN 1
    | #define MR_HAVE_MEMMOVE 1
    | #define MR_HAVE_SIGACTION 1
    | #define MR_HAVE_SIGINTERRUPT 1
    | #define MR_HAVE_SETITIMER 1
    | #define MR_HAVE_SNPRINTF 1
    | #define MR_HAVE_VSNPRINTF 1
    | #define MR_HAVE_STRERROR 1
    | #define MR_HAVE_OPEN 1
    | #define MR_HAVE_CLOSE 1
    | #define MR_HAVE_DUP 1
    | #define MR_HAVE_DUP2 1
    | #define MR_HAVE_FDOPEN 1
    | #define MR_HAVE_FILENO 1
    | #define MR_HAVE_FSTAT 1
    | #define MR_HAVE_STAT 1
    | #define MR_HAVE_LSTAT 1
    | #define MR_HAVE_ISATTY 1
    | #define MR_HAVE_GETPID 1
    | #define MR_HAVE_SETPGID 1
    | #define MR_HAVE_FORK 1
    | #define MR_HAVE_EXECLP 1
    | #define MR_HAVE_WAIT 1
    | #define MR_HAVE_KILL 1
    | #define MR_HAVE_GRANTPT 1
    | #define MR_HAVE_UNLOCKPT 1
    | #define MR_HAVE_PTSNAME 1
    | #define MR_HAVE_TCGETATTR 1
    | #define MR_HAVE_TCSETATTR 1
    | #define MR_HAVE_IOCTL 1
    | #define MR_HAVE_ACCESS 1
    | #define MR_HAVE_SLEEP 1
    | #define MR_HAVE_OPENDIR 1
    | #define MR_HAVE_READDIR 1
    | #define MR_HAVE_CLOSEDIR 1
    | #define MR_HAVE_MKDIR 1
    | #define MR_HAVE_SYMLINK 1
    | #define MR_HAVE_READLINK 1
    | #define MR_HAVE_GETTIMEOFDAY 1
    | #define MR_HAVE_SETENV 1
    | #define MR_HAVE_PUTENV 1
    | #define MR_HAVE_POSIX_SPAWN 1
    | #define STDC_HEADERS 1
    | #define HAVE_SYS_TYPES_H 1
    | #define HAVE_SYS_STAT_H 1
    | #define HAVE_STDLIB_H 1
    | #define HAVE_STRING_H 1
    | #define HAVE_MEMORY_H 1
    | #define HAVE_STRINGS_H 1
    | #define HAVE_INTTYPES_H 1
    | #define HAVE_STDINT_H 1
    | #define HAVE_UNISTD_H 1
    | #define MR_HAVE_UNISTD_H 1
    | #define MR_HAVE_SYS_WAIT_H 1
    | #define MR_HAVE_SYS_SIGNAL_H 1
    | #define MR_HAVE_UCONTEXT_H 1
    | #define MR_HAVE_ASM_SIGCONTEXT_H 1
    | #define MR_HAVE_SYS_PARAM_H 1
    | #define MR_HAVE_SYS_TIME_H 1
    | #define MR_HAVE_SYS_TIMES_H 1
    | #define MR_HAVE_SYS_TYPES_H 1
    | #define MR_HAVE_SYS_STAT_H 1
    | #define MR_HAVE_FCNTL_H 1
    | #define MR_HAVE_TERMIOS_H 1
    | #define MR_HAVE_SYS_IOCTL_H 1
    | #define MR_HAVE_SYS_STROPTS_H 1
    | #define MR_HAVE_DIRENT_H 1
    | #define MR_HAVE_GETOPT_H 1
    | #define MR_HAVE_MALLOC_H 1
    | #define MR_HAVE_SEMAPHORE_H 1
    | #define MR_HAVE_PTHREAD_H 1
    | #define MR_HAVE_TIME_H 1
    | #define MR_HAVE_SPAWN_H 1
    | #define MR_SIGACTION_FIELD sa_sigaction
    | #define MR_HAVE_SIGINFO 1
    | /* end confdefs.h. */
    |
    | /* see runtime/mercury_signal.h for documentation of this code */
    |
    | #define sigcontext_struct sigcontext
    |
    | #define __KERNEL__
    | #include <signal.h>
    | #undef __KERNEL__
    |
    | #ifdef MR_HAVE_ASM_SIGCONTEXT_H
    | #include <asm/sigcontext.h>
    | #endif
    |
    | #include "mercury_faultaddr.h"
    |
    | #include <stdio.h>
    |
    | extern void handler(int signum, struct sigcontext_struct info);
    |
    | #define FAULT_ADDRESS ((int *)112)
    |
    | int main() {
    | signal(SIGSEGV, (void (*)(int))handler);
    |
    | /* provoke a SIGSEGV */
    | (*FAULT_ADDRESS)++;
    |
    | exit(1);
    | }
    |
    | void handler(int signum, struct sigcontext_struct context) {
    | int *addr;
    | addr = (int *) MR_GET_FAULT_ADDR(context);
    | if (signum == SIGSEGV && addr == FAULT_ADDRESS) {
    | exit(0);
    | } else {
    | exit(1);
    | }
    | }
    configure:6114: result: no
    configure:6120: checking for working `sigcontext_struct' in third arg
    configure:6178: gcc -o conftest -O -Iruntime -Iruntime/machdeps -Itrace conftest.c >&5
    In file included from /usr/include/asm/sigcontext.h:5,
                     from conftest.c:103:
    /usr/include/asm-x86_64/sigcontext.h:9: error: redefinition of 'struct _fpstate'
    /usr/include/asm-x86_64/sigcontext.h:23: error: redefinition of 'struct sigcontext'
    conftest.c: In function 'main':
    conftest.c:121: warning: incompatible implicit declaration of built-in function 'exit'
    conftest.c: In function 'handler':
    conftest.c:126: warning: cast to pointer from integer of different size
    conftest.c:128: warning: incompatible implicit declaration of built-in function 'exit'
    conftest.c:130:
    (0000132)
    pbone   
    2008-08-19 10:36   
    I think that the options

    $ ./configure --with-llds-base-grade=reg --with-default-grade=hlc.gc

    don't enable the garbage collector for the complier's grade, and hence the compiler now runs out of memory. The original problem is probably still the 64bit issue. Try with:

    $ ./configure --with-llds-base-grade=reg.gc --with-default-grade=hlc.gc

    Thanks.
    (0000133)
    wangp   
    2008-08-19 11:06   
    (Last edited: 2008-08-19 11:07)
    --with-llds-base-grade doesn't expect ".gc"

    The address space limit might be too small. Check with "ulimit -v" or try "ulimit -v unlimited".

    Another thing to try is ./configure --enable-gc-munmap, then `export MERCURY_OPTIONS="--boehm-gc-munmap"' before making. Might help.

    (0000134)
    juliensf   
    2008-08-19 13:55   
    Ah okay, I was using the x86 version of OpenSUSE 10.3 not the x86_86 version.
    (It appears to be fine on the former except for the gcc 4.2 issue).
    (0000135)
    michael_george_hart   
    2008-08-20 01:27   
    Followed your last set or recommendation to the letter and I get the same

    make install failure

    I was looking forward in using the Mercury language over PROLOG or HASKELL.

    Hopefully someone can come up with a solution soon to simply compile and install the system. Any other ideas I should be trying? I find it very strange that I should be getting stack overflows when the RAM on this machine is 8 GB. Could anyone give me a better idea of what is going on? Perhaps I can help
    (0000136)
    juliensf   
    2008-08-20 01:53   
    The two most likely explanations for what is going on are:

    (1) the way Mercury uses one or GNU C extension is conflicting with
    some of the optimisations used by gcc on that platform.

    or (2) there is some problem with x86_64/SUSE 10.3 and the version of the Boehm GC
    that Mercury uses. (A quick search on the web indicates that this is a possibility.)

    Let's try dealing with (1) first. Doing the following will disable the the use of any GNU C extensions
    plus any optimisations which may be causing problems.

    Create a file named Mmake.params at the top-level of the source tree (in the same directory
    as the configure script.) The file should contain the following line:

        EXTRA_CFLAGS=-O0

    Invoke configure (in a freshly unpacked source distribution) with the following options:

        --with-llds-base-grade=none
        --with-default-grade=hlc.gc

    Does that work?
    (0000137)
    michael_george_hart   
    2008-08-20 06:34   
    OK Great!!!

    I added EXTRA_CFLAGS=-O0 to the created file Mmake.params and ran
    ./configure --with-llds-base-grade=none --with-default-grade=hlc.gc
    make
    make install
    And the build ran to completion... Fantastic...

    Next I took mercury-compiler-rotd-2008-08-18-unstable.tar.gz and this time set EXTRA_CFLAGS=-O3
    ./configure
    make
    make install
    That ended in the usual install failure.

    Did the same again running configure with the recommended parameters
    ./configure --with-llds-base-grade=none --with-default-grade=hlc.gc
    The make install ran to completion.

    So now I can start to experiment and hopefully build some QT/KDE application I have in mind

    Anyway not being yet familar with your product what exactly did the "--with-llds-base-grade=none --with-default-grade=hlc.gc" do?
    What is a grade?


    Built some sample application and they all worked so I guess you can close this issues now?

    Thanks
    (0000145)
    subw   
    2008-09-03 05:06   
    The workaround described in 0000136 worked for me on Fedora 9 on X86_64 with GCC 4.3, or at least I was able to build and run the Hello World from the Mercury tutorial.

    Building took quite long (namely make install), but not exceedingly so compared to, say, GHC.


    Would it make sense to try to build again now with different settings to make Mercury faster? (And which settings would those be?)
    (0000148)
    juliensf   
    2008-09-04 19:13   
    You could build a faster version of the Mercury compiler by rebuilding
    from the source in CVS using the hlc.gc grade. You will need an existing
    Mercury compiler in your PATH to do this.

    (1) Check out the sources from CVS (the instructions for doing so
    are here <http://www.mercury.csse.unimelb.edu.au/information/developers/remote_cvs.html>)

    (2) Create a file named Mmake.params at the top-level of the freshly
    checked out source tree. Put the following line in it:

        GRADE=hlc.gc

    (3) invoke configure with the following:

       ./configure --with-default-grade=hlc.gc --enable-libgrades=hlc.gc

    plus any other options, such as --prefix, that you would usually use.

    (4) Do make and make install

    This should be the compiler in the hlc.gc grade, which shouldn't have the same
    problems with gcc as the C with the low-level backend.

    You can install the libraries in further grades by appending them to
    the list given to the --enable-libgrades (using commas as separators).
    Note that grades using the low-level C backend (those with base grade
    asm_fast, reg, or none won't work due to the problems with gcc 4.2 -- which
    means that debugging and deep profiling won't work unless you have the original
    workaround in place.)
    (0000169)
    mgiuca   
    2009-06-02 16:44   
    Just reporting the same issue and the workaround works. I am on Ubuntu 8.10, 32-bit.

    I ran
    ./configure --disable-most-grades

    Then ran make and make install. Make install crashes with a segfault the *first* time mmc is called. Even running the built version of mmc from the command-line with no arguments still causes it to segfault.

    For good measure, I tried this with gcc-3.4 and gcc-4.3.

    I then took your advice and ran with "--with-default-grade=hlc.gc --with-llds-base-grade=none" and it built fine on both versions of GCC.

    I have full logs for both runs (available on request), but I threw away the binaries. I can rebuild them if required.
    (0000221)
    wangp   
    2009-12-01 01:57   
    Another gcc 4 thing.




    View Issue Details
    39 [mercury] Bug minor always 2008-01-22 17:48 2009-11-27 02:03
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    gcc 4.1.2 on x86-64 miscompiles computed gotos
    In compiler/purity.m we needed a work around to avoid a segfault while purity checking invalid/purity/purity.m.
    We get a segfault when jumping to the `unnecessary_promise_pure' branch.

    Happens with gcc 4.1.2 on x86-64, at gcc -O1 and above.
    This also works around the problem. Note the volatile.

    #define MR_COMPUTED_GOTO(val, labels) \
            { \
                    static MR_Code *jump_table[] = { \
                            labels \
                    }; \
                    volatile int val1 = (val); \
                    MR_GOTO(jump_table[val1]); \
            }
     
    Notes
    (0000190)
    pbone   
    2009-09-26 06:24   
    Julian suggested I look at this, saying it might be related to bug66.

    It looks like there's a more general problem, GCC 4.x and in particular 4.3 loads addresses into registers in the prelude of a function and then dereferences the register later in the function.

    I'm trying to solve the more general problem,




    View Issue Details
    78 [mercury] Bug minor always 2008-08-20 16:54 2009-11-27 00:56
    juliensf  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    make install fails on Fedora 9 with gcc 4.3
    Building the source distribution on Fedora 9 fails due to segmentation fault during
    the install_grades step.
     
    Notes
    (0000138)
    juliensf   
    2008-08-20 16:54   
    (Last edited: 2008-08-20 16:55)
    This was on an x86 with rotd-2008-08-19.

    (0000139)
    juliensf   
    2008-08-20 18:38   
    This problem also occurs with the reg grades. The source distribution can be installed
    using the none grade, i.e. invoking configure with

        --with-llds-base-grade=none
    (0000140)
    juliensf   
    2008-08-20 18:56   
    Actually, while the above allows make install to successfully run to completion, other things
    still don't work, e.g. G12's configuration check for mmc.




    View Issue Details
    66 [mercury] Bug minor always 2008-07-07 14:47 2009-11-25 21:29
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    gcc 4.2 incompatibility
    gcc 4.2.3 on my x86-64 machine doesn't compile the Mercury compiler properly.
    This is in asm_fast.gc grade.

    % ./mercury_compile
    Mercury.options:085: Warning: variable `GCC_SRC_DIR' is undefined.
    mercury_compile: unrecognized option `-O'
    Mercury Compiler, version DEV, configured for x86_64-unknown-linux-gnu
    Copyright (C) 1993-2008 The University of Melbourne
    Usage: mmc [<options>] <arguments>
    Use `mmc --help' for more information.

    Note the "unrecognized option" message even when there are no arguments.
     
    Notes
    (0000127)
    juliensf   
    2008-08-18 17:21   
    The problem can be worked around by by compiling the C code at -O0; it looks as
    though some gcc optimisation is breaking things. This probably only affects the
    asm_fast version of the compiler.




    View Issue Details
    108 [mercury] Bug minor N/A 2009-09-28 11:38 2009-11-23 22:11
    gloomdemon  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    invalid java path with mercury and mingw
    Mercury Compiler, version rotd-2009-09-15
    mingw with gcc4.4 on windows vista

    while compiling java grade, mercury compiler uses invalid path:
    $ mmc --java -v --make family
    ...
    % Invoking system command `/c/Java/jdk1.6.0_12/bin/javac -classpath :c:/mingw/me
    rcury/lib/mercury/lib/java/mer_rt.jar:c:/mingw/mercury/lib/mercury/lib/java/mer_
    std.jar:c:/mingw/mercury/lib/mercury/lib/java/mer_mdbcomp.jar:c:/mingw/mercury/l
    ib/mercury/lib/java/mer_browser.jar:c:/mingw/mercury/lib/mercury/lib/java/mer_ss
    db.jar -sourcepath Mercury\javas -d Mercury\classs -J-Xmx256m Mercury\javas\jmer
    cury\family.java'...
    ...
    Error: system command received signal 1.

    ,must be:

    % Invoking system command `c:/Java/jdk1.6.0_12/bin/javac -classpath c:/mingw/...
    with c:\ and no : after -classpath or dot before :

    % Invoking system command `c:/Java/jdk1.6.0_12/bin/javac -classpath .:c:/mingw/...

    === ===

    after compiling and linking created sh file incorrect.

    #!/bin/sh
    DIR=${0%/*}
    CLASSPATH=$DIR/Mercury\classs:$CLASSPATH:c:/mingw/mercury/lib/mercury/lib/java/mer_rt.jar:c:/mingw/mercury/lib/mercury/lib/java/mer_std.jar:c:/mingw/mercury/lib/mercury/lib/java/mer_mdbcomp.jar:c:/mingw/mercury/lib/mercury/lib/java/mer_browser.jar:c:/mingw/mercury/lib/mercury/lib/java/mer_ssdb.jar
    export CLASSPATH
    JAVA=${JAVA:-/c/Windows/system32/java}
    exec $JAVA jmercury.family "$@"

    ,must be:

    CLASSPATH=$DIR/Mercury/classs:
     
    Notes
    (0000191)
    wangp   
    2009-09-28 22:56   
    Thanks for testing.

    I thought javac on Windows needs ";" separators instead of ":", as colons are
    use to denote drive letters?

    I will commit something for the CLASSPATH problem.
    (0000192)
    gloomdemon   
    2009-09-29 03:35   
    Yes, javac works normally with ":" as path delimiter, but better use ";".

    Configure script under mingw also can not use java.exe (javac.exe) with spaces in path (i.e. c:/program files/java/jdk/javac.exe), and disable java grade.
    (0000193)
    wangp   
    2009-09-30 03:49   
    I have committed fixes for the first two problems you mentioned.
    (0000194)
    wangp   
    2009-10-01 03:26   
    Committed further fixes today, except for the problem with spaces in the path.
    (0000216)
    gloomdemon   
    2009-11-22 10:50   
    Hi, i get the rotd-2009-11-12 and try to install with java grade under mingw. And get error while linking java class files into grade library: path not found. This old error with /c/Java/jdk1.6.0_12/bin/javac, to check this, i use new compiler mmc --very-verbose --java hello.m and get:

    % Compiling `jmercury\hello.java':
    % Invoking system command `/c/Java/jdk1.6.0_12/bin/javac -classpath c:/mingw/mer
    cury/lib/mercury/lib/java/mer_rt.jar;c:/mingw/mercury/lib/mercury/lib/java/mer_s
    td.jar;c:/mingw/mercury/lib/mercury/lib/java/mer_mdbcomp.jar;c:/mingw/mercury/li
    b/mercury/lib/java/mer_browser.jar;c:/mingw/mercury/lib/mercury/lib/java/mer_ssd
    b.jar -J-Xmx256m jmercury\hello.java'...
    ??????? ?? ??????? ????? ????????? ????.
    Error: system command received signal 1.
    % Touching `hello.java_date'... done.

    I decided recompile mmc with JAVAC=javac. I tried JAVAC='javac' ./configure ... and add JAVAC=javac to Mmake.params, but configure converts it to /c/Java/jdk1.6.0_12/bin/javac, so i hack configure and make new mmc. While making java grade (mmake LIBGRADES='java' install) get new error:

    Making Java class files
    Mercury\javas\jmercury\array.java:779: illegal unicode escape
    // Mercury\opts\univ.opt:8

    file array.java at line 779 contains:

    // Mercury\opts\univ.opt:8
              {
                V_4_38 = univ.type_to_univ_2_p_1(TypeInfo_for_T_28, V_12_12);
              }

    Mercury added comments on lines while compiling .m to .java but this is old java bug:

    http://bugs.sun.com/view_bug.do?bug_id=4364486
    http://bugs.sun.com/view_bug.do?bug_id=4324927
    (0000217)
    gloomdemon   
    2009-11-22 11:02   
    Converting comment like // Mercury\opts\univ.opt:8 to // Mercury\\opts\\univ.opt:8 solves this problem.
    (0000218)
    wangp   
    2009-11-23 22:11   
    Thanks for the report. Committed a patch just then.




    View Issue Details
    114 [mercury] Bug minor have not tried 2009-10-19 19:19 2009-10-30 09:45
    janicek Darwin  
    Mac OS X  
    normal 10.5.8  
    acknowledged  
    rotd-2009-10-05 open  
    none    
    none  
       
    rotd-2009-10-05's library install fails for grade hlc.agc
    Trying to install Mercury library with grade hlc.agc fails in "make install" ends with an error:

    -- BEGIN SNIPPET --

    mmc --compile-to-c --grade hlc.agc --mercury-linkage shared --flags LIB_FLAGS --flags INTER_FLAGS -R/Users/sandius/Developer/mercury-rotd-2009-10-05-agc/lib/mercury/lib/hlc.agc -R/Users/sandius/Develop
    er/mercury-rotd-2009-10-05-agc/l
    ib/mercury/lib version_hash_table > version_hash_table.err 2>&1
    mmc --compile-to-c --grade hlc.agc --mercury-linkage shared --flags LIB_FLAGS --flags INTER_FLAGS -R/Users/sandius/Developer/mercury-rotd-2009-10-05-agc/lib/mercury/lib/hlc.agc -R/Users/sandius/Develop
    er/mercury-rotd-2009-10-05-agc/lib/mercury/lib version_store > version_store.err 2>&1
    mmc --compile-to-c --grade hlc.agc --mercury-linkage shared --flags LIB_FLAGS --flags INTER_FLAGS -R/Users/sandius/Developer/mercury-rotd-2009-10-05-agc/lib/mercury/lib/hlc.agc -R/Users/sandius/Develop
    er/mercury-rotd-2009-10-05-agc/lib/mercury/lib version_types > version_types.err 2>&1
    /Users/sandius/tmp/mercury-compiler-rotd-2009-10-05/install_grade_dir.hlc.agc/scripts/mgnuc --grade hlc.agc -- -c array.c -o array.o
    array.c: In function ‘mercury__array__f_84_121_112_101_83_112_101_99_79_102_95_95_112_114_101_100_95_111_114_95_102_117_110_99_95_95_115_111_114_116_95_95_91_84_32_61_32_105_110_116_93_95_48_95_49_1_f_0’:
    array.c:1369: error: ‘mercury__array__frame_ptr’ undeclared (first use in this function)
    array.c:1369: error: (Each undeclared identifier is reported only once
    array.c:1369: error: for each function it appears in.)
    array.c: In function ‘mercury__array__f_84_121_112_101_83_112_101_99_79_102_95_95_112_114_101_100_95_111_114_95_102_117_110_99_95_95_115_111_114_116_95_95_91_84_32_61_32_115_116_114_105_110_103_93_95_48_95_49
    _1_f_0’:
    array.c:1469: error: ‘mercury__array__frame_ptr’ undeclared (first use in this function)
    array.c: In function ‘mercury__array__f_84_121_112_101_83_112_101_99_79_102_95_95_112_114_101_100_95_111_114_95_102_117_110_99_95_95_115_97_109_115_111_114_116_95_115_117_98_97_114_114_97_121_95_95_91_84_32_6
    1_32_105_110_116_93_95_48_95_49_3_f_0’:
    array.c:1569: error: ‘mercury__array__frame_ptr’ undeclared (first use in this function)
    array.c: In function ‘mercury__array__f_84_121_112_101_83_112_101_99_79_102_95_95_112_114_101_100_95_111_114_95_102_117_110_99_95_95_115_97_109_115_111_114_116_95_115_117_98_97_114_114_97_121_95_95_91_84_32_6
    1_32_115_116_114_105_110_103_93_95_48_95_49_3_f_0’:
    array.c:1626: error: ‘mercury__array__frame_ptr’ undeclared (first use in this function)
    array.m: In function ‘mercury__array__f_84_121_112_101_83_112_101_99_79_102_95_95_112_114_101_100_95_111_114_95_102_117_110_99_95_95_115_97_109_115_111_114_116_95_117_112_95_95_91_84_32_61_32_105_110_116_93_9
    5_48_95_49_8_p_0’:
    array.m:1715: error: ‘mercury__array__frame_ptr’ undeclared (first use in this function)
    array.m: In function ‘mercury__array__f_84_121_112_101_83_112_101_99_79_102_95_95_112_114_101_100_95_111_114_95_102_117_110_99_95_95_115_97_109_115_111_114_116_95_117_112_95_95_91_84_32_61_32_115_116_114_105_
    110_103_93_95_48_95_49_8_p_0’:
    array.m:1715: error: ‘mercury__array__frame_ptr’ undeclared (first use in this function)
    array.m: In function ‘mercury__array__f_84_121_112_101_83_112_101_99_79_102_95_95_112_114_101_100_95_111_114_95_102_117_110_99_95_95_115_97_109_115_111_114_116_95_100_111_119_110_95_95_91_84_32_61_32_105_110_
    116_93_95_48_95_49_8_p_0’:
    array.m:1747: error: ‘mercury__array__frame_ptr’ undeclared (first use in this function)
    array.m: In function ‘mercury__array__f_84_121_112_101_83_112_101_99_79_102_95_95_112_114_101_100_95_111_114_95_102_117_110_99_95_95_115_97_109_115_111_114_116_95_100_111_119_110_95_95_91_84_32_61_32_115_116_
    114_105_110_103_93_95_48_95_49_8_p_0’:
    array.m:1747: error: ‘mercury__array__frame_ptr’ undeclared (first use in this function)
    array.c: In function ‘mercury__array__f_84_121_112_101_83_112_101_99_79_102_95_95_112_114_101_100_95_111_114_95_102_117_110_99_95_95_99_111_112_121_95_114_117_110_95_97_115_99_101_110_100_105_110_103_95_95_91
    _84_32_61_32_105_110_116_93_95_48_95_49_6_p_0’:
    array.c:2343: error: ‘mercury__array__frame_ptr’ undeclared (first use in this function)
    array.c: In function ‘mercury__array__f_84_121_112_101_83_112_101_99_79_102_95_95_112_114_101_100_95_111_114_95_102_117_110_99_95_95_99_111_112_121_95_114_117_110_95_97_115_99_101_110_100_105_110_103_95_95_91
    _84_32_61_32_115_116_114_105_110_103_93_95_48_95_49_6_p_0’:

    -- END SNIPPET --

    Configured with

    $ ./configure --prefix=$HOME/Developer/mercury-rotd-2009-10-05-agc --enable-libgrades=hlc.gc,hlc.agc

    $ gcc --version
    i686-apple-darwin9-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5566)
    Copyright (C) 2007 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    $ uname -a
    Darwin freya.local 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386

    config.log attached.
    config.log (235,898 bytes) 2009-10-19 19:19
    https://bugs.mercurylang.org/file_download.php?file_id=86&type=bug
    make_install.nohup (387,005 bytes) 2009-10-19 19:21
    https://bugs.mercurylang.org/file_download.php?file_id=87&type=bug
     
    Notes
    (0000214)
    janicek   
    2009-10-19 19:22   
    The code snippet is truncated (there are many more errors than this, see the attached "make_install.nohup").
    (0000215)
    juliensf   
    2009-10-30 09:45   
    It's probably just bitrot; the .agc grades have not been actively worked on
    for some time. They should be considered as still experimental in any case.




    View Issue Details
    112 [mercury] Bug feature always 2009-10-12 23:18 2009-10-17 06:10
    colanderman  
    juliensf  
    normal  
    resolved  
    no change required  
    none    
    none  
       
    set_* modules inconsistent
    set_bbbtree, set_ordlist, and set_unordlist all have a predicate member(T, set(T)) with modes semidet and nondet, and a predicate contains(set(T), T) with mode semidet.

    set_tree234 reverses the order of the arguments of member relative to these three modules, and set_ctree234 drops member and provides instead one_member(set(T), T) with only mode nondet.

    At the very least the order of arguments to set_tree234.member should be reversed, or the predicate renamed.
     
    Notes
    (0000207)
    colanderman   
    2009-10-12 23:20   
    Whoops, meant to say same applies to insert, delete, etc.
    (0000208)
    juliensf   
    2009-10-13 00:55   
    The inconsistency in the argument orderings is deliberate in the sense that the set_tree234
    orderings are what we want (because they are more uesful with higher-order programming),
    the versions in the other set modules will eventually be changed to conform to this; but not
    until after the next stable release.
    (0000209)
    colanderman   
    2009-10-13 02:37   
    OK, good to know, thanks.
    (0000213)
    juliensf   
    2009-10-17 06:10   
    The argument orderings will be modified sometime after the 0.14 release.




    View Issue Details
    113 [mercury] Bug minor always 2009-10-13 02:33 2009-10-17 03:56
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    abort during purity checking.
    The attached program results in a compiler abort.
    It looks as though the compiler should not be proceeding to purity checking
    in the presence of earlier errors.

    The output from mmc -V is below.
    % Parsing file `bug113' and imported interfaces...
    % Reading file `bug113'... successful parse.
    % Reading interface for module `builtin.int'... successful parse.
    % Reading interface for module `bool.int'... successful parse.
    % Reading interface for module `list.int'... successful parse.
    % Reading interface for module `exception.int'... successful parse.
    % Reading interface for module `int.int'... successful parse.
    % Reading interface for module `string.int'... successful parse.
    % Reading interface for module `private_builtin.int'... successful parse.
    % Reading short interface for module `enum.int2'... successful parse.
    % Reading short interface for module `pretty_printer.int2'... successful parse.
    % Reading short interface for module `term.int2'... successful parse.
    % Reading short interface for module `io.int2'... successful parse.
    % Reading short interface for module `deconstruct.int2'... successful parse.
    % Reading short interface for module `stream.int2'... successful parse.
    % Reading short interface for module `type_desc.int2'... successful parse.
    % Reading short interface for module `univ.int2'... successful parse.
    % Reading short interface for module `map.int2'... successful parse.
    % Reading short interface for module `bitmap.int2'... successful parse.
    % Reading short interface for module `char.int2'... successful parse.
    % Reading short interface for module `maybe.int2'... successful parse.
    % Reading short interface for module `ops.int2'... successful parse.
    % Reading short interface for module `time.int2'... successful parse.
    % Reading short interface for module `construct.int2'... successful parse.
    % Reading short interface for module `rtti_implementation.int2'... successful parse.
    % Reading short interface for module `assoc_list.int2'... successful parse.
    % Reading short interface for module `set.int2'... successful parse.
    % Reading short interface for module `tree234.int2'... successful parse.
    % Reading short interface for module `pair.int2'... successful parse.
    % Reading short interface for module `stm_builtin.int2'... successful parse.
    % Reading short interface for module `store.int2'... successful parse.
    % Reading short interface for module `array.int2'... successful parse.
    % Reading short interface for module `random.int2'... successful parse.
    % Reading short interface for module `set_ordlist.int2'... successful parse.
    % Module qualifying items...
    bug113.m:001: In module `bug113':
    bug113.m:001: warning: module `list' is imported in the interface, but is not
    bug113.m:001: used in the interface.
    % done.
    % Expanding equivalence types...
    % done.
    % Converting parse tree to hlds...
    % Processing clause 1 for function `bug113.new/1'...
    % Processing clause 1 for function `bug113.new/2'...
    bug113.m:036: Error: clause for function `bug113.new'/1
    bug113.m:036: without preceding `func' declaration.
    bug113.m:038: Error: clause for function `bug113.new'/2
    bug113.m:038: without preceding `func' declaration.
    % done.
    % Writing auto-dependency file `bug113.d'... done.
    % Checking typeclasses...
    % Checking instance declaration types...
    % Checking typeclass instances...
    % Checking for cyclic classes...
    % Checking for missing concrete instances...
    % Checking functional dependencies on instances...
    % Checking typeclass constraints...
    % Checking typeclass constraints on unification predicate for type bug113.bitmap
    % Checking typeclass constraints on comparison predicate for type bug113.bitmap
    % Checking typeclass constraints on unification predicate for type bug113.foo
    % Checking typeclass constraints on comparison predicate for type bug113.foo
    % Checking typeclass constraints on function `bug113.new'/1
    % Checking typeclass constraints on function `bug113.new'/2
    % Checking that insts have matching types... done.
    % Type-checking...
    % Type-checking clauses...
    % Type-checking unification predicate for type deconstruct.maybe_arg
    % Inferring type of function `bug113.new'/1
    % Inferring type of function `bug113.new'/2
    % Type-checking predicate `list.TypeSpecOf__pred__member__[T = var(V_2)]'/2
    % Type-checking predicate `list.TypeSpecOf__pred__merge__[T = var(V_2)]'/3
    % Type-checking predicate `list.TypeSpecOf__pred__merge_and_remove_dups__[T = var(V_2)]'/3
    % Type-checking function `list.TypeSpecOf__pred_or_func__merge_and_remove_dups__[T = var(V_2)]'/2
    % Type-checking function `list.TypeSpecOf__pred_or_func__remove_adjacent_dups__[T = var(V_2)]'/1
    % Type-checking predicate `list.TypeSpecOf__pred_or_func__remove_adjacent_dups__[T = var(V_2)]'/2
    % Type-checking predicate `list.TypeSpecOf__pred__sort__[T = var(V_2)]'/2
    % Type-checking function `list.TypeSpecOf__pred_or_func__sort__[T = var(V_2)]'/1
    % Type-checking function `list.TypeSpecOf__pred_or_func__sort_and_remove_dups__[T = var(V_2)]'/1
    % Type-checking predicate `list.TypeSpecOf__pred_or_func__sort_and_remove_dups__[T = var(V_2)]'/2
    bug113.m:036: Inferred :- func new(T1) = T2.
    bug113.m:040: In clause for function `new'/2:
    bug113.m:040: error: undefined symbol `throw_bitmap_error/1'.
    bug113.m:042: In clause for function `new'/2:
    bug113.m:042: error: undefined symbol `initializer/1'.
    bug113.m:043: In clause for function `new'/2:
    bug113.m:043: error: undefined symbol `initialize_bitmap/3'.
    bug113.m:043: In clause for function `new'/2:
    bug113.m:043: in argument 1 of functor `initialize_bitmap/3':
    bug113.m:043: error: undefined symbol `allocate_bitmap/1'.
    bug113.m:044: In clause for function `new'/2:
    bug113.m:044: error: undefined symbol `clear_filler_bits/1'.
    % Program contains type error(s).
    % Purity-checking clauses...
    % Purity-checking unification predicate for type bug113.bitmap
    % Purity-checking comparison predicate for type bug113.bitmap
    % Purity-checking unification predicate for type bug113.foo
    % Purity-checking comparison predicate for type bug113.foo
    % Purity-checking function `bug113.new'/1
    Uncaught Mercury exception:
    Software Error: prog_type.m: Unexpected: type_to_ctor_and_args_det: type_to_ctor_and_args failed
    Stack dump not available in this grade.
    bug113.m (1,504 bytes) 2009-10-13 02:33
    https://bugs.mercurylang.org/file_download.php?file_id=84&type=bug
     
    Notes
    (0000211)
    zs   
    2009-10-17 03:56   
    Fix committed 16 Oct 2009.




    View Issue Details
    111 [mercury] Bug minor always 2009-10-12 15:03 2009-10-12 15:03
    colanderman  
     
    normal  
    new  
    open  
    none    
    none  
       
    Throwing exception in tabled predicate causes table entry to remain active
    If a memoized function or predicate throws an exception, then the call remains "active" in the memo table, and subsequent calls trigger a spurious loop check exception.
    Expected output of attached test should be "exn" printed twice. The second call however produces an infinite loop exception.
    table_exn_test.m (503 bytes) 2009-10-12 15:03
    https://bugs.mercurylang.org/file_download.php?file_id=83&type=bug
     
    There are no notes attached to this issue.




    View Issue Details
    104 [mercury] Bug minor always 2009-09-14 13:55 2009-10-06 08:40
    colanderman  
     
    normal  
    feedback  
    open  
    none    
    none  
       
    Static linking doesn't properly track dependencies
    Let there be two libraries, a and b, and one program, c. Let b use a (in Mercury.options: EXTRA_LIBRARIES = a) and c use b (EXTRA_LIBRARIES = b). Compile a with "mmc --generate-mmc-deps -m liba.install", b with "mmc --generate-mmc-deps -m libb.install", and c with "mmc --linkage static -m c". Linking c will fail, since only libb.a is linked, and it doesn't contain symbols from liba.a which are necessary to produce the final executable.
    Normally this isn't a problem with shared linking, because shared objects (at least on Linux) track this sort of dependency information for you. Nonetheless I have ran into this problem once with shared linking under 0.13.1: the asm_fast.gc.mmsc.debug grade of a library failed to build because its .c file directly referenced a constructor which the .m file could not see (it was nested two levels deep). (Linking would have succeeded, but compilation failed.) The problem was "resolved" by changing the definition of the type which was "leaking" from an alias to a constructor -- clearly not something that should have any effect. I have been unable to reproduce this error with a small test case but if I am able to I will supply it.
     
    Notes
    (0000195)
    juliensf   
    2009-10-06 02:36   
    --generate-mmc-deps does *not* track library dependencies only module ones.
    You need to specify the that c also uses a, either via the --ml option or explicitly
    listing it in the Mercury.options file.
    (0000197)
    colanderman   
    2009-10-06 08:40   
    That's exactly the problem -- it *should* track C library dependencies. I, as the writer of c and the user of b, should not need to know that b uses a. This is a leaky abstraction which induces build brittleness: if the author of b decides in version 1.2.7 that library d does the job better than a, then I require two different build scripts for *my* user depending on whether he has version 1.2.6 or 1.2.7 of library b.

    Objective Caml provides a good example of how to properly handle this situation. It tracks C library dependencies (even external ones) as well as ML library dependencies.




    View Issue Details
    105 [mercury] Bug minor always 2009-09-16 10:43 2009-10-06 02:45
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    hl.gc grade is broken
    Trying to install the standard library in the hl.gc grade results in these kinds of messages:

    io.m: In function `mercury__io__compare_file_id_2_3_p_0':
    io.m:3829: error: conversion to non-scalar type requested
    io.m:3830: error: conversion to non-scalar type requested
    ...
    lexer.m:925: warning: missing braces around initializer
    lexer.m:925: warning: (near initialization for `mercury__lexer__const_var_22.mercury__lexer__token_0__error_1__base_1')
    ...
     
    Notes
    (0000196)
    wangp   
    2009-10-06 02:45   
    Fixed today. Still plenty of warnings but compiles.




    View Issue Details
    107 [mercury] Bug minor N/A 2009-09-24 05:56 2009-09-24 22:30
    gloomdemon  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    undefined kill function while link mercury compiler under mingw
    error while link compiler under mingw with gcc 3.4 (4.4)
    file compiler/libs.process_util.c, line 644, function send_signal
    calling kill(Pid, Signal) not wrapped with #ifdef MC_CAN_FORK
     
    Notes
    (0000189)
    wangp   
    2009-09-24 22:30   
    Fixed.




    View Issue Details
    93 [mercury] Bug minor always 2009-04-08 13:27 2009-09-22 17:35
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    large ground terms optimisation and unique modes
    The optimised handling of large ground terms (23 Dec) breaks mode checking when the term being constructed is declared to be unique. When the term is large enough for the optimisation to kick in, the term is assumed to be non-unique.

    I tracked this as far as "TermInst = bound(shared, [BoundInst])," in modecheck_ground_term_construct_goal_loop.
    On the attached example the error message is:

    uo_regression1.m:035: In clause for `init_message = uo':
    uo_regression1.m:035: mode error: argument 1 had the wrong instantiatedness.
    uo_regression1.m:035: Final instantiatedness of `HeadVar__1' was
    uo_regression1.m:035: `bound(uo_regression1.response(bound((uo_regression1.status_ok)),
    uo_regression1.m:035: bound((maybe.no)), bound((maybe.no)),
    uo_regression1.m:035: bound((maybe.no)), bound((maybe.no))))',
    uo_regression1.m:035: expected final instantiatedness was `unique'.
    uo_regression1.m (1,195 bytes) 2009-04-08 13:27
    https://bugs.mercurylang.org/file_download.php?file_id=73&type=bug
     
    Notes
    (0000165)
    petdr   
    2009-04-27 12:10   
    A workaround for this bug is to increase the threshold to a sufficiently large number.

    --from-ground-term-threshold 100000
    (0000166)
    zs   
    2009-04-27 13:53   
    This is not so much as a bug as an issue that arises because we have not (yet) resolved the tension between two competing optimizations. Opt1 is replacing code that constructs ground terms at runtime with references to static ground terms; opt2 is compile time garbage collection. Opt1 requires ground terms to be non-unique; opt2 requires ground terms to be unique. When I implemented the special handling of large ground terms, I obviously did what opt1 wants, since opt2 did not yet work anyway. Just as obviously, deciding between unique and non-unique based only on the size of the term is not a good idea, but what should the criterion be?

    I think all ground terms should be non-unique, and ctgc should introduce code that makes unique copies of ground terms whenever it needs them. It has to think about this possibility *anyway*, because it has to balance the gain in speed from ctgc against the loss in speed from having to build the ground term from scratch each time. Asking it to record the result of its analysis in the form of a call to a copy predicate, or in the form of replacing a from_ground term scope with a conjunction of construct_dynamically unifications, doesn't sound like asking too much.
    (0000188)
    zs   
    2009-09-22 17:35   
    Fix committed 22 Sep 2009.




    View Issue Details
    106 [mercury] Bug major always 2009-09-22 01:07 2009-09-22 02:09
    janicek  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Linking with multiple C++ files yields a "duplicate symbol" error
    Linking a Mercury main module with two (or more) C++ files that utilise some Mercury code through pragma foreign_export fails with the linker reporting the following:

    ** Error making `mercury_main'.
    ld: duplicate symbol _MR_trace_tailrec_have_reused_frames in CPlusPlus2.o and CPlusPlus1.o
    collect2: ld returned 1 exit status

    (See the attachment for a minimal example.)

    The platform is Darwin (Mac OS X 10.5.8), using Apple's GCC 4.1.2 which is shipped with Xcode 3.1.2.

    $ uname -a
    Darwin dfki-guestpool3.dfki.uni-sb.de 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386

    $ g++ --version
    i686-apple-darwin9-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5566)
    Copyright (C) 2007 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    $ mmc --version
    Mercury Compiler, version rotd-2008-11-30, configured for i686-apple-darwin9.6.0
    Copyright (C) 1993-2008 The University of Melbourne
    Adding the keyword "extern" to variables

    MR_trace_tailrec_have_reused_frames
    and
    MR_trace_tailrec_num_reused_frames

    in `mercury_trace_base.h'

    seems to resolve the issue, i.e. the program links and seems to run fine.
    duplicate-symbol-error.tar.gz (1,794 bytes) 2009-09-22 01:07
    https://bugs.mercurylang.org/file_download.php?file_id=80&type=bug
     
    Notes
    (0000183)
    janicek   
    2009-09-22 01:09   
    Ah, forgot to mention the grade -- it's hlc.gc. Sorry!
    (0000184)
    juliensf   
    2009-09-22 01:53   
    The missing externs are a bug - I will fix this shortly.
    (0000185)
    juliensf   
    2009-09-22 02:09   
    Fix committed - it will take a day or two to make its way into the ROTDS.




    View Issue Details
    101 [mercury] Bug major always 2009-07-23 17:58 2009-07-28 16:45
    pbone  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Deep profiling of programs compiled against G12 creates currupt Deep.data files.
    When running even trivial programs such as "hello world" against the G12 libraries the Mercury runtime cannot correctly write out the proc statics to the Deep.data file.
    pbone@goliath:/home/goliath/pbone/rect_pack$ ./hello
    Hello world!
    Mercury runtime: MR_write_out_proc_static: seen ps
    pbone@goliath:/home/goliath/pbone/rect_pack$ echo $?
    1

    The minimal set of G12 libraries required to trigger this problem can be linked against if Mercury.options contains:

    include "/home/goliath/pbone/g12/install/G12.options"
    MCFLAGS = $(G12_LIBFLAGS_ZINC_RT) $(G12_LIBFLAGS_ZINC_GENERIC_PROP) $(G12_LIBFLAGS_LAZYFD) $(G12_LIBFLAGS_COMMON)

    This occurs regardless of optimization level.

    mmc --grade asm_fast.gc.trseg.profdeep --rebuild hello

    Note that G12 requires trailing so this cannot be tested in a non-trailed grade.

     
    Notes
    (0000178)
    juliensf   
    2009-07-23 22:03   
    That is not the minimal set of G12 libraries required to reproduce the
    problem. Just linking hello world against the FD/IC backend library
    produces:

        Mercury runtime: UNWRITTEN nodes: Deep.data file corrupted

    Linking hello world against just the FD/IC backend library and the
    G12/FD library produces the original abort, i.e.

        Mercury runtime: MR_write_out_proc_static: seen ps
    (0000179)
    juliensf   
    2009-07-23 22:19   
    (Last edited: 2009-07-23 22:27)
    The problem here is that the we are writing out the proc statics for
    the G12/FD and Zinc runtime libraries twice, i.e. there are two calls to mercury__g12_fd__write_out_proc_statics() etc in the _init.c file.

    This is occuring because the command lines used to invoke the compiler
    contain duplicate --ml options, e.g.

       --ml g12_fd --ml g12_fd

    It isn't entirely obvious because it's all hidden behind several layers of
    variables and includes in Mercury.options files. It may be possible to
    modify G12's library handling to avoid this, but IMO the Mercury compiler
    should also be changed to remove duplicate --ml options.

    (0000180)
    pbone   
    2009-07-24 09:59   
    Ahh, I was removing each of the zinc flags variables until I could remove no more without either causing the error or having link errors.

    Your diagnosis makes sense fro the 'seen ps' case. After fixing this we should retest it to determine if this and the UNWRITTEN NODES errors are _both_ fixed.
    (0000181)
    juliensf   
    2009-07-28 16:45   
    The compiler now removes duplicates from the list of .init files before invoking mkinit.




    View Issue Details
    95 [mercury] Bug tweak always 2009-05-28 12:07 2009-06-16 15:27
    pbone  
    rafe  
    normal  
    resolved  
    no change required  
    none    
    none  
       
    svset module descriptions don't match declarations.

    In the svset module descriptions of predicates don't match their declarations.
    For example:

         % `svset.insert(X, Set0, Set)' is true iff `Set' is the union of
         % `Set0' and the set containing only `X'.
         %
      :- pred svset.insert(T::in, set(T)::in, set(T)::out) is det.

    The description says insert/3 is *true iff* however the predicate is deterministic. As a user I'm not sure if this will throw an exception if the key already exists or just ignore it.

    It may be best to adjust the declaration to match the description.

      paul@tarrango:~/code/edsnap/src$ mmc -V
      Mercury Compiler, version rotd-2009-03-13, configured for i686-pc-linux-gnu
      Copyright (C) 1993-2009 The University of Melbourne
      Usage: mmc [<options>] <arguments>
      Use `mmc --help' for more information.
     
    Notes
    (0000176)
    rafe   
    2009-06-16 15:26   
    User has misunderstood the comment.




    View Issue Details
    97 [mercury] Bug minor always 2009-06-03 00:17 2009-06-12 15:13
    juliensf  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    rotd-2009-06-02 generates invalid Erlang code
    When compiled in the erlang grade the attached test case results in an
    error message from the Erlang compiler.

    $ mmc --grade erlang --make zf_erlang_bug

    Making Mercury/beams/zf_erlang_bug.beam
    Mercury/erls/zf_erlang_bug.erl:64: variable 'STATE_VARIABLE_IO_1_12' unsafe in 'case' (line 43)
    ** Error making `Mercury/beams/zf_erlang_bug.beam'.
    zf_erlang_bug.m (1,703 bytes) 2009-06-03 00:17
    https://bugs.mercurylang.org/file_download.php?file_id=75&type=bug
     
    There are no notes attached to this issue.




    View Issue Details
    83 [mercury] Bug minor always 2008-09-11 12:36 2009-04-06 02:49
    wangp  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    ambiguous names in foreign_export
    The compiler does the wrong thing if the predicate in a foreign_export is
    ambiguous. e.g. for the attached test case

    % mmc -C fe
    fe.m:018: Error: `:- pragma foreign_export' declaration for `make_io_error'/2
    fe.m:018: without corresponding `pred' or `func' declaration.

    fe.m (844 bytes) 2008-09-11 12:36
    https://bugs.mercurylang.org/file_download.php?file_id=66&type=bug
     
    Notes
    (0000163)
    juliensf   
    2009-04-06 02:49   
    Fixed. See r1.88 of compiler/add_pragma.m for details.




    View Issue Details
    68 [mercury] Bug minor always 2008-07-14 10:44 2009-03-26 17:33
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    version_hash_table.delete is buggy
    version_hash_table.delete doesn't always delete the element. See the test case.
    vht_delete.m (1,341 bytes) 2008-07-14 10:44
    https://bugs.mercurylang.org/file_download.php?file_id=52&type=bug
    ht_delete.m (1,564 bytes) 2008-08-07 15:57
    https://bugs.mercurylang.org/file_download.php?file_id=62&type=bug
     
    Notes
    (0000118)
    juliensf   
    2008-08-07 15:57   
    Non-version hash tables, i.e. in library/hash_table.m, exhibit the same behaviour.
    I'll add a test case for them too.
    (0000119)
    juliensf   
    2008-08-07 16:23   
    The bug can be reproduced with just the following keys:

    "abandoned",
    "abase",
    "abases"
    (0000120)
    wangp   
    2008-08-07 16:38   
    I think the problem is this:

        find_slot(HT, K) looks up key K in hash table HT and
        returns the index for the entry K in H. This is either the
        first free slot identified (K is not in the table, but here
        is where it would go) or the slot for K (K is in the table
        and this is its slot).

        Whether or not K is actually in the table can be decided
        by checking to see whether its bit in the bitmap is set
        or clear.

    That's fine if keys never get deleted. But say two keys K1, K2 both
    want to go into slot S1. K1 gets there first, so K2 must reprobe and
    go into slot S2. Delete K1 so slot S1 becomes free. If you try to
    search for K2, it won't be found since S1 is free so it won't bother
    to look in S2.
    (0000121)
    juliensf   
    2008-08-07 16:43   
    That's what I had concluded as well - I was just waiting for a workspace with deep tracing
    in the library directory to compile in order to confirm it. For this sort of hash table the
    deletion algorithm needs to traverse the entire array until it finds the key it is deleting
    or until it get backs to where it starts.
    (0000122)
    juliensf   
    2008-08-07 16:52   
    (Last edited: 2008-08-07 16:52)
    Actually, supporting deletion at all would mean that you could insert duplicate keys
    into the table without it being detected - maybe we should just not support deletion?

    (0000123)
    wangp   
    2008-08-07 16:58   
    Let's just switch to separate chaining. Deleting is important.
    (0000124)
    juliensf   
    2008-08-07 17:07   
    In that case, yes.




    View Issue Details
    92 [mercury] Bug minor always 2009-03-09 23:43 2009-03-09 23:43
    juliensf  
     
    normal  
    new  
    open  
    none    
    none  
       
    generated C code contains a block that defines a variable that shadows a headvar in hlc.gc
    Compiling the C code generated for the attached module in the hlc.gc grade results in:

    shadowed_headvar.m: In function 'shadowed_headvar__type_defined_in_runtime_1_p_0':
    shadowed_headvar.m:64: warning: declaration of 'shadowed_headvar__HeadVar__1_1' shadows a parameter
    shadowed_headvar.m:38: warning: shadowed declaration is here
    shadowed_headvar.m (2,455 bytes) 2009-03-09 23:43
    https://bugs.mercurylang.org/file_download.php?file_id=71&type=bug
     
    There are no notes attached to this issue.




    View Issue Details
    88 [mercury] Bug block always 2008-11-17 07:42 2008-11-17 07:42
    psnively  
     
    normal  
    new  
    open  
    none    
    none  
       
    test_odbc hangs on call to SQLConnect()
    I'm running Mac OS X 10.5.5 on a PowerPC box. I have EnterpriseDB's "Postgres Plus" distro 8.3.5 installed. This means that my iODBC driver manager version is 03.52.0406.1211 and my PostgreSQL ODBC driver (psqlodbcw.so) version is 08.03.0200, both as reported by iodbctest. I've created a database called "test" with a table called "test" and populated the table with some simple sample data. I've also created an ODBC DSN called "test" referring to the test DB. I've confirmed that I can access the DSN with iodbctest and select data from the "test" table that way.

    I've done a complete build of all available grades of the 2008-10-19 release of Mercury on this box, as excruciating as that was. I'm now attempting to get the ODBC interface working. In my Mmakefile, I have MODBC_DRIVER=MODBC_IODBC, MODBC_DB = MODBC_SQL_SERVER (because there isn't explicit support for PostgreSQL but the MySQL support seems quite limited relative to SQL Server and PostgreSQL is more likely to be as featureful as SQL Server than as limited as MySQL), and MLLIBS=-liodbc -lpthread -ldl. At the top of the file, I've also added:

    GRADEFLAGS = --debug
    CFLAGS = -DMR_DEBUG_ON=1

    in order to be able to use mdb and get logging output from C functions that generate it, which, thankfully, the C functions in odbc.m do.

    With this configuration, odbc_test builds fine, and I can run it under mdb and step through it. I see the list of datasources on my box:

    Available data source names:
    source_desc("test", "Postgres Plus ODBC Driver")

    and the expected log output up to and including:

    SQLAllocEnv status: 0
    SQLAllocConnect status: 0
    manual commit status: 0

    from do_open_connection(). However, I never see a "connect status:" log entry at all, leading me to believe that SQLConnect() is never returning.


     
    There are no notes attached to this issue.




    View Issue Details
    87 [mercury] Bug major sometimes 2008-10-29 11:48 2008-11-03 14:09
    pbone  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Programs compiled in profdeep grade create currupt Deep.data files.
    Programs compiled in the asm_fast.gc.profdeep grade exit with a message similar to
    "Not all nodes written out, Deep.data file corrupted".

    Programs tasted: mercury compiler, mdprof_dump, hello world, and the test suite, they all show the same symptom.

    This occurs when using a compiler from roughly 2008-10-27. But not when using a compiler from 2008-10-12. (Tested on taura)

    The bug has probably existed for a while but has only surfaced recently due to some seemingly-unrelated change.

    When I have spare time I'll continue to bisect time to track down when exactly this surfaced.
     
    Notes
    (0000154)
    zs   
    2008-10-31 13:08   
    I don't know why the problem only surfaced recently, but it seems that its
    underlying cause is a misunderstanding about the import_status of predicates.

    In integer.m in the library, the predicate integer.to_string calls the function
    string.++.

    (a) String.++ is marked (correctly) as opt_imported.
    (b) The test predicate pred_info_is_imported FAILS for opt_imported predicates.
    (c) This causes make_rtti_proc_label to put "no" into the pred_is_imported
        field of the rtti_proc_label for string.++.
    (d) This rtti_proc_label is put into the element of the call_site_static_data
        list for integer.to_string that corresponds to the call to string.++
        as the rtti_proc_label of the callee.
    (e) When the time comes to write out the call_site_static structures,
        layout_out.m invokes make_proc_label_from_rtti to convert this
        rtti_proc_label in the call_site_static_data to a plain, non-RTTI
        proc_label. However, since the current module name ("integer") does not
        match the name of the module that defines the function ("string") AND
        the function is not marked as imported, make_user_proc_label (invoked
        from make_proc_label_from_rtti) believes that this means that this module
        generates code for the callee (as we do for some opt_imported procedures).
    (f) For procedures for which we generate target code in a different module
        than their defining module, we generate different labels for them
        than the label for the code for the procedure in its own module.
        We derive the name of a procedure's proc_static structure directly from
        its label, so this difference holds for the names of proc_static structures
        as well as for labels.
    (g) This lead to the problem, which was that the call_site_static for this call
        site referred to the proc_static for string.++ defined in integer.c
        (as opposed to string.++ defined in string.c), since integer.c did not
        actually generate code for string.++, there was no such proc_static.
        This should be a link error, but it isn't, due to the requirement on unix
        linkers of being compatible with Fortran's ancient semantics (specifically,
        Fortran's common areas). Instead, the C compiler happily allocates memory
        for the undefined symbol and fills it with zeros as if it were a
        proc_static structure.
    (h) The assertion violation in mercury_deep_profiling.c occurs because the
        call_site_static refers to this bogus proc_static, but of course no module
        writes out this proc_static.
    (0000155)
    juliensf   
    2008-10-31 16:04   
    I suspect that the reason that the problem has only recently surfaced is that we have only
    recently started doing deep profiling with inlining enabled.
    (0000156)
    zs   
    2008-11-03 14:09   
    Fix committed nov 3 2008.




    View Issue Details
    42 [mercury] Bug minor always 2008-02-04 11:01 2008-10-22 15:35
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    bug with LCMC in hlc grades
    In the attached test case, a list is converted to a bag then back again.
    The input is [1,1,1,2,3,3,4]. The output should be the same.
    When the module is compiled with

        mmc -s hlc.gc --optimize-constructor-last-call --no-inlining

    the output is just "[1]".
    bag_to_list.m (665 bytes) 2008-02-04 11:01
    https://bugs.mercurylang.org/file_download.php?file_id=35&type=bug
     
    Notes
    (0000094)
    wangp   
    2008-03-28 11:26   
    This appears to have been fixed by Mark's recent changes.
    (0000095)
    wangp   
    2008-03-28 15:06   
    Sorry, I was wrong. The reason it "works" now is that the latest compiler no longer performs the LCMC optimisation on the test case at all.
    (0000098)
    juliensf   
    2008-04-04 17:43   
    (Last edited: 2008-04-04 17:44)
    The reason that the compiler no longer performs LCMC optimisation is a change in the
    behaviour of common structure optimisation:

    Compiling with: -O2 --optimize-constructor-last-call --nolining --no-common-struct
    gives me the following at stage 135 (which is the last pass that does something meaningful
    before the LCMC pass) for the predicate to_list_2.

    bag_to_list.to_list_2(TypeInfo_for_T, HeadVar__1, HeadVar__2) :-
      ( % cannot_fail switch on `HeadVar__1'
        % HeadVar__1 has functor list.[]/0
        HeadVar__2 = list.[]
      ;
        % HeadVar__1 has functor list.[|]/2
        HeadVar__1 = list.[V_9 | Xs],
        V_9 = pair.(X - Int),
        (if
          V_10 = 0,
          int.(Int =< V_10)
        then
          bag_to_list.to_list_2(TypeInfo_for_T, Xs, HeadVar__2)
        else
          V_11 = 1,
          NewInt = int.(Int - V_11),
          V_13 = pair.(X - NewInt),
          V_12 = list.[V_13 | Xs],
          bag_to_list.to_list_2(TypeInfo_for_T, V_12, Out0),
          HeadVar__2 = list.[X | Out0]
        )
      ).

    Enabling common structure optimisation gives the following:

    bag_to_list.to_list_2(TypeInfo_for_T, HeadVar__1, HeadVar__2) :-
      ( % cannot_fail switch on `HeadVar__1'
        % HeadVar__1 has functor list.[]/0
        HeadVar__2 = list.[]
      ;
        % HeadVar__1 has functor list.[|]/2
        HeadVar__1 = list.[V_9 | Xs],
        V_9 = pair.(X - Int),
        (if
          V_10 = 0,
          int.(Int =< V_10)
        then
          bag_to_list.to_list_2(TypeInfo_for_T, Xs, Out)
        else
          V_11 = 1,
          NewInt = int.(Int - V_11),
          V_13 = pair.(X - NewInt),
          V_12 = list.[V_13 | Xs],
          bag_to_list.to_list_2(TypeInfo_for_T, V_12, Out0),
          Out = list.[X | Out0]
        ),
        HeadVar__2 = Out
      ).

    The unification HeadVar__2 = Out is introduced in stage 65 by common structure optimisation
    and it inhibits LCMC. Compiling with --no-common-struct causes the program to exhibit
    the original buggy behaviour reported by Peter Wang.

    Since there is no advantage gained by adding the new assignment unification and given
    that it inhibits other optimisations this behaviour from --common-struct is also a bug.

    (0000147)
    wangp   
    2008-09-03 17:10   
    Fix is here
    http://www.cs.mu.oz.au/research/mercury/mailing-lists/mercury-reviews/mercury-reviews.200806/0032.html

    but store_at_ref needs to be declared impure first.




    View Issue Details
    85 [mercury] Bug minor always 2008-09-23 09:44 2008-09-23 18:45
    juliensf  
     
    normal  
    new  
    open  
    none    
    none  
       
    stage 1 compiler aborts when compiled with -O5 --intermodule-optimization

    Compilation of compiler/deep_profiling.m fails in grade asm_fast.gc with
    -O5 --intermodule-optimization using ROTD 2008-09-19 (on taura, although
    this is occurring on all machines that use the above optimization settings).

    The abort message is:

    Uncaught Mercury exception:
    Software Error: code_gen.m: Unexpected: nondet model in det/semidet context
    Stack dump not available in this grade.
    bug85.m (5,854 bytes) 2008-09-23 16:14
    https://bugs.mercurylang.org/file_download.php?file_id=67&type=bug
     
    Notes
    (0000150)
    juliensf   
    2008-09-23 11:21   
    The abort occurs during the following step:

    % Generating low-level (LLDS) code for predicate `ll_backend.deep_profiling.coverage_prof_second_pass_goal'/7 mode 0

    I've committed a workaround that forces the affected module to be compiled at -O2.
    The bug does not occur at that optimization level.
    (0000151)
    juliensf   
    2008-09-23 11:29   
    In fact, this has nothing to do with --intermodule-optimisation. The bug occurs with -O3.
    (0000152)
    juliensf   
    2008-09-23 16:14   
    (Last edited: 2008-09-23 16:17)
    I've added a test case for this one that is independent of the compiler.
    Compile with: -O0 --deforestation -C

    (0000153)
    zs   
    2008-09-23 18:45   
    The body of the affected predicate has two switches followed by an if-then-else. Deforestation pushes the second switch and the if-then-else into each arm of the first switch, and then specializes the if-then-else. The problem is that in the process of specialization, it sets the determinism of the condition to nondet, when it should be semidet. The cause could be fact that, after propagating CoverageAfterKnown0 = CoverageAfterKnown1, it replaces the original test in the condition (CoverageAfterKnown1 = coverage_after_known) with a test on CoverageAfterKnown0, and thus updates the nonlocals set. It may think that this affects the determinism of the disjunction that is the condition, but in this case it doesn't.

    The problem part of the HLDS dump is the following.

       ( % cannot_fail switch on `MaybeDPCoverageInfo'
          % MaybeDPCoverageInfo has functor maybe.no/0
          % nonlocals: CoverageAfterKnown0, GoalExpr0, CPOptions, IsMDProfInst, CoverageAfterKnown
          % determinism: multi
          ( % conjunction
            % nonlocals: GoalTrivial
            % determinism: det
            GoalTrivial = bug85.goal_is_nontrivial
            ,
            % nonlocals: CoverageAfterKnown0, GoalExpr0, CPOptions, IsMDProfInst, GoalTrivial, CoverageAfterKnown
            % determinism: multi
            (if
              % nonlocals: CoverageAfterKnown0, GoalExpr0, IsMDProfInst, GoalTrivial
              % determinism: nondet
              ( % disjunction
                % nonlocals: IsMDProfInst
                % determinism: semidet
                IsMDProfInst = bug85.goal_is_mdprof_inst
              ;
                % nonlocals: CoverageAfterKnown0
                % determinism: semidet
                CoverageAfterKnown0 = bug85.coverage_after_known
              ;
                % nonlocals: GoalTrivial
                % determinism: semidet
                GoalTrivial = bug85.goal_is_trivial
              ;
                % nonlocals: GoalExpr0
                % determinism: semidet
                ( % conjunction
                  % nonlocals: GoalExpr0, V_42
                  % determinism: semidet
                  GoalExpr0 = bug85.conj(V_42, V_25)
                  ,
                  % nonlocals: V_42
                  % determinism: semidet
                  V_42 = bug85.plain_conj
                )
              )




    View Issue Details
    72 [mercury] Bug minor always 2008-08-02 18:16 2008-09-17 08:33
    iamphet  
    petdr  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Erroneous reference to snprintf when compiling mercury_wrapper.c with MSVC
    There are several several references to snprintf in mercury_wrapper.c without autoconf checks.

    It seems the correct way is to add lines below at the top of the file

    #if defined(MR_HAVE__SNPRINTF) && ! defined(MR_HAVE_SNPRINTF)
      #define snprintf _snprintf
    #endif
     
    Notes
    (0000149)
    petdr   
    2008-09-17 08:33   
    I applied three patches on 2008-09-16, one of which fixes this bug. The three patches find a 64 bit integer, detect no unistd.h when compiler flex c code and finally fixing this bug.




    View Issue Details
    74 [mercury] Bug crash always 2008-08-07 02:32 2008-09-02 04:42
    obo  
     
    normal  
    confirmed  
    open  
    none    
    none  
       
    abstract data types in type classes get garbled on x64
    The attached code is a reduced version of bug 0000073 (please close bug 0000073).

    What happens is that the method recombine/1 of typeclass stackable/3 instantiated by the predicate myrecombine/1 gets called with a bad type information on 64-bit machines (rotd-2008-08-03):

    18:15 tauri4 nano-nano$./bug_x64_typeclass
    insprune calls recombine: bug_x64_typeclass.h(string, string)
    Recombining: bug_x64_typeclass.h(bug_x64_typeclass.h(string, string), bug_x64_typeclass.h(string, string))
    Uncaught Mercury exception:
    Software Error: type screwed up

    On 32-bit machines (rotd-2007-08-13, I don't have a fresher version, sorry), the code works.
    bug_x64_typeclass.m (1,940 bytes) 2008-08-07 02:32
    https://bugs.mercurylang.org/file_download.php?file_id=61&type=bug
     
    Notes
    (0000117)
    juliensf   
    2008-08-07 15:27   
    The same also occurs on 32-bit machines with rotd-2008-08-06.
    (0000144)
    juliensf   
    2008-09-02 04:41   
    The problem here is that the current Mercury RTTI implementation does not supported
    "complicated" typeclass constraints like the following:

    :- pred myrecombine(h(OCC, OC)::in) is semidet <= (stackable(h(OCC, OC), float, string)).

    Currently, the parameters of typeclass constraints can only be type variables or types
    with no arguments. Anything else, like h(OCC, OC), (probably) won't work.




    View Issue Details
    82 [mercury] Bug major always 2008-08-25 14:38 2008-08-27 14:05
    maclarty  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Functions returning a wrapped dummy type cause invalid c code to be generated in grade hlc.gc
    Compiling the attached code yields:

    $ mmc --make --grade hlc.gc main
    Making Mercury/int3s/main.int3
    Making Mercury/int3s/mod1.int3
    Making Mercury/ints/main.int
    Making Mercury/ints/mod1.int
    Making Mercury/cs/main.c
    Making Mercury/cs/mod1.c
    Making Mercury/os/main.o
    main.m: In function `main_2_p_0':
    main.m:14: error: void value not ignored as it ought to be
    ** Error making `Mercury/os/main.o'.

    $ mmc --version
    Mercury Compiler, version rotd-2008-08-20, configured for i686-pc-linux-gnu
    main.m (186 bytes) 2008-08-25 14:38
    https://bugs.mercurylang.org/file_download.php?file_id=64&type=bug
    mod1.m (192 bytes) 2008-08-25 14:39
    https://bugs.mercurylang.org/file_download.php?file_id=65&type=bug
     
    Notes
    (0000142)
    wangp   
    2008-08-26 11:40   
    The problem is that there are three kinds of dummy types, but the code which
    generates .int files only recognises two of them. No-tag dummy types need
    to have their definitions written out to .int files, so importing modules
    will know they are dummy types. I am working on this.
    (0000143)
    wangp   
    2008-08-27 14:05   
    Patch committed




    View Issue Details
    81 [mercury] Bug minor always 2008-08-22 16:00 2008-08-22 16:00
    juliensf  
    juliensf  
    normal  
    assigned  
    open  
    none    
    none  
       
    failure of hard_coded/tl_backjump_test with --intermodule-optimization
    This is failing because the compiler is not adding a foreign_import_module declaration
    to thread.opt for the thread module.
     
    There are no notes attached to this issue.




    View Issue Details
    76 [mercury] Bug minor always 2008-08-14 15:13 2008-08-22 13:12
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    --make-opt-int incorrectly handles existentially typed methods
    The compiler aborts when making a .opt file if the module contains a
    typeclass instance which implements a method with existentially typed
    arguments, but the predicate which implements the method is not itself
    existentially typed, e.g.

        :- typeclass dynamic_block(T) where [
        some [Q] pred generate_block(T::in, Q::out) is det
        ].

        :- instance dynamic_block(simple_dynamic_block) where [
        pred(generate_block/2) is do_generate_block
        ].

        :- pred do_generate_block(simple_dynamic_block::in, string::out) is det.

    % mmc --make-opt-int intermod_typeclass_exist
    Uncaught Mercury exception:
    Software Error: pred_table.m: Unexpected: type error in pred call: no matching pred
    Stack dump follows:
       0 pred exception.throw/1-0 (erroneous) (exception.m:388)
       1 pred require.error/1-0 (erroneous) (require.m:122)
       2 pred libs.compiler_util.unexpected/2-0 (erroneous) (compiler_util.m:87)
       3 pred hlds.pred_table.resolve_pred_overloading/7-0 (det) (pred_table.m:983)
       4 pred transform_hlds.intermod.qualify_instance_method/5-0 (det) (intermod.m:907)
       5 pred list.map_foldl/5-1 (det) (list.m:2292)
       6 pred transform_hlds.intermod.gather_instances_3/5-0 (det) (intermod.m:822)
       7 pred list.foldl/4-1 (det) (list.m:2164)
       8 pred transform_hlds.intermod.gather_instances_2/5-0 (det) (intermod.m:786)
       9 2* pred tree234.foldl/4-0 (det) (tree234.m:2506 and others)
      11 pred map.foldl/4-0 (det) (map.m:863)
      12 pred transform_hlds.intermod.gather_instances/2-0 (det) (intermod.m:779)
      13 pred transform_hlds.intermod.write_opt_file/4-0 (det) (intermod.m:171)
      14 pred top_level.mercury_compile.maybe_write_optfile/7-0 (det) (mercury_compile.m:2287)
      15 pred top_level.mercury_compile.frontend_pass_no_type_error/9-0 (det) (mercury_compile.m:2238)
      16 pred top_level.mercury_compile.frontend_pass/11-0 (det) (mercury_compile.m:2110)
      17 pred top_level.mercury_compile.mercury_compile/8-0 (det) (mercury_compile.m:1499)
      18 pred top_level.mercury_compile.compile/10-0 (det) (mercury_compile.m:1478)

    intermod_typeclass_exist.m (1,037 bytes) 2008-08-14 15:13
    https://bugs.mercurylang.org/file_download.php?file_id=63&type=bug
     
    Notes
    (0000141)
    wangp   
    2008-08-22 13:12   
    Patch committed 2008-08-22.




    View Issue Details
    65 [mercury] Bug minor always 2008-07-03 15:22 2008-08-07 11:20
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    probable bug in .stseg grades
    We can't bootcheck in asm_fast.gc.decldebug.stseg. This is on saturn. The
    compiler crashes when trying to make the stage 2 dependencies:

    % MERCURY_OPTIONS= mmake depend
    ...
    make[1]: *** [mer_std.depend] Illegal instruction
    make[1]: Leaving directory `/home/saturn/wangp/ws_try_debug_stseg_bootcheck/stage2/library'


    The crash goes away if you bump up the nondet stack size (e.g. --nondetstack-size 8192).
    nondet_stseg.m (1,413 bytes) 2008-07-18 17:09
    https://bugs.mercurylang.org/file_download.php?file_id=53&type=bug
    nondetstseg2.diff (15,373 bytes) 2008-08-01 14:53
    https://bugs.mercurylang.org/file_download.php?file_id=57&type=bug
     
    Notes
    (0000105)
    wangp   
    2008-07-18 17:12   
    I think this has nothing to do with debugging. The nondet stack segments
    code seems just not to have been tested before.

    The attached program crashes in asm_fast.gc.stseg if you set
    MERCURY_OPTIONS=--nondet-stack-size <n> low enough to require more nondet
    stack segments.

    ----

    Some debugging notes:

    * MR_nondetstack_extend_and_check calls MR_new_nondetstack_segment with
    a second argument `incr', which is MR_NONDET_FIXED_SIZE + n. But we add
    MR_NONDET_FIXED_SIZE again in MR_new_nondetstack_segment so
    MR_NONDET_FIXED_SIZE is added twice.

    * The start of MR_pop_nondetstack_segment is:

        orig_maxfr = (MR_Word *) MR_stackvar(1);
        orig_succip = (MR_Code *) MR_stackvar(2);

    which looks suspiciously close to the corresponding lines in
    MR_pop_detstack_segment. I think the value of maxfr should be restored from
    the nondet stack, given that's where it's saved. And what's succip doing here?
    (0000110)
    wangp   
    2008-08-01 14:57   
    nondetstseg2.diff contains my attempt to fix this.
    MR_pop_nondetstack_segment() seems to pop off the top stack segment correctly
    now. However, it seems MR_pop_nondetstack_segment() can be called prematurely
    (I'm not sure why) leading to missing solutions.

    Uploading the incomplete fix in case zs or someone else knows what to do.
    (0000115)
    wangp   
    2008-08-07 11:20   
    Fix committed 2008-08-07.




    View Issue Details
    69 [mercury] Bug minor always 2008-07-23 20:02 2008-07-23 21:06
    pbone  
     
    low  
    new  
    open  
    none    
    none  
       
    Deep profiling tools can have integer overflows.
    The deep profiler and it's tools use machine word sized integers. (the int type in mercury). On 32 bit machines these values can be overflowed by a long-enough profiling run. Since the int type is a signed integer this can result in negative numbers.

    This can be seen with the icfp2000 program in the 'bytes allocated' statistic of the float.+ and float.* functions.
     
    Notes
    (0000106)
    juliensf   
    2008-07-23 21:06   
    This has come up before. IIRC, there is not a good solution (other than to use a 64-bit machine)
    since the Mercury code in the deep profiler also needs to manipulate these values.
    One thing which might alleviate the problem somewhat is to support unsigned integers
    as atomic types in Mercury.




    View Issue Details
    63 [mercury] Bug minor always 2008-06-26 10:52 2008-06-26 10:52
    pbone  
     
    normal  
    new  
    open  
    none    
    none  
       
    mdprof_cgi gets confused about the webserver's port number.
    When running mdprof_cgi through apache as normal. And accessing it both directly and with ssh port-forwarding from a remote host (via a different TCP port) it places the wrong port number in URLs.
    It seems that the first use of mdprof_cgi causing it to start the backend server sets the port number (and probably hostname and path to cgi executable). for future sessions.

    To work-around this issue when accessing mdprof_cgi via a different url than used earlier, kill the background process. This doesn't scale to allow concurrent access.
     
    There are no notes attached to this issue.




    View Issue Details
    62 [mercury] Bug minor have not tried 2008-06-06 13:01 2008-06-06 18:33
    pbone  
    juliensf  
    low  
    resolved  
    duplicate  
    none    
    none  
       
    Compiler crashes at bad end_module declaration.
    When i mis-spell the end_module declaration differently to the module declaration, the complier crashes. This seems reproducible but I have not written a test case.
    pbone@plum:~/mercury/mdprof_data_structure/deep_profiler$ mmake
    /usr/local/mercury/bin/mmc --make-interface --grade asm_fast.gc --mercury-linkage static --flags DEEP_FLAGS percent_adt
    Uncaught Mercury exception:
    Software Error: modules.m: Unexpected: standardize_impl_items: unexpected items
    Stack dump not available in this grade.
    make: *** [percent_adt.date] Error 1

    pbone@plum:~/mercury/mdprof_data_structure/deep_profiler$ /usr/local/mercury/bin/mmc --version
    Mercury Compiler, version rotd-2008-02-11, configured for i686-pc-linux-gnu
    Copyright (C) 1993-2008 The University of Melbourne

    pbone@plum:~/mercury/mdprof_data_structure/deep_profiler$ gcc --version
    gcc (GCC) 4.1.2 (Ubuntu 4.1.2-0ubuntu4)
    Copyright (C) 2006 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
     
    There are no notes attached to this issue.




    View Issue Details
    61 [mercury] Bug minor always 2008-06-03 18:40 2008-06-03 18:41
    maclarty  
     
    normal  
    new  
    open  
    none    
    none  
       
    problem with _init suffix in module names
    If the main predicate is defined in module 'test', and module 'test' imports module 'test_init', then running mmc --make results in the following link error:

    ** Error making `test'.
    Mercury/os/test_init.o: In function `<predicate 'test_init.p'/2 mode 0>':
    test_init.c:(.text+0x14): multiple definition of `<predicate 'test_init.p'/2 mod
    e 0>'
    Mercury/os/test_init.o:test_init.c:(.text+0x14): first defined here
    Mercury/os/test_init.o: In function `mercury__test_init__init_debugger':
    test_init.c:(.text+0x20): multiple definition of `mercury__test_init__init_debug
    ger'
    Mercury/os/test_init.o:test_init.c:(.text+0x20): first defined here
    Mercury/os/test_init.o: In function `mercury__test_init__init':
    test_init.c:(.text+0x40): multiple definition of `mercury__test_init__init'
    Mercury/os/test_init.o:test_init.c:(.text+0x40): first defined here
    Mercury/os/test_init.o: In function `mercury__test_init__init_type_tables':
    test_init.c:(.text+0x70): multiple definition of `mercury__test_init__init_type_
    tables'
    Mercury/os/test_init.o:test_init.c:(.text+0x70): first defined here
    /usr/lib/gcc/i486-linux-gnu/3.4.6/../../../../lib/crt1.o: In function `_start':
    ../sysdeps/i386/elf/start.S:115: undefined reference to `main'
    collect2: ld returned 1 exit status

    test.m (162 bytes) 2008-06-03 18:40
    https://bugs.mercurylang.org/file_download.php?file_id=49&type=bug
    test_init.m (122 bytes) 2008-06-03 18:41
    https://bugs.mercurylang.org/file_download.php?file_id=50&type=bug
     
    There are no notes attached to this issue.




    View Issue Details
    55 [mercury] Bug major always 2008-03-29 02:38 2008-06-02 15:06
    obo  
     
    normal  
    confirmed  
    open  
    none    
    none  
       
    typeclass instances for e.g. bag(T) no longer work
    with rotd-2008-03-27, the attached file bug.m gives the following error:

    bug.m:001: Warning: interface for module `bug' does not export anything.
    bug.m:011: In instance declaration for `bug.fooable((bag.bag(V)))':
    bug.m:011: the first arg contains a type variable which is used in another
    bug.m:011: arg

    with rotd-2007-08-13, the same code was compilable and worked as expected.


    When I tried to avoid the type variable by instantiating the typeclass for eg. bag(string) specifically, the recent ROTD gives me this error:

    testhugemap.m:047: In instance declaration for
    testhugemap.m:047: `pickle.tc_picklable((bag.bag(string)))':
    testhugemap.m:047: the first arg is a type whose first arg is not a variable

    What is the correct way of instantiating such typeclasses?

    Thanks, Ondrej.


    bug.m (206 bytes) 2008-03-29 02:38
    https://bugs.mercurylang.org/file_download.php?file_id=47&type=bug
     
    Notes
    (0000096)
    mark   
    2008-03-29 12:00   
    The basic problem is the following restriction from the
    reference manual:

        "The types in an instance declaration must not be abstract
        types which are elsewhere defined as equivalence types."

    bag/1 is an abstract type that happens to be defined as an
    equivalence type.

    The error message is just plain wrong, however.
    (0000103)
    juliensf   
    2008-06-02 15:06   
    I have changed the definition of bag/1 so that it can be used in type class instances --
    the issue with the error message is still a bug though.




    View Issue Details
    56 [mercury] Bug major always 2008-04-09 12:52 2008-05-26 13:13
    wangp  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    compiler crashes in decldebug grade
    The stage1 compiler crashes in decldebug grades. The workaround is:

    MCFLAGS-check_hlds.polymorphism = --no-common-struct
    MCFLAGS-transform_hlds.lambda = --no-common-struct
     
    Notes
    (0000102)
    zs   
    2008-05-26 13:13   
    Fix posted May 26.




    View Issue Details
    60 [mercury] Bug minor always 2008-04-29 13:51 2008-04-29 13:51
    wangp  
     
    normal  
    new  
    open  
    none    
    none  
       
    inconsistent type_infos after type specialisation?
    The following test case the compiler aborts with the message:

    % mmc my
    Uncaught Mercury exception:
    Software Error: hlds_rtti.m: Unexpected: inconsistent type_infos
    Stack dump follows:
       0 pred exception.throw_impl/1-0 (erroneous) (exception.m:817)
       1 pred exception.throw/1-0 (erroneous) (exception.m:388)
       2 pred require.error/1-0 (erroneous) (require.m:122)
       3 pred libs.compiler_util.unexpected/2-0 (erroneous) (compiler_util.m:87)
       4 pred hlds.hlds_rtti.apply_substs_to_type_map/7-0 (det) (hlds_rtti.m:642)
       5 2* pred tree234.foldl/4-0 (det) (tree234.m:2492 and others)
       7 pred map.foldl/4-0 (det) (map.m:871)
       8 pred hlds.hlds_rtti.apply_substitutions_to_rtti_varmaps/5-0 (det) (hlds_rtti.m:565)
       9 pred check_hlds.simplify.excess_assigns_in_conj/5-0 (det) (simplify.m:2919)
      10 pred check_hlds.simplify.simplify_goal_2_plain_conj/6-0 (det) (simplify.m:889)
      11 pred check_hlds.simplify.simplify_goal_2/6-0 (det) (simplify.m:836)
      12 pred check_hlds.simplify.simplify_goal/4-0 (det) (simplify.m:766)
      13 pred check_hlds.simplify.do_process_clause_body_goal/4-0 (det) (simplify.m:541)
      14 pred check_hlds.simplify.simplify_process_clause_body_goal/4-0 (det) (simplify.m:526)
      15 pred transform_hlds.pd_util.pd_simplify_goal/5-0 (det) (pd_util.m:254)
      16 pred transform_hlds.deforest.deforest_proc_2/7-0 (det) (deforest.m:212)
      17 pred transform_hlds.deforest.deforest_proc/5-0 (det) (deforest.m:193)
      18 17* pred list.foldl2/6-5 (det) (list.m:2056 and others)
      35 pred transform_hlds.deforest.deforestation/4-0 (det) (deforest.m:121)
      36 pred top_level.mercury_compile.maybe_deforestation/6-0 (det) (mercury_compile.m:3942)
      37 pred top_level.mercury_compile.middle_pass/7-0 (det) (mercury_compile.m:2668)
      38 pred top_level.mercury_compile.mercury_compile_after_front_end/10-0 (det) (mercury_compile.m:1588)
      39 pred top_level.mercury_compile.mercury_compile/8-0 (det) (mercury_compile.m:1531)
      40 pred top_level.mercury_compile.compile/10-0 (det) (mercury_compile.m:1464)
      ...
    bug.tar.gz (724 bytes) 2008-04-29 13:51
    https://bugs.mercurylang.org/file_download.php?file_id=48&type=bug
     
    There are no notes attached to this issue.




    View Issue Details
    57 [mercury] Bug minor always 2008-04-10 11:51 2008-04-10 11:51
    juliensf  
    mark  
    normal  
    assigned  
    open  
    none    
    none  
       
    --common-struct inhibits tail call optimisation
    In some cases --common-struct is introducing extra assignment unifications after
    recursive calls. This is inhibiting tail call recursion.

    The test case for bug 0000042 exhibits this problem (see the notes for that problem.)


     
    There are no notes attached to this issue.




    View Issue Details
    52 [mercury] Bug minor always 2008-03-13 17:07 2008-03-27 23:42
    maclarty  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    rebuilding a program with a mutable in a different grade causes invalid c to be generated
    Compile the attached program in hlc.gc and then rebuild in asm_fast.gc and the c compiler gives an error:

    jupiter:/home/jupiter/maclarty/mut> mmc --make mut --grade hlc.gc
    Making Mercury/int3s/mut.int3
    Making Mercury/ints/mut.int
    Making Mercury/cs/mut.c
    Making Mercury/os/mut.o
    Making mut
    jupiter:/home/jupiter/maclarty/mut> ./mut
    1
    jupiter:/home/jupiter/maclarty/mut> mmc --make mut --grade asm_fast.gc
    Making mut
    ** Error making `mut'.
    Mercury/os/mut_init.o(.text+0x458): In function `mercury_init':
    : undefined reference to `<predicate 'main'/2 mode 0>'
    Mercury/os/mut.o(.text+0x1a): In function `<predicate 'main'/2 mode 0>':
    : undefined reference to `<predicate 'io.write_int'/3 mode 0>'
    Mercury/os/mut.o(.text+0x22): In function `<predicate 'main'/2 mode 0>':
    : undefined reference to `<predicate 'io.nl'/2 mode 0>'
    collect2: ld returned 1 exit status
    mut.m (247 bytes) 2008-03-13 17:07
    https://bugs.mercurylang.org/file_download.php?file_id=46&type=bug
     
    Notes
    (0000087)
    juliensf   
    2008-03-13 17:30   
    That's happening because the .mh file that is built in the hlc.gc grade is not
    replaced when the program is re-compiled in asm_fast.gc (since the timestamp
    on the .m file won't have changed). The hlc and asm_fast versions of the
    program use different C types in the mutable definition which is why it fails
    to compile.

    The are already two solutions to this:

    (1) do a --make mut.realclean before rebuilding the program in a different grade.

    or, if you wish to support multiple grades simulatenously

    (2) use --use-grade-subdirs
    (0000088)
    maclarty   
    2008-03-14 12:08   
    The problem still occurs with --use-grade-subdirs in the original program. The test case I submitted does however work with --use-grade-subdirs. I'll see if I can create another test case that exhibits the problem when --use-grade-subdirs is enabled.
    (0000089)
    juliensf   
    2008-03-15 01:25   
    The bug here is that the compiler doesn't consider .mh files to be grade
    dependent when in fact they are because the types of the global variables
    used to implement mutables will vary depending on whether the high-level
    or low-level C backend is being used.

    This can be fixed by writing both mutable declarations to the .mh
    file and use #ifdef MR_HIGHLEVEL_CODE to conditionally include only
    one of them.

    (A alternative fix is to make the .mh files grade dependent but this is
    more involved as it will invovle chaning the way that libraries
    are installed.)
    (0000093)
    juliensf   
    2008-03-27 23:42   
    Fix committed. See log message for r1.77 of compiler/make_hlds_passes.m for details.




    View Issue Details
    33 [mercury] Bug major always 2007-12-20 15:54 2008-03-26 15:36
    maclarty  
    mark  
    normal  
    assigned  
    open  
    none    
    none  
       
    Compiler abort when generating low level code
    Running "mmc --make bug" on the attached source files results in the following abort from the compiler:

    Software Error: map.lookup: key not found
            Key Type: term.var(parse_tree.prog_data.prog_var_type)
            Key Value: var(81)
            Value Type: ll_backend.var_locn.var_state

    The abort happens after:
    % Generating low-level (LLDS) code for predicate `bug.test'/4 mode 0

    Turning off all optimisations makes no difference.

    I trimmed the test case down as much as I could, but any further changes seem to make the bug go away.

    I'm using rotd-2007-12-19 on jupiter.
     
    Notes
    (0000066)
    wangp   
    2007-12-20 17:19   
    I had a quick look at it. The bug is related to the fact that the second argument of the call to bug.load (TypeClassInfo_for_rdfStoreTStore_81) is not used elsewhere, so doesn't appear in the non-local set for that goal.
    (0000067)
    wangp   
    2007-12-20 17:39   
    At 035-modecheck var(81) is not in the non-local set of the bug.load call as it is not used later. It also doesn't appear in the instmap delta.

    After 110-lambda, var(81) *is* used later and does appear in the non-local set. But it is *not* in the instmap delta.
    (0000068)
    zs   
    2007-12-20 19:07   
    Instmap deltas are always restricted to the nonlocal set. The problem is the fact that the lambda transformation is including TypeClassInfo_for_rdfStoreTStore_81 in the argument list of the new lambda predicate, even though it isn't used. If it weren't there, then the construction of the closure wouldn't need its value.

    The underlying problem, as so many times before, is the inclusion of typeinfos in typeclassinfos. The argument list of the lambda predicate includes variables of type S, therefore the typeinfo of type S must be included in the argument list.

    In this case, TypeClassInfo_for_rdfStore_80 would be sufficient, but lambda.m does not know that. In fact, the relevant code in lambda.m, around line 354, does not seem to know about typeclassinfos as anything distinct from typeinfos at all. I think the short term fix would be to fix this state of affairs.

    If mantis would let me, I would unassign myself from this bug.
    (0000069)
    zs   
    2007-12-20 19:36   
    Another possible fix would be, when restricting the instmap_delta of the original goal to its nonlocal set, to have mode analysis *notice* that it is deleting a typeinfo or typeclass info from the instmap delta, and to delete those variables from the rtti varmaps as well (since a typeinfo or typeclassinfo that isn't referred to anywhere doesn't do one any good in those maps). The right person for this fix would be Mark.




    View Issue Details
    48 [mercury] Bug minor always 2008-02-28 02:55 2008-03-26 15:32
    juliensf  
    mark  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    compiler abort in .decldebug grade
    Compiling compiler/analysis.m in asm_fast.gc.decldebug on pluto (linux-x86_64) results in

    Uncaught Mercury exception:
    Software Error: map.lookup: key not found
    Key Type: term.var(parse_tree.prog_data.prog_var_type)
    Key Value: var(160)
    Value Type: ll_backend.var_locn.var_state

    This Mercury compiler used was rotd-2008-02-27.
    Compiling the affected module with -O0 makes the problem go away.
    DIFF.55_65 (11,818 bytes) 2008-02-28 16:27
    https://bugs.mercurylang.org/file_download.php?file_id=41&type=bug
     
    Notes
    (0000080)
    juliensf   
    2008-02-28 03:03   
    I've added the workaround for this to compiler/Mercury.options and committed it.
    (0000081)
    juliensf   
    2008-02-28 11:45   
    --common-struct seems to be triggering the problem. The bug does not occur with
    --no-common-struct.
    (0000082)
    zs   
    2008-02-28 16:33   
    The problem is caused by one or more bugs in common.m, as shown by the attached diff between the HLDS dumps at level 55 and 65. The diff shows that common.m finds and eliminates several common structures, most of which are type_infos or type_ctor_infos, and one of which is an ordinary field of the analysis_info structure. I have visually examined the diff and I think all these changes in the code are fine.

    The problems lie in the changes to the rtti var maps. The diff shows some updates to type_class_info maps that I don't think should be there. It does NOT show updates to type_info maps that SHOULD be there. Common.m eliminates several type_info variables, replacing them with references to other, identical type_info variables, but does not update the rtti_var_maps. (common.m was written BEFORE we added rtti_var_maps.) I believe these dangling references that cause the bug symptom.
    (0000083)
    juliensf   
    2008-02-28 17:13   
    For reference, this is r1.2 of compiler/analysis.m.
    (0000091)
    mark   
    2008-03-26 12:51   
    I've committed one fix to some dangling references left by common.m
    (26/3/2008). This allows compilation of analysis.m to complete.
    However, similar segfaults have been reported in the G12 project,
    so I'll leave this bug open and investigate further.
    (0000092)
    mark   
    2008-03-26 15:32   
    The other failures were caused by a different bug,
    which I have reported as bug 0000054




    View Issue Details
    54 [mercury] Bug minor always 2008-03-26 15:28 2008-03-26 15:28
    mark  
    mark  
    normal  
    assigned  
    open  
    none    
    none  
       
    rtti_varmaps not updated by follow_code
    The rtti_varmaps data structure keeps track of which program
    variables hold which type(class)_infos. When follow_code migrates
    an existentially typed deconstruction into the branches of a
    branched goal, a type(class)_info that was accessed from one
    location is now accessed from multiple locations -- none of
    which is correct in all cases.
     
    There are no notes attached to this issue.




    View Issue Details
    49 [mercury] Bug minor always 2008-02-28 18:36 2008-03-17 17:21
    juliensf  
     
    normal  
    new  
    open  
    none    
    none  
       
    loop invariant hoisting causes MLDS backend to abort
    The attached program causes the MLDS backend to abort when compiled in a hl or hlc grade
    with:

    mmc -C -O0 --common-struct --loop-invariants

    The problem seems to be related to the fact that calls to array.init/1 are being incorrectly
    hoisted (presumably because they arrays are not unique at the moment.)

    The LLDS backend compiles this code down to what is invalid C code (at least on eris).

    colgen_dw.m (1,777 bytes) 2008-02-28 18:36
    https://bugs.mercurylang.org/file_download.php?file_id=42&type=bug
    str_loopinv.m (2,913 bytes) 2008-03-05 17:17
    https://bugs.mercurylang.org/file_download.php?file_id=45&type=bug
     
    Notes
    (0000084)
    wangp   
    2008-03-05 17:21   
    I added a second test case which seems like it might be the same bug, only the abort happens with the LLDS backend.

      mmc -O0 --common-struct --inlining --loop-invariants str_loopinv.m

    In str_loopinv.loop_inv_0__func__float_to_string_2__40__1 the non-local sets for the calls to str_loopinv.append_iio are wrong.

    Also, both cases are fine with rotd-2008-01-19 so something was broken between then and now.
    (0000085)
    juliensf   
    2008-03-05 17:29   
    Actually the invalid C code problem on eris is a red herring. It's due to the asm_fast grades
    not being supported on that platform.
    (0000090)
    wangp   
    2008-03-17 17:21   
    (Last edited: 2008-03-17 17:22)
    I think the bug is somewhere in the stm change posted by zs on 25/02. The problem doesn't occur for the version retrieved with "cvs up -D 2008-02-27" but does for the version retrieved with "cvs up -D '2008-02-27 19:00'".

    Or at least, that was when some previous problem was exposed.





    View Issue Details
    43 [mercury] Bug minor always 2008-02-04 17:14 2008-03-05 18:51
    wangp  
    wangp  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    intermod unused args analysis and typeclass constraints
    The compiler aborts on the following module, when performing unused argument
    analysis while making the intermodule optimisation file, i.e.

    mmc --intermod-unused-args --make-optimisation-interface bug


    The seems to require these conditions:

    a function f has a typeclass constraint, and
    f is type specialised, and
    the type that f is specialised for is polymorphic

    Here's a stack trace.

    Uncaught Mercury exception:
    Software Error: map.lookup: key not found
            Key Type: term.var(parse_tree.prog_data.tvar_type)
            Key Value: var(1)
            Value Type: hlds.hlds_rtti.type_info_locn
    Stack dump follows:
       0 pred exception.throw_impl/1-0 (erroneous) (exception.m:816)
       1 pred exception.throw/1-0 (erroneous) (exception.m:388)
       2 pred require.error/1-0 (erroneous) (require.m:122)
       3 pred require.report_lookup_error/3-0 (erroneous) (require.m:98)
       4 pred map.lookup/3-0 (det) (map.m:612)
       5 pred hlds.hlds_rtti.rtti_lookup_type_info_locn/3-0 (det) (hlds_rtti.m:438)
       6 pred transform_hlds.unused_args.lambda_unused_args_m_553/3-0 (det) (unused_args.m:554)
       7 pred list.map/3-0 (det) (list.m:1890)
       8 pred transform_hlds.unused_args.setup_typeinfo_dep/6-0 (det) (unused_args.m:553)
       9 pred transform_hlds.unused_args.setup_typeinfo_deps/6-0 (det) (unused_args.m:544)
      10 pred transform_hlds.unused_args.setup_proc_args/12-0 (det) (unused_args.m:503)
      11 pred transform_hlds.unused_args.setup_pred_args/12-0 (det) (unused_args.m:379)
      12 pred transform_hlds.unused_args.maybe_setup_pred_args/11-0 (det) (unused_args.m:365)
      13 91* pred transform_hlds.unused_args.setup_local_var_usage/11-0 (det) (unused_args.m:336 and others)
     104 pred transform_hlds.unused_args.init_var_usage/7-0 (det) (unused_args.m:323)
     105 pred transform_hlds.unused_args.process_module/6-0 (det) (unused_args.m:224)
     106 pred top_level.mercury_compile.maybe_unused_args/6-0 (det) (mercury_compile.m:4004)
     107 pred top_level.mercury_compile.maybe_write_optfile/7-0 (det) (mercury_compile.m:2336)
     108 pred top_level.mercury_compile.frontend_pass_no_type_error/9-0 (det) (mercury_compile.m:2242)
     109 pred top_level.mercury_compile.frontend_pass/11-0 (det) (mercury_compile.m:2120)
     110 pred top_level.mercury_compile.mercury_compile/8-0 (det) (mercury_compile.m:1518)
     111 pred top_level.mercury_compile.compile/10-0 (det) (mercury_compile.m:1497)
    bug.m (252 bytes) 2008-02-04 17:14
    https://bugs.mercurylang.org/file_download.php?file_id=36&type=bug
     
    Notes
    (0000086)
    wangp   
    2008-03-05 18:51   
    Patch committed 2008-03-05.




    View Issue Details
    47 [mercury] Bug minor always 2008-02-25 11:43 2008-02-25 13:29
    user57  
     
    normal  
    new  
    open  
    none    
    none  
       
    mutable dependency problem
    The program (attached) contains two mutables `a' and `b' whose initialisation mutually depends on each other. Thus to initialise `a' we need the value of `b' and vice versa. Mercury does not detect this problem, and happily compiles the program, which (unsurprisingly) seg. faults when you try and run it.

    Note that non-mutual dependencies may also be a problem, depending on the order the mutables are initialised. This is how the bug was discovered.
    crash.m (485 bytes) 2008-02-25 11:43
    https://bugs.mercurylang.org/file_download.php?file_id=40&type=bug
     
    Notes
    (0000079)
    juliensf   
    2008-02-25 13:29   
    In *this* case it could be detected, but in general it is not possible to detect this at compile-time.

    The order in which mutables are initialised is specified in the reference manual, for initialisations
    within a module it is:

        For the purposes of determining when mutables are assigned their initial values, the expression `initial_value' behaves as though it were a predicate specified in an `initialise' directive.

    There is no initialisation order assumed beteween (sub-)modules.

    As a matter of practice I recommend that mutable initialisation expressions should not call mutable
    access predicates (I will add this to the reference manual).




    View Issue Details
    44 [mercury] Bug major always 2008-02-07 16:44 2008-02-20 14:05
    juliensf  
    zs  
    high  
    resolved  
    fixed  
    none    
    none  
       
    compiler abort in debug grades
    The attached program causes the compiler to abort in (decl)debug grades with the
    following error:

    Uncaught Mercury exception:
    Software Error: llds_out.m: Unexpected: stack var out of range

    Compile with:

    mmc --grade asm_fast.gc.tr.debug -C fzn_debug_abort.m
    fzn_debug_abort.m (2,638 bytes) 2008-02-07 16:44
    https://bugs.mercurylang.org/file_download.php?file_id=37&type=bug
     
    Notes
    (0000074)
    zs   
    2008-02-07 21:27   
    There are two reasons for the abort. First, unify_gen.m wasn't checking whether a variable it was adding to a closure was of dummy type or not. (The abort is when writing out the code that constructs the closure.) I have a fix for that. Second,
    the code for recognizing whether a type is dummy or not recognized only two cases: builtin dummy types such as io.state, and types with one function symbol of arity zero. In this program, there is a notag wrapper around a dummy type. Since the representation of a notag type is always the same as the type it wraps, this notag type should be recognized as a dummy type too. I am still working on that.
    (0000078)
    zs   
    2008-02-20 14:05   
    fix committed feb 12.




    View Issue Details
    45 [mercury] Bug minor always 2008-02-19 15:26 2008-02-20 14:03
    maclarty  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    mdb not using format params from .mdbrc
    Compile the attached mdb.m in a debug grade.

    Put the attached .mdbrc file in the same directory as the executable.

    Run:

    mdb ./mdb
    Melbourne Mercury Debugger, mdb version rotd-2008-01-16.
    Copyright 1998-2008 The University of Melbourne, Australia.
    mdb is free software, covered by the GNU General Public License.
    There is absolutely no warranty for mdb.
           1: 1 1 CALL pred mdb.main/2-0 (det) mdb.m:13
    mdb> step
           2: 2 2 CALL func list.../2-0 (det) list.m:2561 (mdb.m:14)
    mdb> finish
         817: 2 2 EXIT func list.../2-0 (det) list.m:2561 (mdb.m:14)
    mdb> p 3
           List (arg 3)
    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...]
    mdb> source .mdbrc
    mdb> p 3
           List (arg 3)
    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
     22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
     41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
     60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
     79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97,
     98, 99, 100]
    mdb>

    The source command should not be necessary for the format_param commands in .mdbrc to take effect.
    .mdbrc (50 bytes) 2008-02-19 15:26
    https://bugs.mercurylang.org/file_download.php?file_id=38&type=bug
    mdb.m (190 bytes) 2008-02-19 15:26
    https://bugs.mercurylang.org/file_download.php?file_id=39&type=bug
     
    Notes
    (0000077)
    zs   
    2008-02-20 14:03   
    fix committed feb 20




    View Issue Details
    46 [mercury] Bug minor always 2008-02-19 18:40 2008-02-20 13:44
    juliensf  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    regression of general/det_complicated_unify in grade asm_fast.gc.profdeep
    The test case general/det_complicated_unify causes the compiler to abort in
    grade asm_fast.gc.profdeep with the following:

    Uncaught Mercury exception:
    Software Error: llds_out.m: Unexpected: stack var out of range

    The test case passes in non .profdeep grades.
     
    Notes
    (0000076)
    zs   
    2008-02-20 13:44   
    Fix committed feb 20.




    View Issue Details
    30 [mercury] Bug minor always 2007-11-28 15:29 2008-01-23 12:49
    juliensf  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    break promise_equivalent_solutions
    Inlining can cause the insts of variables to change from any to ground
    and this, in turn, can cause erroneous error messages about promise_equivalent_solutions scopes that contain inst any variables in the scope head.

    The attached test case is a cut-down version of the optimised version
    of flatzinc_backend.m from the FlatZinc interpreter. This illustrates
    the problem.
    equiv_solns_ia.m (1,278 bytes) 2007-11-28 15:29
    https://bugs.mercurylang.org/file_download.php?file_id=23&type=bug
    equiv_solns_ia.m.new (1,624 bytes) 2007-11-28 16:50
    https://bugs.mercurylang.org/file_download.php?file_id=24&type=bug
     
    Notes
    (0000060)
    juliensf   
    2007-11-28 16:43   
    Actually, the current version of equiv_solns_ia.m strips away too
    much of the detail, and is actually an error. What is happening here
    is that re-running the check on the the non-local variables in promise_equivalent_solutions scopes should not be done after inlining.
    This is because after inlining the compiler may be able to infer that
    some things that previously had inst any are in fact ground.

    I'll add a new test case that demonstrates this.
    (0000061)
    juliensf   
    2007-11-28 16:52   
    (Last edited: 2007-12-05 15:04)
    The file equiv_solns.a.m.new contains a test case that exhibits the
    bug under something like the original conditions in which it occurred.

    Compile with: -C -O0 --inlining --local-constraint-propagation

    I think the fix here is not to perform the check on non-locals in
    promise_equivalent_solutions scopes after inlining has been performed.

    (0000072)
    juliensf   
    2008-01-23 12:49   
    Fixed. See log message for r1.142 of compiler/det_report.m for details.




    View Issue Details
    37 [mercury] Bug minor always 2008-01-15 11:39 2008-01-17 00:30
    juliensf  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    high-level C backend produces invalid C code
    The attached test case causes the high-level C backend tries to initialise static data using
    a function call (in order to box a float). The program compiles succesfully with the low-level
    backend.
    This test case was derived from code generated by the experimental Zinc-to-Mercury
    compiler.
    bad_static_data.m (1,195 bytes) 2008-01-15 11:39
    https://bugs.mercurylang.org/file_download.php?file_id=33&type=bug
     
    Notes
    (0000071)
    juliensf   
    2008-01-17 00:30   
    Fixed. See log message of r1.121 of compiler/ml_unify_gen.m for details.




    View Issue Details
    38 [mercury] Bug minor always 2008-01-16 14:02 2008-01-16 14:02
    rafe  
     
    normal  
    new  
    open  
    none    
    none  
       
    Compiler aborts in detism analysis with inst any case in negated context
    Try compiling this module:

    ===
    :- module negctxtbug.
    :- interface.
    :- import_module bool, list.

    :- pred any_square(list(list(T))::ia, bool::out) is det.

    :- implementation.
    :- import_module int.

    any_square(Xss, YN) :-
            N = any_length(Xss),
            promise_pure
            ( if all [Xs] (any_member(Xs, Xss) => any_length(Xs) = N)
              then YN = yes
              else YN = no
            ).

    :- func any_length(list(T)::ia) = (int::out) is det.

    any_length([]) = 0.
    any_length([_ | Xs]) = 1 + any_length(Xs).

    :- pred any_member(T::oa, list(T)::ia) is nondet.

    any_member(X, [X | _ ]).
    any_member(X, [_ | Xs]) :- any_member(X, Xs).
    ===
    The if-then-else condition causes the compiler to abort with:
    Making Mercury/int3s/negctxtbug.int3
    Making Mercury/ints/negctxtbug.int
    Making Mercury/hlc.gc.tr/x86_64-unknown-linux-gnu/Mercury/cs/negctxtbug.c
    Uncaught Mercury exception:
    Software Error: det_analysis.m: Unexpected: inappropriate determinism inside a negation
    Stack dump follows:
       0 pred exception.throw/1-0 (erroneous) (exception.m:388)
       1 pred require.error/1-0 (erroneous) (require.m:122)
       2 pred libs.compiler_util.unexpected/2-0 (erroneous) (compiler_util.m:87)
       3 pred check_hlds.det_analysis.det_infer_not/10-0 (det) (det_analysis.m:1305)
       4 pred check_hlds.det_analysis.det_infer_goal_2/12-0 (det) (det_analysis.m:607)
       5 pred check_hlds.det_analysis.det_infer_goal/11-0 (det) (det_analysis.m:434)
       6 pred check_hlds.det_analysis.det_infer_if_then_else/15-0 (det) (det_analysis.m:1238)
    ...

    If you change s/ia/in/;s/oa/out/ then the bug does not manifest itself.
     
    There are no notes attached to this issue.




    View Issue Details
    34 [mercury] Bug minor always 2008-01-03 04:52 2008-01-03 04:52
    obo  
     
    normal  
    new  
    open  
    none    
    none  
       
    confusing error message in lambda function (but good message in predicate version)
    The attached code has two routines, both exhibit the same error (unsatisfied uniqueness). However, only the 'pred' closure reports a reasonable error message. The 'func' version is just confusing:

    confusing_message.m:001: Warning: interface for module `confusing_message' does
    confusing_message.m:001: not export anything.
    confusing_message.m:012: In clause for `nice_message(out)':
    confusing_message.m:012: in argument 1 of call to predicate
    confusing_message.m:012: `confusing_message.read_outcome'/3:
    confusing_message.m:012: mode error: variable `COutcomes' has
    confusing_message.m:012: instantiatedness `ground',
    confusing_message.m:012: expected instantiatedness was `unique'.
    confusing_message.m:020: In clause for `confusing_message(out)':
    confusing_message.m:020: in argument 1 of call to function `int.fold_down'/4:
    confusing_message.m:020: mode error: variable `V_7' has instantiatedness
    confusing_message.m:020: `free',
    confusing_message.m:020: expected instantiatedness was `(func((ground >>
    confusing_message.m:020: ground), (ground >> ground)) = (free >> ground) is
    confusing_message.m:020: det)'.

    Best wishes in the new year,
      yours Ondrej.
    confusing_message.m (1,766 bytes) 2008-01-03 04:52
    https://bugs.mercurylang.org/file_download.php?file_id=30&type=bug
     
    There are no notes attached to this issue.




    View Issue Details
    32 [mercury] Bug minor always 2007-12-14 18:37 2007-12-14 18:37
    zs  
     
    normal  
    new  
    open  
    none    
    none  
       
    loop invariant optimization generates invalid HLDS
    The bug can be reproduced by
       mmc -Cv check_typeclass.m -Dmost -d145 -d150 -O5
    The stage 150 HLDS dump shows that the loop invariant predicate for the is_valid_instance_type predicate has the argument HeadVar__6 in the argument list *twice*, in both cases with the mode unique>>unique, even though the right thing for loop_inv to do would have been not to pass it at all (it is computed *before* the loop is entered).

    I think loop_inv might be confused by the fact that the sixth position in the "loop" call is an unwanted output.
    This bug occurs with version 1.117 of check_typeclass.m. I have a diff to make is_valid_instance_type look nicer, but the version with the change does not tickle this bug.
     
    There are no notes attached to this issue.




    View Issue Details
    31 [mercury] Bug minor always 2007-12-09 03:36 2007-12-10 18:00
    ony  
    juliensf  
    normal  
    resolved  
    won't fix  
    none    
    none  
       
    modules compilation on 64-bit platform eats too much memory
    During building process of v0.13.1 on amd64-compatible platform there is stage with building modules (Internals) and at that moment there is huge memory usage which finally produce out of memory (tried at 2 GB ram + 4 GB swap).
    As contrary to that 32-bit version is built normally on the same platform.
    CPU: Intel Core 2 Duo E6600
    RAM: 2 GB
    OS: GNU/Linux 2.6.23-gentoo-r2 0000002 SMP
    Distribution: Gentoo Linux amd64 (default-linux/amd64/2007.0 profile)
    GCC: gcc version 4.2.2 (Gentoo 4.2.2 p1.0)
    build.log.bz2 (16,040 bytes) 2007-12-09 04:16
    https://bugs.mercurylang.org/file_download.php?file_id=25&type=bug
    emerge_start.log.bz2 (818 bytes) 2007-12-09 04:16
    https://bugs.mercurylang.org/file_download.php?file_id=26&type=bug
    environment.bz2 (21,463 bytes) 2007-12-09 04:16
    https://bugs.mercurylang.org/file_download.php?file_id=27&type=bug
    config.log.bz2 (17,395 bytes) 2007-12-09 04:22
    https://bugs.mercurylang.org/file_download.php?file_id=28&type=bug
     
    Notes
    (0000062)
    juliensf   
    2007-12-09 03:42   
    Hi,

    What does building modules (Internals) mean?
    Do you mean when the file compiler/modules.m is being compiled?

    At what stage of compilation is this happening? When Mercury is being compiled
    to C code, or when the C code is being compiled to object code.

    It would be helpful if you could provide a copy of the output of the build process
    (0000064)
    ony   
    2007-12-09 04:22   
    Sorry, I'm newbie in Mercury just starting to use, but looks like it have problems during building modules in library subdirectory using "mmc".

    You can find building process log in attachment build.log.bz2.
    At this time I've limited memory usage to 1.5 GB to avoid breaking of other processes. Please see emerge_start.log.bz2 for info.
    config.log.bz2 - is copied and compressed from topdir.
    (0000065)
    juliensf   
    2007-12-10 18:00   
    The entire configuration process looks very odd for that type of machine.
    My guess is that it is something to do with the way the Gentoo package is running the
    build process.

    I think this should be reported as a bug in the Gentoo Mercury package, via bugs.gentoo.org.




    View Issue Details
    4 [mercury] Bug minor always 2007-09-27 23:36 2007-12-09 03:45
    anonymous  
    juliensf  
    normal  
    resolved  
    won't fix  
    none    
    none  
       
    change in --runtime-flags should rebuild <main>_init.o
    From bojar@csse.unimelb.edu.au Fri Aug 17 14:47:53 2007
    Date: Fri, 17 Aug 2007 14:49:19 +1000
    From: Ondrej Bojar <bojar@csse.unimelb.edu.au>
    To: mercury-bugs@csse.unimelb.edu.au
    Subject: change in --runtime-flags should rebuild <main>_init.o

     Hi.

    If 'mmc --make' is used with --runtime-flags, it is not sufficient to touch the
    source file of the main module after I change the flags.

    If the correct behaviour (i.e. dependency of <main>_init.o on the actual string
    of --runtime-flags) is difficult to implement, the user's manual/manpage should
    probably remind users to delete the _init.o file.

    Thanks, O.

    --
    Ondrej Bojar (mailto:obo@cuni.cz / bojar@ufal.mff.cuni.cz)
    http://www.cuni.cz/~obo
    bug-runtime-flags.tgz (577 bytes) 2007-11-19 14:38
    https://bugs.mercurylang.org/file_download.php?file_id=22&type=bug
     
    Notes
    (0000041)
    juliensf   
    2007-10-26 16:32   
    (Last edited: 2007-10-26 16:32)
    <main>_init.c (and consequently .o) should be rebuilt after _any_ .m file
    in the program is touched. The implementation does not appear to be
    doing this.

    (0000053)
    juliensf   
    2007-11-19 14:11   
    Ignore my previous note. The implementation is working correctly.
    <main>_init.o will be rebuilt if the contents of <main>_init.c have
    changed since the last build. The implementation checks to see if this
    is case and only rebuild <main>_init.o if they have changed. Touching
    <main>.m has no effect upon whether <main>_init.o is rebuilt - it will
    only be rebuilt if <main>_init.c has changed.
    (0000054)
    juliensf   
    2007-11-19 14:12   
    Ondrej, can you provide an example of where this is not working?
    (I will close this bug otherwise.)
    (0000055)
    obo   
    2007-11-19 14:40   
    Use the above attached example:
    bug-runtime-flags.tgz [^] (577 bytes) 11-19-07 14:38

    make
    # ... this will pass

    SUBDIRS=--use-grade-subdirs make
    # ... this will fail, the two executables will be identical,
    # despite different detstack-size requests in --runtime-flags
    (0000056)
    juliensf   
    2007-11-19 14:57   
    Making the programs in bug-runtime-flags.tgz with --use-grade-subdirs works
    for me with rotd-2007-11-18, i.e. it prints out "PASSED" at the end.

    Also, strings test-w-stacksize.x | grep "\-\-detstack-size"

    prints out the appropriate thing where x is either 1000 or 400000.

    Can you please compile it on your machine with -V enabled and check that
    the _init.c file actually being updated second time around.
    (0000057)
    obo   
    2007-11-19 15:16   
    It failed now even without --use-subdirs.
    My guess is that Mercury/os/test_init.o is not being recompiled, though Mercury/cs/test_init.c is correctly updated:

    ...
    make test-w-stacksize.1000
    make[1]: Entering directory `/home/obo/bug-runtime-flags'
    rm -f test
    mmc -V --make test --runtime-flags "--detstack-size 1000"
    % Creating initialization file...
    % Invoking system command `mkinit -g asm_fast.gc -r "--detstack-size 1000" -o Mercury/cs/test_init.c.tmp -I /home/obo/opt/mercury-compiler-rotd-2007-09-22/lib/mercury/modules/asm_fast.gc /home/obo/opt/mercury-compiler-rotd-2007-09-22/lib/mercury/modules/asm_fast.gc/mer_rt.init /home/obo/opt/mercury-compiler-rotd-2007-09-22/lib/mercury/modules/asm_fast.gc/mer_std.init Mercury/cs/test.c'...
    % done.
    % Updating interface:
    % `Mercury/cs/test_init.c' has CHANGED.
    % Invoking system command `cp Mercury/cs/test_init.c.tmp Mercury/cs/test_init.c'...
    % done.
    Making test
    % Linking...
    % Invoking system command `gcc -s -o test Mercury/os/test_init.o Mercury/os/test.o -L/home/obo/opt/mercury-compiler-rotd-2007-09-22/lib/mercury/lib -L/home/obo/opt/mercury-compiler-rotd-2007-09-22/lib/mercury/lib/asm_fast.gc -Wl,-rpath,/home/obo/opt/mercury-compiler-rotd-2007-09-22/lib/mercury/lib -Wl,-rpath,/home/obo/opt/mercury-compiler-rotd-2007-09-22/lib/mercury/lib/asm_fast.gc /home/obo/opt/mercury-compiler-rotd-2007-09-22/lib/mercury/lib/asm_fast.gc/libmer_std.a /home/obo/opt/mercury-compiler-rotd-2007-09-22/lib/mercury/lib/asm_fast.gc/libmer_rt.a /home/obo/opt/mercury-compiler-rotd-2007-09-22/lib/mercury/lib/libgc.a -lm '...
    % done.
    % done.
    cp -L test test-w-stacksize.1000
    make[1]: Leaving directory `/home/obo/bug-runtime-flags'
    if diff test-w-stacksize.400000 test-w-stacksize.1000; then \
              echo "Files don't differ!"; \
              exit 1; \
            fi
    Files don't differ!
    make: *** [all] Error 1



    When I run the two first lines of 'all' manually one by one, mmc -V log for the second run looks differently:

    ...
    % `Mercury/cs/test_init.c' has CHANGED.
    % Invoking system command `cp Mercury/cs/test_init.c.tmp Mercury/cs/test_init.c'...
    % done.
    % Compiling initialization file...
    % Compiling `Mercury/cs/test_init.c':
    % Invoking system command `gcc -I. -I. -I./Mercury/mihs -I/home/obo/opt/mercury-compiler-rotd-2007-09-22/lib/mercury/lib/asm_fast.gc/inc -I/home/obo/opt/mercury-compiler-rotd-2007-09-22/lib/mercury/conf -I/home/obo/opt/mercury-compiler-rotd-2007-09-22/lib/mercury/inc -O2 -fomit-frame-pointer -fno-strict-aliasing -DMR_USE_GCC_GLOBAL_REGISTERS -DMR_USE_GCC_NONLOCAL_GOTOS -DMR_USE_ASM_LABELS -fno-builtin -fno-omit-frame-pointer -fno-defer-pop -fno-function-cse -fno-gcse -DMR_CONSERVATIVE_GC -DMR_BOEHM_GC -DMR_TAGBITS=2 -ansi -Wall -Wwrite-strings -Wshadow -Wmissing-prototypes -Wno-unused -Wno-uninitialized -Wstrict-prototypes -c Mercury/cs/test_init.c -o Mercury/os/test_init.o'...
    % done.
    Making test
    % Linking...
    ...


    Could it be a slight time-stamping bug/hack between
      - % Invoking system command `cp Mercury/cs/test_init.c.tmp Mercury/cs/test_init.c'...
    and
      - Making test
    ?
    (0000058)
    juliensf   
    2007-11-19 15:53   
    Ondrej and I have looked at this in person. It's a timing issue - apparently
    the timestamp on the new version of the _init.c file hasn't been updated
    when --make checks to see if the _init.o file should be rebuilt. Adding
    a small delay between the invocations of mmc in Ondrej's Makefile avoids
    the problem. (Thus far I have only been able to reproduce it on his machine.)
    (0000063)
    juliensf   
    2007-12-09 03:44   
    I don't think this is worth fixing at the moment - it seems to be specific
    to Ondrej's setup.




    View Issue Details
    28 [mercury] Bug major always 2007-11-15 12:28 2007-11-19 17:37
    obo  
    zs  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Unexpected: adjust_livevals
    Hi,

    I've come across a bug in tail recursion optimization (my guess) if foreign code is involved.

    Typing 'make' in the testcase provided, mmc dies with this message:

    Uncaught Mercury exception:
    Software Error: jumpopt.m: Unexpected: adjust_livevals: BetweenLivevals and PrevLivevals differ
    Stack dump not available in this grade.

    If you explicitly prevent tail recursion by uncommenting the line:

        % io.write_string("", !IO), % prevent tail recursion

    at the end of testxmlreader.m, the code compiles, runs (and wastes quite some time, performance is 10x worse than same xmlreader demo implemented in C). I'm not sure if I can attribute all the performance loss to stack management and the extra boxing and unboxing.

    If I fake all the calls to xmlreader, as in:

    testxmlreader.m-no-C-code (to replace testxmlreader.m)

    the jumpopt exception goes away.

    Thanks, Ondrej.
    bug.tgz (1,939 bytes) 2007-11-15 12:28
    https://bugs.mercurylang.org/file_download.php?file_id=20&type=bug
     
    Notes
    (0000059)
    zs   
    2007-11-19 17:37   
    fix posted nov 19




    View Issue Details
    27 [mercury] Bug crash always 2007-11-12 15:35 2007-11-14 15:02
    rafe  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Type var in instance declaration can cause compiler to crash
    The compiler crashes when compiling the following code:

    :- module instance_var_bug.
    :- interface.
    :- typeclass tc(T) where [ pred p(T::in) is semidet ].
    :- implementation.
    :- instance tc(V) where [ p(_) :- semidet_true ].

    The bug is that the instance argument is a variable, but this is not being caught.
     
    Notes
    (0000048)
    juliensf   
    2007-11-12 16:11   
    The compiler is checking that the instance declarations don't contain
    type variables. The problem is that it doesn't do this check until
    *after* the code that causing this abort is executed. Fixing this
    should just be a matter of either re-ordering some of the checks in
    compiler/check_typeclass.m.
    (0000051)
    juliensf   
    2007-11-14 15:02   
    Fixed. See r1.116 of compiler/check_typeclass.m for details.




    View Issue Details
    18 [mercury] Bug minor always 2007-10-12 12:57 2007-11-08 16:01
    maclarty  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    inconsistent treatment of true goals with no outputs.
    Even with the --fully-strict option, mmc will optimise away a goal like the following:

        promise_pure(
            impure set_m(I) % m is a mutable.
        ).

    However it will not optimise away the following goal under --fully-strict:

        p("hello")

    where

    p(I) :-
        trace [io(!IO)] (
            io.write(I, !IO)
        ).

    (even with --no-inlining)

    Either the semantics of --fully-strict needs to be further refined, or the compiler needs to behave the same in both of these cases.
    Attached is an example.

    With mmc fs --fully-strict the call to p gets optimised away.
    With mmc fs --fully-strict --no-inling it doesn't.
    fs.m (452 bytes) 2007-10-12 12:57
    https://bugs.mercurylang.org/file_download.php?file_id=10&type=bug
     
    Notes
    (0000031)
    juliensf   
    2007-10-18 17:43   
    Ian, what exactly are you talking about? The example you attached
    doesn't seem to match the description you posted.

    Note that just because the compiler can replace goals, doesn't
    necessarily mean it will. Also, in order to be able to safely be
    able to replace a goal the compiler must be able to prove that it
    the goal terminates and does not throw an exception.

    If you run your example with --fully-strict --no-inlining and with --enable-termination --analyse-exceptions
    you will get the same result as the case with inlining enabled.
    (If you look in compiler/goal_form.m you will notice that in the absence
    of those two analyses the compiler cannot infer termination/non-exception
    throwing across procedure boundaries.)

    In any case, the real problem is that the following purity promise is
    a lie:

        promise_pure (
            impure set_m(I)
        )

    An additional complication in this case, is that trace goals have a
    particular semantics w.r.t goal replacement, i.e. they are never replaced
    but calls to procedures containing them may be.
    (0000032)
    maclarty   
    2007-10-18 18:21   
    I think you misunderstood what I was saying.

    The documentation currently says that with --fully-strict, the compiler is *not* allowed to replace (semi)pure det goals with no outputs, however the compiler replaces the following with 'true' when the --fully-strict option is given.

        promise_pure (
            impure set_m(I)
        )

    The attached example illustrates this (don't you get the output 0 2 when you compile fs.m with --fully-strict?).

    Yes, I know the promise_pure is a lie, and I'm not actually using this in any real code. It was just something I came across and I didn't expect this behaviour based on what the reference manual says.
    (0000033)
    juliensf   
    2007-10-19 00:46   
    The documentation and the implementation seem to differ on what should be
    happening with --fully-strict / --no-fully-strict.

    (1) The comments (and code) in compiler/simplify.m mean suggest that if --fully-strict
    is enabled then det goals with no outputs should not be replaced by true, and
    goals that always fail should not be replaced by false.

    (2) The documentation gives a different impression: rather than preventing the compiler
    from replacing such goals, --fully-strict and --no-fully-strict just alter the requirements
    under which the replacement can occur.

    For --no-fully-strict the compiler can replace any semi(pure) det goal with no outputs,
    regardless of whether it terminates or throws an exception. (And similarly for the always
    fails case.)

    For --fully-strict it can only perform that replacement if it can prove that the goal does
    terminate and does not throw an exception.

    The help message for --no-fully-strict says:

    "Allow mmc to optimize away infinite loops or calls to error/1"

    That suggest to me that --fully-strict is still allowed to optimise away the goals if
    doing so won't change the termination or exception throwing properties of the
    program, i.e. doing so won't turn a non-terminating program into a terminating one.
    (The reference manual says something.)

    It doesn't appear that this is what the compiler does though. There is a bug somewhere here,
    I'm just not sure what it is. We should decide what --fully-strict/--no-fully-strict actually
    mean before trying to work that out though.
    (0000034)
    maclarty   
    2007-10-19 09:17   
    Perhaps we should make the semantics of --no-fully-strict simply:
    Allow the compiler to improve completeness by replacing infinite loops or calls to error with 'true' or 'false'.

    And then change simplify.m so that it doesn't use the --fully-strict option to decide if it can replace terminating (semi)pure det goals with no outputs with 'true' (similarly for failing goals).

    The last change I made to the docs tried to get the docs more in line with what the compiler actually does. But I now think we should be fixing the compiler to get it in line with the original docs. The original docs don't say anything about terminating (semi)pure goals that produce no outputs, so simply.m shouldn't be checking the --fully-strict options to decide if it can optimise these away or not (they don't affect completeness anyway).
    (0000036)
    juliensf   
    2007-10-19 11:28   
    Actually, looking at it with fresh eyes, the code in simplify.m does the
    correct thing, i.e. behaviour (2) in my last note, either --no-fully-strict
    is set or the goal must terminate and not throw an exception. (I mistook
    the disjunctions for conjunctions last night.)
    (0000037)
    juliensf   
    2007-10-19 11:38   
    Incidentally, this means that the warning message at compiler/simplify.m:653
    is incorrect because compiling with --fully-strict is not sufficient
    to disable the optimisation.
    (0000047)
    juliensf   
    2007-11-08 16:01   
    Fixed - see log message for r1.219 of compiler/simplify.m.




    View Issue Details
    25 [mercury] Bug crash always 2007-11-01 14:24 2007-11-01 14:29
    petdr  
     
    high  
    confirmed  
    open  
    none    
    none  
       
    tabling of predicates with type class constraints causes an internal compiler error
    $ mmc --make table_tc
    Making Mercury/int3s/table_tc.int3
    Making Mercury/ints/table_tc.int
    Making Mercury/cs/table_tc.c
    Uncaught Mercury exception:
    Software Error: table_gen.m: Unexpected: gen_lookup_call_for_type: typeclass_info_type
    Stack dump not available in this grade.
    ** Error making `Mercury/cs/table_tc.c'.
    table_tc.m (369 bytes) 2007-11-01 14:24
    https://bugs.mercurylang.org/file_download.php?file_id=17&type=bug
     
    Notes
    (0000046)
    juliensf   
    2007-11-01 14:29   
    This is a known problem. Basically, tabling of predicates with
    type class constraints will not work until we change the compiler
    not to pack type_infos into typeclass_infos.




    View Issue Details
    21 [mercury] Bug minor always 2007-10-22 14:54 2007-11-01 02:05
    juliensf  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    equivalences for solver types lead to badly typed initialisation predicates
    The attached code fragment exhibits a bug with solver types and
    equivalence types that causes the compiler to report that an
    initialisation predicate is badly typed. (The fragment compiles
    without error if the equivalence type definition is commented out.)

    (At a cursory glance, it looks like expansion of equivalence types is
    not happening somewhere.)
    fz_conf.m (945 bytes) 2007-10-22 14:54
    https://bugs.mercurylang.org/file_download.php?file_id=14&type=bug
     
    Notes
    (0000045)
    juliensf   
    2007-11-01 02:04   
    Support for automatic initialisation of solver types has been removed so, in a sense, this bug
    can no longer occur.

    The actual bug has also been fixed in the developer-only support for solver initialisation.

    See the log message of r1.195 of compiler/unify_proc.m for details.




    View Issue Details
    24 [mercury] Bug minor have not tried 2007-10-31 15:56 2007-10-31 17:45
    pbone  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    Debugger commands inconsistant with help message.
    During a debugging session the "help forwards" information message describes a command called "fail" which dosn't appear to be supported. I don't know if it's supposed to work or not.
    mdb> help forward
    forward - Commands that move execution forward.
                 The forward commands are `step', `goto', `next', `finish',
                 `fail', `exception', `return', `user, `forward',
                 `mindepth', `maxdepth' and `continue'.

    mdb> fail
    Unknown command `fail'. Give the command `help' for help.

    The command 'help fail' returns the main help page.
     
    Notes
    (0000042)
    juliensf   
    2007-10-31 16:31   
    It's not mentioned in the user's guide but there is code to implement it
    in the trace library, in trace/mercury_trace_cmd_forward.[ch], although
    the code to enable that command in trace/mercury_trace_internal.c has
    been omitted. It's easy to fix, either enable it properly or delete it.
    It's just a question of which one.
    (0000043)
    juliensf   
    2007-10-31 16:58   
    zs said it should exist. I'll post a fix for this problem shortly.
    (0000044)
    juliensf   
    2007-10-31 17:45   
    The current implementation of the `fail' command is buggy which is
    why some of the documentation was already commented out. I've
    removed the rest of the user visible documentation, i.e. the reference
    to it from mdb's help message.

    I've added to fail to mdb's internal table of commands, so that developers
    can use it if they wish.




    View Issue Details
    7 [mercury] Bug minor always 2007-09-27 23:53 2007-10-26 15:48
    anonymous  
     
    normal  
    feedback  
    open  
    none    
    none  
       
    Type ctor module name bug
    Date: Wed, 1 Aug 2007 17:45:29 +1000
    From: Ralph Becket <rafe@csse.unimelb.edu.au>
    To: Julien Fischer <juliensf@csse.unimelb.edu.au>
    Subject: Type ctor module name bug

    Unpack the attached tar file and build and run foo1 and foo2.
    They give different answers, which I think is wrong.

    -- Ralph
    foobar.tgz (585 bytes) 2007-09-27 23:53
    https://bugs.mercurylang.org/file_download.php?file_id=5&type=bug
     
    Notes
    (0000040)
    juliensf   
    2007-10-26 15:48   
    The problem is that in the program `foo2' it is ambiguous as to whether
    the file bar.m contains the module `bar' or the module `foo2.bar'.
    The compiler apparently decides that it contains both!

    I think the best thing to do here would be to emit a warning if the
    module -> source file map is not a bijection.




    View Issue Details
    22 [mercury] Bug minor always 2007-10-23 18:13 2007-10-23 18:13
    juliensf  
     
    normal  
    new  
    open  
    none    
    none  
       
    compiler abort with memoing, dead proc. elimination and the hlc backend
    The attached program causes a compiler abort during the HLDS->MLDS pass if
    dead procedure elimination is enabled.

    (This is similar, if not identical, to the recently fixed problems with
    the low-level backend.)

    (Curiously, the compiler also aborts if --high-level-data is enabled, even
    though tabling is supposed to be disabled in that grade.)
    fzn_table_bug.m (553 bytes) 2007-10-23 18:13
    https://bugs.mercurylang.org/file_download.php?file_id=15&type=bug
     
    There are no notes attached to this issue.




    View Issue Details
    11 [mercury] Bug minor always 2007-09-28 13:14 2007-10-22 15:18
    anonymous  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    instance declarations for unknown types accepted in interface
    The compiler accepts instance declarations in the interface of a module on types which don't appear in the interface, if the type is later defined in the module.
    instance_no_type.m (612 bytes) 2007-09-28 13:14
    https://bugs.mercurylang.org/file_download.php?file_id=8&type=bug
     
    Notes
    (0000006)
    juliensf   
    2007-09-28 14:06   
    Yes, it's a bug. I'm not sure how serious this is since all instance
    declarations are in some sense global anyway. Still, it would be nice
    to make it report something here.
    (0000039)
    juliensf   
    2007-10-22 15:18   
    Fixed. See log message of r1.115 of compiler/check_typeclass.m for details.




    View Issue Details
    6 [mercury] Bug minor always 2007-09-27 23:49 2007-10-19 16:07
    anonymous  
    zs  
    normal  
    assigned  
    open  
    none    
    none  
       
    compiler abort
    From rafe@csse.unimelb.edu.au Sun Aug 5 09:55:55 2007
    Date: Sun, 5 Aug 2007 09:55:53 +1000
    From: Ralph Becket <rafe@csse.unimelb.edu.au>
    To: Mercury Bugs <mercury-bugs@csse.unimelb.edu.au>
    Subject: Compiler abort

    Unpack the small tar file and run Make in the BUG directory to get:

    $ make
    mmc --make endo
    Making Mercury/int3s/endo.int3
    Making Mercury/int3s/dna.int3
    Making Mercury/ints/dna.int
    Making Mercury/ints/endo.int
    Making Mercury/cs/dna.c
    Making Mercury/cs/endo.c
    Uncaught Mercury exception:
    Software Error: jumpopt.m: Unexpected: adjust_livevals: BetweenLivevals
    and PrevLivevals differ
    Stack dump not available in this grade.
    ** Error making `Mercury/cs/endo.c'.
    make: *** [all] Error 1
    BUG.tgz (2,672 bytes) 2007-09-27 23:49
    https://bugs.mercurylang.org/file_download.php?file_id=4&type=bug
    endo2.m (833 bytes) 2007-10-16 18:17
    https://bugs.mercurylang.org/file_download.php?file_id=13&type=bug
     
    Notes
    (0000029)
    juliensf   
    2007-10-16 18:19   
    I have uploaded a cut-down version of Ralph's original program that
    exhibits this bug (the attached file endo2.m.)

    The bug can be reproduced by compiling in asm_fast.gc with -O0 --optimize-frames
    --optimize-repeat=2.




    View Issue Details
    5 [mercury] Bug minor always 2007-09-27 23:39 2007-10-19 15:11
    anonymous  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    bad error message for state vars
    From bojar@csse.unimelb.edu.au Wed Aug 15 16:50:01 2007
    Date: Wed, 15 Aug 2007 16:51:13 +1000
    From: Ondrej Bojar <bojar@csse.unimelb.edu.au>
    To: mercury-bugs@csse.unimelb.edu.au
    Subject: bad error message for state vars

    Hi.

    Here is an error message that wrongly reports the variable name:

    oc_tree.m:015: Error: !FTFileName cannot appear as a unification argument.
    oc_tree.m:015: You probably meant !.FTFileName or !:FTFileName.

    where the actual error I made on that particular line was related to !D:

                !D = svg.new,

    See the source code attached. (Other errors are correct.)

    Thanks, Ondrej.

    --
    Ondrej Bojar (mailto:obo@cuni.cz / bojar@ufal.mff.cuni.cz)
    http://www.cuni.cz/~obo
    oc_tree.m (571 bytes) 2007-09-27 23:39
    https://bugs.mercurylang.org/file_download.php?file_id=3&type=bug
     
    Notes
    (0000038)
    juliensf   
    2007-10-19 15:11   
    Fixed. See log message for revision 1.46 of compiler/add_clause.m.




    View Issue Details
    16 [mercury] Bug text always 2007-10-05 16:26 2007-10-18 16:20
    pjrm  
    juliensf  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    doc: description of float token wrong
    According to the current definition of the float token in the Mercury Reference manual, 1.0E-3 is not a float token (unless `-' is considered a "decimal digit"; which it isn't according to every authority I can think of):

      @item float
      A floating point literal consists of a sequence of decimal digits,
      a decimal point and a sequence of digits (the fraction part), and
      the letter @samp{E} and another sequence of decimal digits (the exponent).
      The fraction part or the exponent (but not both) may be omitted.

    Please insert

      and an optional sign (@samp{+} or @samp{-})

    after {E}. Please also consider inserting

      (or @samp{e})

    Thanks,

    pjrm.
     
    Notes
    (0000026)
    juliensf   
    2007-10-15 22:58   
    I've posted a diff that fixes this.
    (0000030)
    juliensf   
    2007-10-18 16:20   
    r1.409 of doc/reference_manual.texi fixes this.




    View Issue Details
    19 [mercury] Bug minor always 2007-10-16 16:24 2007-10-16 17:37
    wangp  
     
    normal  
    confirmed  
    open  
    none    
    none  
       
    foreign type mutables don't work in high-level C grades
    In hlc grades, a mutable of a foreign type FT in a module M will result in a variable declaration in M.mih that refers to FT before the #inclusion of the header that defines FT.
    For the given modules:

    % mmc -m aa -s hlc.gc
    Making Mercury/os/aa.o
    In file included from Mercury/cs/aa.c:26:
    aa.m:17: error: syntax error before '*' token
    aa.m:17: warning: type defaults to `int' in declaration of `aa__mutable_variable_my_bb'
    aa.m:17: warning: data definition has no type or storage class
    aa.m:17: error: conflicting types for 'aa__mutable_variable_my_bb'
    aa.m:17: error: previous declaration of 'aa__mutable_variable_my_bb' was here
    ** Error making `Mercury/os/aa.o'.


    The same thing works in asm_fast.gc
    aa.m (606 bytes) 2007-10-16 16:24
    https://bugs.mercurylang.org/file_download.php?file_id=11&type=bug
    bb.m (840 bytes) 2007-10-16 16:25
    https://bugs.mercurylang.org/file_download.php?file_id=12&type=bug
     
    Notes
    (0000027)
    juliensf   
    2007-10-16 16:46   
    (Last edited: 2007-12-31 11:53)
    The same thing works in asm_fast.gc because in that grade mutables always
    have type MR_Word.

    I think that we need to ensure that all mutables that are foreign types
    in the hl* grades also have type MR_Word, rather than the foreign type.
    (Actually, since we don't know the type in question it should be boxed
    anyway.) [I reported a related set of bugs with float and non-word sized
    foreign type mutables in the hl* grades at the beginning of this year, I
    haven't fixed them yet since I was waiting for zs's parse tree restructure.]





    View Issue Details
    9 [mercury] Bug minor always 2007-09-28 00:13 2007-10-13 22:39
    juliensf  
     
    normal  
    new  
    open  
    none    
    none  
       
    spurious error message when testing equivalence of equal things
    From bojar@csse.unimelb.edu.au Fri May 18 19:03:54 2007
    Date: Fri, 18 May 2007 19:06:43 +1000
    From: Ondrej Bojar <bojar@csse.unimelb.edu.au>
    To: mercury-bugs@csse.unimelb.edu.au
    Subject: spurious error message when testing equivalence of equal things

    Hi.

    When compiling this code:

    :- module testbug.
    :- interface.
    :- import_module io.
    :- pred main(io::di, io::uo) is det.
    :- implementation.

    :- import_module list, int.

    main(!IO) :-
       A = [1,2,3],
       B = [1,2,3],
       (
       if A = B
       % if same(A, B) % use this to compile seamlessly
       then io.write_string("yes\n", !IO)
       else io.write_string("no\n", !IO)
       ).

    :- pred same(T::in, T::in) is semidet.
    same(A, B) :- A = B.


    The compiler emits a lengthy message:

    testbug.m:013: In clause for `'__Unify__'(in, (unique(list.'[|]'(unique(1),
    testbug.m:013: unique(list.'[|]'(unique(2), unique(list.'[|]'(unique(3),
    testbug.m:013: unique((list.[])))))))) >> unique(list.'[|]'(unique(1),
    testbug.m:013: unique(list.'[|]'(unique(2), unique(list.'[|]'(unique(3),
    testbug.m:013: unique((list.[]))))))))), (unique(list.'[|]'(unique(1),
    testbug.m:013: unique(list.'[|]'(unique(2), unique(list.'[|]'(unique(3),
    testbug.m:013: unique((list.[])))))))) >> unique(list.'[|]'(unique(1),
    testbug.m:013: unique(list.'[|]'(unique(2), unique(list.'[|]'(unique(3),
    testbug.m:013: unique((list.[]))))))))))':
    testbug.m:013: mode error: argument 2 did not get sufficiently instantiated.
    testbug.m:013: Final instantiatedness of `HeadVar__1' was
    testbug.m:013: `unique(list.'[|]'(bound(1), bound(list.'[|]'(bound(2),
    testbug.m:013: bound(list.'[|]'(bound(3), bound((list.[]))))))))',
    testbug.m:013: expected final instantiatedness was
    testbug.m:013: `unique(list.'[|]'(unique(1), unique(list.'[|]'(unique(2),
    testbug.m:013: unique(list.'[|]'(unique(3), unique((list.[]))))))))'.
    testbug.m:016: Warning: the condition of this if-then-else cannot fail.


    The code seamlessly compiles if I test for the equivalence using an extra
    predicate call to same/2.

    The issue does not arise with primitive types, e.g. A=1, B=1.

    Thanks, O.


    --
    Ondrej Bojar (mailto:obo@cuni.cz / bojar@ufal.mff.cuni.cz)
    http://www.cuni.cz/~obo
    testbug.m (397 bytes) 2007-09-28 00:13
    https://bugs.mercurylang.org/file_download.php?file_id=6&type=bug
     
    There are no notes attached to this issue.




    View Issue Details
    13 [mercury] Bug minor always 2007-10-03 14:27 2007-10-12 21:15
    wangp  
    juliensf  
    normal  
    assigned  
    open  
    none    
    none  
       
    builtin types inconsistently module qualified
    The compiler seems to be inconsistent in its treatment of builtin types. In some cases they are module qualified with "builtin.", in other cases they are not, and it's not clear when.

    This is related to a workaround for a compiler abort I committed on 2007-10-03.

    (Julien asked me to file this report so he would remember to look into it.)
     
    Notes
    (0000014)
    juliensf   
    2007-10-12 21:14   
    Remind self to look at it.




    View Issue Details
    14 [mercury] Bug minor always 2007-10-03 17:40 2007-10-03 17:40
    wangp  
     
    normal  
    new  
    open  
    none    
    none  
       
    mmc --make install should not touch unmodified files
    Installing a library with mmc --make will update the timestamps of all files it installs, even if their contents are unchanged.
     
    There are no notes attached to this issue.




    View Issue Details
    2 [mercury] Bug minor always 2007-09-21 15:48 2007-10-03 14:17
    wangp  
    petdr  
    normal  
    resolved  
    fixed  
    none    
    none  
       
    equivalence types in instance declarations
    mmc accepts the LHS of an equivalence type in an instance declaration even when it would not accept the type on the RHS, e.g.

    :- type list_int == list(int).
    :- instance tc(list_int) where [].

    If that's not actually a bug, then there is a bug when intermodule optimisation is enabled. ":- instance tc(list(int))." is written to the .opt file and produces an error message when that .opt file is used for another module.
    eqv_instance.m (180 bytes) 2007-09-21 15:48
    https://bugs.mercurylang.org/file_download.php?file_id=2&type=bug
     
    Notes
    (0000002)
    juliensf   
    2007-09-21 16:09   
    Depending on whether int_list is an abstract type or not then it's
    either one or two bugs. From the reference manual on type class instances:

        The types in an instance declaration must not be abstract types which are
        elsewhere defined as equivalence types.

    The same section also says that ground types like list(int) may not appear
    in the head of an instance declaration. (IIRC from one of the Haskell papers
    on this, then there is no particularly good reason for the latter restriction,
    but I may be mistaken - it's been a months since I though much about type classes.)

    For the current set of restrictions the implementation does admittedly not
    do a good job reporting violations; given that we are intending to address
    this as part of extending the type class system I'm not sure it's worth
    putting too much effort into now.
    (0000003)
    wangp   
    2007-09-21 17:06   
    Am I right in thinking that this restriction won't be lifted any time soon? I've read the thread from earlier this year [1] and it sounds like a lot of work.

    [1] http://www.mercury.cs.mu.oz.au/mailing-lists/mercury-developers/mercury-developers.200705/0022.html
    (0000004)
    juliensf   
    2007-09-21 17:15   
    The key point in the that thread is the first one:

        (1) A language issue. Restrictions are necessary -- we need to choose a
        set of restrictions such that the type system is sound and (semi) decidable.
        It is one thing to suggest lifting individual restrictions, but the only
        way to design this is to consider the typeclass system as a whole.

    Some of the proposed type class extensions are a lot of work; others are
    relatively simple (allowing compound type like list(set(T)) in constraints
    for example would happen as a result of fixing up the type-info being
    packed into typeclass-info thing, you would get tabling of predicates with
    type class methods into the bargain as well.)

    I have been intending to work on this stuff all year; I just need to find a way
    of making G12 disappear for a month or two.
    (0000008)
    petdr   
    2007-10-03 14:17   
    This compiler now detects this case.




    View Issue Details
    1 [mercury] Bug minor always 2007-09-17 11:18 2007-09-25 11:54
    obo  
     
    normal  
    acknowledged  
    open  
    none    
    none  
       
    non-instructive error message: 'unused' mode requires explicit lambda expression
    Hi.

    the attached code demonstrates a not quite instructive error message.

    While the predicate main2/2 compiles fine, main/2 does not, because I try to directly pass/curry an argument in 'unused' mode.

    One solution is to automatically infer the correct mode when currying, another is to make the error message more specific.

    Thanks, O.
    bug.m:019: In clause for `main(in, out)':
    bug.m:019: in argument 1 of call to predicate `call_int_modifier'/3:
    bug.m:019: mode error: variable `V_7' has instantiatedness `free',
    bug.m:019: expected instantiatedness for non-local variables of lambda goals
    bug.m:019: is `ground'.
    bug.m (615 bytes) 2007-09-17 11:18
    https://bugs.mercurylang.org/file_download.php?file_id=1&type=bug
     
    Notes
    (0000001)
    obo   
    2007-09-17 11:56   
    Oh, in fact, changing main2 to something more useful -- i.e. passing the 'unused' value from outside (to pass type information) is prohibited for the same reasons: non-local vars ought to have ground inst.

    :- pred main2(mytype::unused, int::in, int::out) is det.
    main2(X, In, Out) :-
      call_int_modifier(
        (pred(I::in, O::out) is det :- add(X, I, O)),
        In, Out).


    I'm failing to work around it using (ground) type_desc:

    :- import_module type_desc.

    :- pred main3(mytype::unused, int::in, int::out) is det.
    main3(X, In, Out) :-
      XType = type_of(X),
      call_int_modifier(
        (pred(I::in, O::out) is det :-
          has_type(NewX, XType),
          add(NewX, I, O)),
        In, Out).

    bug.m:037: In clause for predicate `main3'/3:
    bug.m:037: in argument 1 of call to predicate `add'/3:
    bug.m:037: type error: variable `NewX' has type `(some [T] T)',
    bug.m:037: expected type was `(bug2.mytype)'.

    Is there a way to construct a free variable with a specific type? My guess is that this is the core restriction of the current mode checker...
    (0000005)
    juliensf   
    2007-09-25 11:54   
    We will take a look at it.