Comments (10)
I have a few test cases reproducing this one for my system, but it depends on the DLL you link to; the code you provided works fine for me for example.
It's a pretty serious issue though and I'm not sure how to best fix it. Porting all of Lua to D is one option. I suppose recompiling the Lua DLL with the proper flags is another option?
from luad.
For me that simple example works with LuaJIT but not with my installed Lua-5.1.4.
For other examples it's vice versa.
As http://pgl.yoyo.org/luai/i/lua_atpanic says you may escape
with a longjmp something along this line would work.
// untested
void* stacktop;
auto wrap_call(alias func, Args...)(auto ref Args args)
{
asm { mov stacktop, ESP; }
return func(args);
}
extern(C) void onPanic()
{
asm { mov ESP, stacktop; }
throw new Exception("");
}
void doString()
{
...
wrap_call!lua_pcall(...);
}
After reading http://www.lua.org/pil/24.3.1.html I'm really wondering
why it calls at_panic in the first place because it should be in protected mode.
from luad.
@dawgfoto, the effort is to make it unroll the D stack on the way up.
If you use pcall, you don't get that. If you use xpcall, you can do the same as the panic function, but with the same problems.
from luad.
Since this LuaD functionality has known problems I suggest disabling it by default and adding a compile or runtime option to enable.
from luad.
Some more dialogue concerning this issue can be found at issue #40.
I hope we can keep it centralized here in the future.
from luad.
I pushed Lua libraries for x86-32 and x86-64 Linux compiled with -fno-omit-frame-pointer
, which works around this issue for those platforms. That also fixes the travis build and test run. It's also working for 32-bit Windows.
The D issue for this is 10671.
from luad.
This issue has just drawn one of my projects to a crashing halt... what workarounds exist?
from luad.
Why aren't we using pcall and catching the error there? Ideally, we could avoid the panic completely...
from luad.
The issue is compiler and platform specific. The general fix is to compile Lua with frame pointers intact. Which platform/compiler targets do you have issues with?
from luad.
I expect compiling with frame pointers intact would have a very high cost on performance...
Right now I'm on Win-x86_64 MSVC2015 + DMD, but this is a cross-platform project, including intended Android/iOS builds. Perhaps if Lua is built with C++ exceptions support?
Are there other known workarounds? SJLJ?
from luad.
Related Issues (20)
- Struct binding with empty constructor fail
- Broken with latest DMD
- const
- nil doesn't seem to work properly. HOT 2
- Can't build example using dub HOT 2
- lua 5.3 support? HOT 1
- Nice Library!
- Multiple linker errors of: PIE object; recompile with -fPIC HOT 3
- a problem when using a LDC2 HOT 4
- Unittest don't build with DMD 2.088 and up (don't know the actual fail point)
- An immutable bool will get converted to an integer on the Lua side.
- Lua program crashes when using delegates instead of function pointers HOT 3
- Lua coroutines/threads support HOT 2
- DUB Tag for v5.1.5 HOT 2
- dub compilation for osx and lua 5.1 HOT 3
- unittests crash on exit with dmd 2.067 and dmd 2.068 HOT 7
- Need more examples and some blogposts HOT 2
- wrapping of structs with private members
- lua 5.2 HOT 1
- Type mismatch for struct parameters crashes on Windows
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from luad.