* [PATCH] Fix get-bytevector-all read redundant eof
@ 2013-03-14 9:30 Nala Ginrut
2013-03-15 8:39 ` Nala Ginrut
2013-04-01 1:18 ` Mark H Weaver
0 siblings, 2 replies; 5+ messages in thread
From: Nala Ginrut @ 2013-03-14 9:30 UTC (permalink / raw)
To: guile-devel
[-- Attachment #1: Type: text/plain, Size: 218 bytes --]
Attached the patch to fix get-bytevector-all.
You may check it like this:
(get-bytevector-all (current-input-port))
And try to input then type ctrl+d, the current implementation needs you
type ctrl+d twice.
Regards.
[-- Attachment #2: 0001-Fix-get-bytevector-all-read-redundant-eof.patch --]
[-- Type: text/x-patch, Size: 1032 bytes --]
From 1e22ce9468a09a186ce77552bae310d2e4a6178d Mon Sep 17 00:00:00 2001
From: Nala Ginrut <nalaginrut@gmail.com>
Date: Thu, 14 Mar 2013 17:24:58 +0800
Subject: [PATCH] Fix get-bytevector-all read redundant eof.
---
libguile/r6rs-ports.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/libguile/r6rs-ports.c b/libguile/r6rs-ports.c
index e867429..c812979 100644
--- a/libguile/r6rs-ports.c
+++ b/libguile/r6rs-ports.c
@@ -644,7 +644,7 @@ SCM_DEFINE (scm_get_bytevector_all, "get-bytevector-all", 1, 0, 0,
c_bv = (char *) scm_gc_malloc_pointerless (c_len, SCM_GC_BYTEVECTOR);
c_total = c_read = 0;
- do
+ while (!SCM_EOF_OBJECT_P (scm_peek_char (port)))
{
if (c_total + c_read > c_len)
{
@@ -660,7 +660,6 @@ SCM_DEFINE (scm_get_bytevector_all, "get-bytevector-all", 1, 0, 0,
c_read = scm_c_read (port, c_bv + c_total, c_count);
c_total += c_read, c_count -= c_read;
}
- while (!SCM_EOF_OBJECT_P (scm_peek_char (port)));
if (c_total == 0)
{
--
1.7.10.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix get-bytevector-all read redundant eof
2013-03-14 9:30 [PATCH] Fix get-bytevector-all read redundant eof Nala Ginrut
@ 2013-03-15 8:39 ` Nala Ginrut
2013-03-15 21:20 ` Mark H Weaver
2013-04-01 1:18 ` Mark H Weaver
1 sibling, 1 reply; 5+ messages in thread
From: Nala Ginrut @ 2013-03-15 8:39 UTC (permalink / raw)
To: guile-devel
On Thu, 2013-03-14 at 17:30 +0800, Nala Ginrut wrote:
> Attached the patch to fix get-bytevector-all.
> You may check it like this:
> (get-bytevector-all (current-input-port))
>
> And try to input then type ctrl+d, the current implementation needs you
> type ctrl+d twice.
>
> Regards.
Sorry, but I realized that this patch only fixed when you type ctrl+d in
the beginning. But if you input something, the problem is still there.
I'll look deeper.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix get-bytevector-all read redundant eof
2013-03-15 8:39 ` Nala Ginrut
@ 2013-03-15 21:20 ` Mark H Weaver
2013-03-16 4:25 ` Nala Ginrut
0 siblings, 1 reply; 5+ messages in thread
From: Mark H Weaver @ 2013-03-15 21:20 UTC (permalink / raw)
To: Nala Ginrut; +Cc: guile-devel
Nala Ginrut <nalaginrut@gmail.com> writes:
> On Thu, 2013-03-14 at 17:30 +0800, Nala Ginrut wrote:
>> Attached the patch to fix get-bytevector-all.
>> You may check it like this:
>> (get-bytevector-all (current-input-port))
>>
>> And try to input then type ctrl+d, the current implementation needs you
>> type ctrl+d twice.
>>
>> Regards.
>
>
> Sorry, but I realized that this patch only fixed when you type ctrl+d in
> the beginning. But if you input something, the problem is still there.
> I'll look deeper.
FWIW, I suspect you'll have to dig fairly deep to fix this properly.
AFAIK, the ports code was not designed to ensure that exactly one EOF is
reported to the user for each EOF returned by the kernel. I hope to
look into this soon (possibly before 2.0.8), as part of my investigation
of <http://bugs.gnu.org/12216>.
Thanks,
Mark
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix get-bytevector-all read redundant eof
2013-03-15 21:20 ` Mark H Weaver
@ 2013-03-16 4:25 ` Nala Ginrut
0 siblings, 0 replies; 5+ messages in thread
From: Nala Ginrut @ 2013-03-16 4:25 UTC (permalink / raw)
To: Mark H Weaver; +Cc: guile-devel
On Fri, 2013-03-15 at 17:20 -0400, Mark H Weaver wrote:
> Nala Ginrut <nalaginrut@gmail.com> writes:
>
> > On Thu, 2013-03-14 at 17:30 +0800, Nala Ginrut wrote:
> >> Attached the patch to fix get-bytevector-all.
> >> You may check it like this:
> >> (get-bytevector-all (current-input-port))
> >>
> >> And try to input then type ctrl+d, the current implementation needs you
> >> type ctrl+d twice.
> >>
> >> Regards.
> >
> >
> > Sorry, but I realized that this patch only fixed when you type ctrl+d in
> > the beginning. But if you input something, the problem is still there.
> > I'll look deeper.
>
> FWIW, I suspect you'll have to dig fairly deep to fix this properly.
> AFAIK, the ports code was not designed to ensure that exactly one EOF is
> reported to the user for each EOF returned by the kernel. I hope to
> look into this soon (possibly before 2.0.8), as part of my investigation
> of <http://bugs.gnu.org/12216>.
>
Yes, I tried the bug-demo code of dwheeler, and found that EOF seems was
eaten in somewhere.
I read the code on the calling-tree of scm_peek_char, but hardly find
the problem related.
Maybe it's something about the 'port' implementation?
> Thanks,
> Mark
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix get-bytevector-all read redundant eof
2013-03-14 9:30 [PATCH] Fix get-bytevector-all read redundant eof Nala Ginrut
2013-03-15 8:39 ` Nala Ginrut
@ 2013-04-01 1:18 ` Mark H Weaver
1 sibling, 0 replies; 5+ messages in thread
From: Mark H Weaver @ 2013-04-01 1:18 UTC (permalink / raw)
To: Nala Ginrut; +Cc: guile-devel
Nala Ginrut <nalaginrut@gmail.com> writes:
> You may check it like this:
> (get-bytevector-all (current-input-port))
>
> And try to input then type ctrl+d, the current implementation needs you
> type ctrl+d twice.
I just pushed a fix for this (and some other related problems) to
stable-2.0.
http://git.savannah.gnu.org/gitweb/?p=guile.git;a=commit;h=47f2bce5ae332c274270882c259776b8e4ea12f7
Thanks for bringing this to our attention!
Mark
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-04-01 1:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-14 9:30 [PATCH] Fix get-bytevector-all read redundant eof Nala Ginrut
2013-03-15 8:39 ` Nala Ginrut
2013-03-15 21:20 ` Mark H Weaver
2013-03-16 4:25 ` Nala Ginrut
2013-04-01 1:18 ` Mark H Weaver
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).