Mercury Bugs - mercury
View Issue Details
0000547mercuryBugpublic2022-02-09 12:322022-02-26 07:20
Reporterjuliensf 
Assigned To 
PrioritynormalSeverityminorReproducibilityrandom
StatusnewResolutionopen 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000547: Test failure: intermittent failure of valid/foreign_import_module
DescriptionThe 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'
TagsNo tags attached.
Attached Files? DIFF.fim.d (3,540) 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.

Issue History
2022-02-09 12:32juliensfNew Issue
2022-02-09 20:35zsNote Added: 0001173
2022-02-26 07:20zsFile Added: DIFF.fim.d
2022-02-26 07:20zsNote Added: 0001179