# Crash when labelling

**URL:** <https://swi-prolog.discourse.group/t/crash-when-labelling/9557>\
**Category:** General\
**Tags:** bug\
**Created:** [March 27, 2026, 7:33pm UTC](https://swi-prolog.discourse.group/t/crash-when-labelling/9557 "2026-03-27T19:33:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AZH](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/azh/32/6831_2.png) [@AZH](https://swi-prolog.discourse.group/u/AZH)\
**Post date:** [March 27, 2026, 7:33pm UTC](https://swi-prolog.discourse.group/t/crash-when-labelling/9557/1 "2026-03-27T19:33:40Z")

</div>

Hi there, just found probably a bug in labeling/2. The following can recreate it:

```prolog
test :-

    A = [_],

    A ins 0..1,

    when(ground(A), A mod 1 #= _),

    labeling([enum], A).

```

The expected outcome should be an Error message, but this produces a crash.

It only occurs when the option [enum] is used in labeling/2 – other options are fine.

Any insights? Thanks a lot 🙂

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [March 29, 2026, 9:22am UTC](https://swi-prolog.discourse.group/t/crash-when-labelling/9557/2 "2026-03-29T09:22:04Z")

</div>

> [@AZH](#):
>
> Any insights?

Its a bug 🙂 . Any crash is, unless it is caused by user supplied foreign code. I see what is going wrong, but fixing it needs a proper machine. Probably somewhere coming week …

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [March 30, 2026, 6:59pm UTC](https://swi-prolog.discourse.group/t/crash-when-labelling/9557/3 "2026-03-30T18:59:36Z")

</div>

Fixed with commit 03f4975ed6dadd456b2e3811177105dc41855132. The issue is with non-deterministic foreign predicates that unify an attributed variable where running the attribute hooks triggers an exception.

---

<div class="post-metadata">

**Author:** ![AZH](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/azh/32/6831_2.png) [@AZH](https://swi-prolog.discourse.group/u/AZH)\
**Post date:** [April 3, 2026, 1:52pm UTC](https://swi-prolog.discourse.group/t/crash-when-labelling/9557/4 "2026-04-03T13:52:22Z")

</div>

That’s upmost efficiency 🚀  
Thank you so much Jan!
