Thread overview | ||||||
---|---|---|---|---|---|---|
|
November 27, 2003 Compiling without -g | ||||
---|---|---|---|---|
| ||||
Finally got time to look at the problem with embeding the PHP interpreter in D. Again, the program runs just fine when compiled with -g but raises an AccessViolation error on the php_embed_init() call. Here's the source code. const int SUCCESS = 0; extern (C) { int php_embed_init(int argc, char** argv , void**** ptsrm_ls); void php_embed_shutdown(void*** tsrm_ls); export char* get_zend_version(); } int main() { static char *argv[2] = ["test1", null]; static void*** tsrm_ls = null; if (SUCCESS != php_embed_init(1, argv, &tsrm_ls)) { printf("Failed initializing php_embed sapi\n"); return -1; } printf("Zend version: %s\n", get_zend_version()); php_embed_shutdown(tsrm_ls); return 0; } Following the advice from Walter, I've disassembled the files but given my poor skills in ASM I've lost track just from the start so I ask for help now. The main function got translated to: Comdat: __Dmain SEGMENT NONE '_TEXT' 00000052 bytes 0000 55 push ebp 0001 8B EC mov ebp,esp 0003 68 04 00 00 00 push offset L$8 0008 68 08 00 00 00 push offset L$2 000D 6A 01 push 0x00000001 000F E8 00 00 00 00 call _php_embed_init 0014 83 C4 0C add esp,0x0000000c 0017 85 C0 test eax,eax 0019 74 14 je L$9 001B 68 10 00 00 00 push offset L$3 0020 E8 00 00 00 00 call _printf 0025 B8 FF FF FF FF mov eax,0xffffffff 002A 83 C4 04 add esp,0x00000004 002D 5D pop ebp 002E C3 ret That's the debug version. The optimized one doesn't have the following lines 0000 55 push ebp 0001 8B EC mov ebp,esp (...) 002D 5D pop ebp So that must be the reason. Only that I don't know why, saving ebp on the stack prevents an access violation from raising. Mmmm... Help! -- Julio César Carrascal Urquijo http://www.artelogico.com/ |
November 28, 2003 Re: Compiling without -g | ||||
---|---|---|---|---|
| ||||
Posted in reply to Julio César Carrascal Urquijo | Are you using linux? "Julio César Carrascal Urquijo" <adnoctum@phreaker.net> wrote in message news:bq3sm3$2992$1@digitaldaemon.com... > Finally got time to look at the problem with embeding the PHP interpreter in > D. > > > Again, the program runs just fine when compiled with -g but raises an AccessViolation error on the php_embed_init() call. Here's the source code. > > const int SUCCESS = 0; > > extern (C) > { > int php_embed_init(int argc, char** argv , void**** ptsrm_ls); > void php_embed_shutdown(void*** tsrm_ls); > > export char* get_zend_version(); > } > > > int main() > { > static char *argv[2] = ["test1", null]; > static void*** tsrm_ls = null; > > if (SUCCESS != php_embed_init(1, argv, &tsrm_ls)) > { > printf("Failed initializing php_embed sapi\n"); > return -1; > } > > printf("Zend version: %s\n", get_zend_version()); > > php_embed_shutdown(tsrm_ls); > return 0; > } > > Following the advice from Walter, I've disassembled the files but given my poor skills in ASM I've lost track just from the start so I ask for help now. > > The main function got translated to: > > Comdat: __Dmain SEGMENT NONE '_TEXT' 00000052 bytes > 0000 55 push ebp > 0001 8B EC mov ebp,esp > 0003 68 04 00 00 00 push offset L$8 > 0008 68 08 00 00 00 push offset L$2 > 000D 6A 01 push 0x00000001 > 000F E8 00 00 00 00 call _php_embed_init > 0014 83 C4 0C add esp,0x0000000c > 0017 85 C0 test eax,eax > 0019 74 14 je L$9 > 001B 68 10 00 00 00 push offset L$3 > 0020 E8 00 00 00 00 call _printf > 0025 B8 FF FF FF FF mov eax,0xffffffff > 002A 83 C4 04 add esp,0x00000004 > 002D 5D pop ebp > 002E C3 ret > > > That's the debug version. The optimized one doesn't have the following lines > > 0000 55 push ebp > 0001 8B EC mov ebp,esp > (...) > 002D 5D pop ebp > > So that must be the reason. Only that I don't know why, saving ebp on the stack prevents an access violation from raising. > > Mmmm... Help! > > > -- > Julio César Carrascal Urquijo > http://www.artelogico.com/ > > |
November 29, 2003 Re: Compiling without -g | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Tested on win98se and Win2k dmd 0.75 php-4.3.3 libs. If you want to compile the example I'll send you the OMF libs. Didn't posted to the ng because their +600k. "Walter" <walter@digitalmars.com> wrote in message news:bq897i$2s6v$2@digitaldaemon.com... > Are you using linux? > -- Julio César Carrascal Urquijo http://www.artelogico.com/ |
December 29, 2003 Re: Compiling without -g | ||||
---|---|---|---|---|
| ||||
Posted in reply to Julio César Carrascal Urquijo | "Julio César Carrascal Urquijo" <adnoctum@phreaker.net> wrote in message news:bq8vrj$qog$1@digitaldaemon.com... > Tested on win98se and Win2k dmd 0.75 php-4.3.3 libs. > > If you want to compile the example I'll send you the OMF libs. Didn't posted > to the ng because their +600k. It's just not practical for me to debug 600k of code I'm not familiar with. I really need small, reproducible examples of problems. |
Copyright © 1999-2021 by the D Language Foundation