[m-dev.] ROTDs broken since rotd-2023-12-13

Zoltan Somogyi zoltan.somogyi at runbox.com
Fri Dec 15 02:49:53 AEDT 2023


On 2023-12-15 02:23 +11:00 AEDT, "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
> 
> On 2023-12-14 23:50 +11:00 AEDT, "Julien Fischer" <jfischer at opturion.com> wrote:
>> According to testing.mercurylang.org, building the compiler with --intermod-opt -O5 in asm_fast.gc or hlc.gc has been broken since rotd-2023-12-13.  The problem is due to aborts in the compiler like
>> the following (for the module transform_hlds.pd_info).
>> 
>>     Uncaught Mercury exception:
>>     Software Error: predicate `hlds.hlds_module.module_info_pred_info'/3:
>>     Unexpected: cannot find predicate number 1884
>>     Stack dump not available in this grade.
> 
> This seems to be caused by an unfortunate interaction between
> a new format_call pragma in pd_debug.m and dead predicate elimination.
> I am looking into it.

Actually, this seems straightforward: the modules for which the compiler
crashes get both the declaration of the pd_debug_message, and the
format_call pragma I added for it on dec 13.  The dead pred elimination
pass sees no reference to this predicate, and deletes it, but there is still
a reference which dead_pred_elim has not been updated to know about:
the mri_format_call_pragma_preds field of the module_info. The later
check_pragma_format_call pass finds the pred_id in that field,
and tries to do its checking, but the pred_id it looks up does not work
anymore.

I see three possible simple fixes. All should work.

The first is to modify dead_pred_elim to use the pred_ids mentioned
in the mri_format_call_pragma_preds fields as roots, keeping them
alive even in the absence of other references.

The second is to make the check_pragma_format_call pass be able
to handle the possibility that the pred_ids that it is supposed to check
has been deleted before its invocation.

From a semantic sense, the first fix is feels cleaner but
in cases like three modules for which the compiler now crashes,
it keeps from memory alive for longer. Granted, the waste is tiny.

A clean yet non-wasteful third fix would let dead_pred_elim delete pred_infos
that have pred_ids referring to them in that field of the module_info
(if they are otherwise dead), *but* would then delete such pred_ids
from that field.

Approach two would be easiest to implement, and a comment on
the module_info field saying that the pred_ids there may be dangling
references, and that this is ok, would make it semantically ok as well.
This is my preferred solution. What are yours?

BTW, my internet will be flaky today and tomorrow, due to
scheduled NBN maintenance in my area.

Zoltan.


More information about the developers mailing list