Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught RuntimeError: invalid index into function table with 1.39.0 #380

Closed
ShuangLiu1992 opened this issue Oct 25, 2019 · 5 comments
Closed

Comments

@ShuangLiu1992
Copy link

I'm getting Uncaught RuntimeError: invalid index into function table with the latest version 1.39.0, tried master as well. Also std::string seems to pick up some random garbage memory.

It happens when making calls to functions in static library targets create in cmake add_subdirectory, both of which are compiled with the cmake tool chain file that came with the sdk

I haven't been able to identify where went wrong.

Can confirm the same code works with 1.38.48.

wasm-0f0acda6-2498:1 Uncaught RuntimeError: invalid index into function table
    at std::__2::__function::__policy_func<bool (int, nlohmann::detail::parser<nlohmann::basic_json<std::__2::map, std::__2::vector, std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char> >, bool, long long, unsigned long long, double, std::__2::allocator, nlohmann::adl_serializer> >::parse_event_t, nlohmann::basic_json<std::__2::map, std::__2::vector, std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char> >, bool, long long, unsigned long long, double, std::__2::allocator, nlohmann::adl_serializer>&)>::__policy_func(std::__2::__function::__policy_func<bool (int, nlohmann::detail::parser<nlohmann::basic_json<std::__2::map, std::__2::vector, std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char> >, bool, long long, unsigned long long, double, std::__2::allocator, nlohmann::adl_serializer> >::parse_event_t, nlohmann::basic_json<std::__2::map, std::__2::vector, std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char> >, bool, long long, unsigned long long, double, std::__2::allocator, nlohmann::adl_serializer>&)> const&) (wasm-function[2498]:0x682ee)
    at std::__2::function<bool (int, nlohmann::detail::parser<nlohmann::basic_json<std::__2::map, std::__2::vector, std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char> >, bool, long long, unsigned long long, double, std::__2::allocator, nlohmann::adl_serializer> >::parse_event_t, nlohmann::basic_json<std::__2::map, std::__2::vector, std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char> >, bool, long long, unsigned long long, double, std::__2::allocator, nlohmann::adl_serializer>&)>::function(std::__2::function<bool (int, nlohmann::detail::parser<nlohmann::basic_json<std::__2::map, std::__2::vector, std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char> >, bool, long long, unsigned long long, double, std::__2::allocator, nlohmann::adl_serializer> >::parse_event_t, nlohmann::basic_json<std::__2::map, std::__2::vector, std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char> >, bool, long long, unsigned long long, double, std::__2::allocator, nlohmann::adl_serializer>&)> const&) (wasm-function[2032]:0x55961)
    at nlohmann::basic_json<std::__2::map, std::__2::vector, std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char> >, bool, long long, unsigned long long, double, std::__2::allocator, nlohmann::adl_serializer>::parse(nlohmann::detail::input_adapter&&, std::__2::function<bool (int, nlohmann::detail::parser<nlohmann::basic_json<std::__2::map, std::__2::vector, std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char> >, bool, long long, unsigned long long, double, std::__2::allocator, nlohmann::adl_serializer> >::parse_event_t, nlohmann::basic_json<std::__2::map, std::__2::vector, std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char> >, bool, long long, unsigned long long, double, std::__2::allocator, nlohmann::adl_serializer>&)>, bool) (wasm-function[2009]:0x54615)
    at exec_json(std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char> > const&) (wasm-function[2002]:0x53b61)
    at _exec_json(std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char> >) (wasm-function[104]:0x6041)
    at emscripten::internal::Invoker<std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char> >, std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char> > >::invoke(std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char> > (*)(std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char> >), emscripten::internal::BindingType<std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char> >, void>::'unnamed'*) (wasm-function[109]:0x6246)
    at dynCall_iii (wasm-function[14915]:0x2b5c80)
    at Module.dynCall_iii (https://192.168.1.94:4443/gl_camera_web.js:8940:39)
    at dynCall_iii_5 (eval at makeDynCaller (https://192.168.1.94:4443/gl_camera_web.js:5607:19), <anonymous>:2:12)
    at Object.exec_json (eval at new_ (https://192.168.1.94:4443/gl_camera_web.js:5418:27), <anonymous>:6:10)
@kripken
Copy link
Member

kripken commented Oct 25, 2019

This may be related to the backend change in 1.39.0. Does 1.39.0-fastcomp work?

This may be related to emscripten-core/emscripten#9013 which is a known open issue with the new backend atm.

If that's not it, the new backend has sanitizers that can help: https://emscripten.org/docs/debugging/Sanitizers.html

@ShuangLiu1992
Copy link
Author

I will try 1.39.0-fastcomp and report back.
Does it mean I can't use -fPIC with 1.39.0 for now?

@ShuangLiu1992
Copy link
Author

1.39.0-fastcomp works.

@ShuangLiu1992
Copy link
Author

removing fPIC for all dependency solved the problem (very tedious though), closing this issue.

@kripken
Copy link
Member

kripken commented Oct 25, 2019

Thanks @ShuangLiu1992 , then this is the same as emscripten-core/emscripten#9013 - we are working on a fix for it, sorry for the breakage meanwhile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants