473,320 Members | 2,035 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Bug in SosMan's getline_test

I believe I have found a bug in Dr Sosman's getline_test program, which
is one of the official newsgroup programs. Debugging information
follows.

$ gdb ./getline_test
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i586-suse-linux"...Using host libthread_db library
"/lib/tls/libthread_db.so.1".

(gdb) r
Starting program: /tmp/getline_test

Program received signal SIGSEGV, Segmentation fault.
0x4008febf in getdelim () from /lib/tls/libc.so.6
(gdb) bt
#0 0x4008febf in getdelim () from /lib/tls/libc.so.6
#1 0x4008d844 in getline () from /lib/tls/libc.so.6
#2 0x080486b2 in verify (file=0x804a008, st=0xbfffee70, special=0) at
getline_test.c:44
#3 0x0804891d in main () at getline_test.c:103
(gdb) f 2
#2 0x080486b2 in verify (file=0x804a008, st=0xbfffee70, special=0) at
getline_test.c:44
44 buff = getline(file);
(gdb) p *file
$1 = {_flags = -72539008,
_IO_read_ptr = 0x40018000 'n' <repeats 25 times>, "\n", 'd' <repeats 174 times>...,
_IO_read_end = 0x40018000 'n' <repeats 25 times>, "\n", 'd' <repeats 174 times>...,
_IO_read_base = 0x40018000 'n' <repeats 25 times>, "\n", 'd' <repeats 174 times>...,
_IO_write_base = 0x40018000 'n' <repeats 25 times>, "\n", 'd' <repeats 174 times>...,
_IO_write_ptr = 0x40018000 'n' <repeats 25 times>, "\n", 'd' <repeats 174 times>...,
_IO_write_end = 0x40018000 'n' <repeats 25 times>, "\n", 'd' <repeats 174 times>...,
_IO_buf_base = 0x40018000 'n' <repeats 25 times>, "\n", 'd' <repeats 174 times>...,
_IO_buf_end = 0x40019000 'b' <repeats 200 times>...,
_IO_save_base = 0x0,
_IO_backup_base = 0x0, _IO_save_end = 0x0, _markers = 0x0,
_chain = 0x40151460,
_fileno = 6, _flags2 = 0, _old_offset = 0, _cur_column = 0,
_vtable_offset = 0 '\0',
_shortbuf = "", _lock = 0x804a0a0, _offset = 0, __pad1 =
0x0, __pad2 = 0x804a0ac,
_mode = -1, _unused2 = '\0' <repeats 51 times>}
(gdb)

It looks to me like the _flags field of file has become corrupted - it
seems to have an odd value.

Sep 11 '07 #1
38 1898
Friar Tuck <no****@invalid.comwrites:
I believe I have found a bug in Dr Sosman's getline_test program, which
is one of the official newsgroup programs.
There is no such thing as an "official newsgroup program", at
least not in comp.lang.c
(gdb) bt
#0 0x4008febf in getdelim () from /lib/tls/libc.so.6
#1 0x4008d844 in getline () from /lib/tls/libc.so.6
#2 0x080486b2 in verify (file=0x804a008, st=0xbfffee70, special=0) at
getline_test.c:44
#3 0x0804891d in main () at getline_test.c:103
(gdb) f 2
#2 0x080486b2 in verify (file=0x804a008, st=0xbfffee70, special=0) at
getline_test.c:44
44 buff = getline(file);
It seems very unlikely that Eric would have written his code to
call into the "getline" function in the GNU C library, which is
what this backtrace is showing. I think that you did not compile
and link the test program correctly.

GNU lib'c getline and Eric's getline evidently have different
interfaces, judging from the line of source code above.
--
"If I've told you once, I've told you LLONG_MAX times not to
exaggerate."
--Jack Klein
Sep 11 '07 #2
Ben Pfaff said:
Friar Tuck <no****@invalid.comwrites:
>I believe I have found a bug in Dr Sosman's getline_test program,
which is one of the official newsgroup programs.

There is no such thing as an "official newsgroup program", at
least not in comp.lang.c
There is one. It is:

#include <stdio.h>

int main(void)
{
puts("Hello, world!");
return 0;
}

(or minor variations thereof).

<snip>
>44 buff = getline(file);

It seems very unlikely that Eric would have written his code to
call into the "getline" function in the GNU C library, which is
what this backtrace is showing. I think that you did not compile
and link the test program correctly.
Quite so. I think Eric is guilty of poor name choice here, but no more.
GNU lib'c getline and Eric's getline evidently have different
interfaces, judging from the line of source code above.
Alas, I think Eric forgot Einstein's dictum that "it should be as simple
as possible, but no simpler". Eric's function is simpler than possible.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Sep 12 '07 #3
On 11 Sep 2007 at 23:30, Ben Pfaff wrote:
Friar Tuck <no****@invalid.comwrites:
>I believe I have found a bug in Dr Sosman's getline_test program, which
is one of the official newsgroup programs.

There is no such thing as an "official newsgroup program", at
least not in comp.lang.c
Well, it's listed on the group website, so I'd say that's official.
>
>(gdb) bt
#0 0x4008febf in getdelim () from /lib/tls/libc.so.6
#1 0x4008d844 in getline () from /lib/tls/libc.so.6
#2 0x080486b2 in verify (file=0x804a008, st=0xbfffee70, special=0) at
getline_test.c:44
#3 0x0804891d in main () at getline_test.c:103
(gdb) f 2
#2 0x080486b2 in verify (file=0x804a008, st=0xbfffee70, special=0) at
getline_test.c:44
44 buff = getline(file);

It seems very unlikely that Eric would have written his code to
call into the "getline" function in the GNU C library, which is
what this backtrace is showing. I think that you did not compile
and link the test program correctly.

GNU lib'c getline and Eric's getline evidently have different
interfaces, judging from the line of source code above.
I don't believe there's a standard library function called getline. If
there is, wouldn't it be better if Dr Sosman's version either had a
different name, or followed the same interface?

Sep 12 '07 #4
On Sep 12, 10:59 am, Friar Tuck <nos...@invalid.comwrote:
On 11 Sep 2007 at 23:30, Ben Pfaff wrote:
Friar Tuck <nos...@invalid.comwrites:
I believe I have found a bug in Dr Sosman's getline_test program, which
is one of the official newsgroup programs.
There is no such thing as an "official newsgroup program", at
least not in comp.lang.c

Well, it's listed on the group website, so I'd say that's official.
What's the group website?
(gdb) bt
#0 0x4008febf in getdelim () from /lib/tls/libc.so.6
#1 0x4008d844 in getline () from /lib/tls/libc.so.6
#2 0x080486b2 in verify (file=0x804a008, st=0xbfffee70, special=0) at
getline_test.c:44
#3 0x0804891d in main () at getline_test.c:103
(gdb) f 2
#2 0x080486b2 in verify (file=0x804a008, st=0xbfffee70, special=0) at
getline_test.c:44
44 buff = getline(file);
It seems very unlikely that Eric would have written his code to
call into the "getline" function in the GNU C library, which is
what this backtrace is showing. I think that you did not compile
and link the test program correctly.
GNU lib'c getline and Eric's getline evidently have different
interfaces, judging from the line of source code above.

I don't believe there's a standard library function called getline.
There isn't. But there is a GNU version that is very popular among
POSIX platforms.
http://www.gnu.org/software/libc/man...ine-Input.html
If
there is, wouldn't it be better if Dr Sosman's version either had a
different name, or followed the same interface?
Right. But there isn't a standard C function called getline(). There
is a popular one, so it still might be a good idea to change the name
a bit.
Sep 12 '07 #5
On Wed, 12 Sep 2007 19:59:32 +0200 (CEST), in comp.lang.c , Friar Tuck
<no****@invalid.comwrote:
>On 11 Sep 2007 at 23:30, Ben Pfaff wrote:
>Friar Tuck <no****@invalid.comwrites:
>>I believe I have found a bug in Dr Sosman's getline_test program, which
is one of the official newsgroup programs.

There is no such thing as an "official newsgroup program", at
least not in comp.lang.c

Well, it's listed on the group website, so I'd say that's official.
There /is/ no group website. Do you mean the CLC wiki? Thats an
unofficial effort maintained by some of the regulars here, but by no
means officially sanctioned (how could it be, there's no elected
officers of this unmoderated group).
>>
GNU lib'c getline and Eric's getline evidently have different
interfaces, judging from the line of source code above.

I don't believe there's a standard library function called getline.
Correct. However what Ben said was "GNU libc's getline". GNU evidently
provide a nonstandard 'getline' function with different semantics to
Eric's.

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Sep 12 '07 #6
Friar Tuck wrote:
>
On 11 Sep 2007 at 23:30, Ben Pfaff wrote:
Friar Tuck <no****@invalid.comwrites:
I believe I have found a bug in
Dr Sosman's getline_test program,
Is he really a doctor?
which is one of the official newsgroup programs.
There is no such thing as an "official newsgroup program", at
least not in comp.lang.c

Well, it's listed on the group website, so I'd say that's official.
There is no such thing as "the group website".
GNU lib'c getline
I don't believe there's a standard library function called getline.
There isn't.
What is your native language?

--
pete
Sep 12 '07 #7
user923005 wrote:
>
On Sep 12, 10:59 am, Friar Tuck <nos...@invalid.comwrote:
I don't believe there's a standard library function called getline.

There isn't. But there is a GNU version that is very popular among
POSIX platforms.
http://www.gnu.org/software/libc/man...ine-Input.html
I have a somewhat similar one:

http://www.mindspring.com/~pfilandr/...ine/get_line.c
If there is,
wouldn't it be better if Dr Sosman's version either had a
different name, or followed the same interface?

Right. But there isn't a standard C function called getline(). There
is a popular one, so it still might be a good idea to change the name
a bit.
I changed the name of my function a little bit.

--
pete
Sep 13 '07 #8
Friar Tuck wrote:
On 11 Sep 2007 at 23:30, Ben Pfaff wrote:
>Friar Tuck <no****@invalid.comwrites:
>>I believe I have found a bug in Dr Sosman's getline_test program,
which is one of the official newsgroup programs.

There is no such thing as an "official newsgroup program", at
least not in comp.lang.c

Well, it's listed on the group website, so I'd say that's official.
There is no such thing as a 'group website'.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Sep 13 '07 #9

"Richard Heathfield" <rj*@see.sig.invalidwrote in message
news:jY******************************@bt.com...
#include <stdio.h>

int main(void)
{
puts("Hello, world!");
return 0;
}

(or minor variations thereof).
Buggy code is highly frowned on here.
Your progrm returns a success status if the puts operation fails.
It should be

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
if(puts("Hello world!") == EOF)
exit(EXIT_FAILURE);
return 0;
}

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

Sep 13 '07 #10
"Malcolm McLean" <re*******@btinternet.coma écrit dans le message de news:
zf******************************@bt.com...
>
"Richard Heathfield" <rj*@see.sig.invalidwrote in message
news:jY******************************@bt.com...
>#include <stdio.h>

int main(void)
{
puts("Hello, world!");
return 0;
}

(or minor variations thereof).
Buggy code is highly frowned on here.
Your progrm returns a success status if the puts operation fails.
It should be

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
if(puts("Hello world!") == EOF)
exit(EXIT_FAILURE);
return 0;
}
Since you want to be overtly picky, you should also notice that writing text
to stdout without a final new-line invokes implementation defined behaviour
(7.19.2p2). There is always one more bug.

--
Chqrlie
Sep 13 '07 #11
"Charlie Gordon" <ne**@chqrlie.orgschrieb im Newsbeitrag
news:46**********************@news.free.fr...
"Malcolm McLean" <re*******@btinternet.coma écrit dans le message de
news: zf******************************@bt.com...
>>
"Richard Heathfield" <rj*@see.sig.invalidwrote in message
news:jY******************************@bt.com...
>>#include <stdio.h>

int main(void)
{
puts("Hello, world!");
return 0;
}

(or minor variations thereof).
Buggy code is highly frowned on here.
Your progrm returns a success status if the puts operation fails.
It should be

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
if(puts("Hello world!") == EOF)
exit(EXIT_FAILURE);
return 0;
}

Since you want to be overtly picky, you should also notice that writing
text to stdout without a final new-line invokes implementation defined
behaviour (7.19.2p2). There is always one more bug.
True had he used printf(). puts() though does add a newline (7.17.7.10-2 in
n1124)

Bye, Jojo
Sep 13 '07 #12

"Joachim Schmitz" <no*********@schmitz-digital.deschrieb im Newsbeitrag
news:fc**********@online.de...
"Charlie Gordon" <ne**@chqrlie.orgschrieb im Newsbeitrag
news:46**********************@news.free.fr...
>"Malcolm McLean" <re*******@btinternet.coma écrit dans le message de
news: zf******************************@bt.com...
>>>
"Richard Heathfield" <rj*@see.sig.invalidwrote in message
news:jY******************************@bt.com.. .
#include <stdio.h>

int main(void)
{
puts("Hello, world!");
return 0;
}

(or minor variations thereof).

Buggy code is highly frowned on here.
Your progrm returns a success status if the puts operation fails.
It should be

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
if(puts("Hello world!") == EOF)
exit(EXIT_FAILURE);
return 0;
}

Since you want to be overtly picky, you should also notice that writing
text to stdout without a final new-line invokes implementation defined
behaviour (7.19.2p2). There is always one more bug.
True had he used printf(). puts() though does add a newline (7.17.7.10-2
in n1124)
Sorry, 7.19.7.10-2:
The puts function writes the string pointed to by s to the stream pointed to
by stdout, and appends a new-line character to the output.
Sep 13 '07 #13
Charlie Gordon wrote:
"Malcolm McLean" <re*******@btinternet.coma écrit dans le message de news:
>Buggy code is highly frowned on here.
Your progrm returns a success status if the puts operation fails.
It should be

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
if(puts("Hello world!") == EOF)
exit(EXIT_FAILURE);
return 0;
}

Since you want to be overtly picky, you should also notice that writing text
to stdout without a final new-line invokes implementation defined behaviour
(7.19.2p2). There is always one more bug.
puts() supplies that newline for you.

Phil

--
Philip Potter pgp <atdoc.ic.ac.uk
Sep 13 '07 #14
"Charlie Gordon" <ne**@chqrlie.orga écrit dans le message de news:
46**********************@news.free.fr...
"Malcolm McLean" <re*******@btinternet.coma écrit dans le message de
news: zf******************************@bt.com...
>>
"Richard Heathfield" <rj*@see.sig.invalidwrote in message
news:jY******************************@bt.com...
>>#include <stdio.h>

int main(void)
{
puts("Hello, world!");
return 0;
}

(or minor variations thereof).
Buggy code is highly frowned on here.
Your progrm returns a success status if the puts operation fails.
It should be

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
if(puts("Hello world!") == EOF)
exit(EXIT_FAILURE);
return 0;
}

Since you want to be overtly picky, you should also notice that writing
text to stdout without a final new-line invokes implementation defined
behaviour (7.19.2p2). There is always one more bug.
OOPS! it was puts, not printf !
But why betray the original scriptures? The Word has always been

printf("Hello world!\n");

--
Chqrlie.
Sep 13 '07 #15
"Malcolm McLean" <re*******@btinternet.comwrites:
int main(void)
{
if(puts("Hello world!") == EOF)
exit(EXIT_FAILURE);
return 0;
}
I'd recommend flushing stdout and checking its return value also,
to ensure that the message was actually printed.
--
"The way I see it, an intelligent person who disagrees with me is
probably the most important person I'll interact with on any given
day."
--Billy Chambless
Sep 13 '07 #16
Charlie Gordon wrote:
>
"Charlie Gordon" <ne**@chqrlie.orga écrit dans le message de news:
46**********************@news.free.fr...
"Malcolm McLean" <re*******@btinternet.coma écrit dans le message de
news: zf******************************@bt.com...
>
"Richard Heathfield" <rj*@see.sig.invalidwrote in message
news:jY******************************@bt.com...
#include <stdio.h>

int main(void)
{
puts("Hello, world!");
return 0;
}

(or minor variations thereof).

Buggy code is highly frowned on here.
Your progrm returns a success status if the puts operation fails.
It should be

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
if(puts("Hello world!") == EOF)
exit(EXIT_FAILURE);
return 0;
}
Since you want to be overtly picky,
you should also notice that writing
text to stdout without a final new-line
invokes implementation defined
behaviour (7.19.2p2). There is always one more bug.

OOPS! it was puts, not printf !
It's not implementation defined behavior either.
Whether or not the behavior is defined,
is implementation defined.
In other words, the behavior of a program which does not
terminate the last line of a text stream with a newline,
is not constrained by the standard;
and in yet other words, it's undefined behavior.

--
pete
Sep 13 '07 #17
On 12 Sep 2007 at 23:47, pete wrote:
Friar Tuck wrote:
>>
On 11 Sep 2007 at 23:30, Ben Pfaff wrote:
Friar Tuck <no****@invalid.comwrites:

I believe I have found a bug in
Dr Sosman's getline_test program,

Is he really a doctor?
>which is one of the official newsgroup programs.

There is no such thing as an "official newsgroup program", at
least not in comp.lang.c

Well, it's listed on the group website, so I'd say that's official.

There is no such thing as "the group website".
Isn't the group website cpac.org? It's in one of the group moderator's
signatures and has lots of C resources. It certainly looks official.
GNU lib'c getline
>I don't believe there's a standard library function called getline.

There isn't.
What is your native language?
C (gcc 4.1.3).

Was the final conclusion of this thread that Dr Sosman's function
clashes with a common library funcion and should be renamed?

Actually, looking through that backtrace again is quite interesting:

(gdb) p *file
$1 = {_flags = -72539008,
_IO_read_ptr = 0x40018000 'n' <repeats 25 times>, "\n", 'd' <repeats
174 times>...,
_IO_read_end = 0x40018000 'n' <repeats 25 times>, "\n", 'd' <repeats
174 times>...,
_IO_read_base = 0x40018000 'n' <repeats 25 times>, "\n", 'd'
<repeats 174 times>...,
_IO_write_base = 0x40018000 'n' <repeats 25 times>, "\n", 'd'
<repeats 174 times>...,
_IO_write_ptr = 0x40018000 'n' <repeats 25 times>, "\n", 'd'
<repeats 174 times>...,
_IO_write_end = 0x40018000 'n' <repeats 25 times>, "\n", 'd'
<repeats 174 times>...,
_IO_buf_base = 0x40018000 'n' <repeats 25 times>, "\n",
'd' <repeats 174 times>...,
_IO_buf_end = 0x40019000 'b' <repeats 200 times>...,
_IO_save_base = 0x0,
_IO_backup_base = 0x0, _IO_save_end = 0x0, _markers
= 0x0,
_chain = 0x40151460,
_fileno = 6, _flags2 = 0, _old_offset = 0,
_cur_column = 0,
_vtable_offset = 0 '\0',
_shortbuf = "", _lock = 0x804a0a0, _offset =
0, __pad1 =
0x0, __pad2 = 0x804a0ac,
_mode = -1, _unused2 = '\0' <repeats
51 times>}
(gdb)

Does anyone know what all these fields in the FILE * structure do? It
could be useful to be able to pick out information directly from a file
pointer. (By the way, it still looks to me like the _flags field has
been corrupted somehow by getline_test.)

Sep 13 '07 #18
On Fri, 14 Sep 2007 01:39:12 +0200 (CEST), Friar Tuck
<no****@invalid.comwrote:
>On 12 Sep 2007 at 23:47, pete wrote:
>Friar Tuck wrote:
>>>
On 11 Sep 2007 at 23:30, Ben Pfaff wrote:
Friar Tuck <no****@invalid.comwrites:

I believe I have found a bug in
Dr Sosman's getline_test program,

Is he really a doctor?
>>which is one of the official newsgroup programs.

There is no such thing as an "official newsgroup program", at
least not in comp.lang.c

Well, it's listed on the group website, so I'd say that's official.

There is no such thing as "the group website".

Isn't the group website cpac.org? It's in one of the group moderator's
signatures and has lots of C resources. It certainly looks official.
This group doesn't have a moderator either.

I wonder what you think a political web site has to do with the C
language.
snip
>
Actually, looking through that backtrace again is quite interesting:

(gdb) p *file
$1 = {_flags = -72539008,
_IO_read_ptr = 0x40018000 'n' <repeats 25 times>, "\n", 'd' <repeats
174 times>...,
_IO_read_end = 0x40018000 'n' <repeats 25 times>, "\n", 'd' <repeats
174 times>...,
_IO_read_base = 0x40018000 'n' <repeats 25 times>, "\n", 'd'
<repeats 174 times>...,
_IO_write_base = 0x40018000 'n' <repeats 25 times>, "\n", 'd'
<repeats 174 times>...,
_IO_write_ptr = 0x40018000 'n' <repeats 25 times>, "\n", 'd'
<repeats 174 times>...,
_IO_write_end = 0x40018000 'n' <repeats 25 times>, "\n", 'd'
<repeats 174 times>...,
_IO_buf_base = 0x40018000 'n' <repeats 25 times>, "\n",
'd' <repeats 174 times>...,
_IO_buf_end = 0x40019000 'b' <repeats 200 times>...,
_IO_save_base = 0x0,
_IO_backup_base = 0x0, _IO_save_end = 0x0, _markers
= 0x0,
_chain = 0x40151460,
_fileno = 6, _flags2 = 0, _old_offset = 0,
_cur_column = 0,
_vtable_offset = 0 '\0',
_shortbuf = "", _lock = 0x804a0a0, _offset =
0, __pad1 =
0x0, __pad2 = 0x804a0ac,
_mode = -1, _unused2 = '\0' <repeats
51 times>}
(gdb)
The internal structure of a FILE object is implementation dependent.
You will need to ask in a group that discusses your implementation.
Remove del for email
Sep 14 '07 #19
Friar Tuck <no****@invalid.comwrites:
On 12 Sep 2007 at 23:47, pete wrote:
>Friar Tuck wrote:
>>>
On 11 Sep 2007 at 23:30, Ben Pfaff wrote:
Friar Tuck <no****@invalid.comwrites:

I believe I have found a bug in
Dr Sosman's getline_test program,

Is he really a doctor?
>>which is one of the official newsgroup programs.

There is no such thing as an "official newsgroup program", at
least not in comp.lang.c

Well, it's listed on the group website, so I'd say that's official.

There is no such thing as "the group website".

Isn't the group website cpac.org? It's in one of the group moderator's
signatures and has lots of C resources. It certainly looks official.
Do you mean www.cpax.org.uk? That's just a website that Richard
Heathfield likes to point to, and apparently contributes to
and/or maintains. He's a leading contributor to comp.lang.c, but
doesn't speak for the group (no one does).

(I doubt that an "official" comp.lang.c website would have a
pointer to "the next Northampton Prayer and Praise meeting", as
that seems quite off-topic for the purpose of the group.)
--
"Your correction is 100% correct and 0% helpful. Well done!"
--Richard Heathfield
Sep 14 '07 #20
Friar Tuck <no****@invalid.comwrites:
On 12 Sep 2007 at 23:47, pete wrote:
[...]
>There is no such thing as "the group website".

Isn't the group website cpac.org? It's in one of the group moderator's
signatures and has lots of C resources. It certainly looks official.
comp.lang.c has no moderator. Perhaps you're thinking of
comp.lang.c.moderate. In any case, cpac.org has nothing to do with C;
it's a political site.

[...]
Was the final conclusion of this thread that Dr Sosman's function
clashes with a common library funcion and should be renamed?
[...]

I don't think there was a conclusion. (One could also argue, though
less persuasively, that GNU's getline function should be renamed
because it conflicts with Eric's.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Sep 14 '07 #21
Friar Tuck wrote:
Isn't the group website cpac.org?
No.
It's in one of the group moderator's
comp.lang.c doesn't have a moderator.
signatures and has lots of C resources. It certainly looks official.
What do you mean, "looks official"?
>GNU lib'c getline
>>I don't believe there's a standard library function called getline.

There isn't.
What is your native language?

C (gcc 4.1.3).
I think they meant your native /spoken/ language.
Does anyone know what all these fields in the FILE * structure do?
Something implementation-dependant. Portable code can't care about it.

--
Chris "here be dragons" Dollin

Hewlett-Packard Limited registered office: Cain Road, Bracknell,
registered no: 690597 England Berks RG12 1HN

Sep 14 '07 #22
On 14 Sep 2007 at 0:06, Barry Schwarz wrote:
On Fri, 14 Sep 2007 01:39:12 +0200 (CEST), Friar Tuck
<no****@invalid.comwrote:
>>On 12 Sep 2007 at 23:47, pete wrote:
>>Friar Tuck wrote:

On 11 Sep 2007 at 23:30, Ben Pfaff wrote:
Friar Tuck <no****@invalid.comwrites:

I believe I have found a bug in
Dr Sosman's getline_test program,

Is he really a doctor?

which is one of the official newsgroup programs.

There is no such thing as an "official newsgroup program", at
least not in comp.lang.c

Well, it's listed on the group website, so I'd say that's official.

There is no such thing as "the group website".

Isn't the group website cpac.org? It's in one of the group moderator's
signatures and has lots of C resources. It certainly looks official.

This group doesn't have a moderator either.
OK, well senior member then.
>
I wonder what you think a political web site has to do with the C
language.
Whoops, yes, I seem to have remembered the address wrongly. I think it
was .org.uk instead.
>

snip
>>
Actually, looking through that backtrace again is quite interesting:

(gdb) p *file
$1 = {_flags = -72539008,
_IO_read_ptr = 0x40018000 'n' <repeats 25 times>, "\n", 'd' <repeats
174 times>...,
_IO_read_end = 0x40018000 'n' <repeats 25 times>, "\n", 'd' <repeats
174 times>...,
_IO_read_base = 0x40018000 'n' <repeats 25 times>, "\n", 'd'
<repeats 174 times>...,
_IO_write_base = 0x40018000 'n' <repeats 25 times>, "\n", 'd'
<repeats 174 times>...,
_IO_write_ptr = 0x40018000 'n' <repeats 25 times>, "\n", 'd'
<repeats 174 times>...,
_IO_write_end = 0x40018000 'n' <repeats 25 times>, "\n", 'd'
<repeats 174 times>...,
_IO_buf_base = 0x40018000 'n' <repeats 25 times>, "\n",
'd' <repeats 174 times>...,
_IO_buf_end = 0x40019000 'b' <repeats 200 times>...,
_IO_save_base = 0x0,
_IO_backup_base = 0x0, _IO_save_end = 0x0, _markers
= 0x0,
_chain = 0x40151460,
_fileno = 6, _flags2 = 0, _old_offset = 0,
_cur_column = 0,
_vtable_offset = 0 '\0',
_shortbuf = "", _lock = 0x804a0a0, _offset =
0, __pad1 =
0x0, __pad2 = 0x804a0ac,
_mode = -1, _unused2 = '\0' <repeats
51 times>}
(gdb)

The internal structure of a FILE object is implementation dependent.
You will need to ask in a group that discusses your implementation.
Are you sure? I'm fairly confident that the FILE * structure is a
fundamental type in standard C. Maybe there are some basic fields
guaranteed to be present (which ones?) and others may be added as an
extension?

Sep 14 '07 #23
Friar Tuck wrote:

[Snipped]

Can I hear something under this bridge?
Sep 14 '07 #24
On 14 Sep 2007 at 7:41, Chris Dollin wrote:
Friar Tuck wrote:
>Isn't the group website cpac.org?

No.
Sorry, .org.uk
>
>It's in one of the group moderator's

comp.lang.c doesn't have a moderator.
Sorry, senior member.
>
>signatures and has lots of C resources. It certainly looks official.

What do you mean, "looks official"?
It has this resources page
http://cpax.org.uk/prg/portable/c/resources.php that gives the
impression it's the official resources page for comp.lang.c though maybe
that's just what comes across from the first paragraph.
>
>>GNU lib'c getline

I don't believe there's a standard library function called getline.

There isn't.
What is your native language?

C (gcc 4.1.3).

I think they meant your native /spoken/ language.
What in any of my posts suggests that my native spoken language isn't
English?? Why is it relevant?
>
>Does anyone know what all these fields in the FILE * structure do?

Something implementation-dependant. Portable code can't care about it.
I believe you are mistaken - portable functions like fread etc. take a
FILE * structure for an argument.

Sep 14 '07 #25
"Friar Tuck" <no****@invalid.comschrieb im Newsbeitrag
news:sl********************@nospam.invalid...
On 14 Sep 2007 at 0:06, Barry Schwarz wrote:
>On Fri, 14 Sep 2007 01:39:12 +0200 (CEST), Friar Tuck
<no****@invalid.comwrote:
<snip>
>The internal structure of a FILE object is implementation dependent.
You will need to ask in a group that discusses your implementation.

Are you sure? I'm fairly confident that the FILE * structure is a
fundamental type in standard C. Maybe there are some basic fields
guaranteed to be present (which ones?) and others may be added as an
extension?
from n1256, 7.19.1 p2:
The types declared are ...; FILE which is an object type capable of
recording all the information needed to control a stream, including its file
position indicator, a pointer to its associated buffer (if any), an error
indicator that records whether a read/write error has occurred, and an
end-of-file indicator that records whether the end of the file has been
reached: ...

Bye, Jojo
Sep 14 '07 #26
"Friar Tuck" <no****@invalid.comschrieb im Newsbeitrag
news:sl********************@nospam.invalid...
On 14 Sep 2007 at 7:41, Chris Dollin wrote:
>Friar Tuck wrote:
<snip>
>>
>>Does anyone know what all these fields in the FILE * structure do?

Something implementation-dependant. Portable code can't care about it.

I believe you are mistaken - portable functions like fread etc. take a
FILE * structure for an argument.
So what? Of course fread would know (need to) about the (implementation
dependant) internals of FILE, but you don't need to know to be able to use
it.

Bye, Jojo
Sep 14 '07 #27
"Joachim Schmitz" <no*********@schmitz-digital.dewrote:
"Friar Tuck" <no****@invalid.comschrieb im Newsbeitrag
Are you sure? I'm fairly confident that the FILE * structure is a
There's no such thing as a "FILE * structure". There's a FILE, which is
an object type, not necessarily a struct, and a FILE *, which is a
pointer to that type.
fundamental type in standard C. Maybe there are some basic fields
guaranteed to be present (which ones?) and others may be added as an
extension?
from n1256, 7.19.1 p2:
The types declared are ...; FILE which is an object type capable of
recording all the information needed to control a stream, including its file
position indicator, a pointer to its associated buffer (if any), an error
indicator that records whether a read/write error has occurred, and an
end-of-file indicator that records whether the end of the file has been
reached: ...
And note that there is no indication whatsoever _how_ a FILE records
this information. It could be a struct; it could also be an array of
unsigned chars.

Richard
Sep 14 '07 #28
Richard Bos said:

