Thread overview |
---|
February 19, 2004 libcurl , DMC | ||||
---|---|---|---|---|
| ||||
Hey all, Im building libcurl with DMC ( www.atari-soldiers.com/libcurlDMC.zip ) and it builds ok , but when I compile the simple.c example it crashes. The line that crashes is url.c , line 2116 if((1 > sscanf(data->change.url, "%512[^\n/?]%[^\n]",conn->gname, conn->path)) ) I dont use sscanf , I think this is supposed to format it by stripping the http:// of a URL string , but I cant read it. Why would this be causing DMC to crash , and not others ? Any help is super appreciated. Thanks, Charles |
February 19, 2004 Re: libcurl , DMC | ||||
---|---|---|---|---|
| ||||
Posted in reply to C | Hmm, changing the URL a bit, it crashes a bit earlier on with sscanf again. if((2 == sscanf(data->change.url, "%64[^:]:%[^\n]", conn->protostr, conn->path)) && strequal(conn->protostr, "file")) Is there a known issue with sscanf ? C On Wed, 18 Feb 2004 21:07:28 -0800, C <dont@respond.com> wrote: > Hey all, > > Im building libcurl with DMC ( www.atari-soldiers.com/libcurlDMC.zip ) and > it builds ok , but when I compile the simple.c example it crashes. > > The line that crashes is > > url.c , line 2116 > > if((1 > sscanf(data->change.url, "%512[^\n/?]%[^\n]",conn->gname, > conn->path)) ) > > I dont use sscanf , I think this is supposed to format it by stripping the > http:// of a URL string , but I cant read it. > > Why would this be causing DMC to crash , and not others ? > > Any help is super appreciated. > > Thanks, > Charles > > -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ |
February 19, 2004 Re: libcurl , DMC | ||||
---|---|---|---|---|
| ||||
Posted in reply to C | "C" <dont@respond.com> wrote in message news:c118pk$168f$1@digitaldaemon.com... > Hey all, > > Im building libcurl with DMC ( www.atari-soldiers.com/libcurlDMC.zip ) and it builds ok , but when I compile the simple.c example it crashes. > > The line that crashes is > > url.c , line 2116 > > if((1 > sscanf(data->change.url, "%512[^\n/?]%[^\n]",conn->gname, > conn->path)) ) > > I dont use sscanf , I think this is supposed to format it by stripping the http:// of a URL string , but I cant read it. > > Why would this be causing DMC to crash , and not others ? > > Any help is super appreciated. > > Thanks, > Charles Please cut it down to the smallest reproducible example, and send it to me so I can fix it. Thanks, -Walter |
February 19, 2004 Re: libcurl , DMC | ||||
---|---|---|---|---|
| ||||
Posted in reply to C | No, no known issues with sscanf. ------------------------------------------- "C" <dont@respond.com> wrote in message news:opr3lrcsozehmtou@localhost... Hmm, changing the URL a bit, it crashes a bit earlier on with sscanf again. if((2 == sscanf(data->change.url, "%64[^:]:%[^\n]", conn->protostr, conn->path)) && strequal(conn->protostr, "file")) Is there a known issue with sscanf ? C |
February 19, 2004 Re: libcurl , DMC | ||||
---|---|---|---|---|
| ||||
Posted in reply to C | Charles:
If you really felt enterprising enough -- the C RTL source is included on the CD -- you could copy over the scanf.c source (that's its name), compile it with libcurl, and actually diagnose the problem yourself, fix it, provide patch file.
-scooter
C wrote:
> Hey all,
>
> Im building libcurl with DMC ( www.atari-soldiers.com/libcurlDMC.zip ) and
> it builds ok , but when I compile the simple.c example it crashes.
>
> The line that crashes is
>
> url.c , line 2116
>
> if((1 > sscanf(data->change.url, "%512[^\n/?]%[^\n]",conn->gname,
> conn->path)) )
>
> I dont use sscanf , I think this is supposed to format it by stripping the
> http:// of a URL string , but I cant read it.
>
> Why would this be causing DMC to crash , and not others ?
>
> Any help is super appreciated.
>
> Thanks,
> Charles
>
>
|
March 20, 2004 Re: libcurl , DMC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Hmm appears I was wrong , the problem seems to stem from entry_id = create_hostcache_id(hostname, port, &entry_len); Its late though, ill have to look more into it later. Thought i'd mention incase someone else ran across this ? thx C On Wed, 18 Feb 2004 19:28:03 -0800, Walter <walter@digitalmars.com> wrote: > > "C" <dont@respond.com> wrote in message > news:c118pk$168f$1@digitaldaemon.com... >> Hey all, >> >> Im building libcurl with DMC ( www.atari-soldiers.com/libcurlDMC.zip ) and >> it builds ok , but when I compile the simple.c example it crashes. >> >> The line that crashes is >> >> url.c , line 2116 >> >> if((1 > sscanf(data->change.url, "%512[^\n/?]%[^\n]",conn->gname, >> conn->path)) ) >> >> I dont use sscanf , I think this is supposed to format it by stripping the >> http:// of a URL string , but I cant read it. >> >> Why would this be causing DMC to crash , and not others ? >> >> Any help is super appreciated. >> >> Thanks, >> Charles > > Please cut it down to the smallest reproducible example, and send it to me > so I can fix it. Thanks, -Walter > > -- D Newsgroup. |
March 20, 2004 Re: libcurl , DMC | ||||
---|---|---|---|---|
| ||||
Posted in reply to C | That was a silly post sorry, think Ive found the problem. /* Create a hostcache id */ static char * create_hostcache_id(char *server, int port, ssize_t *entry_len) { char *id = NULL; /* Get the length of the new entry id */ *entry_len = *entry_len + /* Hostname length */ 1 + /* ':' seperator */ _num_chars(port); /* number of characters the port will take up */ /* Allocate the new entry id */ // this is failing, segfaulting id = malloc(*entry_len + 1); // never gets past here if (!id) { return NULL; } /* Create the new entry */ /* If sprintf() doesn't return the entry length, that signals failure */ if (sprintf(id, "%s:%d", server, port) != *entry_len) { /* Free the allocated id, set length to zero and return NULL */ *entry_len = 0; free(id); return NULL; } return id; } A printf at the begging of the function reveals the parameters to be www.google.com : 80 : 512 Exactly like that, not sure why the string is that long :/. Malloc seems to be crashing it , sorry I cant get it reduced further, ill try more. C On Sat, 20 Mar 2004 02:12:31 -0800, C <dont@respond.com> wrote: > Hmm appears I was wrong , the problem seems to stem from > > entry_id = create_hostcache_id(hostname, port, &entry_len); > > Its late though, ill have to look more into it later. Thought i'd mention incase someone else ran across this ? > > thx > C > > On Wed, 18 Feb 2004 19:28:03 -0800, Walter <walter@digitalmars.com> wrote: > >> >> "C" <dont@respond.com> wrote in message >> news:c118pk$168f$1@digitaldaemon.com... >>> Hey all, >>> >>> Im building libcurl with DMC ( www.atari-soldiers.com/libcurlDMC.zip ) and >>> it builds ok , but when I compile the simple.c example it crashes. >>> >>> The line that crashes is >>> >>> url.c , line 2116 >>> >>> if((1 > sscanf(data->change.url, "%512[^\n/?]%[^\n]",conn->gname, >>> conn->path)) ) >>> >>> I dont use sscanf , I think this is supposed to format it by stripping the >>> http:// of a URL string , but I cant read it. >>> >>> Why would this be causing DMC to crash , and not others ? >>> >>> Any help is super appreciated. >>> >>> Thanks, >>> Charles >> >> Please cut it down to the smallest reproducible example, and send it to me >> so I can fix it. Thanks, -Walter >> >> > > > -- D Newsgroup. |
March 20, 2004 Re: libcurl , DMC | ||||
---|---|---|---|---|
| ||||
Posted in reply to C | Replacing this with GlobalAlloc succeeds, but then fails on this function if ((size = sprintf(id, "%s:%d", server, port)) != *entry_len) { /* Free the allocated id, set length to zero and return NULL */ printf("ID : %s\nSIZE : %d",id,size); *entry_len = 0; free(id); return NULL; } Where sprintf returns 15 ( the length of the string WITHOUT all those spaces ) , but *entry_len is 512. After compiling this with VC , those spaces should not be in there, so I think the problem is still with sscanf. Sorry if im flooding writing this out helps me diagnose. C On Sat, 20 Mar 2004 02:23:55 -0800, C <dont@respond.com> wrote: > That was a silly post sorry, think Ive found the problem. > > > /* Create a hostcache id */ > static char * > create_hostcache_id(char *server, int port, ssize_t *entry_len) > { > > char *id = NULL; > > /* Get the length of the new entry id */ > *entry_len = *entry_len + /* Hostname length */ > 1 + /* ':' seperator */ > _num_chars(port); /* number of characters the port will take up */ > > /* Allocate the new entry id */ > > > // this is failing, segfaulting > > id = malloc(*entry_len + 1); > > // never gets past here > > if (!id) { > return NULL; > } > > /* Create the new entry */ > /* If sprintf() doesn't return the entry length, that signals failure */ > if (sprintf(id, "%s:%d", server, port) != *entry_len) { > /* Free the allocated id, set length to zero and return NULL */ > *entry_len = 0; > free(id); > return NULL; > } > > return id; > } > > > A printf at the begging of the function reveals the parameters to be > > www.google.com > > > > > > : 80 : 512 > > Exactly like that, not sure why the string is that long :/. Malloc seems to be crashing it , sorry I cant get it reduced further, ill try more. > > C > > On Sat, 20 Mar 2004 02:12:31 -0800, C <dont@respond.com> wrote: > >> Hmm appears I was wrong , the problem seems to stem from >> >> entry_id = create_hostcache_id(hostname, port, &entry_len); >> >> Its late though, ill have to look more into it later. Thought i'd mention incase someone else ran across this ? >> >> thx >> C >> >> On Wed, 18 Feb 2004 19:28:03 -0800, Walter <walter@digitalmars.com> wrote: >> >>> >>> "C" <dont@respond.com> wrote in message >>> news:c118pk$168f$1@digitaldaemon.com... >>>> Hey all, >>>> >>>> Im building libcurl with DMC ( www.atari-soldiers.com/libcurlDMC.zip ) and >>>> it builds ok , but when I compile the simple.c example it crashes. >>>> >>>> The line that crashes is >>>> >>>> url.c , line 2116 >>>> >>>> if((1 > sscanf(data->change.url, "%512[^\n/?]%[^\n]",conn->gname, >>>> conn->path)) ) >>>> >>>> I dont use sscanf , I think this is supposed to format it by stripping the >>>> http:// of a URL string , but I cant read it. >>>> >>>> Why would this be causing DMC to crash , and not others ? >>>> >>>> Any help is super appreciated. >>>> >>>> Thanks, >>>> Charles >>> >>> Please cut it down to the smallest reproducible example, and send it to me >>> so I can fix it. Thanks, -Walter >>> >>> >> >> >> > > > -- D Newsgroup. |
March 21, 2004 Re: libcurl , DMC | ||||
---|---|---|---|---|
| ||||
Posted in reply to C | "C" <dont@respond.com> wrote in message news:opr46ls1amehmtou@localhost... > Replacing this with GlobalAlloc succeeds, but then fails on this function > > if ((size = sprintf(id, "%s:%d", server, port)) != *entry_len) { > /* Free the allocated id, set length to zero and return > NULL */ > printf("ID : %s\nSIZE : %d",id,size); > *entry_len = 0; > free(id); > return NULL; > } > > Where sprintf returns 15 ( the length of the string WITHOUT all those spaces ) , but *entry_len is 512. > > After compiling this with VC , those spaces should not be in there, so I think the problem is still with sscanf. Sorry if im flooding writing this out helps me diagnose. It sure sounds like a memory corruption bug, which could be anywhere. If you think sscanf is the culprit, try replacing it with some other function. |
Copyright © 1999-2021 by the D Language Foundation