-
-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
imagick.so extension enabled in PHP kills PHP with segfault even with 'php -v' #624
Comments
No. The problem will be unique to your system, and probably depend on how you installed Imagick. Please can you try to generate a back trace using the instructions on this page: https://bugs.php.net/bugs-generating-backtrace.php . Or with just strace if you're on Linux, by installing strace with apt e.g. |
It might also be useful if you say how you installed Imagick. |
@jpbion any info? I can't investigate problems that are only happening on your system without any info. |
I can't do anything without info, so I'm going to close this issue. Feel free to update it with info |
Hello, php loads imagick.so using dlopen |
Removing RTLD_DEEPBIND from dl_open define in php-8.2 Zend/zend_portability.h solves the problem |
Oh, that's very interesting. Please can you write some words as to what you think is going on, as I have no idea what RTLD_DEEPBIND is. |
If a function name in a loaded library already exists in the runtime (coming from another library etc), the flag causes imagick to always use the function from it self instead of the function already loaded in the runtime. I think gcc 13 did some breaking optimisation changes to stdio/lib initialisation, so this might be related if libraries used by a binary was compiled with different gcc versions. So when imagick is loaded using its own gcc-provided function, it is incompatible with the already loaded function in php and segfault occurrs. Unless all software/libraries used by a process is always compiled with the exact same compiler, using RTLD_DEEPBIND can crash it. |
The discussion contained in the link I am providing here might be quite relevant to this issue. Please note the second link which points to a specific comment that details how a coder would resolve the issue discussed in this thread.
Entire thread:
php/php-src#11291
Specific comment:
php/php-src#11291 (comment)
From: jay92837483 ***@***.***>
Sent: Thursday, December 14, 2023 7:22 AM
To: Imagick/imagick ***@***.***>
Cc: jpbion ***@***.***>; Mention ***@***.***>
Subject: Re: [Imagick/imagick] imagick.so extension enabled in PHP kills PHP with segfault even with 'php -v' (Issue #624)
Removing RTLD_DEEPBIND from dl_open define in php-8.2 Zend/zend_portability.h solves the problem
Oh, that's very interesting.
Please can you write some words as to what you think is going on, as I have no idea what RTLD_DEEPBIND is.
If a function name in a loaded library already exists in the runtime (coming from another library etc), the flag causes imagick to always use the function from it self instead of the function already loaded in the runtime.
I think gcc 13 did some breaking optimisation changes to stdio/lib initialisation, so this might be related if libraries used by a binary was compiled with different gcc versions.
Both php, imagemagick and imagick is compiled with gcc13 on my machine, but not all of the libraries used by imagemagick (pango, cairo etc).
So when imagick is loaded using its own gcc-provided function, it is incompatible with the already loaded function in php and segfault occurrs.
Unless all software/libraries used by a process is always compiled with the exact same compiler, using RTLD_DEEPBIND can crash it.
This is just my guess..
—
Reply to this email directly, view it on GitHub <#624 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAA4UZGWE6FS3NW77773673YJMKQBAVCNFSM6AAAAAA3HH23RGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJWGA2DMNZTGQ> .
You are receiving this because you were mentioned. <https://github.com/notifications/beacon/AAA4UZCUDO5TRF67GSJ34L3YJMKQBA5CNFSM6AAAAAA3HH23RGWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTOUEDI4.gif> Message ID: ***@***.*** ***@***.***> >
|
Also, my entire system is compiled with the same compiler, with the same Glibc etc. I tried enabling imagick.so again in my php.ini and I get this crash again.
I don’t run a distro. I follow a ‘linux from scratch’ procedure to build my system, which means I compile everything from scratch, and whenever I get a new version of GCC or glibc (or a few other items) I rebuild my system from scratch again.
I am running:
Glibc: 2.38
Gcc: 13.2
Php: 8.3
ImageMagick: 7.1.1-22
Imagick: Latest from a “git clone/git pull”
Does/do the developer(s) of Imagick have access to a system with 2.38 GlibC/13.2 GCC?
Thanks,
Joel
From: ***@***.*** ***@***.***>
Sent: Thursday, December 14, 2023 8:01 AM
To: 'Imagick/imagick' ***@***.***>; 'Imagick/imagick' ***@***.***>
Cc: 'jpbion' ***@***.***>; 'Mention' ***@***.***>
Subject: RE: [Imagick/imagick] imagick.so extension enabled in PHP kills PHP with segfault even with 'php -v' (Issue #624)
The discussion contained in the link I am providing here might be quite relevant to this issue. Please note the second link which points to a specific comment that details how a coder would resolve the issue discussed in this thread.
Entire thread:
php/php-src#11291
Specific comment:
php/php-src#11291 (comment)
From: jay92837483 ***@***.*** ***@***.***> >
Sent: Thursday, December 14, 2023 7:22 AM
To: Imagick/imagick ***@***.*** ***@***.***> >
Cc: jpbion ***@***.*** ***@***.***> >; Mention ***@***.*** ***@***.***> >
Subject: Re: [Imagick/imagick] imagick.so extension enabled in PHP kills PHP with segfault even with 'php -v' (Issue #624)
Removing RTLD_DEEPBIND from dl_open define in php-8.2 Zend/zend_portability.h solves the problem
Oh, that's very interesting.
Please can you write some words as to what you think is going on, as I have no idea what RTLD_DEEPBIND is.
If a function name in a loaded library already exists in the runtime (coming from another library etc), the flag causes imagick to always use the function from it self instead of the function already loaded in the runtime.
I think gcc 13 did some breaking optimisation changes to stdio/lib initialisation, so this might be related if libraries used by a binary was compiled with different gcc versions.
Both php, imagemagick and imagick is compiled with gcc13 on my machine, but not all of the libraries used by imagemagick (pango, cairo etc).
So when imagick is loaded using its own gcc-provided function, it is incompatible with the already loaded function in php and segfault occurrs.
Unless all software/libraries used by a process is always compiled with the exact same compiler, using RTLD_DEEPBIND can crash it.
This is just my guess..
—
Reply to this email directly, view it on GitHub <#624 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAA4UZGWE6FS3NW77773673YJMKQBAVCNFSM6AAAAAA3HH23RGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJWGA2DMNZTGQ> .
You are receiving this because you were mentioned. <https://github.com/notifications/beacon/AAA4UZCUDO5TRF67GSJ34L3YJMKQBA5CNFSM6AAAAAA3HH23RGWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTOUEDI4.gif> Message ID: ***@***.*** ***@***.***> >
|
I'm thinking it might be a bug in libgomp. When DEEPBIND is used to load a library, environ is not taken from caller/php and could be NULL during dlopen (might be a bug in itself) |
Ill report it at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111556 and see how it goes |
Aight. This is already fixed in gcc for next release :) |
I applied the patch to my copy of GCC 13.2, rebuilt GCC, php, imagemagick , imagick, and I no longer get a segfault on starting php with imagick.so in php.ini.Sent from my iPhoneOn Dec 14, 2023, at 9:35 AM, jay92837483 ***@***.***> wrote:
Aight. This is already fixed in gcc for next release :)
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Well, I didn't do anything, and yet it looks like the issue is handled. Probably. Just relinking the actual issue here - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111413 |
Kernel 6.4.8
GLibC 2.38
PHP 8.2.8
ImageMagick 7.1.1-15
GCC 13.2
.. I believe this is trivial to reproduce if you have the above installed on your system. Then, just enable the imagick PHP extension, and even just do 'php --version'
The text was updated successfully, but these errors were encountered: