Subject: Bug#1051296: freecad: Crashes when creating/opening a file.

From: Alejandro Rosso <[email-masked]>
Date: Tue, 05 Sep 2023 16:30:31 -0500

Package: freecad
Version: 0.20.2+dfsg1-10
Severity: important
X-Debbugs-Cc: [email-masked]

Dear Maintainer,

FreeCAD crashes when trying to create a new file or opening an existing one.
If it is run from command line, this is the output:

```
$ freecad
FreeCAD 0.20.2, Libs: 0.20.2R
© Juergen Riegel, Werner Mayer, Yorik van Havre and others 2001-2022
FreeCAD is free and open-source software licensed under the terms of LGPL2+ license.
FreeCAD wouldn't be possible without FreeCAD community.
  #####                 ####  ###   ####  
  #                    #      # #   #   # 
  #     ##  #### ####  #     #   #  #   # 
  ####  # # #  # #  #  #     #####  #   # 
  #     #   #### ####  #    #     # #   # 
  #     #   #    #     #    #     # #   #  ##  ##  ##
  #     #   #### ####   ### #     # ####   ##  ##  ##

freecad: ./src/glue/gl.cpp:2354: const cc_glglue* cc_glglue_instance(int): Assertion `current_ctx && "Must have a current GL context when instantiating cc_glglue!! (Note: if you are using an old Mesa GL version, set the environment variable COIN_GL_NO_CURRENT_CONTEXT_CHECK to get around what may be a Mesa bug.)"' failed.
Aborted
```

The following related/same issue is opened upstream:

https://github.com/FreeCAD/FreeCAD/issues/9273

-- System Information:
Debian Release: trixie/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.4.0-3-amd64 (SMP w/12 CPU threads; PREEMPT)
Kernel taint flags: TAINT_OOT_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages freecad depends on:
ii  freecad-python3  0.20.2+dfsg1-10

Versions of packages freecad recommends:
ii  calculix-ccx        2.20-1
ii  graphviz            2.42.2-7+b3
ii  python3-opencamlib  2023.01.11-3

Versions of packages freecad suggests:
pn  povray  <none>

-- no debconf information

---

From: Michele Cane <[email-masked]>
Date: Sat, 07 Oct 2023 19:49:27 +0200

Package: freecad
Version: 0.20.2+dfsg1-10
Followup-For: Bug #1051296

Dear Maintainer,

exact same problem. Followed the upstream issue mentioned in the bugreport and can make it run with:

export COIN_GL_NO_CURRENT_CONTEXT_CHECK=1

Cheers

-- System Information:
Debian Release: trixie/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 6.5.0-1-amd64 (SMP w/8 CPU threads; PREEMPT)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_CH.UTF-8, LC_CTYPE=en_CH.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages freecad recommends:
ii  calculix-ccx        2.20-1
ii  graphviz            2.42.2-7+b3
ii  python3-opencamlib  2023.01.11-4

---

From: Maxime Chambonnet <[email-masked]>
Date: Wed, 15 Nov 2023 14:46:25 +0100

Package: freecad
Version: 0.20.2+dfsg1-10
Followup-For: Bug #1051296
X-Debbugs-Cc: [email-masked]

Dear Maintainer,

I have the same problem with GNOME wayland on trixie.
Unsetting the environment variable as proposed in the linked
github issue solved it for me too.

BR, Maxime

-- System Information:
Debian Release: trixie/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 6.5.0-4-amd64 (SMP w/16 CPU threads; PREEMPT)
Kernel taint flags: TAINT_WARN
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

---

From: Leonardo Canducci <[email-masked]>
Date: Thu, 16 Nov 2023 18:04:08 +0100

Package: freecad
Version: 0.20.2+dfsg1-10

Dear Maintainer,

I've made some tests to get FreeCAD running correctly on my gome+wayland
sid system. First of all version 20.2 runs fine on XFCE and X. It
chashes on gnome+wayland when opening a file or creating a new project.
With the suggested fix (export COIN_GL_NO_CURRENT_CONTEXT_CHECK=1)
FreeCAD runs but its still very slow compared to XFCE (just open some
STL file and try panning or rotating the view). Tu sum up the suggested
fix improves things but doesn't completely solve the problem here.

I've tried the latest version (0.21.1) downloading the appimage file and 
it works fine with wayland. All is fine also with the 0.20.2 appimage
file so I guess the problem is related to the debian packaged version
only or its dependencies.

Regards,
Leonardo

-- System Information:
Debian Release: trixie/sid
  APT prefers stable-security
  APT policy: (500, 'stable-security'), (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.5.0-4-amd64 (SMP w/4 CPU threads; PREEMPT)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=it_IT.UTF-8, LC_CTYPE=it_IT.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

---

From: Leonardo Canducci <[email-masked]>
Date: Tue, 19 Dec 2023 17:57:28 +0100

Package: freecad
Version: 0.21.2+dfsg1-1

Dear Maintainer,
I'm experiencing a simular behaviour with the latest version. FreeCAD
crashes when open a file o creating a new one when launched on gnome
with wayland. All is fine when launched on XFCE. The appimage package
from upstream works fine in both desktop environments.

Using the suggested fix solves the problem right now and doesn't slow
down FreeCAD's execution as with version 0.20. Overall this update is an
improvement and I can stop using the appimage package.

Regards,
Leonardo

-- System Information:

Kernel: Linux 6.5.0-5-amd64 (SMP w/4 CPU threads; PREEMPT)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=C, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages freecad depends on:
ii  freecad-python3  0.21.2+dfsg1-1

Versions of packages freecad recommends:
ii  calculix-ccx        2.20-1
ii  graphviz            2.42.2-7+b3
ii  python3-opencamlib  2023.01.11-4+b1

---

From: Michele Cane <[email-masked]>
Date: Tue, 24 Dec 2024 07:53:18 +0100

Package: freecad
Version: 1.0.0+dfsg-1~exp1
Followup-For: Bug #1051296

Hello,

just installed the new version from experimental 1.0.0 and I am facing the same issue when opening a new file.

-- System Information:

Kernel: Linux 6.12.5-amd64 (SMP w/8 CPU threads; PREEMPT)
Locale: LANG=en_CH.UTF-8, LC_CTYPE=en_CH.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages freecad depends on:
ii  freecad-python3  1.0.0+dfsg-1~exp1
ii  python3          3.12.8-1

Versions of packages freecad recommends:
pn  calculix-ccx        <none>
ii  graphviz            2.42.4-2+b1
ii  python3-opencamlib  2023.01.11-5+b2

---

From: Tobias Frost <[email-masked]>
Date: Sat, 04 Jan 2025 11:03:42 +0100

Thanks for the information.

I can reproduce it here to.

Workarounds that work for me:

  COIN_GL_NO_CURRENT_CONTEXT_CHECK=1 freecad

  freecad -- -platform xcb

This might be coin3 issue #1050302.

---

From: Kai-Martin Knaak <[email-masked]>
Date: Mon, 17 Feb 2025 03:47:04 +0100

>   COIN_GL_NO_CURRENT_CONTEXT_CHECK=1 freecad

In plasma6. both of the workarounds work for me, too. However, with the
first one zoom and rotation seems to be sketchy. The GUI takes its time
to initiate a rotation. Then it skips ahead to compensate.
The xcb workaround does not suffer from this problem.

This workaround works fine for me as well:

XDG_SESSION_TYPE=X freecad

---

From: Scott Ashcroft <[email-masked]>
Date: Mon, 03 Mar 2025 12:42:40 +0000

> This might be coin3 issue #1050302.

I see that the coin3 bug has been closed by version 4.0.3+ds-2.
Just installing the new libcoin80t64 package doesn't seem to fix the
crash for me.
Does freecad or one of its dependencies need to be rebuilt to pick up
the coin3 fix?
Is there any way I can get more information to help track down the
issue?

Cheers,
Scott

---

From: Jelle Haandrikman <[email-masked]>
Date: Tue, 13 May 2025 10:01:25 +0200

As suggested i modified the Desktop file to automatically set this 
variable in the Exec

https://github.com/FreeCAD/FreeCAD/issues/9273#issuecomment-2833296625

So change the rule

Exec=env COIN_GL_NO_CURRENT_CONTEXT_CHECK=1 /usr/bin/freecad - 
--single-instance %F

in the desktop file /usr/share/applications/org.freecad.FreeCAD.desktop 
as well to have it fixed there.

Or add it to the environment variables in /etc/profile.