# Fatal error - IfcGuid is not a 128-bit number

**URL:** <https://forums.buildingsmart.org/t/fatal-error-ifcguid-is-not-a-128-bit-number/3137>\
**Category:** Developers\
**Created:** [November 19, 2020, 9:54am UTC](https://forums.buildingsmart.org/t/fatal-error-ifcguid-is-not-a-128-bit-number/3137 "2020-11-19T09:54:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hannu.lahtela](https://avatars.discourse-cdn.com/v4/letter/h/74df32/32.png) [@hannu.lahtela](https://forums.buildingsmart.org/u/hannu.lahtela)\
**Post date:** [November 19, 2020, 9:54am UTC](https://forums.buildingsmart.org/t/fatal-error-ifcguid-is-not-a-128-bit-number/3137/1 "2020-11-19T09:54:40Z")

</div>

The documentation says:  
“An IfcGloballyUniqueId is a Globally Unique Identifier (GUID) which is an auto-generated 128-bit number.”

However:

0123456789012345678901234567890123456789012345678901234567890123  
0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\_$  
=\>  
64 values \* 22char = 6bit \* 22char = 132bit So there are 4extra bits and only 2 bits in first character are meningful.  
In other words the first character in IFCGUID can only be ‘0’-‘3’.

E.g.  
2sif80O2kC83\_GLKmIlyJ$ =\> b2ffcafc-a5db-4d28-b01a-1b72abeed016  
Asif80O2kC83\_GLKmIlyJ$ =\> b2ffcafc-a5db-4d28-b01a-1b72abeed016

In this case A(001010) -\> 2 (000010)

And this is why its pretty bad bug because converting back to 128 does not work.

So what this means:  
This brings an increased risk of malfunction if a software imports ifc and the native data model of the software uses UUID converted from IfcGUID.  
E.g. An ifcfile contains two instances of IfcBuilding (A & B). The Building A has a guid(2sif80O2kC83\_GLKmIlyJ$) and the Building B has a guid (Asif80O2kC83\_GLKmIlyJ).  
When the ifcfile converted to the native data model, both of the buildings have the same UUID(b2ffcafc-a5db-4d28-b01a-1b72abeed016)!!  
Then it’s up to the software what will happen next. If user didn’t get any fatal error messages what, would happen when the user let’s say creates a bill of quantities of building(b2ffcafc-a5db-4d28-b01a-1b72abeed016) ?

-Sami Lyden & Hannu Lahtela-

---

<div class="post-metadata">

**Author:** ![tauscher](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.buildingsmart.org/tauscher/32/816_2.png) [@tauscher](https://forums.buildingsmart.org/u/tauscher)\
**Post date:** [November 20, 2020, 10:04am UTC](https://forums.buildingsmart.org/t/fatal-error-ifcguid-is-not-a-128-bit-number/3137/2 "2020-11-20T10:04:47Z")

</div>

> [@hannu.lahtela](#):
>
> So there are 4extra bits and only 2 bits in first character are meningful.

You are absolutely right, not every random combination of characters from the character set can be produced from the encoding. Thus, `Asif80O2kC83_GLKmIlyJ$` is not a valid value for the IfcGloballyUniqueId. No software should produce such a GUID, same as it should not produce GUIDs with less than or more than 22 characters. Encoding of `0xB2FFCAFCA5DB4D28B01A1B72ABEED016` should always result in `2sif80O2kC83_GLKmIlyJ$`.

This is not an unusual issue. For example, there are some byte sequences that will never appear in UTF-8 encodings. Hence, a random byte sequence may be invalid UTF-8, impossible to decode.
