Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » 4DIAC - Framework for Distributed Industrial Automation and Control » Building 4DIAC Forte on macOS with luajit leads to segfault on start
Building 4DIAC Forte on macOS with luajit leads to segfault on start [message #1822450] Fri, 06 March 2020 15:37 Go to next message
Radimir Sorokin is currently offline Radimir SorokinFriend
Messages: 4
Registered: March 2020
Junior Member
I've tried to build 4diac forte on macOS with dynamic type loading feature enabled. I've proceeded according to the tutorial and compilation went fine, but when I started forte, it has halted with a segmentation fault.

In LUAJIT_LIBRARY property, I've tried to specify several luajit lib instances:
* static lib <LUAJIT_REPO>/src/libluajit.a
* dynamic lib <LUAJIT_REPO>/src/libluajit.so
* dynamic lib installed by juajit's make at /usr/local/lib/libluajit-5.1.2.0.5.dyliib

What have I done wrong?
Re: Building 4DIAC Forte on macOS with luajit leads to segfault on start [message #1822567 is a reply to message #1822450] Tue, 10 March 2020 06:55 Go to previous messageGo to next message
joy woo is currently offline joy wooFriend
Messages: 198
Registered: May 2019
Senior Member
Have you tried luajit in other OS? It didn't work correctly(the behavior is not correct) most of the time when executing, (I can only export to C++), how about you?
Re: Building 4DIAC Forte on macOS with luajit leads to segfault on start [message #1822585 is a reply to message #1822567] Tue, 10 March 2020 09:23 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 199
Registered: February 2016
Senior Member
In other OS we used the branch v2.0 of luajit-2.0 repo. Did you try that branch? Have you copied the libraries to the same folder as forte, or you added the library folders to PATH?
Re: Building 4DIAC Forte on macOS with luajit leads to segfault on start [message #1822603 is a reply to message #1822585] Tue, 10 March 2020 12:35 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1582
Registered: January 2014
Senior Member

can you run your 4diac FORTE with gdb so that we can see a backtrace on where the segfault is happening. This can help us trace this down.
Re: Building 4DIAC Forte on macOS with luajit leads to segfault on start [message #1822653 is a reply to message #1822603] Tue, 10 March 2020 20:03 Go to previous messageGo to next message
Radimir Sorokin is currently offline Radimir SorokinFriend
Messages: 4
Registered: March 2020
Junior Member
Thank you for your responses!

Quote:
Have you tried luajit in other OS?

No, unfortunately, I have no such options.

Quote:
It didn't work correctly(the behavior is not correct)

Can you elaborate on this? Does this mean I shouldn't rely on dynamic type loading at all?

Quote:
In other OS we used the branch v2.0 of luajit-2.0 repo. Did you try that branch?

Yes, I was trying v2.0.5 for the first time and now tried v2.0.0 with the same effect.

Quote:
can you run your 4diac FORTE with gdb so that we can see a backtrace on where the segfault is happening. This can help us trace this down.

Sure! Here what I got:
lldb) target create "forte"
Current executable set to 'forte' (x86_64).
(lldb) b lj_api.c:626
Breakpoint 1: where = libluajit-5.1.2.dylib`lua_pushcclosure + 12 at lj_api.c:626:3, address = 0x00007fff04c5b99c
(lldb) run
Process 95645 launched: '/usr/local/bin/forte' (x86_64)
libluajit-5.1.2.dylib was compiled with optimization - stepping may behave oddly; variables may not be available.
Process 95645 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x000000010045d99c libluajit-5.1.2.dylib`lua_pushcclosure(L=0x0000000000000000, f=(libluajit-5.1.2.dylib`luaopen_base at lib_base.c:673), n=0) at lj_api.c:626:3 [opt]
   623 	LUA_API void lua_pushcclosure(lua_State *L, lua_CFunction f, int n)
   624 	{
   625 	  GCfunc *fn;
-> 626 	  lj_gc_check(L);
   627 	  api_checknelems(L, n);
   628 	  fn = lj_func_newC(L, (MSize)n, getcurrenv(L));
   629 	  fn->c.f = f;
Target 0: (forte) stopped.
(lldb) frame info
frame #0: 0x000000010045d99c libluajit-5.1.2.dylib`lua_pushcclosure(L=0x0000000000000000, f=(libluajit-5.1.2.dylib`luaopen_base at lib_base.c:673), n=0) at lj_api.c:626:3 [opt]
(lldb) frame variable
(lua_State *) L = 0x0000000000000000
(lua_CFunction) f = 0x00000001004a77e0 (libluajit-5.1.2.dylib`luaopen_base at lib_base.c:673)
(int) n = 0
(GCfunc *) fn = <variable not available>

(lldb) thread backtrace
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
  * frame #0: 0x000000010045d99c libluajit-5.1.2.dylib`lua_pushcclosure(L=0x0000000000000000, f=(libluajit-5.1.2.dylib`luaopen_base at lib_base.c:673), n=0) at lj_api.c:626:3 [opt]
    frame #1: 0x00000001004b3a12 libluajit-5.1.2.dylib`luaL_openlibs(L=0x0000000000000000) at lib_init.c:41:5 [opt]
    frame #2: 0x0000000100028588 forte`CLuaEngine::CLuaEngine(this=0x00000001007001a0) at luaengine.cpp:47:3
    frame #3: 0x00000001000285a5 forte`CLuaEngine::CLuaEngine(this=0x00000001007001a0) at luaengine.cpp:45:26
    frame #4: 0x00000001000220fa forte`CResource::CResource(this=0x0000000100700630, pa_pstInterfaceSpec=0x00000001000c4968, pa_nInstanceNameId=4294967295, pa_acFBConnData="", pa_acFBVarsData="��
") at resource.cpp:53:19
    frame #5: 0x000000010009ab0b forte`CDevice::CDevice(this=0x0000000100700630, pa_pstInterfaceSpec=0x00000001000c4968, pa_nInstanceNameId=4294967295, pa_acFBConnData="", pa_acFBVarsData="��
") at device.h:49:9
    frame #6: 0x000000010009a9e7 forte`RMT_DEV::RMT_DEV(this=0x0000000100700630) at RMT_DEV.cpp:28:3
    frame #7: 0x000000010009ab75 forte`RMT_DEV::RMT_DEV(this=0x0000000100700630) at RMT_DEV.cpp:29:32
    frame #8: 0x00000001000021a1 forte`createDev(pa_acMGRID="localhost:61499") at main.cpp:65:15
    frame #9: 0x00000001000022bd forte`main(argc=1, arg=0x00007ffeefbff7c8) at main.cpp:91:5
    frame #10: 0x00007fff6911b7fd libdyld.dylib`start + 1
    frame #11: 0x00007fff6911b7fd libdyld.dylib`start + 1

Re: Building 4DIAC Forte on macOS with luajit leads to segfault on start [message #1822655 is a reply to message #1822653] Tue, 10 March 2020 20:34 Go to previous messageGo to next message
Radimir Sorokin is currently offline Radimir SorokinFriend
Messages: 4
Registered: March 2020
Junior Member
Just a guess, shouldn't it be related to this issue. Yet I am not aware of forte build internals, so can't test the proposed solution by myself.
Re: Building 4DIAC Forte on macOS with luajit leads to segfault on start [message #1822656 is a reply to message #1822655] Tue, 10 March 2020 20:48 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1582
Registered: January 2014
Senior Member

It looks like this is the issue. You could specify the two options (-pagezero_size 10000 -image_base 100000000) as linker flags in CMake gui for testing. Tick the advanced option and search for Cmake Linker flags.
Re: Building 4DIAC Forte on macOS with luajit leads to segfault on start [message #1822667 is a reply to message #1822656] Wed, 11 March 2020 08:21 Go to previous messageGo to next message
Radimir Sorokin is currently offline Radimir SorokinFriend
Messages: 4
Registered: March 2020
Junior Member
Unfortunately, specifying these options gain no effect.
Re: Building 4DIAC Forte on macOS with luajit leads to segfault on start [message #1822687 is a reply to message #1822667] Wed, 11 March 2020 11:54 Go to previous messageGo to next message
joy woo is currently offline joy wooFriend
Messages: 198
Registered: May 2019
Senior Member
@Mr. Zoitl,
I tested several examples with luajit with the lastest forte and 4diac IDE, but didn't get the correct behavior, so i don't know if the forte with luajit is still not stable?
Re: Building 4DIAC Forte on macOS with luajit leads to segfault on start [message #1822696 is a reply to message #1822667] Wed, 11 March 2020 15:17 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1582
Registered: January 2014
Senior Member

Radimir Sorokin wrote on Wed, 11 March 2020 08:21
Unfortunately, specifying these options gain no effect.


To bad. From your backtrace I can see that the method luaL_newstate(); returns a null pointer. I googled a bit and sofar these linker options seem to be the only right solution. However as I don't have a mac for testing I don't know how to correclty get 4diac FORTE linked with them.
Re: Building 4DIAC Forte on macOS with luajit leads to segfault on start [message #1822697 is a reply to message #1822687] Wed, 11 March 2020 15:18 Go to previous message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1582
Registered: January 2014
Senior Member

joy woo wrote on Wed, 11 March 2020 11:54
@Mr. Zoitl,
I tested several examples with luajit with the lastest forte and 4diac IDE, but didn't get the correct behavior, so i don't know if the forte with luajit is still not stable?


As you can see in our Bugzilla [1] there are still several issues open regarding lua. As always any support here is more then welcome.

[1] https://bugs.eclipse.org/bugs/buglist.cgi?bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&list_id=19225902&product=4DIAC&query_format=advanced
Previous Topic:Adapter connect to several FBs
Next Topic:4DIAC TCP client
Goto Forum:
  


Current Time: Fri Apr 19 16:19:05 GMT 2024

Powered by FUDForum. Page generated in 0.04163 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top