Bug 212866

Summary: [patch] games/7kaa Segmentation fault on exit
Product: Ports & Packages Reporter: kd-dev
Component: Individual Port(s)Assignee: Dmitry Marakasov <amdmi3>
Status: Closed FIXED    
Severity: Affects Only Me Keywords: patch
Priority: --- Flags: bugzilla: maintainer-feedback? (amdmi3)
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Fixes the issue by calling audio.deinit before exiting.
none
Fix from upstream. none

Description kd-dev 2016-09-20 20:29:58 UTC
Created attachment 175017 [details]
Fixes the issue by calling audio.deinit before exiting.

A C++ deconstructor attempts to clean-up OpenAL resources at exit after
the library's deconstructor destroys the internal state.  The called
functions attempt to access the destroyed state causing the program to
exit abnormally.

To reproduce run the port then exit it.

The added patches moves the "deinit" calls out of the deconstructor and
into "SYS::deinit", which is called before exit.
Comment 1 Dmitry Marakasov freebsd_committer freebsd_triage 2016-09-21 13:22:23 UTC
I'd prefer this to be reported to and reviewed by upstream.
Comment 2 kd-dev 2016-09-21 22:03:07 UTC
(In reply to Dmitry Marakasov from comment #1)
It appears that this bug is FreeBSD specific because of the order
in which destructors are called.

FreeBSD:
C Binary         Libraries
Libraries        C++ Binary

Linux:
C Binary         C++ Binary
Libraries        Libraries
Comment 3 Dmitry Marakasov freebsd_committer freebsd_triage 2016-10-04 15:08:00 UTC
(In reply to kdrakehp from comment #2)
> (In reply to Dmitry Marakasov from comment #1)
> It appears that this bug is FreeBSD specific because of the order
> in which destructors are called.
> 
> FreeBSD:
> C Binary         Libraries
> Libraries        C++ Binary
> 
> Linux:
> C Binary         C++ Binary
> Libraries        Libraries

It is not FreeBSD specific. Static data init/deinit order is not specified, so this is an upstream problem. Please report it upstream, it they are ok with the fix, we can add it to the port right away.
Comment 4 kd-dev 2016-10-11 19:37:59 UTC
Created attachment 175636 [details]
Fix from upstream.

The issue was fixed upstream (https://github.com/the3dfxdude/7kaa/pull/70)
Comment 5 commit-hook freebsd_committer freebsd_triage 2016-10-12 09:01:29 UTC
A commit references this bug:

Author: amdmi3
Date: Wed Oct 12 09:01:18 UTC 2016
New revision: 423836
URL: https://svnweb.freebsd.org/changeset/ports/423836

Log:
  - Fix segfault on exit [1]
  - Fix license

  PR:		212866 [1]
  Submitted by:	kdrakehp@zoho.com [1]

Changes:
  head/games/7kaa/Makefile
  head/games/7kaa/files/
  head/games/7kaa/files/patch-src_audio_openal_openal__audio.cpp
  head/games/7kaa/files/patch-src_client_OMUSIC.cpp
  head/games/7kaa/files/patch-src_client_OSYS.cpp
  head/games/7kaa/files/patch-src_video_sdl_vga__sdl.cpp