bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#37066: Using GOOPS #:allocation #:virtual slot option causes stack o


From: David Pirotte
Subject: bug#37066: Using GOOPS #:allocation #:virtual slot option causes stack overflow
Date: Sun, 18 Aug 2019 05:08:53 -0300

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

Attachment: pgp3Q7jJ3KQkK.pgp
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]