Bug#913174: globs: GL_shadow and GL_smoke segmentation fault

2018-11-08 Thread Bernhard Übelacker
Dear Maintainer,
I just tried to reproduce the issue.

This segfault in GL_shadow happens here:

Thread 1 "gl_shadow" received signal SIGSEGV, Segmentation fault.
0x79f6 in LoadTexture (tex_name=0x7fffe120 "tex.png") at 
src/benchmarks/GL_shadow/object.c:196
196 if ((tex_img->format)->Amask)
(gdb) bt
#0  0x55909d0d59f6 in LoadTexture (tex_name=0x7ffd0d909650 "tex.png") 
at src/benchmarks/GL_shadow/object.c:196
#1  0x55909d0d528c in LoadObject (objfile=0x55909d0d8076 "cube.obj") at 
src/benchmarks/GL_shadow/object.c:83
#2  0x55909d0d5ed8 in InitObject (objfile=0x55909d0d8076 "cube.obj") at 
src/benchmarks/GL_shadow/object.c:268
#3  0x55909d0d4a89 in main (argc=4, argv=0x7ffd0d909ad8) at 
src/benchmarks/GL_shadow/main.c:121


This looks like another case of truncated pointer because of
implicit prototypes, which unfortunately on amd64 default
to int (4 bytes) and therefore fail when a pointer (8 bytes) is
returned by a function.

This warning seems to be contained in the build logs:

gcc -o src/benchmarks/GL_shadow/object.o -c -g -D_GNU_SOURCE=1 -D_REENTRANT 
-I/usr/include/SDL src/benchmarks/GL_shadow/object.c
src/benchmarks/GL_shadow/object.c: In function 'LoadTexture':
src/benchmarks/GL_shadow/object.c:192:31: warning: implicit declaration of 
function 'IMG_Load' [-Wimplicit-function-declaration]
  if(tex_img = (SDL_Surface *) IMG_Load(tex_name)) {
   ^~~~
src/benchmarks/GL_shadow/object.c:192:15: warning: cast to pointer from 
integer of different size [-Wint-to-pointer-cast]
  if(tex_img = (SDL_Surface *) IMG_Load(tex_name)) {
   ^


Attached patch adds compiler flags and includes to avoid
implicit prototypes.

Kind regards,
Bernhard


> gdb run is not very helpful due lack of debugging symbols.

PS. @Witold Baryluk:
Also a failing stack can be of some use when the issue
is tried to be reproduced.
And the debug symbols are stored in a different repository.
You find some information at https://wiki.debian.org/HowToGetABacktrace
Description: Force prototypes

---
Author: Bernhard Übelacker 
Bug-Debian: https://bugs.debian.org/913174
Forwarded: no
Last-Update: 2018-11-09

--- globs-0.2.0~svn50.orig/src/benchmarks/GLSL_parallax/extra.c
+++ globs-0.2.0~svn50/src/benchmarks/GLSL_parallax/extra.c
@@ -17,6 +17,8 @@
 */
 
 
+#define GL_GLEXT_PROTOTYPES
+
 #include 
 #include 
 #include 
@@ -26,6 +28,7 @@
 #include  
 
 #include "init.h"
+#include "extra.h"
 
 void UpdateLight(struct Light *l)
 {
--- globs-0.2.0~svn50.orig/src/benchmarks/GLSL_parallax/init.c
+++ globs-0.2.0~svn50/src/benchmarks/GLSL_parallax/init.c
@@ -17,15 +17,19 @@
 */
 
 
+#define GL_GLEXT_PROTOTYPES
+
 #include 
 #include 
 
 #include 
+#include 
 #include 
 #include  
 
 #include "init.h"
 #include "textfile.h"
+#include "extra.h"
 
 
 void InitLighting(struct Light *l, struct Material *m)
--- globs-0.2.0~svn50.orig/src/benchmarks/GLSL_parallax/main.c
+++ globs-0.2.0~svn50/src/benchmarks/GLSL_parallax/main.c
@@ -16,6 +16,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
+#define GL_GLEXT_PROTOTYPES
 
 #include 
 #include 
--- globs-0.2.0~svn50.orig/src/benchmarks/GLSL_parallax/textfile.c
+++ globs-0.2.0~svn50/src/benchmarks/GLSL_parallax/textfile.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include "textfile.h"
 
 
 char *textFileRead(char *fn) {
--- globs-0.2.0~svn50.orig/src/benchmarks/GL_shadow/object.c
+++ globs-0.2.0~svn50/src/benchmarks/GL_shadow/object.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include "object.h"
 
--- globs-0.2.0~svn50.orig/src/benchmarks/GL_smoke/particle.c
+++ globs-0.2.0~svn50/src/benchmarks/GL_smoke/particle.c
@@ -4,6 +4,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include "particle.h"
--- globs-0.2.0~svn50.orig/src/benchmarks/SConstruct
+++ globs-0.2.0~svn50/src/benchmarks/SConstruct
@@ -13,7 +13,7 @@ except SCons.Errors.UserError:
 	install_dir = os.path.join(root, prefix, 'share/globs/benchmarks')
 
 # create build environment
-env = Environment(CCFLAGS = '-g')
+env = Environment(CCFLAGS = '-g -Werror=missing-prototypes -Werror=implicit-function-declaration')
 
 # determine compiler and linker flags for SDL
 env.ParseConfig('sdl-config --cflags')
--- globs-0.2.0~svn50.orig/src/benchmarks/check_time.c
+++ globs-0.2.0~svn50/src/benchmarks/check_time.c
@@ -1,5 +1,6 @@
 #include 
 #include 
+#include "check_time.h"
 
 long int check_time(int time)
 {
--- globs-0.2.0~svn50.orig/src/benchmarks/get_options.c
+++ globs-0.2.0~svn50/src/benchmarks/get_options.c
@@ -1,3 +1,4 @@
+#include 
 #include 
 #include "get_options.h"
 


apt update
apt install dpkg-dev devscripts xserver-xorg lightdm openbox xterm 
systemd-coredump gdb mc mesa-utils globs globs-dbgsym libsdl-image1.2-dbgsym
apt build-dep globs

systemctl start lightdm



mkdir globs/orig -p
cdglobs/orig
apt 

Bug#913174: globs: GL_shadow and GL_smoke segmentation fault

2018-11-07 Thread Witold Baryluk
Package: globs
Version: 0.2.0~svn50-5
Severity: important

GL_shadow and GL_smoke immediately segfaults

I am guessing this is related to textures loaded from the .png files.

If I run gl_smoke manually, with current directory being random, it says
can't load a texture and shows gray smoke.
But if I go to a directory with texture and the execute it, it crashes.

gdb run is not very helpful due lack of debugging symbols.


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

Kernel: Linux 4.18.0-2-amd64 (SMP w/32 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages globs depends on:
ii  libc62.27-8
ii  libgl1   1.1.0-1
ii  libgl1-mesa-glx  18.1.9-1
ii  libsdl-image1.2  1.2.12-9
ii  libsdl1.2debian  1.2.15+dfsg2-4
ii  python   2.7.15-3
ii  python-glade22.24.0-5.1+b1

globs recommends no packages.

globs suggests no packages.

-- no debconf information

-- debsums errors found:
debsums: missing file /usr/share/doc/globs/README (from globs package)
debsums: missing file /usr/share/doc/globs/TODO (from globs package)
debsums: missing file /usr/share/doc/globs/changelog.Debian.gz (from globs 
package)
debsums: missing file /usr/share/doc/globs/changelog.gz (from globs package)
debsums: missing file /usr/share/doc/globs/copyright (from globs package)