Re: Eu2C segmentation fault, wxEuphoria v0.6.0
- Posted by Matt Lewis <matthewwalkerlewis at gmail.com> Apr 24, 2005
- 493 views
Robert Craig wrote: > > Kenneth Rhodes wrote: > > Using Euphoria 2.5 official translator, I get a segmentation fault > > when trying to execute translated/compiled versions > > of calendar.exw and wxIDE-0-2-2 under Linux. > > > > Shroud works like a dream! > > I tried calendar.exw on my Mandrake 10.0 system with GCC 3.3.2 > > It works fine with the interpreter, exu. > > It crashes when translated/compiled with ecu. I'll compile a demo and upload it later today, because I haven't had these problems...I regularly use a translated wxIDE. I strongly suspect that the problem is that wxeu.so was built with a different version of gcc (v3.2). If we find that this is an issue, I can always have multiple versions of the .so (or you could build it yourself :). > It crashes while executing the statement: > c_proc(eucall, {}) > at cplusplus.e:11 > after doing a few pokes into memory. > It has successfully executed this statement a couple of dozen times, > and when it crashes, it's the first time that it tries to execute > wxEntryStart. The parameters are {0, 0}. > > I'm not sure how to debug this further because I don't > seem to have the source for the eucall C++ routine. > In any case, it appears that Matt is doing some very > low-level tricky operation here, and for some reason it works when > interpreted, but not when compiled. It does not look like a > simple code-generation error on the part of the Translator. > It may have something to do with calling conventions, or accessing > the NULL pointer, or something. Perhaps it only works in the > interpreter by luck. calendar.exw is not the only one that fails > in this way. > It's not *that* low level. It's basically a way to call functions by pointer. The source for this is in the patch included in the developer's package. It's in src/common/utilscmn.cpp, and is as follows: // include/wx/utils.h: class WXDLLEXPORT wxEuCall { public: static int eufunc; static int euparam[17]; static int euret; static void eucall(); static int eulog( const char * ); }; // src/common/utilscmn.cpp: typedef int (*eucall_0)(); typedef int (*eucall_1)(int); typedef int (*eucall_2)(int, int); typedef int (*eucall_3)(int, int, int); typedef int (*eucall_4)(int, int, int, int); typedef int (*eucall_5)(int, int, int, int, int); typedef int (*eucall_6)(int, int, int, int, int, int); typedef int (*eucall_7)(int, int, int, int, int, int, int); typedef int (*eucall_8)(int, int, int, int, int, int, int, int); typedef int (*eucall_9)(int, int, int, int, int, int, int, int, int); typedef int (*eucall_10)(int, int, int, int, int, int, int, int, int, int); typedef int (*eucall_11)(int, int, int, int, int, int, int, int, int, int, int); typedef int (*eucall_12)(int, int, int, int, int, int, int, int, int, int, int, int); typedef int (*eucall_13)(int, int, int, int, int, int, int, int, int, int, int, int, int); typedef int (*eucall_14)(int, int, int, int, int, int, int, int, int, int, int, int, int, int); typedef int (*eucall_15)(int, int, int, int, int, int, int, int, int, int, int, int, int, int, int); int wxEuCall::eufunc = 0; int wxEuCall::euparam[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; int wxEuCall::euret = 0; int wxEuCall::eulog( const char *file) { wxLog* oldLog = wxLog::SetActiveTarget(new wxLogStderr(fopen( file, "w" ))); return (int) oldLog; } void wxEuCall::eucall() { int params = euparam[0]; // wxLogMessage( "eucall: %d [%d]", eufunc, euparam[0] ); switch (params){ case 0: euret = ( (eucall_0) eufunc)(); break; case 1: euret = ( (eucall_1) eufunc)( euparam[1]); break; case 2: euret = ( (eucall_2) eufunc)( euparam[1], euparam[2]); break; case 3: euret = ( (eucall_3) eufunc)( euparam[1], euparam[2], euparam[3]); break; case 4: euret = ( (eucall_4) eufunc)( euparam[1], euparam[2], euparam[3], euparam[4]); break; case 5: euret = ( (eucall_5) eufunc)( euparam[1], euparam[2], euparam[3], euparam[4], euparam[5]); break; case 6: euret = ( (eucall_6) eufunc)( euparam[1], euparam[2], euparam[3], euparam[4], euparam[5], euparam[6]); break; case 7: euret = ( (eucall_7) eufunc)( euparam[1], euparam[2], euparam[3], euparam[4], euparam[5], euparam[6], euparam[7]); break; case 8: euret = ( (eucall_8) eufunc)( euparam[1], euparam[2], euparam[3], euparam[4], euparam[5], euparam[6], euparam[7], euparam[8]); break; case 9: euret = ( (eucall_9) eufunc)( euparam[1], euparam[2], euparam[3], euparam[4], euparam[5], euparam[6], euparam[7], euparam[8], euparam[9]); break; case 10: euret = ( (eucall_10) eufunc)( euparam[1], euparam[2], euparam[3], euparam[4], euparam[5], euparam[6], euparam[7], euparam[8], euparam[9], euparam[10]); break; case 11: euret = ( (eucall_11) eufunc)( euparam[1], euparam[2], euparam[3], euparam[4], euparam[5], euparam[6], euparam[7], euparam[8], euparam[9], euparam[10], euparam[11]); break; case 12: euret = ( (eucall_12) eufunc)( euparam[1], euparam[2], euparam[3], euparam[4], euparam[5], euparam[6], euparam[7], euparam[8], euparam[9], euparam[10], euparam[11], euparam[12]); break; case 13: euret = ( (eucall_13) eufunc)( euparam[1], euparam[2], euparam[3], euparam[4], euparam[5], euparam[6], euparam[7], euparam[8], euparam[9], euparam[10], euparam[11], euparam[12], euparam[13]); break; case 14: euret = ( (eucall_14) eufunc)( euparam[1], euparam[2], euparam[3], euparam[4], euparam[5], euparam[6], euparam[7], euparam[8], euparam[9], euparam[10], euparam[11], euparam[12], euparam[13], euparam[14]); break; case 15: euret = ( (eucall_15) eufunc)( euparam[1], euparam[2], euparam[3], euparam[4], euparam[5], euparam[6], euparam[7], euparam[8], euparam[9], euparam[10], euparam[11], euparam[12], euparam[13], euparam[14], euparam[15]); break; default: ; } // wxLogMessage( "eucall returning %d", euret ); }