1. Suspicious behavior when calling functions described in dynamic libraries.
- Posted by kelen_ 3 months ago
- 309 views
A main program calls two procedures each defined in two separate dll files.
-- main.ex include std/dll.e sequence dll_extension ifdef LINUX then dll_extension = ".so" elsifdef WINDOWS then dll_extension = ".dll" end ifdef -- --- printf(1, "main : Begin\n") function_1() function_2() printf(1, "main : End\n") -- --- function function_1() atom dll_id_1 = open_dll("./userdll_1" & dll_extension) integer proc_rid_1 = define_c_proc(dll_id_1, "procedure_1", {}) printf(1, "\tdll_id_1 : %d / proc_rid_1 : %d\n", {dll_id_1, proc_rid_1}) c_proc(proc_rid_1, {}) return(0) end function -- --- function function_2() atom dll_id_2 = open_dll("./userdll_2" & dll_extension) integer proc_rid_2 = define_c_proc(dll_id_2, "procedure_2", {}) printf(1, "\tdll_id_2 : %d / proc_rid_2 : %d\n", {dll_id_2, proc_rid_2}) c_proc(proc_rid_2, {}) return(0) end function
-- userdll_1.ex export procedure procedure_1() printf(1, "\t--> Here userdll_1 / procedure_1()\n") end procedure
-- userdll_2.ex export procedure procedure_2() printf(1, "\t--> Here userdll_2 / procedure_2()\n") end procedure
Under Windows euphoria-4.0.5-ow, euphoria-4.1.0-x86, euphoria-4.1.0-x64 the standard output gives this kind of things :
main : Begin dll_id_1 : 14725352988672 / proc_rid_1 : 28 --> Here userdll_1 / procedure_1() dll_id_2 : 14725352071168 / proc_rid_2 : 29 --> Here userdll_2 / procedure_2() main : Endwe see that everything is going well.
But under Linux euphoria-4.0.5-Linux-ix86, euphoria-4.1.0-Linux-x86, euphoria-4.1.0-Linux-x64 the standard output is :
main : Begin dll_id_1 : 14387712 / proc_rid_1 : 19 --> Here userdll_1 / procedure_1() dll_id_2 : 14384416 / proc_rid_2 : 20 --> Here userdll_1 / procedure_1() main : End free(): double free detected in tcache 2 AbortedWe can see that userdll_1 / procedure_1() is executed twice and program stops.
It seems that userdll_2 / procedure_2 is internally identified as userdll_1 / procedure_1 which can explain the detected double free.
This does not seem to be the expected behavior.
with all courtesy,
Philippe