unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: David Pirotte <david@altosw.be>
To: Jan <tona_kosmicznego_smiecia@interia.pl>
Cc: 37066@debbugs.gnu.org
Subject: bug#37066: Using GOOPS #:allocation #:virtual slot option causes stack overflow
Date: Sun, 18 Aug 2019 05:08:53 -0300	[thread overview]
Message-ID: <20190818050853.17b31311@capac> (raw)
In-Reply-To: <20190818004223.22acd911@kompiuter>

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

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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2019-08-18  8:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-17 22:42 bug#37066: Using GOOPS #:allocation #:virtual slot option causes stack overflow Jan
2019-08-18  8:08 ` David Pirotte [this message]
2019-08-18 21:43   ` Jan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190818050853.17b31311@capac \
    --to=david@altosw.be \
    --cc=37066@debbugs.gnu.org \
    --cc=tona_kosmicznego_smiecia@interia.pl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).