help-smalltalk
[Top][All Lists]
Advanced

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

[Help-smalltalk] Re: Fix (?) for strange CObject at:type: behavior


From: Paolo Bonzini
Subject: [Help-smalltalk] Re: Fix (?) for strange CObject at:type: behavior
Date: Tue, 31 Dec 2002 10:45:15 +0100

> I've discovered what appears to be a bug in VMpr_CObject_at
> (prims.inl:4533).  When the passed type is a real CType instead of an
> integer type, the stack gets messed up:

I'd need to see the context of prims.inl to understand better, but there are
good chances that you're right.

(Please CC: address@hidden, I like to have an archive)

Paolo

>
> SET_STACKTOP (_gst_c_object_new_typed (addr, oop3));
>
> As far as I could figure out, _gst_c_object_new_typed does not place
> it's return OOP on the stack, thus messing the stack up (?).  Or at
> the very least, there's something else below it on the stack.  At any
> rate, changing SET_STACKTOP to PUSH_OOP solved the problem for me and
> seems to work...
>
> Here's the code that triggered it for me:
>
> listDepthsOfScreen: aScreen
>     "Return a list of all depths supported by the given screen."
>     | nCReturn cList result block v idx |
>     nCReturn := CInt new: (CInt sizeof).
>     cList := self cXListDepths: self a2: aScreen a3: nCReturn.
>     result := Set new.
>     (nCReturn value) printNl.
>
>     block := [ :x |
> x display.
> ' ' display.
> idx := ((CIntType sizeof) * x).
> x display.
> ' ' display.
> idx display.
> ' ' display.
> v := (cList at: idx type: CIntType).
> x display.
> ' ' display.
> v := v value.
> x display.
> ' - ' display.
> v displayNl.
> result add: v.].
>
>     0 to: ((nCReturn value) - 1) do: block.
>
>     nCReturn free.
>     cList free. "FIXME: Use XFree"
>     ^result.
> !
>
> This returns the correct result, but it prints out:
>
> st> x listDepthsOfScreen: 0!
> 7
> 0 0 0 CInt(16r83D2010) 24 - 24
> 1 1 4 CInt(16r83D2014) 1 - 1
> 2 2 8 CInt(16r83D2018) 4 - 4
> 3 3 12 CInt(16r83D201C) 8 - 8
> 4 4 16 CInt(16r83D2020) 15 - 15
> 5 5 20 CInt(16r83D2024) 16 - 16
> 6 6 24 CInt(16r83D2028) 32 - 32
>
> Somehow `x' is getting corrupted with the value of `v'.  And if I
> eliminate `block' and just pass the block directly to to:do: it works
> OK, but will only call the block ONCE (thus only returning a set with
> `24' in it.).  If I make `v' a temporary inside the block, it enters
> an infinite loop.
>
> If I pass `10' as the type everything works OK.
>
> The above method can be pasted right into my previous Xlib bindings
> code in Xlib_Display.st:269.  Then to repeat run under X:
>
> FileStream fileIn: 'Xlib.st'!
> Smalltalk at: #x put: (Xlib Display new)!
> x listDepthsOfScreen: 0!
>
> This is with Debian GNU/Linux 3.0 and GNU Smalltalk 2.0.10.
>
> Thanks,
> -Dave
>
>





reply via email to

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