Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stmt.close cause segv #690

Closed
kamipo opened this issue Oct 10, 2015 · 1 comment · Fixed by #697
Closed

stmt.close cause segv #690

kamipo opened this issue Oct 10, 2015 · 1 comment · Fixed by #697
Milestone

Comments

@kamipo
Copy link
Contributor

kamipo commented Oct 10, 2015

  • ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
  • OS X 10.10.5
require 'mysql2'

client = Mysql2::Client.new(
  host: 'localhost',
  username: 'root',
  database: 'test',
)

client.query("DROP TABLE IF EXISTS t")
client.query("CREATE TABLE t (a int)")

stmt = client.prepare('SELECT * FROM t WHERE a = ?')
stmt.execute(1)

client.query("ALTER TABLE t ADD COLUMN b int")

# begin
#   stmt.execute(1)
# rescue
#   # <Mysql2::Error: The number of columns in the result set differs from the number of bound buffers. You must reset the statement, rebind the result set columns, and execute the statement again>
#   p $!
# end

stmt.close
# Segmentation fault
GC.start
@sodabrew sodabrew added this to the 0.4.2 milestone Oct 12, 2015
@sodabrew
Copy link
Collaborator

Thank you for this bug report. I'm able to reproduce this, but I haven't narrowed down where it's happening.

I've just got this partial backtrace so far:

4   libmysqlclient.18.dylib             0x000000010cd19fd6 reset_stmt_handle + 19
5   ???                                 0x00007f95e515ae28 0x0 + 140281770257960

kamipo added a commit to kamipo/mysql2 that referenced this issue Oct 18, 2015
Fixes brianmario#690.

When calling `mysql_stmt_execute`, we should not call `mysql_stmt_close`
before calling `mysql_stmt_free_result`.
kamipo added a commit to kamipo/mysql2 that referenced this issue Oct 18, 2015
Fixes brianmario#690.

When calling `mysql_stmt_execute`, we should not call `mysql_stmt_close`
before calling `mysql_stmt_free_result`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants