Comments (7)
Hmm, that's pretty odd indeed. IIRC those should indeed only pop up if something goes wrong internally.
I did recreate a structure generating a path like the one you posted, and that worked fine, so I'd have to guess it's some weird interaction somewhere. Assuming it's a bug, there are a few things you could do to help me track it down:
- Run an eris.unpersist directly after eris.persist, just to check if that already errors (which it should, otherwise I'd lean towards storage error / difference in environment).
- See if it happens all the time for a 'broken' save state, or if the unpersist can succeed/it's random.
- When it happens again, send me the saved state, and ideally a dumbed down version of the perms table (with mocks instead of the real values), or at least a description of what it contains so i can relatively easily re-create it myself. Then I can try to reproduce it and do some more in-depth testing.
Thanks!
from eris.
Thanks for the quick reply. I'll dig deeper into this and see if I can create a dumbed down version that you can re-create. I'll get back to you soon.
from eris.
Ok, I was able to reduce this to a much simpler test case that fails for you:
local c = {
attribute = 1,
observers = {}
}
local o = {
inner = {}
}
o.inner.foo = {
bar = function()
return c.attribute
end
}
table.insert(c.observers, o)
setmetatable(o, {
__persist = function(old)
local inner = old.inner
return function()
return {inner = inner}
end
end
})
eris.unpersist({}, eris.persist({}, o))
from eris.
Brilliant, thanks! I'm happy to report this is not a bug ;-)
This is indeed a special case that cannot be persisted, and a very indirect variant of that scenario at that. It's basically what's described in the special persistence section of the readme in the last quote:
It is important that the fixup closure returned not reference the original table directly, as that table would again be persisted as an upvalue, leading to an infinite loop.
Which it - indirectly - does, via the upvalue. When simplified a lot more the above boils down to this:
local a
a = {
function() -- this has a as an upvalue...
return a.b
end
}
setmetatable(a, {
__persist = function(t)
local value = t[1] -- so this has an indirect reference to a
return function()
return {value}
end
end
})
eris.unpersist(eris.persist(a))
I'll see if I can make it produce a better error message, though.
from eris.
Awesome! Thanks for taking the time to dig into this with me. A different error message would be helpful.
from eris.
Thinking more about this, I'm not sure there is a clean work around. Am I correct in thinking that this is something that a library like eris could handle directly? If so, I may be willing to give it a shot at some point.
from eris.
Well, I imagine for tables it'd be feasible by "pre-generating" the the table, and passing it to the closure that should restore the table, instead of having that return a new table. It'd not even be necessarily breaking compatibility, if it still had to return the table (as it is now). For userdata that wouldn't work, though...
from eris.
Related Issues (20)
- Potential crash when persisting threads HOT 1
- Eris for Lua 5.3 HOT 5
- Persisting threads and the global environment HOT 9
- Problems with conditionally loaded libraries HOT 4
- some lua unit test failures when using `make mingw` with latest eris release (1.1.0-5.3) HOT 3
- Linking issue when compiling eris as C++ caused by "typedef int bool" HOT 1
- Please update the project description HOT 1
- Memory limit HOT 2
- Internals of eris HOT 2
- What's meaning of invalid reference error?
- Memory corruption was detected in ERIS HOT 15
- Bug HOT 1
- upvalues in global functions to local variables not restored properly HOT 4
- Literal persistance of userdata HOT 1
- What is the purpose of persisting iolib and loadlib? HOT 2
- LuaJIT support HOT 1
- No issue, but seemingly the only way to reach you :) HOT 2
- Two upvalue related bugs HOT 3
- attempt to persist a light C function? HOT 3
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 eris.