Discussion:
Unhandled exception in a call to FtpCommand
(too old to reply)
Noël Danjou
2007-04-25 16:46:53 UTC
Permalink
Windows XP Pro SP2
Internet Explorer 7.0
Visual Studio 2005 Pro SP1
Platform SDK for Windows Server 2003 R2


Hello all,

I am trying to implement a resume feature in a FTP application but when I
call FtpCommand with the RETR command, the debugger breaks in and displays
the following message:

"Unhandled exception at 0x77c42a16 in ftpcmd.exe: 0xC0000005: Access
violation reading location 0x00000001."

The call stack shows that it is related to the VC++ runtime, but I cannot
figure out what's causing the error in my code (see snippet below). Any help
would be very much appreciated. Thank you.

Noël
-----------------------------


msvcrt.dll!77c42a16()
[Frames below may be incorrect and/or missing, no symbols loaded for
msvcrt.dll]
ntdll.dll!7c91b298()
ntdll.dll!7c9106eb()
ntdll.dll!7c91b686()
ntdll.dll!7c91b686()
ntdll.dll!7c96d6cc()
ntdll.dll!7c96d886()
wininet.dll!771d729c()
wininet.dll!771beb43()
...
-----------------------------

CString strCommand;
strCommand.Format(_T("REST %I64d"), qdwPartialFileSize);

if (!FtpCommand(hConnect, FALSE, FTP_TRANSFER_TYPE_BINARY, strCommand, 0,
NULL))
{
...
return FALSE;
}

...
if (!InternetGetLastResponseInfo(&dwError, pszResponse, &dwLength))
{
...
return FALSE;
}

strCommand.Format(_T("RETR %s"), pszServerFileName);

HINTERNET hRequest = NULL;

// Crashes here >>>>
if (!FtpCommand(hConnect, TRUE, FTP_TRANSFER_TYPE_BINARY, strCommand, 0,
&hRequest))
{
...
return FALSE;
}


-----------------------------
--
Noël
http://noeld.com/
Scherbina Vladimir
2007-04-28 13:31:16 UTC
Permalink
How is pszServerFileName defined? Is it ansi or unicode? Due to crash
address, this is definitly not the problem of FtpCommand
--
--Vladimir, Windows SDK MVP
Post by Noël Danjou
Windows XP Pro SP2
Internet Explorer 7.0
Visual Studio 2005 Pro SP1
Platform SDK for Windows Server 2003 R2
Hello all,
I am trying to implement a resume feature in a FTP application but when I
call FtpCommand with the RETR command, the debugger breaks in and displays
"Unhandled exception at 0x77c42a16 in ftpcmd.exe: 0xC0000005: Access
violation reading location 0x00000001."
The call stack shows that it is related to the VC++ runtime, but I cannot
figure out what's causing the error in my code (see snippet below). Any
help would be very much appreciated. Thank you.
NoКl
-----------------------------
msvcrt.dll!77c42a16()
[Frames below may be incorrect and/or missing, no symbols loaded for
msvcrt.dll]
ntdll.dll!7c91b298()
ntdll.dll!7c9106eb()
ntdll.dll!7c91b686()
ntdll.dll!7c91b686()
ntdll.dll!7c96d6cc()
ntdll.dll!7c96d886()
wininet.dll!771d729c()
wininet.dll!771beb43()
...
-----------------------------
CString strCommand;
strCommand.Format(_T("REST %I64d"), qdwPartialFileSize);
if (!FtpCommand(hConnect, FALSE, FTP_TRANSFER_TYPE_BINARY, strCommand, 0,
NULL))
{
...
return FALSE;
}
...
if (!InternetGetLastResponseInfo(&dwError, pszResponse, &dwLength))
{
...
return FALSE;
}
strCommand.Format(_T("RETR %s"), pszServerFileName);
HINTERNET hRequest = NULL;
// Crashes here >>>>
if (!FtpCommand(hConnect, TRUE, FTP_TRANSFER_TYPE_BINARY, strCommand, 0,
&hRequest))
{
...
return FALSE;
}
-----------------------------
--
NoКl
http://noeld.com/
Scherbina Vladimir
2007-04-29 14:33:02 UTC
Permalink
Hello Noel,

The problem refers to IE7, I checked the example, it works like a charm
under IE6 on my XP machine, and crashes on IE7 in Vista. The problem is in
FtpConnect. If you pass the last parameter (pointer to hResponse the
functiona fails.). This is actual only when RETR is specified. Try to pass
NULL in last parameter in case of sending RETR - the function would _not_
crash.

I think this issue has to be reported to WNDP team.

HTH,
--
--Vladimir, Windows SDK MVP
Hello Vladimir,
Thanks for your reply.
pszServerFileName is an ANSI string (e.g. "/404.html"). The application is
MBCS.
I have the same issue when I pass the hardcoded "RETR /404.html" string in
place of the strCommand argument.
I attached the example (found on the Internet) that I used to experiment
with the issue.
Thank you.
--
Noel
http://noeld.com/
Noel Danjou
2007-04-30 09:23:00 UTC
Permalink
Hello Vladimir,

Thanks for your tests and report. I just sent a bug report to the WNDP team.
Thank you.
--
Noel
http://noeld.com/
Scherbina Vladimir
2007-04-30 09:52:42 UTC
Permalink
I also sent a request to a guy from WNDP who always fixes my issues ;)
--
--Vladimir, Windows SDK MVP
Hello Vladimir,
Thanks for your tests and report. I just sent a bug report to the WNDP
team. Thank you.
--
Noel
http://noeld.com/
Scherbina Vladimir
2007-04-30 10:20:40 UTC
Permalink
Btw, I also checked FTP plugin for Far (http://farmanager.com/) and it is
not crashing. An interesting thing, the developers of plugin do not use
FtpCommand, instead they did own implementation of ftp protocol, everything
is done via sockets. Maybe this would be the fastest solution for you,
because rewriting application would take 1 day of extreme programming.
--
--Vladimir, Windows SDK MVP
Hello Vladimir,
Thanks for your tests and report. I just sent a bug report to the WNDP
team. Thank you.
--
Noel
http://noeld.com/
Loading...