#4012 (ok 4.0.5) Crash on CSV file import

4.0.4
fixed
None
1
2013-08-04
2013-07-09
No

PhpMyAdmin crashs on attempts to import long CSV file.

e.g. when I've tried to import about 400K lines, about 10MiB CSV it crashes with the message

[Fri Jul 05 12:44:56 2013] [error] [client 127.0.0.1] PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 40961 bytes) in /Users/dime/Sites/mysql4/libraries/import.lib.php on line 863, referer: http://**/import.php

As you can see memory limit is 1GiB that should be more than enough to import 10MiB file.

The problem is caused by wrong usage referencing for parameters.

Once it fixed:

bash-3.2$ diff -ubp import.lib.php.orig import.lib.php.patched
--- import.lib.php.orig 2013-07-09 15:16:46.000000000 +0300
+++ import.lib.php.patched 2013-07-09 15:18:05.000000000 +0300
@@ -565,7 +565,7 @@ function PMA_getDecimalSize(&$cell)
* @todo Handle the error cases more elegantly
*/
function PMA_detectSize($last_cumulative_size, $last_cumulative_type,
- $curr_type, &$cell
+ $curr_type, $cell
) {
$curr_size = strlen((string)$cell);

@@ -763,7 +763,7 @@ function PMA_detectSize($last_cumulative
* (VARCHAR or INT or BIGINT or DECIMAL or NONE)
* @access public
/
-function PMA_detectType($last_cumulative_type, &$cell)
+function PMA_detectType($last_cumulative_type, $cell)
{
/
*
* If numeric, determine if decimal, int or bigint

bash-3.2$

It obviously works just fine.

Could you please commit the patch.

PS - just in order to prevent flame - passing parameters by value without reference does not initiate a data coping, meanwhile modification of part of the array passed by reference does.

Discussion

  • Marc Delisle

    Marc Delisle - 2013-07-20
    • assigned_to: Marc Delisle
     
  • Marc Delisle

    Marc Delisle - 2013-07-20
    • summary: PhpMyAdmin crashes on CVS file import --> Crash on CSV file import
     
  • Marc Delisle

    Marc Delisle - 2013-07-20
    • summary: Crash on CSV file import --> (ok 4.0.5) Crash on CSV file import
    • status: open --> resolved
    • Priority: 5 --> 1
     
  • Marc Delisle

    Marc Delisle - 2013-08-04
    • Status: resolved --> fixed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks