简体   繁体   中英

PHP extension CLI crashing

I have c++ class used for encrypting a file - works fine on it's own. I wrapped it using swig for 5.6.x-nts-Win32-x64 PHP. Usage:

<?php

require("crypt.php");

$e = new CCrypt();

//(plain, encrypted)
if ($e->EncryptFile("sample","enc/sample")) {
  print "Encrypted file\n";
}
$e = NULL;
print "Goodbye\n"
?>

Problem is this seems to work sometimes , with no consistent line in the extension code as to where it crashes when debugging. Error is corrupted heap. I am new to developing PHP extensions, and I'm wondering if this has to do with unsupported 64-bit PHP version, or something unique to CLI. Swig does not (yet) support PHP 7 :/

UPDATE Forgot to mention encryption works fine if run as an executable from PHP.

Turned out to be my lack of understanding SWIG's implementation of STL. When I removed STL from the wrapper source, the extension worked as expected. I later added STL back in, albeit in proper SWIG fashion!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM