Using prepared statements with an external event loop and non-blocking I/O doesn't seem to work. I'm getting memory corruption problems when repeating the drizzle_stmt_execute call when the first call returned DRIZZLE_RETURN_IO_WAIT.
I've run my code in valgrind and it reports the memory issues:
==13304== Invalid write of size 2
==13304== at 0x48921DC: drizzle_state_result_read (result.cc:477)
==13304== by 0x48921DC: drizzle_state_result_read (result.cc:406)
==13304== by 0x489426C: func (packet.h:108)
==13304== by 0x489426C: current_state (structs.h:379)
==13304== by 0x489426C: drizzle_state_loop (state.cc:56)
==13304== by 0x488E26F: drizzle_command_write (conn.cc:876)
==13304== by 0x4894A0B: drizzle_stmt_execute (statement.cc:299)
...
==13304== Address 0x57bf150 is 2,112 bytes inside a block of size 2,296 free'd
==13304== at 0x483708B: operator delete(void*, unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==13304== by 0x48949DE: drizzle_stmt_execute (statement.cc:292)
...
==13304== Block was alloc'd at
==13304== at 0x483607F: operator new(unsigned long, std::nothrow_t const&) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==13304== by 0x4892262: drizzle_result_create (result.cc:59)
==13304== by 0x488E49C: drizzle_command_write (conn.cc:854)
==13304== by 0x4894A0B: drizzle_stmt_execute (statement.cc:299)
I didn't have problems with drizzle_stmt_prepare but looking at its code I think there are situations in which it would not work either, for example if drizzle_column_skip returned DRIZZLE_RETURN_IO_WAIT.
Hello,
Using prepared statements with an external event loop and non-blocking I/O doesn't seem to work. I'm getting memory corruption problems when repeating the
drizzle_stmt_execute
call when the first call returnedDRIZZLE_RETURN_IO_WAIT
.I've run my code in valgrind and it reports the memory issues:
==13304== Invalid write of size 2 ==13304== at 0x48921DC: drizzle_state_result_read (result.cc:477) ==13304== by 0x48921DC: drizzle_state_result_read (result.cc:406) ==13304== by 0x489426C: func (packet.h:108) ==13304== by 0x489426C: current_state (structs.h:379) ==13304== by 0x489426C: drizzle_state_loop (state.cc:56) ==13304== by 0x488E26F: drizzle_command_write (conn.cc:876) ==13304== by 0x4894A0B: drizzle_stmt_execute (statement.cc:299) ... ==13304== Address 0x57bf150 is 2,112 bytes inside a block of size 2,296 free'd ==13304== at 0x483708B: operator delete(void*, unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) ==13304== by 0x48949DE: drizzle_stmt_execute (statement.cc:292) ... ==13304== Block was alloc'd at ==13304== at 0x483607F: operator new(unsigned long, std::nothrow_t const&) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) ==13304== by 0x4892262: drizzle_result_create (result.cc:59) ==13304== by 0x488E49C: drizzle_command_write (conn.cc:854) ==13304== by 0x4894A0B: drizzle_stmt_execute (statement.cc:299)
I didn't have problems with
drizzle_stmt_prepare
but looking at its code I think there are situations in which it would not work either, for example ifdrizzle_column_skip
returnedDRIZZLE_RETURN_IO_WAIT
.