You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A problem exists when Lua garbage collector deletes a variable which has a reference in C++ but not in Lua. The following example shows a code which could end with a segmentation fault because of this issue:
functionblah(db)
localgridfs=mongo.GridFS.New(db, "foo")
localfile=gridfs:find_file("bar")
returnfunction()
-- do whatever with fileprint(file:chunk(0):data())
endend
This code will produce arbitrary segmentation faults depending in the Lua garbage collection. The reference to gridfs only exists as local in the function blah. The returned closure captures the local file but not gridfs. So, at the end Lua garbage collector will delete gridfs variable because it is not referenced. Unfortunatelly, the GridFile C++ object contains a reference to this variable, but Lua is not acknowledged of that, and the call to file:chunk(0) will produce a segmentation fault.
The text was updated successfully, but these errors were encountered:
A problem exists when Lua garbage collector deletes a variable which has a reference in C++ but not in Lua. The following example shows a code which could end with a segmentation fault because of this issue:
This code will produce arbitrary segmentation faults depending in the Lua garbage collection. The reference to
gridfs
only exists as local in the functionblah
. The returned closure captures the localfile
but notgridfs
. So, at the end Lua garbage collector will deletegridfs
variable because it is not referenced. Unfortunatelly, theGridFile
C++ object contains a reference to this variable, but Lua is not acknowledged of that, and the call tofile:chunk(0)
will produce a segmentation fault.The text was updated successfully, but these errors were encountered: