Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Lambda error invalid ELF header #143

Open
1 task done
johnEthicalTechnology opened this issue Aug 16, 2021 · 0 comments
Open
1 task done

Lambda error invalid ELF header #143

johnEthicalTechnology opened this issue Aug 16, 2021 · 0 comments

Comments

@johnEthicalTechnology
Copy link

johnEthicalTechnology commented Aug 16, 2021

Prerequisites

Description

I'm not entirely sure if this counts as a bug as I'm not entirely sure if the use of this package is supported on AWS Lambda, but I wanted to post this somewhere so as to have a record in case anyone else tries to use it on Lambda.

In any case, I was using this locally to develop a lambda function and when I pushed it to the AWS Lambda environment I ran into the following error: "/var/task/node_modules/spellchecker/build/Release/spellchecker.node: invalid ELF header". I looked into it and discovered the issue was my node modules weren't being built in the correct environment as used by lambda.

After a bunch of investigation and testing I was eventually able to find a docker image that was able to build the modules in an environment as similar to that used by lambda. However, when I ran the lambda I got this error: "SyntaxError: Unexpected token '.'",

I wasn't entirely sure what was going on until I looked at the logs of the docker build. I noticed the following:

> [email protected] install /var/task/node_modules/spellchecker
> node-gyp rebuild

