Segfault when combined with PHPExcel #4

Open
lkraider opened this Issue May 21, 2012 · 7 comments

Projects

None yet

4 participants

@lkraider

I have some code that uses PHPExcel to process files, trying to run codespy on them causes PHP to segfault.

I did not have more time to debug the issue, so I am just disabling codespy on those files for now.

@sandeepcr529
Owner

Thanks for notifying this issue.

Codespy holds the execution data in memory. This, together with the memory usage of phpExcel might be what causing the issue.

It would be great if you could send me the files that causes this issue. Or you can just tell me you memory limit and how big the spreadsheet was when this issue happened.

@lkraider

Sometimes I get a segfault, sometimes the program aborts with an exception:

PHP Fatal error:  Call to undefined method PHPExcel_Reader_CSV::setLoadSheetsOnly()

Note that this error does not occur when codespy is not loaded.

Segfault backtrace:
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x00000001032ef000
0x00007fff8b924fa0 in memmove$VARIANT$sse3x ()
(gdb) bt
#0  0x00007fff8b924fa0 in memmove$VARIANT$sse3x ()
#1  0x0000000100323abf in zend_prepare_string_for_scanning ()
#2  0x00000001002ba647 in zif_token_get_all ()
#3  0x00000001003a8cf0 in zend_do_fcall_common_helper_SPEC ()
#4  0x00000001003a93cd in execute ()
#5  0x000000010033b273 in zend_call_function ()
#6  0x000000010033bb40 in call_user_function_ex ()
#7  0x00000001003106e4 in php_userstreamop_read ()
#8  0x000000010030ac61 in php_stream_fill_read_buffer ()
#9  0x000000010030aec3 in _php_stream_read ()
#10 0x000000010030b140 in _php_stream_copy_to_stream_ex ()
#11 0x0000000100271047 in php_copy_file_ctx ()
#12 0x00000001002711ab in zif_copy ()
#13 0x00000001003a8cf0 in zend_do_fcall_common_helper_SPEC ()
#14 0x00000001003a93cd in execute ()
#15 0x0000000100344799 in zend_execute_scripts ()
#16 0x00000001002f5222 in php_execute_script ()
#17 0x00000001003bf602 in main ()
System:

Memory config is 128M, tried setting to 1024M but no change.
Mac OSX 10.7.3

PHP 5.3.8 with Suhosin-Patch (cli) (built: Nov 15 2011 15:33:15) 
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
@lkraider

I cannot send the file because, even though it is only a test fixture, it contains data from a client. And I currently cannot replace the data with dummy values because I have no way to save in the original format (amazingly I don't use Excel at all on my machine, I only parse files the client sends me with PHP).

But I can describe the structure if it helps:
xlsx Excel 2007 workbook
containing 6 worksheets
first one is a matrix of 6 columns by 100 rows
the others are small matrices of 2 by 20.

@sandeepcr529
Owner

Thank you for the information. Let me check this and get back to you.

@cyril-bouthors

We had similar segmentation faults with PHPExcel.

After a long debug session, I came to the conclusion that something is wrong with the error handler or the session handler but I don't know exactly why, yet.

The good news is that I've found two possible ways to work-around this issue:

  1. Override the session handler at the end of the script:
class MySessionHandler implements SessionHandlerInterface
{
}

$handler = new MySessionHandler();
session_set_save_handler($handler, true);
  1. bypass any handler by forcing an exit at the end of the script:
exit();
@realtebo

@cyril-bouthors : it's incredibile. the exit(); solution works in 100% of cases. Without this, my IE users received a 'unable to download' error (I hate IE and the users).
i'm not using codespy, so you can close this issue because it's 100% due to PHPExcel.

@cyril-bouthors

:)
On Jun 18, 2015 2:54 PM, "Mirko Tebaldi" notifications@github.com wrote:

@cyril-bouthors https://github.com/cyril-bouthors : it's incredibile.
the exit(); solution works in 100% of cases. Without this, my IE users
received a 'unable to download' error (I hate IE and the users).


Reply to this email directly or view it on GitHub
#4 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment