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
In lwt_libev_stubs.c there is code to implement the hash and compare functions for the wrapper object for a libev loop structure (similar issues exists for the watcher structure):
If I read the OCaml code correctly then Data_custom_val will give you a pointer into an ocaml object:
#defineData_custom_val( v ) ((void *) &Field(( v ), 1))
This pointer will change when compaction occurs making the compare and hash functions return different results. This could mess seriously with any data structures that rely on ordering or identity like maps, hash tables, sorted lists ...
I think the intent of the code was to use the C-structs pointer as a basis for calculating the hash and the comparison but that is not what the code is doing.
I tried to verify whether this code actually gets triggered: I attached a debugger to a running process and put some breakpoints in these functions but they were not hit in my small test. If this is indeed dead code, should it not simply be removed?
The text was updated successfully, but these errors were encountered:
Indeed, thanks for catching and reporting this. I don't think these functions are used, but I'd rather not remove them right now. I've yet to thoroughly consider Lwt_engine, and having these preserves some flexibility with what data structures can be used.
In lwt_libev_stubs.c there is code to implement the hash and compare functions for the wrapper object for a libev loop structure (similar issues exists for the watcher structure):
If I read the OCaml code correctly then Data_custom_val will give you a pointer into an ocaml object:
This pointer will change when compaction occurs making the compare and hash functions return different results. This could mess seriously with any data structures that rely on ordering or identity like maps, hash tables, sorted lists ...
I think the intent of the code was to use the C-structs pointer as a basis for calculating the hash and the comparison but that is not what the code is doing.
I tried to verify whether this code actually gets triggered: I attached a debugger to a running process and put some breakpoints in these functions but they were not hit in my small test. If this is indeed dead code, should it not simply be removed?
The text was updated successfully, but these errors were encountered: