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

Stored Procedure -> CREATE code -> upper window -> save as text => sporadic exception #353

Closed
UweAtWork opened this Issue Sep 21, 2018 · 20 comments

Comments

Projects
None yet
4 participants
@UweAtWork
Copy link

UweAtWork commented Sep 21, 2018

Steps to reproduce this issue

  1. select a stored procedure
  2. navigate to "CREATE code" tabcard
  3. position cursor in upper window (also containing the CREATE-Statement)
  4. copy the name of the procedure into clipboard
  5. open context-menu
  6. choose "Als Textdatei speichern..."
  7. enter existing directory (e.g. C:\Temp)
  8. paste name of procedure from clipboard as filename
  9. afterwards heidisql might crash (see attached bugreport)

bugreport.txt

@UweAtWork

This comment has been minimized.

Copy link

UweAtWork commented Sep 21, 2018

BTW: It would be greate if heidisql would automatically choose the name of the stored procedure as default filename...

@ansgarbecker

This comment has been minimized.

Copy link
Collaborator

ansgarbecker commented Sep 21, 2018

I have just tested that, but I can't reproduce an exception here.

I'm not sure anyone can reproduce that anyhow?

@UweAtWork

This comment has been minimized.

Copy link

UweAtWork commented Sep 21, 2018

Just tested it again - and it crashed again on the first trial. I can provide you a (full) crashdump, if you want.

@ansgarbecker

This comment has been minimized.

Copy link
Collaborator

ansgarbecker commented Sep 22, 2018

Thanks. Well, your callstack is already there, but for some reason it does not crash here.

Relevant part of the callstack:

version            : 9.5.0.5293
compiled with      : Delphi XE5
madExcept version  : 4.0.12
callstack crc      : $88f6bfa4, $1f6be76b, $1f6be76b
exception number   : 1
exception class    : EAccessViolation
exception message  : Access violation at address 00000000008861D9 in module 'heidisql.exe'. Read of address 00000000000004D0.

main thread ($3570):
008861d9 heidisql.exe SynEdit        2112  +1 TCustomSynEdit.SynGetText
00c889d9 heidisql.exe Main           4224 +10 TMainForm.actSaveSynMemoToTextfileExecute
005db890 heidisql.exe System.Classes          TBasicAction.Execute
00666cb3 heidisql.exe Vcl.ActnList            TCustomAction.Execute
005db5c4 heidisql.exe System.Classes          TBasicActionLink.Execute
007ec7ac heidisql.exe Vcl.Menus               TMenuItem.Click
007ef851 heidisql.exe Vcl.Menus               DoClick
007ef9bc heidisql.exe Vcl.Menus               TMenu.IsShortCut
006a0d9d heidisql.exe Vcl.Controls            TWinControl.IsMenuKey
006a0e38 heidisql.exe Vcl.Controls            TWinControl.CNKeyDown
0040d90e heidisql.exe System                  TObject.Dispatch
00695ca3 heidisql.exe Vcl.Controls            TControl.WndProc
0069d36e heidisql.exe Vcl.Controls            TWinControl.WndProc
0089c5a6 heidisql.exe SynEdit        8581 +22 TCustomSynEdit.WndProc
0069c5aa heidisql.exe Vcl.Controls            TWinControl.MainWndProc
005dce43 heidisql.exe System.Classes          StdWndProc
7ffddcee user32.dll                           SendMessageW
00815413 heidisql.exe Vcl.Forms               TApplication.IsKeyMsg
00815797 heidisql.exe Vcl.Forms               TApplication.ProcessMessage
00815833 heidisql.exe Vcl.Forms               TApplication.HandleMessage
00815d1f heidisql.exe Vcl.Forms               TApplication.Run
00cd5227 heidisql.exe heidisql         80 +24 initialization
7ffdda9c KERNEL32.dll                         BaseThreadInitThunk
7ffddd30 ntdll.dll                            RtlUserThreadStart
@UB-GH

This comment has been minimized.

Copy link

UB-GH commented Sep 23, 2018

I tried it in my home-office today (on a laptop with almost same environment) - same problem (see attached bugreport.txt).

I´ve used procmon to trace system calls but i do not see anything special (except the name-collision, which should be normal):

(C:\Temp\ was selected as target-directory - it tries to access it here)

15:18:12,0296250 heidisql.exe 8460 QueryDirectory C:\temp SUCCESS Filter: temp, 1: temp

(That´s the last normal message before exception)

15:18:12,0486401 heidisql.exe 8460 QueryBasicInformationFile C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.17134.285_none_fb4297e330656775\comctl32.dll SUCCESS

(Preparation for crash-dump...)

15:18:12,0502683 heidisql.exe 8460 CreateFile C:\Users\me\AppData\Local\Temp NAME COLLISION Desired Access: Read Data/List Directory, Synchronize, Disposition: Create, Options: Directory, Synchronous IO Non-Alert, Open Reparse Point, Attributes: N, ShareMode: Read, Write, AllocationSize: 0

