[BUG] Segfault with unset

47 views
Skip to first unread message

Manuel Presnitz

unread,
Jul 18, 2022, 3:45:18 PM7/18/22
to hugi...@googlegroups.com
Hi,

sorry for not reporting the bug via Launchpad, but after several attempts to create an Ubuntu One
account I gave up.

However, I get a seg fault when starting hugin on two different machines.


Details
-------

hugin version 2021.0.0-4
Arch Linux; up-to-date as of today, July 18th
custom kernel 5.18.3


Steps to reproduce
------------------

To reproduce the crash it is sufficient on my machines to unset the env variable XDG_DATA_HOME, so:

$ unset XDG_DATA_HOME
$ hugin

(...)
(hugin:3437): Gtk-CRITICAL **: 21:30:24.701: gtk_widget_set_size_request: assertion 'height >= -1' failed
/usr/share/hugin/data/plugins/top_five.py
CAT:Control Points
NAM:keep 5 CPs per image pair
fails @api-max
/usr/share/hugin/data/plugins/woa.py
CAT:Control Points
NAM:Warped Overlap Analysis
fails @api-max
/usr/share/hugin/data/plugins/woa.py
CAT:Control Points
NAM:Warped Overlap Analysis
fails @api-max
zsh: IOT instruction (core dumped) hugin


Investigation
-------------

Using gdb I got this backtrace:

Thread 1 "hugin" received signal SIGSEGV, Segmentation fault.
0x00007ffff531f9b4 in hugin_utils::GetUserAppDataDir[abi:cxx11]() () at /usr/users/presnitz/hugin/src/hugin-2021.0.0/src/hugin_base/hugin_utils/utils.cpp:475
475 if (strlen(xdgDataDir) == 0)
(gdb) bt
#0 0x00007ffff531f9b4 in hugin_utils::GetUserAppDataDir[abi:cxx11]() ()
at /usr/users/presnitz/hugin/src/hugin-2021.0.0/src/hugin_base/hugin_utils/utils.cpp:475
#1 0x00005555556d0fb6 in MainFrame::MainFrame(wxWindow*, HuginBase::Panorama&) (this=0x555555f15dc0, parent=0x0, pano=...)
at /usr/users/presnitz/hugin/src/hugin-2021.0.0/src/hugin1/hugin/MainFrame.cpp:475
#2 0x00005555556bb901 in huginApp::OnInit() (this=0x555555b4a590)
at /usr/users/presnitz/hugin/src/hugin-2021.0.0/src/hugin1/hugin/huginApp.cpp:372
#3 0x00005555556bfc15 in wxAppConsoleBase::CallOnInit() (this=0x555555b4a590) at /usr/include/wx-3.2/wx/app.h:93
#4 0x00007ffff670efe2 in wxEntry(int&, wchar_t**) () at /usr/lib/libwx_baseu-3.2.so.0
#5 0x00005555556ba87d in main(int, char**) (argc=1, argv=0x7fffffffd318)
at /usr/users/presnitz/hugin/src/hugin-2021.0.0/src/hugin1/hugin/huginApp.cpp:152


This gave me the hint that the seg fault is connected with XDG_DATA_HOME. And yes, after defining
XDG_DATA_HOME (empty string or some sensible value) hugin starts as expected :)

So, a workaround for my setup is:

$ export XDG_DATA_HOME=""
$ hugin


Additional Information
----------------------

For the sake of completeness I attach hugin's error-report xml file and list my version numbers of
the packages, Arch says that hugin directly depends on:

xwidgets-gtk3 3.2.0-3
boost-libs 1.79.0-1
libtiff 4.4.0-1
libpano13 2.9.21-1
libjpeg-turbo 2.1.3-2
libpng 1.6.37-3
openexr 3.1.5-1
vigra 1.11.1.r67+g093d57d1-3
exiv2 0.27.5-3
glew 2.2.0-3
sqlite 3.39.1-1
lcms2 2.13.1-1
lapack 3.10.1-1
fftw 3.3.10-3
glu 9.0.2-3
libxi 1.8-1
libxmu 1.1.3-3
python 3.10.5-1
lensfun-git 0.3.3.815-1
enblend-enfuse 4.2.r1524+h4c30a326b3f4-2



Best regards,
Manuel.

hugin_report.xml

johnfi...@gmail.com

unread,
Jul 18, 2022, 4:16:06 PM7/18/22
to hugin and other free panoramic software
In case this wasn't obvious and implied by your post, the error in the code is exactly where the seg fault occurs:

hugin/src/hugin-2021.0.0/src/hugin_base/hugin_utils/utils.cpp:475
475 if (strlen(xdgDataDir) == 0)

Seg faults often indicate a bug in a distant place, that may be hard to identify from the location of the seg fault.  But not this time.  The coding error is right there and obvious.

The part I don't know enough about is the hugin build time option: USE_XDG_DIRS

I don't know which official builds of hugin have that defined (the Fedora build I'm using doesn't).
As you discovered, if hugin is built with that build time option, but the environment variable that depends on is not present, then it crashes.
The line of code you identified is clearly intended to check for lack of that environment variable (to fall back on alternate behavior) but checks incorrectly.

T. Modes

unread,
Jul 19, 2022, 11:55:35 AM7/19/22
to hugin and other free panoramic software
Manuel Presnitz schrieb am Montag, 18. Juli 2022 um 21:45:18 UTC+2:
Hi,

sorry for not reporting the bug via Launchpad, but after several attempts to create an Ubuntu One
account I gave up.

However, I get a seg fault when starting hugin on two different machines.

Should be fixed now.

BTW why do you unset environment variables by hand?

Manuel Presnitz

unread,
Jul 19, 2022, 2:14:51 PM7/19/22
to hugi...@googlegroups.com

T. Modes hat am 19.07.2022 um 08:55 folgendes geschrieben:

> > However, I get a seg fault when starting hugin on two different
> > machines.
> >
>
> Should be fixed now.
>
> BTW why do you unset environment variables by hand?

Thanks a lot for the quick fix!

I can confirm that I don't experience a seg fault anymore when
applying your patch / changeset 8476:edfddc6070ca (Fixes crash
when environment variable XDG_DATA_HOME is not set)
to hugin-2021.0.0 source.

I don't unset XDG_DATA_HOME by hand, this was just to reproduce
the seg fault. XDG_DATA_HOME is just never set in my config which
is fine according to the XDG spec [1]:

[ $XDG_DATA_HOME defines the base directory relative to which
[ user-specific data files should be stored. If $XDG_DATA_HOME is either
[ not set or empty, a default equal to $HOME/.local/share should be used.

Regards,
Manuel.


[1] https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html


Reply all
Reply to author
Forward
0 new messages