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.
0x00005555555579f6 in LoadTexture (tex_name=0x7fffffffe120 "tex.png") at
src/benchmarks/GL_shadow/object.c:196
196 if ((tex_img->format)->Amask)
(gdb) bt
#0 0x000055909d0d59f6 in LoadTexture (tex_name=0x7ffd0d909650 "tex.png")
at src/benchmarks/GL_shadow/object.c:196
#1 0x000055909d0d528c in LoadObject (objfile=0x55909d0d8076 "cube.obj") at
src/benchmarks/GL_shadow/object.c:83
#2 0x000055909d0d5ed8 in InitObject (objfile=0x55909d0d8076 "cube.obj") at
src/benchmarks/GL_shadow/object.c:268
#3 0x000055909d0d4a89 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 <[email protected]>
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 <stdio.h>
#include <stdlib.h>
#include <math.h>
@@ -26,6 +28,7 @@
#include <GL/glext.h>
#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 <stdio.h>
#include <stdlib.h>
#include <SDL/SDL.h>
+#include <SDL/SDL_image.h>
#include <GL/gl.h>
#include <GL/glext.h>
#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 <stdio.h>
#include <stdlib.h>
--- 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 <string.h>
#include <sys/types.h>
#include <unistd.h>
+#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 <stdlib.h>
#include <string.h>
#include <SDL/SDL.h>
+#include <SDL/SDL_image.h>
#include <GL/gl.h>
#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 <stdlib.h>
#include <SDL/SDL.h>
+#include <SDL/SDL_image.h>
#include <GL/gl.h>
#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 <stdio.h>
#include <sys/time.h>
+#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 <stdlib.h>
#include <getopt.h>
#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
cd globs/orig
apt source globs
cd ../..
mkdir libsdl-image1.2/orig -p
cd libsdl-image1.2/orig
apt source libsdl-image1.2
cd ../..
export DISPLAY=:0
benutzer@debian:~$ /usr/bin/globs
Erstelle /home/benutzer/.globs.db
Segmentation fault (core dumped)
# no output in dmesg
root@debian:~# coredumpctl gdb
PID: 8234 (gl_shadow)
UID: 1000 (benutzer)
GID: 1000 (benutzer)
Signal: 11 (SEGV)
Timestamp: Thu 2018-11-08 03:05:01 CET (2min 10s ago)
Command Line: ./gl_shadow -w640 -h480 -t5
Executable: /usr/lib/globs/benchmarks/GL_shadow/gl_shadow
Control Group: /user.slice/user-1000.slice/session-6.scope
Unit: session-6.scope
Slice: user-1000.slice
Session: 6
Owner UID: 1000 (benutzer)
Boot ID: f5d327a9af0e4b53a9a429dd392407b7
Machine ID: 32f43b50ac8c4b21941bc0b02f8e7811
Hostname: debian
Storage:
/var/lib/systemd/coredump/core.gl_shadow.1000.f5d327a9af0e4b53a9a429dd392407b7.8234.1541642701000000.lz4
Message: Process 8234 (gl_shadow) of user 1000 dumped core.
Stack trace of thread 8234:
#0 0x000055909d0d59f6 n/a (gl_shadow)
#1 0x000055909d0d528c n/a (gl_shadow)
#2 0x000055909d0d5ed8 n/a (gl_shadow)
#3 0x000055909d0d4a89 main (gl_shadow)
#4 0x00007ff19bb9ab17 __libc_start_main (libc.so.6)
#5 0x000055909d0d44fa n/a (gl_shadow)
GNU gdb (Debian 8.1-4+b1) 8.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/lib/globs/benchmarks/GL_shadow/gl_shadow...Reading
symbols from
/usr/lib/debug/.build-id/a1/accdbb1420b6c36f5c0aeccc0729083b738ea1.debug...done.
done.
[New LWP 8234]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `./gl_shadow -w640 -h480 -t5'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x000055909d0d59f6 in LoadTexture (tex_name=0x7ffd0d909650 "tex.png") at
src/benchmarks/GL_shadow/object.c:196
196 src/benchmarks/GL_shadow/object.c: Datei oder Verzeichnis nicht
gefunden.
(gdb) bt
#0 0x000055909d0d59f6 in LoadTexture (tex_name=0x7ffd0d909650 "tex.png") at
src/benchmarks/GL_shadow/object.c:196
#1 0x000055909d0d528c in LoadObject (objfile=0x55909d0d8076 "cube.obj") at
src/benchmarks/GL_shadow/object.c:83
#2 0x000055909d0d5ed8 in InitObject (objfile=0x55909d0d8076 "cube.obj") at
src/benchmarks/GL_shadow/object.c:268
#3 0x000055909d0d4a89 in main (argc=4, argv=0x7ffd0d909ad8) at
src/benchmarks/GL_shadow/main.c:121
(gdb) directory /home/benutzer/globs/orig/globs-0.2.0~svn50
Source directories searched:
/home/benutzer/globs/orig/globs-0.2.0~svn50:$cdir:$cwd
(gdb) up
#1 0x000055909d0d528c in LoadObject (objfile=0x55909d0d8076 "cube.obj") at
src/benchmarks/GL_shadow/object.c:83
83 obj->TexId = LoadTexture(texbuf);
(gdb) down
#0 0x000055909d0d59f6 in LoadTexture (tex_name=0x7ffd0d909650 "tex.png") at
src/benchmarks/GL_shadow/object.c:196
196 if ((tex_img->format)->Amask)
(gdb) list LoadTexture
183
184 /* Simple code to load a texture and return its id */
185 GLuint LoadTexture(char *tex_name)
186 {
187 GLuint tex_num;
188
189 SDL_Surface *tex_img;
190 glGenTextures(1, &tex_num);
191
192 if(tex_img = (SDL_Surface *) IMG_Load(tex_name)) {
193 glBindTexture(GL_TEXTURE_2D, tex_num);
194 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
195 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR);
196 if ((tex_img->format)->Amask)
197 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex_img->w,
tex_img->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, tex_img->pixels);
198 else
199 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
tex_img->w, tex_img->h, 0, GL_RGB, GL_UNSIGNED_BYTE, tex_img->pixels);
200 SDL_FreeSurface (tex_img);
201 }
202 else
203 printf("Texture not found!\n");
204
205 return tex_num;
206 }
(gdb) print/x tex_img
$1 = 0xffffffff9e93e860
(gdb) print/x tex_img->format
Cannot access memory at address 0xffffffff9e93e868
###################
benutzer@debian:/usr/lib/globs/benchmarks/GL_shadow$ gdb -q --args ./gl_shadow
-w640 -h480 -t5
Reading symbols from ./gl_shadow...Reading symbols from
/usr/lib/debug/.build-id/a1/accdbb1420b6c36f5c0aeccc0729083b738ea1.debug...done.
done.
(gdb) set pagination off
(gdb) set width 0
(gdb) directory /home/benutzer/globs/orig/globs-0.2.0~svn50
Source directories searched:
/home/benutzer/globs/orig/globs-0.2.0~svn50:$cdir:$cwd
(gdb) directory /home/benutzer/libsdl-image1.2/orig/sdl-image1.2-1.2.12
Source directories searched:
/home/benutzer/libsdl-image1.2/orig/sdl-image1.2-1.2.12:/home/benutzer/globs/orig/globs-0.2.0~svn50:$cdir:$cwd
(gdb) b IMG_LoadTyped_RW
Function "IMG_LoadTyped_RW" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (IMG_LoadTyped_RW) pending.
(gdb) run
Starting program: /usr/lib/globs/benchmarks/GL_shadow/gl_shadow -w640 -h480 -t5
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffed801700 (LWP 22201)]
[New Thread 0x7fffed000700 (LWP 22202)]
[New Thread 0x7fffe7fff700 (LWP 22203)]
[New Thread 0x7fffe77fe700 (LWP 22204)]
[New Thread 0x7fffe6ffd700 (LWP 22205)]
[New Thread 0x7fffe67fc700 (LWP 22206)]
[New Thread 0x7fffe5ffb700 (LWP 22207)]
[New Thread 0x7fffe57fa700 (LWP 22208)]
Thread 1 "gl_shadow" hit Breakpoint 1, IMG_LoadTyped_RW (src=0x5555558e6760,
freesrc=1, type=0x7fffffffe124 "png") at IMG.c:164
164 if ( src == NULL ) {
(gdb) finish
Run till exit from #0 IMG_LoadTyped_RW (src=0x5555558e6760, freesrc=1,
type=0x7fffffffe124 "png") at IMG.c:164
0x00005555555579aa in LoadTexture (tex_name=0x7fffffffe120 "tex.png") at
src/benchmarks/GL_shadow/object.c:192
192 if(tex_img = (SDL_Surface *) IMG_Load(tex_name)) {
Value returned is $1 = (SDL_Surface *) 0x5555558dea20
(gdb) bt
#0 0x00005555555579aa in LoadTexture (tex_name=0x7fffffffe120 "tex.png") at
src/benchmarks/GL_shadow/object.c:192
#1 0x000055555555728c in LoadObject (objfile=0x55555555a076 "cube.obj") at
src/benchmarks/GL_shadow/object.c:83
#2 0x0000555555557ed8 in InitObject (objfile=0x55555555a076 "cube.obj") at
src/benchmarks/GL_shadow/object.c:268
#3 0x0000555555556a89 in main (argc=4, argv=0x7fffffffe5a8) at
src/benchmarks/GL_shadow/main.c:121
(gdb) disassemble LoadTexture,LoadTexture+0x40
Dump of assembler code from 0x55555555797c to 0x5555555579bc:
0x000055555555797c <LoadTexture+0>: push %rbp
0x000055555555797d <LoadTexture+1>: mov %rsp,%rbp
0x0000555555557980 <LoadTexture+4>: sub $0x20,%rsp
0x0000555555557984 <LoadTexture+8>: mov %rdi,-0x18(%rbp)
0x0000555555557988 <LoadTexture+12>: lea -0xc(%rbp),%rax
0x000055555555798c <LoadTexture+16>: mov %rax,%rsi
0x000055555555798f <LoadTexture+19>: mov $0x1,%edi
0x0000555555557994 <LoadTexture+24>: callq 0x555555556350
<glGenTextures@plt>
0x0000555555557999 <LoadTexture+29>: mov -0x18(%rbp),%rax
0x000055555555799d <LoadTexture+33>: mov %rax,%rdi
0x00005555555579a0 <LoadTexture+36>: mov $0x0,%eax
0x00005555555579a5 <LoadTexture+41>: callq 0x555555556480 <IMG_Load@plt>
=> 0x00005555555579aa <LoadTexture+46>: cltq
0x00005555555579ac <LoadTexture+48>: mov %rax,-0x8(%rbp)
0x00005555555579b0 <LoadTexture+52>: cmpq $0x0,-0x8(%rbp)
0x00005555555579b5 <LoadTexture+57>: je 0x555555557aa1 <LoadTexture+293>
0x00005555555579bb <LoadTexture+63>: mov -0xc(%rbp),%eax
End of assembler dump.
(gdb) info reg
rax 0x5555558dea20 93824995944992
rbx 0x5555558def50 93824995946320
rcx 0x3 3
rdx 0x0 0
rsi 0x55555555d010 93824992268304
rdi 0x1 1
rbp 0x7fffffffdf50 0x7fffffffdf50
rsp 0x7fffffffdf30 0x7fffffffdf30
r8 0x0 0
r9 0x7fffffffd954 140737488345428
r10 0x187 391
r11 0x7ffff7f3d340 140737353339712
r12 0x5555555564d0 93824992240848
r13 0x7fffffffe5a0 140737488348576
r14 0x0 0
r15 0x0 0
rip 0x5555555579aa 0x5555555579aa <LoadTexture+46>
eflags 0x202 [ IF ]
cs 0x33 51
ss 0x2b 43
ds 0x0 0
es 0x0 0
fs 0x0 0
gs 0x0 0
(gdb) display/i $pc
1: x/i $pc
=> 0x5555555579aa <LoadTexture+46>: cltq
(gdb) display tex_img
3: tex_img = (SDL_Surface *) 0x5555555564d0 <_start>
(gdb) stepi
0x00005555555579ac 192 if(tex_img = (SDL_Surface *)
IMG_Load(tex_name)) {
1: x/i $pc
=> 0x5555555579ac <LoadTexture+48>: mov %rax,-0x8(%rbp)
3: tex_img = (SDL_Surface *) 0x5555555564d0 <_start>
(gdb)
0x00005555555579b0 192 if(tex_img = (SDL_Surface *)
IMG_Load(tex_name)) {
1: x/i $pc
=> 0x5555555579b0 <LoadTexture+52>: cmpq $0x0,-0x8(%rbp)
3: tex_img = (SDL_Surface *) 0x558dea20
(gdb) print sizeof(tex_img)
$2 = 8
(gdb) print IMG_Load
$3 = {SDL_Surface *(const char *)} 0x7ffff7f0b670 <IMG_Load>
(gdb) list LoadTexture
183
184 /* Simple code to load a texture and return its id */
185 GLuint LoadTexture(char *tex_name)
186 {
187 GLuint tex_num;
188
189 SDL_Surface *tex_img;
190 glGenTextures(1, &tex_num);
191
192 if(tex_img = (SDL_Surface *) IMG_Load(tex_name)) {
193 glBindTexture(GL_TEXTURE_2D, tex_num);
194 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
195 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR);
196 if ((tex_img->format)->Amask)
197 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex_img->w,
tex_img->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, tex_img->pixels);
198 else
199 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
tex_img->w, tex_img->h, 0, GL_RGB, GL_UNSIGNED_BYTE, tex_img->pixels);
200 SDL_FreeSurface (tex_img);
201 }
202 else
203 printf("Texture not found!\n");
204
205 return tex_num;
206 }
(gdb) next
193 glBindTexture(GL_TEXTURE_2D, tex_num);
1: x/i $pc
=> 0x5555555579bb <LoadTexture+63>: mov -0xc(%rbp),%eax
3: tex_img = (SDL_Surface *) 0x558dea20
(gdb)
194 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
1: x/i $pc
=> 0x5555555579ca <LoadTexture+78>: mov $0x2601,%edx
3: tex_img = (SDL_Surface *) 0x558dea20
(gdb)
195 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR);
1: x/i $pc
=> 0x5555555579de <LoadTexture+98>: mov $0x2601,%edx
3: tex_img = (SDL_Surface *) 0x558dea20
(gdb)
196 if ((tex_img->format)->Amask)
1: x/i $pc
=> 0x5555555579f2 <LoadTexture+118>: mov -0x8(%rbp),%rax
3: tex_img = (SDL_Surface *) 0x558dea20
(gdb) print tex_img
$4 = (SDL_Surface *) 0x558dea20
(gdb) print tex_img->format
Cannot access memory at address 0x558dea28
(gdb) next
Thread 1 "gl_shadow" received signal SIGSEGV, Segmentation fault.
0x00005555555579f6 in LoadTexture (tex_name=0x7fffffffe120 "tex.png") at
src/benchmarks/GL_shadow/object.c:196
196 if ((tex_img->format)->Amask)
1: x/i $pc
=> 0x5555555579f6 <LoadTexture+122>: mov 0x8(%rax),%rax
3: tex_img = (SDL_Surface *) 0x558dea20
###################
https://tests.reproducible-builds.org/debian/rbuild/unstable/amd64/globs_0.2.0~svn50-5.rbuild.log.gz
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)) {
^
###################
cd /usr/lib/globs/benchmarks/GL_shadow
gdb -q --args ./gl_shadow -w640 -h480 -t5
set pagination off
set width 0
directory /home/benutzer/globs/orig/globs-0.2.0~svn50
directory /home/benutzer/libsdl-image1.2/orig/sdl-image1.2-1.2.12
b IMG_LoadTyped_RW
y
run
#b object.c:192
#b IMG_Load