Ponup / php-sdl

SDL2 bindings for the PHP language
https://pecl.php.net/package/sdl
MIT License
107 stars 20 forks source link

Segfault with examples/004-draw-points.php #51

Open sebastianbergmann opened 3 years ago

sebastianbergmann commented 3 years ago
$ gdb php
GNU gdb (GDB) Fedora 10.2-3.fc34
Copyright (C) 2021 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-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://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 php...
Reading symbols from /usr/lib/debug/usr/bin/php-8.0.7-1.fc34.remi.x86_64.debug...
(gdb) r examples/004-draw-points.php
Starting program: /usr/bin/php examples/004-draw-points.php
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Dwarf Error: Cannot not find DIE at 0xfdec [from module /usr/lib/debug/usr/lib64/libjxl.so.0.3.7-0.3.7-3.fc34.x86_64.debug]

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00007fffe303a9c0 in __glXGetDrawableAttribute (dpy=0x555556190640, drawable=37748749, attribute=8433, value=0x7fffffff9ff4) at ../src/glx/glx_pbuffer.c:338
#2  0x00007ffff0c17a41 in X11_GL_GetSwapInterval (_this=0x5555561a4fd0) at /usr/src/debug/SDL2-2.0.14-3.fc34.x86_64/src/video/x11/SDL_x11opengl.c:913
#3  X11_GL_GetSwapInterval (_this=_this@entry=0x5555561a4fd0) at /usr/src/debug/SDL2-2.0.14-3.fc34.x86_64/src/video/x11/SDL_x11opengl.c:897
#4  0x00007ffff0c17b0b in X11_GL_SetSwapInterval (_this=0x5555561a4fd0, interval=0) at /usr/src/debug/SDL2-2.0.14-3.fc34.x86_64/src/video/x11/SDL_x11opengl.c:870
#5  0x00007ffff0b960d9 in GL_CreateRenderer (window=0x5555561f4550, flags=2) at /usr/src/debug/SDL2-2.0.14-3.fc34.x86_64/src/render/opengl/SDL_render_gl.c:1646
#6  0x00007ffff0b8b76c in SDL_CreateRenderer_REAL (window=0x5555561f4550, index=0, flags=2) at /usr/src/debug/SDL2-2.0.14-3.fc34.x86_64/src/render/SDL_render.c:858
#7  0x00007ffff0cda7cd in zif_SDL_CreateRenderer (execute_data=0x7ffff72130d0, return_value=0x7ffff72130b0) at /usr/src/debug/php-pecl-sdl-2.5.0-1.fc34.remi.8.0.x86_64/NTS/src/render.c:248
#8  0x000055555584588a in ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER () at /usr/src/debug/php-8.0.7-1.fc34.remi.x86_64/Zend/zend_vm_execute.h:1295
#9  execute_ex (ex=0x55555648ef10) at /usr/src/debug/php-8.0.7-1.fc34.remi.x86_64/Zend/zend_vm_execute.h:54528
#10 0x000055555584ae29 in zend_execute (op_array=0x7ffff7271100, return_value=0x0) at /usr/src/debug/php-8.0.7-1.fc34.remi.x86_64/Zend/zend_vm_execute.h:58875
#11 0x00005555557e0080 in zend_execute_scripts (type=type@entry=8, retval=retval@entry=0x0, file_count=file_count@entry=3) at /usr/src/debug/php-8.0.7-1.fc34.remi.x86_64/Zend/zend.c:1680
#12 0x000055555577bbe3 in php_execute_script (primary_file=<optimized out>) at /usr/src/debug/php-8.0.7-1.fc34.remi.x86_64/main/main.c:2501
#13 0x000055555587082c in do_cli (argc=2, argv=0x555555e21c30) at /usr/src/debug/php-8.0.7-1.fc34.remi.x86_64/sapi/cli/php_cli.c:948
#14 0x000055555563a72b in main (argc=2, argv=0x555555e21c30) at /usr/src/debug/php-8.0.7-1.fc34.remi.x86_64/sapi/cli/php_cli.c:1335

I use @remicollet's PHP packages for Fedora.

$ cat /etc/os-release 
NAME=Fedora
VERSION="34 (Workstation Edition)"
ID=fedora
VERSION_ID=34
VERSION_CODENAME=""
PLATFORM_ID="platform:f34"
PRETTY_NAME="Fedora 34 (Workstation Edition)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:34"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/34/system-administrators-guide/"
SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=34
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=34
PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
VARIANT="Workstation Edition"
VARIANT_ID=workstation
$ dnf info php-cli
Installed Packages
Name         : php-cli
Version      : 8.0.7
Release      : 1.fc34.remi
Architecture : x86_64
Size         : 24 M
Source       : php-8.0.7-1.fc34.remi.src.rpm
Repository   : @System
From repo    : remi-modular
Summary      : Command-line interface for PHP
URL          : http://www.php.net/
License      : PHP and Zend and BSD and MIT and ASL 1.0 and NCSA and PostgreSQL
Description  : The php-cli package contains the command-line interface
             : executing PHP scripts, /usr/bin/php, and the CGI interface.
$ dnf info php-pecl-sdl
Installed Packages
Name         : php-pecl-sdl
Version      : 2.5.0
Release      : 1.fc34.remi.8.0
Architecture : x86_64
Size         : 3.4 M
Source       : php-pecl-sdl-2.5.0-1.fc34.remi.8.0.src.rpm
Repository   : @System
From repo    : remi-modular
Summary      : Simple DirectMedia Layer for PHP
URL          : https://pecl.php.net/package/sdl
License      : PHP
Description  : This extension allows you to develop multimedia applications with PHP
             : using the complete SDL library API.
             : 
             : Use the "phpsdl" command to launch a SDL application.
             : 
             : Package built for PHP 8.0.
$ php -v
PHP 8.0.7 (cli) (built: Jun  1 2021 18:43:05) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.7, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.7, Copyright (c), by Zend Technologies
sebastianbergmann commented 3 years ago

What I reported in https://github.com/Ponup/php-sdl/issues/51#issue-932228787 happens inside a VMware Workstation 16 Pro (16.1.2 build-17966106) virtual machine.

I just tried the same example on my ThinkPad T560 where the same version of Fedora with the same version of PHP with the same version of the SDL extension is running natively: there it works.

Could it be that SDL cannot properly initialize OpenGL inside the virtual machine and that this in turn leads to the segmentation fault?