unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#29162: [PATCH] fix scm_make_foreign_object_n
@ 2017-11-05 22:15 Sergei Trofimovich
  2017-11-22 15:12 ` Ludovic Courtès
  0 siblings, 1 reply; 4+ messages in thread
From: Sergei Trofimovich @ 2017-11-05 22:15 UTC (permalink / raw)
  To: 29162; +Cc: Sergei Trofimovich

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@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






^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#29162: [PATCH] fix scm_make_foreign_object_n
  2017-11-05 22:15 bug#29162: [PATCH] fix scm_make_foreign_object_n Sergei Trofimovich
@ 2017-11-22 15:12 ` Ludovic Courtès
  2017-11-22 20:03   ` Sergei Trofimovich
  0 siblings, 1 reply; 4+ messages in thread
From: Ludovic Courtès @ 2017-11-22 15:12 UTC (permalink / raw)
  To: Sergei Trofimovich; +Cc: 29162

Hi Sergei,

Sergei Trofimovich <slyfox@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’.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#29162: [PATCH] fix scm_make_foreign_object_n
  2017-11-22 15:12 ` Ludovic Courtès
@ 2017-11-22 20:03   ` Sergei Trofimovich
  2017-11-22 21:29     ` Ludovic Courtès
  0 siblings, 1 reply; 4+ messages in thread
From: Sergei Trofimovich @ 2017-11-22 20:03 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 29162

[-- Attachment #1: Type: text/plain, Size: 1556 bytes --]

On Wed, 22 Nov 2017 16:12:24 +0100
ludo@gnu.org (Ludovic Courtès) wrote:

> Hi Sergei,
> 
> Sergei Trofimovich <slyfox@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

[-- Attachment #2: Цифровая подпись OpenPGP --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#29162: [PATCH] fix scm_make_foreign_object_n
  2017-11-22 20:03   ` Sergei Trofimovich
@ 2017-11-22 21:29     ` Ludovic Courtès
  0 siblings, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2017-11-22 21:29 UTC (permalink / raw)
  To: Sergei Trofimovich, Andy Wingo; +Cc: 29162

Heya,

Sergei Trofimovich <slyfox@gentoo.org> skribis:

> On Wed, 22 Nov 2017 16:12:24 +0100
> ludo@gnu.org (Ludovic Courtès) wrote:
>
>> Hi Sergei,
>> 
>> Sergei Trofimovich <slyfox@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’.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-11-22 21:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-05 22:15 bug#29162: [PATCH] fix scm_make_foreign_object_n Sergei Trofimovich
2017-11-22 15:12 ` Ludovic Courtès
2017-11-22 20:03   ` Sergei Trofimovich
2017-11-22 21:29     ` Ludovic Courtès

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).