From owner-freebsd-ports@freebsd.org Thu Apr 14 11:58:31 2016 Return-Path: Delivered-To: freebsd-ports@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B6F79B10504 for ; Thu, 14 Apr 2016 11:58:31 +0000 (UTC) (envelope-from FreeBSD@shaneware.biz) Received: from ipmail04.adl6.internode.on.net (ipmail04.adl6.internode.on.net [150.101.137.141]) by mx1.freebsd.org (Postfix) with ESMTP id 582D5197F for ; Thu, 14 Apr 2016 11:58:30 +0000 (UTC) (envelope-from FreeBSD@shaneware.biz) Received: from ppp118-210-182-127.lns20.adl6.internode.on.net (HELO leader.local) ([118.210.182.127]) by ipmail04.adl6.internode.on.net with ESMTP; 14 Apr 2016 21:28:30 +0930 To: FreeBSD-ports From: Shane Ambler Subject: Need some help with c++/qt5 code Message-ID: <570F85E3.6060000@ShaneWare.Biz> Date: Thu, 14 Apr 2016 21:28:27 +0930 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Apr 2016 11:58:31 -0000 Hi there, while I am comfortable with c and python, I only know a little c++ and could use some help. I am in the process of getting a QT5 based app running on FreeBSD and have an issue that I'm not sure how to resolve. The project is opentoonz which is a commercial project that was recently open sourced. The code base has been previously built only on OSX and windows By using work others have done to build on linux I have got to the point of compiling and linking on FreeBSD but get a segfault on startup. The failing code is part of the variable initialising run before the first line of main() I am using clang 3.4.1 on 10-STABLE-amd64, (gcc build needs more work) the binary is linked to gcc48/libgcc_s.so which is needed for the superlu/blas libraries that are used. The class definition is - class TPanelFactory { QString m_panelType; static QMap m_table; public: TPanelFactory(QString panelType); ~TPanelFactory(); QString getPanelType() const { return m_panelType; } virtual void initialize(TPanel *panel) = 0; virtual TPanel *createPanel(QWidget *parent); static TPanel *createPanel(QWidget *parent, QString panelType); }; m_table is then in the source file as QMap TPanelFactory::m_table; The segfault happens in the constructor - TPanelFactory::TPanelFactory(QString panelType) : m_panelType(panelType) { assert(m_table.count(panelType) == 0); m_table[m_panelType] = this; } the last line causes the segfault, if I comment it out then main() is entered, but I expect removing that line will bite back soon enough. How can I get this working? Why would this fail on FreeBSD but not OSX or windows? The backtrace I get from lldb and gdb - % lldb opentoonz Current executable set to 'opentoonz' (x86_64). (lldb) run Process 80086 launching Process 80086 stopped (lldb) Process 80086 launched: '/home/shane/Projects/opentoonz/test_install/bin/opentoonz' (x86_64) Process 80086 stopped * (lldb) thread #1: tid = 101033, 0x00000000004f2026 opentoonz`TPanelFactory::TPanelFactory(QString) + 70, stop reason = invalid address (fault address: 0x0) frame #0: 0x00000000004f2026 opentoonz`TPanelFactory::TPanelFactory(QString) + 70 opentoonz`TPanelFactory::TPanelFactory(QString) + 70: -> 0x4f2026: cmpl $0x2, (%rax) 0x4f2029: jb 0x4f203d ; TPanelFactory::TPanelFactory(QString) + 93 0x4f202b: movq 0x73eb5e(%rip), %r15 ; opentoonz..got + 6728 0x4f2032: movq %r15, %rdi (lldb) bt * thread #1: tid = 101033, 0x00000000004f2026 opentoonz`TPanelFactory::TPanelFactory(QString) + 70, stop reason = invalid address (fault address: 0x0) * frame #0: 0x00000000004f2026 opentoonz`TPanelFactory::TPanelFactory(QString) + 70 frame #1: 0x0000000000570cfd opentoonz`XsheetViewerFactory::XsheetViewerFactory() + 45 frame #2: 0x000000000056fd47 opentoonz`_GLOBAL__I_a + 1687 frame #3: 0x0000000000809d22 opentoonz`__do_global_ctors_aux + 34 frame #4: 0x00000000004854ae opentoonz`_init + 14 frame #5: 0x0000000800c02c9f frame #6: 0x0000000800c0228e (lldb) quit % gdb opentoonz ... (gdb) run Starting program: /home/shane/Projects/opentoonz/test_install/bin/opentoonz Program received signal SIGSEGV, Segmentation fault. 0x00000000004f2026 in TPanelFactory::TPanelFactory(QString) () (gdb) bt #0 0x00000000004f2026 in TPanelFactory::TPanelFactory(QString) () #1 0x0000000000570cfd in XsheetViewerFactory::XsheetViewerFactory() () #2 0x000000000056fd47 in global constructors keyed to a () #3 0x0000000000809d22 in __do_global_ctors_aux () #4 0x00000000004854ae in _init () #5 0x00007fffffffda20 in ?? () #6 0x0000000800c02c9f in objlist_call_init () from /libexec/ld-elf.so.1 #7 0x0000000800c0228e in _rtld () from /libexec/ld-elf.so.1 #8 0x0000000800c00449 in .rtld_start () from /libexec/ld-elf.so.1 #9 0x0000000000000000 in ?? () (gdb) quit -- FreeBSD - the place to B...Software Developing Shane Ambler