Maxima Segmentation Fault PHP exec() on Ubuntu 20.04

43
November 30, 2020, at 09:20 AM

Update: by redirecting stderr from php exec, I can now see that running maxima produces a segmentation fault, increasing the likelihood that this is in fact a bug.

Important note: this used to work perfectly on older versions of PHP/Ubuntu.

I'm trying to get PHP exec() (or shell_exec() ) to redirect the output (stdout) of a maxima call to a text file. All I get is an empty file.

I have tried the simplest of commands:

exec( "maxima -b /var/www/tmpIn.txt > /var/www/tmp/tmpOut.txt"); 

(tmpIn.txt just contains the text "1+1;", all permissions are set properly).

If I paste this command in the terminal it will work fine, php's exec() will only produce an empty file. However, this is the case only for the maxima binary; cat/echo/ls etc. redirect just fine.

To me this seems exceedingly strange especially as this code used to work well as mentioned. Is there any workaround for this "bug"?

System info: ubuntu 20.04 PHP version 7.4 on Apache2 Maxima 5.43.2 bash

Answer 1

assuming that the path of installation is /usr/local/maxima5.43.2

please try using the following:

exec( "/usr/local/maxima5.43.2/maxima -b /var/www/tmpIn.txt > /var/www/tmp/tmpOut.txt"); 

Please adjust the path according to your own installation path . In addition, please add read and execute permission of maxima to apache , and also try using sudo to run

Answer 2

I have finally resolved the issue by changing the Apache 2 user from www-data to another user on the machine, so that user was restricted in some way. I believe this should still be considered a bug as the Segmentation Fault message should have been replaced by an actual error message in case those restrictions were intentional.

Update: the new apache2 user (set from envvars file) must have a home directory (e.g. added through adduser and not useradd) otherwise the problem will persist. If you set this to an active user the server might shutdown if that user is logged in/out externally. Those findings might point to a bug in maxima assuming a user directory or similar. I'm not sure if going the other way around (adding a home directory for www-data) would resolve this bug or not.

READ ALSO
How to programmatically to capture iOS camera app FROM Android custom app.? (connect via Bluetooth.) [closed]

How to programmatically to capture iOS camera app FROM Android custom app.? (connect via Bluetooth.) [closed]

Want to improve this question? Update the question so it focuses on one problem only by editing this post

70
How to make a button display random images on the slideshow

How to make a button display random images on the slideshow

I have here a simple program that displays random images that are in order, with two buttons that enable you to switch from an ascending order and then descending orderNow, I want to implement a random button that will display a random image of the selection...

24
Downgrade from Tensorflow 2.x to 1.15

Downgrade from Tensorflow 2.x to 1.15

I'm running into an issue where I'm unable to downgrade to tensorflow 115

84
Windows: How to solve port is taken by a process but I can't find it [closed]

Windows: How to solve port is taken by a process but I can't find it [closed]

Want to improve this question? Update the question so it's on-topic for Stack Overflow

74