GNU bug report logs - #29162
[PATCH] fix scm_make_foreign_object_n

Previous Next

Package: guile;

Reported by: Sergei Trofimovich <slyfox <at> gentoo.org>

Date: Sun, 5 Nov 2017 22:16:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 29162 in the body.
You can then email your comments to 29162 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#29162; Package guile. (Sun, 05 Nov 2017 22:16:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Sergei Trofimovich <slyfox <at> gentoo.org>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Sun, 05 Nov 2017 22:16:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Sergei Trofimovich <slyfox <at> gentoo.org>
To: bug-guile <at> gnu.org
Cc: Sergei Trofimovich <slyfox <at> gentoo.org>
Subject: [PATCH] fix scm_make_foreign_object_n
Date: Sun,  5 Nov 2017 22:15:10 +0000
Noticed the error when ran test suite on ia64
but failure is not specific to t. x86_64 is as broken.

test-foreign-object-c fails as:

```
Backtrace:
           0 (apply-smob/1 #<catch-closure 556d010a52a0>)

ERROR: In procedure apply-smob/1:
ERROR: In procedure make-foreign-object: Value out of range: 2
FAIL: test-foreign-object-c
```

The cause of the failure is wrong check for amount of available
slots prepared by 'scm_make_foreign_object_type'.

The fix is easy: check for amount of slots available.

* libguile/foreign-object.c(scm_make_foreign_object_n): fix slot
  count check in foreign object constructors.

Signed-off-by: Sergei Trofimovich <slyfox <at> gentoo.org>
---
 libguile/foreign-object.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libguile/foreign-object.c b/libguile/foreign-object.c
index 34b9f22ca..8fd2c384c 100644
--- a/libguile/foreign-object.c
+++ b/libguile/foreign-object.c
@@ -108,7 +108,7 @@ scm_make_foreign_object_n (SCM type, size_t n, void *vals[])
 
   SCM_VALIDATE_VTABLE (SCM_ARG1, type);
 
-  if (SCM_VTABLE_SIZE (type) / 2 < n)
+  if (SCM_VTABLE_SIZE (type) < n)
     scm_out_of_range (FUNC_NAME, scm_from_size_t (n));
 
   for (i = 0; i < n; i++)
-- 
2.15.0





Information forwarded to bug-guile <at> gnu.org:
bug#29162; Package guile. (Wed, 22 Nov 2017 15:13:02 GMT) Full text and rfc822 format available.

Message #8 received at 29162 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Sergei Trofimovich <slyfox <at> gentoo.org>
Cc: 29162 <at> debbugs.gnu.org
Subject: Re: bug#29162: [PATCH] fix scm_make_foreign_object_n
Date: Wed, 22 Nov 2017 16:12:24 +0100
Hi Sergei,

Sergei Trofimovich <slyfox <at> gentoo.org> skribis:

> diff --git a/libguile/foreign-object.c b/libguile/foreign-object.c
> index 34b9f22ca..8fd2c384c 100644
> --- a/libguile/foreign-object.c
> +++ b/libguile/foreign-object.c
> @@ -108,7 +108,7 @@ scm_make_foreign_object_n (SCM type, size_t n, void *vals[])
>  
>    SCM_VALIDATE_VTABLE (SCM_ARG1, type);
>  
> -  if (SCM_VTABLE_SIZE (type) / 2 < n)
> +  if (SCM_VTABLE_SIZE (type) < n)
>      scm_out_of_range (FUNC_NAME, scm_from_size_t (n));

Your analysis seems right, but the code in the current ‘stable-2.2’
branch (which corresponds to the 2.2.x stable series) has different code
(correct code):

  SCM_VALIDATE_VTABLE (SCM_ARG1, type);

  layout = SCM_VTABLE_LAYOUT (type);

  if (scm_i_symbol_length (layout) / 2 < n)
    scm_out_of_range (FUNC_NAME, scm_from_size_t (n));

What version were you looking at?

Thanks,
Ludo’.




Information forwarded to bug-guile <at> gnu.org:
bug#29162; Package guile. (Wed, 22 Nov 2017 20:04:02 GMT) Full text and rfc822 format available.

Message #11 received at 29162 <at> debbugs.gnu.org (full text, mbox):

From: Sergei Trofimovich <slyfox <at> gentoo.org>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: 29162 <at> debbugs.gnu.org
Subject: Re: bug#29162: [PATCH] fix scm_make_foreign_object_n
Date: Wed, 22 Nov 2017 20:03:20 +0000
[Message part 1 (text/plain, inline)]
On Wed, 22 Nov 2017 16:12:24 +0100
ludo <at> gnu.org (Ludovic Courtès) wrote:

