Bug #51815 SQL Editor crashes on syntax checking: Sql_editor::check_sql()
Submitted: 8 Mar 2010 0:40 Modified: 26 Mar 2010 13:32
Reporter: Bob Lamberson Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench: SQL Editor Severity:S2 (Serious)
Version:5.2.16 beta OS:Any
Assigned to: Sergei Tkachenko CPU Architecture:Any

[8 Mar 2010 0:40] Bob Lamberson
Description:
Opened a text file that was opened in notepad, then saved as utf-8 text. The conversion was because original file would not even open in sql editor - got an error that the file encoding was Latin1 and could not be opened.
Workbench showed an error near the first line of comments marked with -- . I clicked on the first position and hit enter once to add code, and the error occured.

I am new to MySQL but I think, from what I have read, I may be able to run this script from the command prompt, once I figure the syntax out. I am submitting this report because the error dialog requested it. I have run Memtest86+ and it reports no memory errors.

From MySQL Workbench Unexpected Error dialog....

Exception = System.AccessViolationException
Message = Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
FullText = System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at Sql_editor.check_sql(Sql_editor* , shared_ptr<Sql_editor>* , Boolean )
   at MySQL.Grt.Db.Sql.Sql_editor.check_sql()
   at MySQL.Grt.Db.Sql.SqlEditor.CheckSyntax()
   at MySQL.Grt.Db.Sql.SqlEditor.BackgroundActionTimer(Object obj, EventArgs args)
   at System.Windows.Forms.Timer.OnTick(EventArgs e)
   at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

How to repeat:
Opened a text file that was opened in notepad, then saved as utf-8 text. The conversion was because original file would not even open in sql editor - got an error that the file encoding was Latin1 and could not be opened.
Workbench showed an error near the first line of comments marked with -- . I clicked on the first position and hit enter once to add code, and the error occured.
[8 Mar 2010 0:56] Bob Lamberson
After closing the reported error dialog, I typed in use test on the first line of the sql window and got another error message show in the jpg screen snip added in the files section.
[8 Mar 2010 0:57] Bob Lamberson
2nd error dialog

Attachment: addedUseTest db then this error.JPG (image/pjpeg, text), 69.50 KiB.

[8 Mar 2010 5:49] Peter Laursen
As this happens after first linebreak my guess is that WB expects Unix linebreaks (\n) and the file created by Notepad has Windows linebreaks (\r\n). I think there is a similar or maybe even identical report already.

Also a utf8-file saved by Notepad has BOM's (Byte Order marks) what I do not know if WB handles properly.

Peter
(not a MySQL person)
[8 Mar 2010 6:08] Peter Laursen
Besides WB should handle ANSI-encoded files smoothly (if it does not).  Most .sql/.txt files generated by (Microsoft or non-Microsoft) Windows programs will be ANSI encoded.
[8 Mar 2010 6:18] Bob Lamberson
Bug #51308 does deal with the issue of line endings, if that is the cause of the error messages described here, as Peter Laursen suggests.
[8 Mar 2010 13:33] Sergei Tkachenko
I have strong reasons to blame a threading issue related to missing mutex quarder. Fix for that was pushed to repository.
Let me know if this bug reoccur in next version.
[23 Mar 2010 13:30] Johannes Taxacher
fix confirmed in repository
[26 Mar 2010 13:32] Tony Bedford
An entry has been added to the 5.2.17 changelog:

MySQL Workbench crashed while attempting to edit code in the SQL Editor.
[3 Dec 2011 20:36] Gordon MacKay
I have at least one crash a day where the SQL parser looses it. Good fix would be the ability to turn the parser off and avoid the libwpublic.be.dylib Sql_edit::check_sql crashes.