<snip>
It could be a struct; it could also be an array of
unsigned chars.
Only if it's a union. :-)

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Sep 14 '07 #29
Friar Tuck wrote:
On 14 Sep 2007 at 0:06, Barry Schwarz wrote:
>On Fri, 14 Sep 2007 01:39:12 +0200 (CEST), Friar Tuck
<no****@invalid.comwrote:
>>>Isn't the group website cpac.org? It's in one of the group moderator's
signatures and has lots of C resources. It certainly looks official.

This group doesn't have a moderator either.

OK, well senior member then.
The word you're groping for is "regular". It has no official status.
>The internal structure of a FILE object is implementation dependent.
You will need to ask in a group that discusses your implementation.

Are you sure? I'm fairly confident that the FILE * structure is a
fundamental type in standard C.
It isn't.
Maybe there are some basic fields
guaranteed to be present (which ones?) and others may be added as an
extension?
No.

--
Chris "PLANE *" Dollin

Hewlett-Packard Limited registered office: Cain Road, Bracknell,
registered no: 690597 England Berks RG12 1HN

Sep 14 '07 #30
Friar Tuck wrote:
On 14 Sep 2007 at 7:41, Chris Dollin wrote:
>What do you mean, "looks official"?

It has this resources page
http://cpax.org.uk/prg/portable/c/resources.php that gives the
impression it's the official resources page for comp.lang.c though maybe
that's just what comes across from the first paragraph.
I get no such impression.
>>>GNU lib'c getline

I don't believe there's a standard library function called getline.

There isn't.
What is your native language?

C (gcc 4.1.3).

I think they meant your native /spoken/ language.

What in any of my posts suggests that my native spoken language isn't
English?? Why is it relevant?
Don't ask me; ask the person who asked the question. Probably they
thought that what you said suggested you hadn't understood them in
a way that suggests ESL.
>>Does anyone know what all these fields in the FILE * structure do?

Something implementation-dependant. Portable code can't care about it.

I believe you are mistaken - portable functions like fread etc. take a
FILE * structure for an argument.
`fread` isn't portable; it is specific to each implementation. That's
why it's there in the Standard; you can't portably write one yourself.
(Well, you can -- but it's useless.)

--
Chris "return 0;" Dollin

Hewlett-Packard Limited registered office: Cain Road, Bracknell,
registered no: 690597 England Berks RG12 1HN

Sep 14 '07 #31
Mark Bluemel wrote:
Friar Tuck wrote:

[Snipped]

Can I hear something under this bridge?
Insufficient data. Yet.

--
Chris "waiting" Dollin

Hewlett-Packard Limited Cain Road, Bracknell, registered no:
registered office: Berks RG12 1HN 690597 England

Sep 14 '07 #32
Friar Tuck wrote:
On 14 Sep 2007 at 0:06, Barry Schwarz wrote:
>This group doesn't have a moderator either.

OK, well senior member then.
As in "senior moment"?
Sep 14 '07 #33
Friar Tuck <no****@invalid.comwrites:
On 14 Sep 2007 at 7:41, Chris Dollin wrote:
>Friar Tuck wrote:
>>Isn't the group website cpac.org?

No.

Sorry, .org.uk
You're thinking of cpax.org.uk, but that site has absolutely no
official standing with respect to this newsgroup.
>>
>>It's in one of the group moderator's

comp.lang.c doesn't have a moderator.

Sorry, senior member.
Richard Heathfield is a regular participant in this newsgroup. So am
I. So are a number of others. Since this is an unmoderated
newsgroup, nobody has any official status, because there is no
official status to be had.
>>signatures and has lots of C resources. It certainly looks official.

What do you mean, "looks official"?

It has this resources page
http://cpax.org.uk/prg/portable/c/resources.php that gives the
impression it's the official resources page for comp.lang.c though maybe
that's just what comes across from the first paragraph.
I'm sure that Richard did not intend to give that impression.

The FAQ site, <http://www.c-faq.com/>, is the closest thing we have to
an "offical" site for the newsgroup, but even it has no real official
standing. I could set up my own FAQ site tomorrow. I don't because
(a) it would be a lot of work, and (b) Steve Summit has already done
such a fine job of it.
>>>GNU lib'c getline

I don't believe there's a standard library function called getline.

There isn't.
What is your native language?

C (gcc 4.1.3).

I think they meant your native /spoken/ language.

What in any of my posts suggests that my native spoken language isn't
English?? Why is it relevant?
The question was, I believe, intended to point out that you had
misunderstood something that should have been reasonably clear.
Somebody mentioned the 'getline' function that's part of the GNU
library. You responded by saying that there's no such standard
library function -- but nobody had said that there was. The 'getline'
function in question is specific the GNU library (glibc), and the
person who mentined it said so explicitly.

Making this point by questioning whether English is your native
language was perhaps a bit rude. But I'll mention that there are
plenty of people with other native languages who write excellent
English, better than some native speakers. Such people sometimes make
surprising errors.
>>Does anyone know what all these fields in the FILE * structure do?

Something implementation-dependant. Portable code can't care about it.

I believe you are mistaken - portable functions like fread etc. take a
FILE * structure for an argument.
No, he's not mistaken. That's why the fread function cannot be
implemented in portable code. Each (hosted) implementation must
provide the function, so code that uses it can be portable, but the
function itself can and must use implementation-specific techniques
(unless it's implemented entirely in terms of other standard
functions).

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Sep 14 '07 #34
Keith Thompson said:
Friar Tuck <no****@invalid.comwrites:
>On 14 Sep 2007 at 7:41, Chris Dollin wrote:
>>Friar Tuck wrote:
<snip>
>>>signatures and has lots of C resources. It certainly looks
official.

What do you mean, "looks official"?

It has this resources page
http://cpax.org.uk/prg/portable/c/resources.php that gives the
impression it's the official resources page for comp.lang.c though
maybe that's just what comes across from the first paragraph.

I'm sure that Richard did not intend to give that impression.
Actually, I'd /love/ to give the impression that my site is "official"
in some way, because that would indicate that my Web skills are just as
amazing as all my other skills - but apathy always wins out. :-)