(Creation of crash-dump...)

15:18:12,0505661 heidisql.exe 8460 CreateFile C:\Users\me\AppData\Local\Temp\heidisql.madExcept SUCCESS Desired Access: Read Data/List Directory, Synchronize, Disposition: Create, Options: Directory, Synchronous IO Non-Alert, Open Reparse Point, Attributes: N, ShareMode: Read, Write, AllocationSize: 0, OpenResult: Created

@ansgarbecker

This comment has been minimized.

Copy link
Collaborator

ansgarbecker commented Sep 23, 2018

The crash happens before actually writing the file, in TCustomSynEdit.SynGetText, which just reads the lines of text in the SQL editor. This makes it quite mysterious and leaves me with no clue how to reproduce the crash.

@ansgarbecker

This comment has been minimized.

Copy link
Collaborator

ansgarbecker commented Sep 23, 2018

Perhaps it is important what you defined in the procedure body, the parameters and in the other fields. Some critical character probably, or something else. Post a screenshot here?

@UB-GH

This comment has been minimized.

Copy link

UB-GH commented Sep 23, 2018

SP.txt

(Please also note the blank line after the last argument. Each time i save a changed procedure/function, heidisql automatically appends an additional blank line between the last argument and the ending bracket. But i guess i will have to open another github issue to address this...)

@fifonik

This comment has been minimized.

Copy link

fifonik commented Sep 24, 2018

I tried it a number of times with my own SP and with the SP provided (definer changed to root@localhost) -- no crashes.
Win10 64bit, Heidi 9.5.0.5293

@UweAtWork

This comment has been minimized.

Copy link

UweAtWork commented Sep 25, 2018

I can provide you a full memory dump of the crashed application (not only the call-stack), if you want...

@ansgarbecker

This comment has been minimized.

Copy link
Collaborator

ansgarbecker commented Sep 25, 2018

Ok feel free to attach that dump here. I guess it's not of much use, as the context with the lines of code in HeidiSQL will be missing, but who knows.

@UB-GH

This comment has been minimized.

Copy link

UB-GH commented Sep 25, 2018

Do you also have a debug-version (including debug-symbols) i could use?
Or Is a free IDE availble i could use to build and debug HeidiSQL (e.g. Lazarus)?

@ansgarbecker

This comment has been minimized.

Copy link
Collaborator

ansgarbecker commented Sep 27, 2018

There is no debug version available.
HeidiSQL sources are compatible only to Delphi XE5 professional, which is unfortunately not free.

@UweAtWork

This comment has been minimized.

Copy link

UweAtWork commented Oct 11, 2018

I just checked the list of loaded modules: heidisql_loaded_modules.txt.

The module "Sophos Buffer Overrun Protection" looks interesting.
It belongs to our enpoint protection software.
Maybe the method "TCustomSynEdit.SynGetText" tries to access memory which is shielded by that module.

But that`s just a guess. Could you please compare the list against the modules loaded on your machine?!
(I used sysinternals process explorer to create the list via "File"->"Save")

@ansgarbecker

This comment has been minimized.

Copy link
Collaborator

ansgarbecker commented Oct 11, 2018

Here's my process list. Looks quite different than yours, though. I suppose that this is not so useful?
processes.txt

@UB-GH

This comment has been minimized.

Copy link

UB-GH commented Oct 11, 2018

More interesting are the HeidiSQL´s loaded modules (DLLs) and versions - not the processes...

@ansgarbecker

This comment has been minimized.

Copy link
Collaborator

ansgarbecker commented Dec 24, 2018

Is this still crashing, with the latest HeidiSQL build? There were lots of changes in the meantime, so probably...

@UweAtWork

This comment has been minimized.

Copy link

UweAtWork commented Dec 26, 2018

Sorry - still crashing...
bugreport.txt

@ansgarbecker

This comment has been minimized.

Copy link
Collaborator

ansgarbecker commented Dec 26, 2018

I just made the code for detecting the current SQL editor a bit more stable, and also added a fallback. Also, it now shows an error message when failing, not an exception.

Howver, the code used is the same for other editor save-as-actions as well. So I wonder if you had (and have?) the same problem on the table editor as well?

@ansgarbecker ansgarbecker added this to the v10 milestone Dec 26, 2018

@ansgarbecker ansgarbecker removed the question label Dec 26, 2018

@UB-GH

This comment has been minimized.

Copy link

UB-GH commented Dec 26, 2018

Thank you for the workaround,. I will give you feedback once the new binary is available.

Just googled around and found something that looks a bit questionable here
(in the assumption that this the current code behind the function):

function TCustomSynEdit.SynGetText: string;
var
ts : TStrings;
begin
ts := GetUncollapsedStrings;
Result := ts.Text;
ts.Free;
end;

Will "Result :=" allocate new memory (in the heap) and copy ts.Text in it
or will it just assign a reference to an object thats "Free"d in the next line?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment