curl-library
Re: bugs in sample C code for fopen
Date: Mon, 03 May 2004 00:04:12 -0700
I downloaded the latest source for fopen.c from
http://curl.haxx.se/lxr/source/docs/examples/fopen.c
We upgraded curl to 7.11.2
[mobi_at_catlow bin]$ ./curl -V
curl 7.11.2 (i386-redhat-linux-gnu) libcurl/7.11.2 OpenSSL/0.9.6b ipv6 zlib/1.1.4
Protocols: ftp gopher telnet dict ldap http file https ftps
Features: IPv6 SSL libz NTLM Largefile
We are running gcc v.2.96
[mobi_at_catlow forums]$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-113)
-------------------
I modified the initial url from:
url="http://192.168.7.3/testfile";/* default to testurl */
to:
url="http://www.myownbusiness.org/index.html";/* default to testurl */
I also modified the various fopen and url_fopen statements from:
outf=fopen("fgets.test","w+");
if(!outf)
{
to:
outf=fopen("fgets.test","w+");
if(outf==NULL){
Further down in the code I changed it from:
handle = url_fopen("testfile", "r");
if(!handle) {
to:
handle = url_fopen(url, "r");
if(handle==NULL){
-------------------
I modified the code by placing printf/fflush debug statements to
find out where it was failing.
It seems to proceed just fine through the first "fgets" pass.
In the "fread" pass it dies when it calls url_fopen and tries to execute
the line:
while(curl_multi_perform(multi_handle, &file->still_running) == CURLM_CALL_MULTI_PERFORM );
and outputs:
Segmentation fault (core dumped)
-------------------
If I comment out the "fgets" section, then it completes the "fread" pass
and dies at the same place in url_fopen while running the "rewind" pass.
-------------------
If I comment out both "fgets" and "fread" then it hangs (with no error message)
during the "rewind" pass in url_fread. It hangs at the line:
curl_fill_buffer(file,want,1);
-------------------
Does this help? What other info do you need to find out where I made my mistake?
Thanks,
Dan
Daniel Stenberg wrote:
> On Sun, 2 May 2004, Dickerson wrote:
>
>
>>Has anyone gotten this to work?
>
>
> I believe at least Vincent Sanders has (as he wrote the latest incarnation of
> the example), and I had one of the first versions working at least mostly.
>
>
>>Has there been an update?
>
>
> Since when? The current example code has basicly been the same since August
> 2003.
>
>
>>It seems to die when I try to close one URL and open another or when I try
>>to rewind the URL. I have the latest version of libcurl installed.
>
>
> The fopen.c is a rather advanced example. I think you need to tell us more if
> you want better help.
>
> What is "It seems to die" in more exact terms? Is "try to close one URL" a
> call to url_fclose() ? etc
>
> Can you provide us with an as small as possible working source code (working
> against a public URL) that shows the problem happen?
>
Received on 2004-05-03