From the sidelines, I've been watching this discussion with some
amusement, and I saw no particular need to interfere (that cpac
political thing was a real eye-opener, btw!), but a word in season
seems to be indicated here, so here we go:

Anyone who looks at my Web site and genuinely thinks it to be the
official comp.lang.c Web site has got to be off his rocker. Completely
out to lunch. A brick, two windows, several roofing slates, two
teenagers, a loft hatch, and twenty square feet of dry rot short of a
house.

Message ends.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Sep 14 '07 #35
On Fri, 14 Sep 2007 11:24:56 GMT, rl*@hoekstra-uitgeverij.nl (Richard
Bos) wrote:
>"Joachim Schmitz" <no*********@schmitz-digital.dewrote:
>"Friar Tuck" <no****@invalid.comschrieb im Newsbeitrag
Are you sure? I'm fairly confident that the FILE * structure is a

There's no such thing as a "FILE * structure". There's a FILE, which is
an object type, not necessarily a struct, and a FILE *, which is a
pointer to that type.
fundamental type in standard C. Maybe there are some basic fields
guaranteed to be present (which ones?) and others may be added as an
extension?
>from n1256, 7.19.1 p2:
The types declared are ...; FILE which is an object type capable of
recording all the information needed to control a stream, including its file
position indicator, a pointer to its associated buffer (if any), an error
indicator that records whether a read/write error has occurred, and an
end-of-file indicator that records whether the end of the file has been
reached: ...

And note that there is no indication whatsoever _how_ a FILE records
this information. It could be a struct; it could also be an array of
unsigned chars.
And in a reply with insufficient quoting

On Fri, 14 Sep 2007 11:48:08 +0000, Richard Heathfield
<rj*@see.sig.invalidwrote:

Discussing the internal nature of a FILE object
>Richard Bos said:

<snip>
>It could be a struct; it could also be an array of
unsigned chars.

Only if it's a union. :-)
Care to expand?

Do you infer that the file position information must be stored in a
long, the pointer information in a pointer object, etc? It is
certainly possible for an array of unsigned char to contain this data
without any other type of object.

By the way, since the buffer need not be a defined C object, what type
of pointer do you think would be appropriate?
Remove del for email
Sep 14 '07 #36
Barry Schwarz <sc******@doezl.netwrites:
On Fri, 14 Sep 2007 11:24:56 GMT, rl*@hoekstra-uitgeverij.nl (Richard
Bos) wrote:
>>"Joachim Schmitz" <no*********@schmitz-digital.dewrote:
[...]
>>It could be a struct; it could also be an array of
unsigned chars.

Only if it's a union. :-)

Care to expand?
O n l y i f i t ' s a u n i o n . : - )

I believe RH was making one of his little jokes. Note:

It could be a struct; it could *also* be an array of unsigned
chars.

The only way it could be *both* is if it's a union.

Actually, that's not *strictly* correct (a union containing a struct
is not a struct), but it's close enough for humorous purposes.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Sep 14 '07 #37
Friar Tuck wrote:
>
On 12 Sep 2007 at 23:47, pete wrote:
Friar Tuck wrote:
>
On 11 Sep 2007 at 23:30, Ben Pfaff wrote:
Friar Tuck <no****@invalid.comwrites:

I believe I have found a bug in
Dr Sosman's getline_test program,
Is he really a doctor?
which is one of the official newsgroup programs.

There is no such thing as an "official newsgroup program", at
least not in comp.lang.c

Well, it's listed on the group website, so I'd say that's official.
There is no such thing as "the group website".

Isn't the group website cpac.org?
No.
It's in one of the group moderator's
There is no group moderator.

You're coming across as being delusional.

--
pete
Sep 14 '07 #38
Keith Thompson wrote:
>
Friar Tuck <no****@invalid.comwrites:
What in any of my posts suggests
that my native spoken language isn't
English?? Why is it relevant?

The question was, I believe, intended to point out that you had
misunderstood something that should have been reasonably clear.
Somebody mentioned the 'getline' function that's part of the GNU
library. You responded by saying that there's no such standard
library function -- but nobody had said that there was. The 'getline'
function in question is specific the GNU library (glibc), and the
person who mentined it said so explicitly.

Making this point by questioning whether English is your native
language was perhaps a bit rude.
Yes, it was.

Most of OP's writings seem to consist of bizarre assumptions,
stated as facts.

OP's camel case spelling of "SosMan" in the subject line
is an unusual affectation, which makes me wonder
if the doctorate in "Dr Sosman" is also a delusion.

--
pete
Sep 14 '07 #39

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: Ashutosh Iddya | last post by:
Hi , I am performing an integer count of a particular operation in my program. After a sufficiently large value an overflow occurs. At the moment I have gone around the problem by declaring it...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.