GNU bug report logs - #37066
Using GOOPS #:allocation #:virtual slot option causes stack overflow

Previous Next

Package: guile;

Reported by: Jan <tona_kosmicznego_smiecia <at> interia.pl>

Date: Sat, 17 Aug 2019 22:44:02 UTC

Severity: normal

Full log


View this message in rfc822 format

From: David Pirotte <david <at> altosw.be>
To: Jan <tona_kosmicznego_smiecia <at> interia.pl>
Cc: 37066 <at> debbugs.gnu.org
Subject: bug#37066: Using GOOPS #:allocation #:virtual slot option causes stack overflow
Date: Sun, 18 Aug 2019 05:08:53 -0300
[Message part 1 (text/plain, inline)]
Hello Jan,

> I've written the program attached below and it hangs at writing 
> "after changing (K): ", computer freezes for a moment and then Guile
> throws the following message:
 
> allocate_stack failed: Can't allocate memory
> Warning: Unwind-only `stack-overflow' exception; skipping pre-unwind
> handler.
> ...

This is not goops bug. The problem occurs because you try to set the
value of the virtual slot, something you should never do. Here is a
slightly corrected version of your code:

(define-module (temperature)
  #:use-module (oop goops)

  #:export (<temperature>
            kelvin
            celsius))

(define-class <temperature> ()
  (k #:accessor kelvin
     #:init-keyword #:k
     #:init-value 0)
  (c #:accessor celsius
     #:init-keyword #:c
     #:allocation #:virtual
     #:slot-ref (lambda (o)
                  (- (kelvin o) 273.15))
     #:slot-set! (lambda (o c)
                   (set! (kelvin o) (+ 273.15 c)))))

Then, in a repl:

scheme@(guile-user)> (add-to-load-path "/your/temperature/module/path")
scheme@(guile-user)> ,use (oop goops)
scheme@(guile-user)> ,use (oop goops describe)
scheme@(guile-user)> ,use (temperature)
;;; note: source file ...  newer than compiled ...
;;; ...
scheme@(guile-user)> (make <temperature>)
$2 = #<<temperature> 5604c4614200>
scheme@(guile-user)> (describe $2)
#<<temperature> 5604c4614200> is an instance of class <temperature>
Slots are: 
     k = 0
     c = -273.15
scheme@(guile-user)> (set! (celsius $2) 0)
$3 = 273.15
scheme@(guile-user)> (describe $2)
#<<temperature> 5604c4614200> is an instance of class <temperature>
Slots are: 
     k = 273.15
     c = 0.0

> ... it also throws a different error ...

I didn't look into this manual example code yet, I wanted to get back
to your own example first ...

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

This bug report was last modified 5 years and 300 days ago.

Previous Next


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