0

PLEASE IGNORE THIS QUESITON - I FOUND THAT THE PROBLEM DESCRIBED HERE IS NOT THE REAL PROBLEM. thanks to those who tried to help. The problem is gmagick specific. Not a general php issue.

I have this simple code on PHP Version 5.6.40-6+ubuntu18.04.1+deb.sury.org+3

<?php
header("Content-type: image/png");
$base_image = new Gmagick();
$base_image->newImage(3, 3, "#555555");
$base_image->setImageFormat('png');     
$x = $base_image->getImage();
echo $x;
?>

It works well (put out a 3x3 image) on ubuntu 16 php 5.6 server. I've created a new Ubuntu 18.04 server from scratch with the same stack (details below) but it crashes on the echo statement.

The error log shows: [Thu Apr 11 11:35:48.110542 2019] [core:notice] [pid 9875] AH00051: child pid 10298 exit signal Segmentation fault (11), possible coredump in /etc/apache2

What can cause such failure in the echo of a binary string representing an image?

See stack details here https://www.awesomescreenshot.com/image/3968080/0606779cd806f2d6a6e02828dd643dfd

Nir
  • 24,619
  • 25
  • 81
  • 117
  • 1
    Have you tried to `var_dump($x)` to see if it's actually a binary string? – Andrei Lupuleasa Apr 11 '19 at 11:51
  • 1
    try doing var_dump or print_r instead of echo – Rahul Apr 11 '19 at 11:51
  • 1
    Possible duplicate of ["\[notice\] child pid XXXX exit signal Segmentation fault (11)" in apache error.log](https://stackoverflow.com/questions/7745578/notice-child-pid-xxxx-exit-signal-segmentation-fault-11-in-apache-error-lo) – M. Eriksson Apr 11 '19 at 11:51
  • @RahulMeshram Interesting . var_dump gives object(Gmagick)#2 (0) { } It shows the same thing also on the older server which works. – Nir Apr 11 '19 at 12:04
  • @AndreiLupuleasa var_dump gives object(Gmagick)#2 (0) { } It shows the same thing also on the older server which works. – Nir Apr 11 '19 at 12:05

2 Answers2

0

I am referring to this documentation.

so var_dump($x); should give you a proper solution as it's object not string.

Returns a new Gmagick object with the current image sequence.

Rahul
  • 18,271
  • 7
  • 41
  • 60
0

It's an Imagick object. You can convert it to string like:

$x::getImageBlob()

see in: https://www.php.net/manual/en/imagick.getimageblob.php

Andrei Lupuleasa
  • 2,677
  • 3
  • 14
  • 32
  • I changed to getImageBlob(); Now it gives me a string in the working server and NULL in the non working one. – Nir Apr 11 '19 at 12:17