guile-devel
[Top][All Lists]
Advanced

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

Re: A Pango attribute deallocated twice


From: Mark H Weaver
Subject: Re: A Pango attribute deallocated twice
Date: Tue, 05 Jun 2018 16:28:22 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Hi,

Tommi Höynälänmaa <address@hidden> writes:

> A Pango attribute gets deallocated twice in program calc-9.scm causing
> the program to crash. The Scheme code calc-9.scm is generated from the
> Theme-D program calc-9.thp.

[...]

> IMHO the variable attrlist should not be deallocated at all in the
> position where it is done now since it is defined in the surrounding
> let expression.

Sorry, but your expectation here is simply not fulfilled by Guile's
compiler, nor by other modern compilers.  In this case:

  (define-simple-proc make-calculator
      (((lst-panels (:uniform-list <panel>)))
       <none>
       nonpure)
    (console-display-line "*1*")
    (force-output)
    (let* ((attrlist (pango-attr-list-create))
           (tmp1 (begin
                   (console-display-line "*2*")
                   (force-output)
                   0))
           (tmp3 (begin
                   (pango-attr-list-insert
                    attrlist
                    (pango-attr-background-new 65535 0 0))
                   0))

I omitted the rest of this procedure, but it turns out that the only
reference to 'attrlist' is in the initializer for 'tmp3'.  After that,
there's no guarantee that Guile will retain a reference to 'attrlist'.
It probably doesn't.

If you need to artificially keep a reference to some object alive, you
should store it in a top-level variable, or in a data structure that's
referenced by a top-level variable.  Those are never optimized away.

      Mark



reply via email to

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