[Ecls-list] [emscripten] function pointer casting issue?

Rujia Liu 2575127 at qq.com
Sun Mar 22 15:53:15 UTC 2015


Dear all,


>AFAICS the manipulation with 'foo' makes no sense in Javascript.
I would just remove the test (which seem to fail now) and the
'else' branch.

Thanks for your suggestion. I removed this and got stuck in another place:

d:\ecl-em\msvc\bclink>node a.out.js
Calling stub instead of signal()
Calling stub instead of signal()
Calling stub instead of signal()
Calling stub instead of signal()
Calling stub instead of signal()
Calling stub instead of signal()
Calling stub instead of signal()
Invalid function pointer called with signature 'iii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefine
d behavior which can cause this)
Build with ASSERTIONS=2 for more info.
26
26

d:\ecl-em\msvc\bclink\a.out.js:84
      throw ex;
            ^
abort() at Error
    at jsStackTrace (d:\ecl-em\msvc\bclink\a.out.js:987:13)
    at stackTrace (d:\ecl-em\msvc\bclink\a.out.js:1004:22)
    at abort (d:\ecl-em\msvc\bclink\a.out.js:227042:25)
    at nullFunc_iii (d:\ecl-em\msvc\bclink\a.out.js:7092:467)
    at Array.b26 (d:\ecl-em\msvc\bclink\a.out.js:223280:46)
    at Array._test_compare [as 1248] (d:\ecl-em\msvc\bclink\a.out.js:201030:39)
    at _do_assoc (d:\ecl-em\msvc\bclink\a.out.js:175171:41)
    at _cl_assoc (d:\ecl-em\msvc\bclink\a.out.js:64909:9)
    at _ecl_logical_hostname_p (d:\ecl-em\msvc\bclink\a.out.js:144716:9)
    at _ecl_parse_namestring (d:\ecl-em\msvc\bclink\a.out.js:144801:11)
‍
I tried to build with ASSERSION=2 but the program (a.out.js) becomes 33MB and takes forever to run, so I added some printf calls and found that it is failling here in do_assoc():

            if (TEST(t, ECL_CONS_CAR(pair)))
                return pair;

‍where TEST is defined as:
#define TEST(t,k) ((t)->test_c_function)((t),(k))
‍
here the variable t (which is a struct cl_test‍*) was passed from ecl_logical_hostname_p (pathname.c, produced by dpp from pathname.d)

bool ecl_logical_hostname_p(cl_object host)
{
    if (!ecl_stringp(host))
        return FALSE;
    return !Null(cl_assoc(4, host, cl_core.pathname_translations, ECL_SYM(":TEST",1316), ECL_SYM("STRING-EQUAL",808)));
}
‍
It looks like the c code of "STRING_EQUAL" was stored in a big table called cl_symbols, as ECL_SYM was defined this way(in external.h):
#define ECL_SYM(name,code) ((cl_object)(cl_symbols+(code)))
‍
In emscrpten, casting function pointers can lead to issues (http://kripken.github.io/emscripten-site/docs/porting/guidelines/function_pointer_issues.html‍), which is similar in this case.

So could anyone explains how cl_symbols work? I looked at symbol_list.h but it's not clear to me whether there can be issues described above (function pointer casting).

- Rujia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20150322/65c84ef6/attachment.html>


More information about the ecl-devel mailing list