make: Entering directory `/var/task/node_modules/spellchecker/build'
  CXX(target) Release/obj.target/hunspell/vendor/hunspell/src/hunspell/affentry.o
In file included from ../vendor/hunspell/src/hunspell/affentry.cxx:9:0:
../vendor/hunspell/src/hunspell/affentry.hxx:30:105: warning: converting to non-pointer type ‘short unsigned int’ from NULL [-Wconversion-null]
   struct hentry *      check_twosfx(const char * word, int len, char in_compound, const FLAG needflag = NULL);
                                                                                                         ^~~~
../vendor/hunspell/src/hunspell/affentry.hxx:93:114: warning: converting to non-pointer type ‘short unsigned int’ from NULL [-Wconversion-null]
   struct hentry *   check_twosfx(const char * word, int len, int optflags, PfxEntry* ppfx, const FLAG needflag = NULL);
                                                                                                                  ^~~~
../vendor/hunspell/src/hunspell/affentry.cxx: In member function ‘int PfxEntry::test_condition(const char*)’:
../vendor/hunspell/src/hunspell/affentry.cxx:113:20: warning: this statement may fall through [-Wimplicit-fallthrough=]
          case '.': if (!pos) { // dots are not metacharacters in groups: [.]
                    ^~
../vendor/hunspell/src/hunspell/affentry.cxx:120:5: note: here
     default: {
     ^~~~~~~
../vendor/hunspell/src/hunspell/affentry.cxx: In member function ‘int SfxEntry::test_condition(const char*, const char*)’:
../vendor/hunspell/src/hunspell/affentry.cxx:501:19: warning: this statement may fall through [-Wimplicit-fallthrough=]
         case '.': if (!pos) { // dots are not metacharacters in groups: [.]
                   ^~
../vendor/hunspell/src/hunspell/affentry.cxx:516:5: note: here
     default: {
     ^~~~~~~
  CXX(target) Release/obj.target/hunspell/vendor/hunspell/src/hunspell/affixmgr.o
In file included from ../vendor/hunspell/src/hunspell/affixmgr.cxx:12:0:
../vendor/hunspell/src/hunspell/affentry.hxx:30:105: warning: converting to non-pointer type ‘short unsigned int’ from NULL [-Wconversion-null]
   struct hentry *      check_twosfx(const char * word, int len, char in_compound, const FLAG needflag = NULL);
                                                                                                         ^~~~
../vendor/hunspell/src/hunspell/affentry.hxx:93:114: warning: converting to non-pointer type ‘short unsigned int’ from NULL [-Wconversion-null]
   struct hentry *   check_twosfx(const char * word, int len, int optflags, PfxEntry* ppfx, const FLAG needflag = NULL);
                                                                                                                  ^~~~
../vendor/hunspell/src/hunspell/affixmgr.cxx: In member function ‘int AffixMgr::parse_convtable(char*, FileMgr*, RepList**, const char*)’:
../vendor/hunspell/src/hunspell/affixmgr.cxx:3654:64: warning: argument to ‘sizeof’ in ‘int strncmp(const char*, const char*, size_t)’ call is the same expression as the second source; did you mean to provide an explicit length? [-Wsizeof-pointer-memaccess]
                              if (strncmp(piece, keyword, sizeof(keyword)) != 0) {
                                                                ^
  CXX(target) Release/obj.target/hunspell/vendor/hunspell/src/hunspell/csutil.o
  CXX(target) Release/obj.target/hunspell/vendor/hunspell/src/hunspell/dictmgr.o
../vendor/hunspell/src/hunspell/dictmgr.cxx: In member function ‘int DictMgr::parse_file(const char*, const char*)’:
../vendor/hunspell/src/hunspell/dictmgr.cxx:102:37: warning: this statement may fall through [-Wimplicit-fallthrough=]
                        pdict->region=NULL;
                                     ^
../vendor/hunspell/src/hunspell/dictmgr.cxx:103:21: note: here
                     case 2: //deliberate fallthrough
                     ^~~~
  CXX(target) Release/obj.target/hunspell/vendor/hunspell/src/hunspell/filemgr.o
  CXX(target) Release/obj.target/hunspell/vendor/hunspell/src/hunspell/hashmgr.o
  CXX(target) Release/obj.target/hunspell/vendor/hunspell/src/hunspell/hunspell.o
../vendor/hunspell/src/hunspell/hunspell.cxx: In member function ‘int Hunspell::spell(const char*, int*, char**)’:
../vendor/hunspell/src/hunspell/hunspell.cxx:369:19: warning: this statement may fall through [-Wimplicit-fallthrough=]
             *info += SPELL_ORIGCAP;
../vendor/hunspell/src/hunspell/hunspell.cxx:370:6: note: here
      case NOCAP: {
      ^~~~
../vendor/hunspell/src/hunspell/hunspell.cxx:439:13: warning: this statement may fall through [-Wimplicit-fallthrough=]
             }
             ^
../vendor/hunspell/src/hunspell/hunspell.cxx:441:6: note: here
      case INITCAP: {
      ^~~~
../vendor/hunspell/src/hunspell/hunspell.cxx: In member function ‘int Hunspell::suggest(char***, const char*)’:
../vendor/hunspell/src/hunspell/hunspell.cxx:741:30: warning: this statement may fall through [-Wimplicit-fallthrough=]
                     capwords = 1;
                     ~~~~~~~~~^~~
../vendor/hunspell/src/hunspell/hunspell.cxx:742:6: note: here
      case HUHCAP: {
      ^~~~
../vendor/hunspell/src/hunspell/hunspell.cxx:865:24: warning: this statement may fall through [-Wimplicit-fallthrough=]
               capwords = 1;
               ~~~~~~~~~^~~
../vendor/hunspell/src/hunspell/hunspell.cxx:866:11: note: here
           case HUHCAP: {
           ^~~~
  CXX(target) Release/obj.target/hunspell/vendor/hunspell/src/hunspell/hunzip.o
  CXX(target) Release/obj.target/hunspell/vendor/hunspell/src/hunspell/phonet.o
  CXX(target) Release/obj.target/hunspell/vendor/hunspell/src/hunspell/replist.o
  CXX(target) Release/obj.target/hunspell/vendor/hunspell/src/hunspell/suggestmgr.o
  CXX(target) Release/obj.target/hunspell/vendor/hunspell/src/parsers/textparser.o
  AR(target) Release/obj.target/hunspell.a
  COPY Release/hunspell.a
  CXX(target) Release/obj.target/spellchecker/src/main.o
../src/main.cc: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE {anonymous}::Spellchecker::CheckSpelling(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/main.cc:138:98: warning: ignoring return value of ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)’, declared with attribute warn_unused_result [-Wunused-result]
       misspelled_range->Set(context, Nan::New("start").ToLocalChecked(), Nan::New<Integer>(start));
                                                                                                  ^
In file included from /root/.cache/node-gyp/12.20.1/include/node/node.h:67:0,
                 from ../../nan/nan.h:58,
                 from ../src/main.cc:3:
/root/.cache/node-gyp/12.20.1/include/node/v8.h:3504:37: note: declared here
   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
                                     ^~~
../src/main.cc:139:94: warning: ignoring return value of ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)’, declared with attribute warn_unused_result [-Wunused-result]
       misspelled_range->Set(context, Nan::New("end").ToLocalChecked(), Nan::New<Integer>(end));
                                                                                              ^
In file included from /root/.cache/node-gyp/12.20.1/include/node/node.h:67:0,
                 from ../../nan/nan.h:58,
                 from ../src/main.cc:3:
/root/.cache/node-gyp/12.20.1/include/node/v8.h:3504:37: note: declared here
   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
                                     ^~~
../src/main.cc:140:51: warning: ignoring return value of ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, uint32_t, v8::Local<v8::Value>)’, declared with attribute warn_unused_result [-Wunused-result]
       result->Set(context, index, misspelled_range);
                                                   ^
In file included from /root/.cache/node-gyp/12.20.1/include/node/node.h:67:0,
                 from ../../nan/nan.h:58,
                 from ../src/main.cc:3:
/root/.cache/node-gyp/12.20.1/include/node/v8.h:3509:37: note: declared here
   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
                                     ^~~
../src/main.cc: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE {anonymous}::Spellchecker::GetAvailableDictionaries(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/main.cc:225:82: warning: ignoring return value of ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, uint32_t, v8::Local<v8::Value>)’, declared with attribute warn_unused_result [-Wunused-result]
       result->Set(context, i, Nan::New(dict.data(), dict.size()).ToLocalChecked());
                                                                                  ^
In file included from /root/.cache/node-gyp/12.20.1/include/node/node.h:67:0,
                 from ../../nan/nan.h:58,
                 from ../src/main.cc:3:
/root/.cache/node-gyp/12.20.1/include/node/v8.h:3509:37: note: declared here
   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
                                     ^~~
../src/main.cc: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE {anonymous}::Spellchecker::GetCorrectionsForMisspelling(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/main.cc:252:51: warning: ignoring return value of ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, uint32_t, v8::Local<v8::Value>)’, declared with attribute warn_unused_result [-Wunused-result]
       result->Set(context, i, val.ToLocalChecked());
                                                   ^
In file included from /root/.cache/node-gyp/12.20.1/include/node/node.h:67:0,
                 from ../../nan/nan.h:58,
                 from ../src/main.cc:3:
/root/.cache/node-gyp/12.20.1/include/node/v8.h:3509:37: note: declared here
   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
                                     ^~~
  CXX(target) Release/obj.target/spellchecker/src/worker.o
../src/worker.cc: In member function ‘virtual void CheckSpellingWorker::HandleOKCallback()’:
../src/worker.cc:39:96: warning: ignoring return value of ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)’, declared with attribute warn_unused_result [-Wunused-result]
     misspelled_range->Set(context, Nan::New("start").ToLocalChecked(), Nan::New<Integer>(start));
                                                                                                ^
In file included from /root/.cache/node-gyp/12.20.1/include/node/node.h:67:0,
                 from ../../nan/nan.h:58,
                 from ../src/worker.h:4,
                 from ../src/worker.cc:1:
/root/.cache/node-gyp/12.20.1/include/node/v8.h:3504:37: note: declared here
   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
                                     ^~~
../src/worker.cc:40:92: warning: ignoring return value of ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)’, declared with attribute warn_unused_result [-Wunused-result]
     misspelled_range->Set(context, Nan::New("end").ToLocalChecked(), Nan::New<Integer>(end));
                                                                                            ^
In file included from /root/.cache/node-gyp/12.20.1/include/node/node.h:67:0,
                 from ../../nan/nan.h:58,
                 from ../src/worker.h:4,
                 from ../src/worker.cc:1:
/root/.cache/node-gyp/12.20.1/include/node/v8.h:3504:37: note: declared here
   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
                                     ^~~
../src/worker.cc:41:49: warning: ignoring return value of ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, uint32_t, v8::Local<v8::Value>)’, declared with attribute warn_unused_result [-Wunused-result]
     result->Set(context, index, misspelled_range);
                                                 ^
In file included from /root/.cache/node-gyp/12.20.1/include/node/node.h:67:0,
                 from ../../nan/nan.h:58,
                 from ../src/worker.h:4,
                 from ../src/worker.cc:1:
/root/.cache/node-gyp/12.20.1/include/node/v8.h:3509:37: note: declared here
   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
                                     ^~~
../src/worker.cc:45:25: warning: ‘v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const’ is deprecated [-Wdeprecated-declarations]
   callback->Call(2, argv);
                         ^
In file included from ../src/worker.h:4:0,
                 from ../src/worker.cc:1:
../../nan/nan.h:1744:3: note: declared here
   Call(int argc, v8::Local<v8::Value> argv[]) const {
   ^~~~
  CXX(target) Release/obj.target/spellchecker/src/spellchecker_hunspell.o
  CXX(target) Release/obj.target/spellchecker/src/spellchecker_linux.o
  CXX(target) Release/obj.target/spellchecker/src/transcoder_posix.o
  SOLINK_MODULE(target) Release/obj.target/spellchecker.node
  COPY Release/spellchecker.node
make: Leaving directory `/var/task/node_modules/spellchecker/build'

I'm not familiar with the linux build environment so I couldn't exactly decipher what all that means. However, I'm get the impression how spellchecker was built in that linux environment is somehow incompatible with the node runtime or there's some issue with how it was built. But I don't really know. I see a lot of warnings in there but no errors.

I did find this issue in electron-spellchecker which is related.

Steps to Reproduce

Expected behavior:

Actual behavior:

Reproduces how often:

Versions

3.7.1

Additional Information

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

No branches or pull requests

1 participant