Manual talk:$wgMaxShellMemory

Error creating thumbnail: Invalid thumbnail parameters
This particular code was discussed in detail here: http://www.gossamer-threads.com/lists/wiki/mediawiki/169439 as fixing imagemagick problems. Adamtheclown 22:24, 17 January 2011 (UTC)
 * This line can be added to the end of LocalSettings.php. Adamtheclown 00:31, 21 February 2011 (UTC)

Please change default to something that WORKS
The default value of $wgMaxShellMemory in MW1.19.2 is too low for SVG thumbnail rendering. Please change the default value to one that consistently works on most servers, say 300000K.

The Error message produced by a value too low is far too obtuse: Error creating thumbnail: ERROR: meta.c (179): wmf_header_read: this isn't a wmf file convert: Delegate failed `"wmf2svg" -o "%o" "%i"'. convert: unable to open image `/tmp/magick-XXn4EQJ3': No such file or directory. convert: unable to load module `/usr/lib64/ImageMagick-6.2.8/modules-Q16/coders/svg.la': libdbus-1.so.3: failed to map segment from shared object: Cannot allocate memory. convert: unable to open file `/tmp/magick-XXn4EQJ3': No such file or directory. convert: missing an image filename `PNG:/tmp/transform_402f06e-1.png'.

Setting $wgMaxShellMemory to 300000 FIXED IT. (Thanks folks on Mediawiki-l for the tip! I would never have thought of this!)

A comment in MW-generated LocalSettings.php suggesting "Set $wgMaxShellMemory = 300000; when you allow SVG uploads" might help. --Rogerhc (talk) 19:29, 31 October 2012 (UTC)

Caution: This is LINUX only! Won't work with POSIX like systems e.g. FreeBSD
Hi everyone,

the function wfShellExec checks OS for "Linux" before using "ulimit4.sh", so for example FreeBSD won't use any ulimit here. This will fail sooner or later.

Someone[tm] should[tm] create a patch for ulimit4.sh and wfShellExec to enable ulimits for any POSIX aware operating system having a /bin/sh. Bug report will follow. --Rabe (talk) 10:06, 26 April 2013 (UTC)


 * I patched this for my system and verified it by getting a memory allocation error now:

Fehler beim Erstellen des Vorschaubildes: convert: memory allocation failed `/data/www/wiki.*****.org/secure/images/1/1b/FreeBSD_System_verschluesseln_mit_geli(8)_Diagramm.svg' @ error/svg.c/ReadSVGImage/2968. convert: no images defined `PNG:/data/www/wiki.*****.org/secure/images/temp/transform_28149c237e88-1.png' @ error/convert.c/ConvertImageCommand/3078.
 * The Community should check my patches (especially on Linux):

--- includes/GlobalFunctions.php.orig  2013-04-26 23:44:01.280681587 +0200 +++ includes/GlobalFunctions.php       2013-04-26 23:46:42.801299979 +0200 @@ -2785,7 +2785,7 @@       }        $cmd = $envcmd. $cmd; -      if ( php_uname( 's' ) == 'Linux' ) { +      if ( in_array(php_uname( 's' ) ,array('Linux','FreeBSD' ))) { $time = intval ( isset($limits['time']) ? $limits['time'] : $wgMaxShellTime ); $mem = intval ( isset($limits['memory']) ? $limits['memory'] : $wgMaxShellMemory ); $filesize = intval ( isset($limits['filesize']) ? $limits['filesize'] : $wgMaxShellFileSize ); @@ -2793,7 +2793,7 @@               if ( $time > 0 && $mem > 0 ) { $script = "$IP/bin/ulimit4.sh"; if ( is_executable( $script ) ) { -                              $cmd = '/bin/bash '. escapeshellarg( $script ). " $time $mem $filesize ". escapeshellarg( $cmd ); +                              $cmd = '/bin/sh '. escapeshellarg( $script ). " $time $mem $filesize ". escapeshellarg( $cmd ); }               }        }
 * 1) diff -u includes/GlobalFunctions.php.orig includes/GlobalFunctions.php

--- bin/ulimit4.sh.orig 2013-03-04 19:08:25.000000000 +0100 +++ bin/ulimit4.sh     2013-04-26 23:54:32.935097415 +0200 @@ -1,4 +1,8 @@ -#!/bin/bash +#!/bin/sh -ulimit -t $1 -v $2 -f $3 +logger -t MediaWiki::wfShellExec "$*" + +ulimit -t $1 +ulimit -v $2 +ulimit -f $3 eval "$4"
 * 1) diff -u bin/ulimit4.sh.orig bin/ulimit4.sh
 * Regards --Rabe (talk) 22:24, 26 April 2013 (UTC)