> Hi Sergei,
> 
> Sergei Trofimovich <slyfox <at> gentoo.org> skribis:
> 
> > diff --git a/libguile/foreign-object.c b/libguile/foreign-object.c
> > index 34b9f22ca..8fd2c384c 100644
> > --- a/libguile/foreign-object.c
> > +++ b/libguile/foreign-object.c
> > @@ -108,7 +108,7 @@ scm_make_foreign_object_n (SCM type, size_t n, void *vals[])
> >  
> >    SCM_VALIDATE_VTABLE (SCM_ARG1, type);
> >  
> > -  if (SCM_VTABLE_SIZE (type) / 2 < n)
> > +  if (SCM_VTABLE_SIZE (type) < n)
> >      scm_out_of_range (FUNC_NAME, scm_from_size_t (n));  
> 
> Your analysis seems right, but the code in the current ‘stable-2.2’
> branch (which corresponds to the 2.2.x stable series) has different code
> (correct code):
> 
>   SCM_VALIDATE_VTABLE (SCM_ARG1, type);
> 
>   layout = SCM_VTABLE_LAYOUT (type);
> 
>   if (scm_i_symbol_length (layout) / 2 < n)
>     scm_out_of_range (FUNC_NAME, scm_from_size_t (n));
> 
> What version were you looking at?

It was the master branch of
    git://git.savannah.gnu.org/guile.git

Commit from November:
    http://git.savannah.gnu.org/cgit/guile.git/commit/?id=f96a670332b224326b89ce135a0edfb77a70c46e    

The link with line number:
    http://git.savannah.gnu.org/cgit/guile.git/tree/libguile/foreign-object.c?id=f96a670332b224326b89ce135a0edfb77a70c46e#n111

In master branch it still seems to be around:
    http://git.savannah.gnu.org/cgit/guile.git/tree/libguile/foreign-object.c#n111

-- 

  Sergei
[Message part 2 (application/pgp-signature, inline)]

Information forwarded to bug-guile <at> gnu.org:
bug#29162; Package guile. (Wed, 22 Nov 2017 21:30:03 GMT) Full text and rfc822 format available.

Message #14 received at 29162 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Sergei Trofimovich <slyfox <at> gentoo.org>, Andy Wingo <wingo <at> igalia.com>
Cc: 29162 <at> debbugs.gnu.org
Subject: Re: bug#29162: [PATCH] fix scm_make_foreign_object_n
Date: Wed, 22 Nov 2017 22:29:56 +0100
Heya,

Sergei Trofimovich <slyfox <at> gentoo.org> skribis:

> On Wed, 22 Nov 2017 16:12:24 +0100
> ludo <at> gnu.org (Ludovic Courtès) wrote:
>
>> Hi Sergei,
>> 
>> Sergei Trofimovich <slyfox <at> gentoo.org> skribis:
>> 
>> > diff --git a/libguile/foreign-object.c b/libguile/foreign-object.c
>> > index 34b9f22ca..8fd2c384c 100644
>> > --- a/libguile/foreign-object.c
>> > +++ b/libguile/foreign-object.c
>> > @@ -108,7 +108,7 @@ scm_make_foreign_object_n (SCM type, size_t n, void *vals[])
>> >  
>> >    SCM_VALIDATE_VTABLE (SCM_ARG1, type);
>> >  
>> > -  if (SCM_VTABLE_SIZE (type) / 2 < n)
>> > +  if (SCM_VTABLE_SIZE (type) < n)
>> >      scm_out_of_range (FUNC_NAME, scm_from_size_t (n));  
>> 
>> Your analysis seems right, but the code in the current ‘stable-2.2’
>> branch (which corresponds to the 2.2.x stable series) has different code
>> (correct code):
>> 
>>   SCM_VALIDATE_VTABLE (SCM_ARG1, type);
>> 
>>   layout = SCM_VTABLE_LAYOUT (type);
>> 
>>   if (scm_i_symbol_length (layout) / 2 < n)
>>     scm_out_of_range (FUNC_NAME, scm_from_size_t (n));
>> 
>> What version were you looking at?
>
> It was the master branch of
>     git://git.savannah.gnu.org/guile.git
>
> Commit from November:
>     http://git.savannah.gnu.org/cgit/guile.git/commit/?id=f96a670332b224326b89ce135a0edfb77a70c46e    
>
> The link with line number:
>     http://git.savannah.gnu.org/cgit/guile.git/tree/libguile/foreign-object.c?id=f96a670332b224326b89ce135a0edfb77a70c46e#n111
>
> In master branch it still seems to be around:
>     http://git.savannah.gnu.org/cgit/guile.git/tree/libguile/foreign-object.c#n111

Indeed.

Andy, could you take a look?  The patch LGTM.

Ludo’.




bug closed, send any further explanations to 29162 <at> debbugs.gnu.org and Sergei Trofimovich <slyfox <at> gentoo.org> Request was from Ludovic Courtès <ludo <at> gnu.org> to control <at> debbugs.gnu.org. (Mon, 02 Oct 2023 08:54:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 30 Oct 2023 11:24:10 GMT) Full text and rfc822 format available.

This bug report was last modified 177 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.