Pharo-dev
By thread
pharo-dev@lists.pharo.org
By month
Messages by month
- ----- 2026 -----
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
November 2017
- 846 messages
Re: [Pharo-dev] ExternalAddress uniqueness (was Re: Call for help for stability and rewrite of FreeType)
by Nicolas Cellier
2017-11-08 15:35 GMT+01:00 Nicolas Cellier <
nicolas.cellier.aka.nice(a)gmail.com>:
>
>
> 2017-11-08 14:53 GMT+01:00 Nicolas Cellier <nicolas.cellier.aka.nice@
> gmail.com>:
>
>>
>>
>> 2017-11-08 14:42 GMT+01:00 Nicolas Cellier <nicolas.cellier.aka.nice@gmai
>> l.com>:
>>
>>>
>>> Ben,
>>>
>>> This is my fresh crash.dmp
>>> it sounds very related to your analysis!!!
>>>
>>> In fact we are not freeing by ourselves, but telling libgit2 to do it...
>>>
>>>
>> Oh worse than that, it sounds like git implemented its own mechanism of
>> counted pointers...
>> So we don't tell anything, he guesses by himself.
>> I would search for places where we #gcallocate: or manually #free a
>> pointer on a structure passed back by git...
>>
>>
> and of course, it's not gcallocate: because this was a very old wheel...
> It's rather somewhere in UFFI equivalent
> FFIExternalResourceExecutor <- FFIExternalResourceManager <-
> LGitExternalStructure autoRelease
>
> Among the senders, we see (tiens, tiens...):
> LGitTree>>...
>
> So this is where I would search the origin of my own crash dump...
>
> But also (tiens, tiens...):
> CairoFontFace>>initializeWithFreetypeFace:
>
> What if FreeType plugin was not the problem per se, but its usage in cairo
> was?
>
> cairo_font_face_destroy ()
> void cairo_font_face_destroy (cairo_font_face_t
> *font_face);
> Decreases the reference count on font_face by one. If the result is zero, *then
> font_face and all associated resources are freed*. See
> cairo_font_face_reference().
> font_face :
> a cairo_font_face_t
>
> Since we pass a pointer to the free type font at creation:
>
> fromFreetypeFace: aFace
> | handle cairoFace |
> handle := aFace handle pointerAt: 1.
> cairoFace := self primFtFace: handle loadFlags: ( LoadNoHinting |
> LoadTargetLCD | LoadNoAutohint | LoadNoBitmap).
> ^ cairoFace initializeWithFreetypeFace: aFace
>
> Isn't it possible that we somehow double free the free type font too?
>
>
Hmm not the exact catch but it could well be related
https://www.cairographics.org/manual/cairo-FreeType-Fonts.html tells how to
couple lifetime of the 2 data structures.
I see that CairoFontFace retains a pointer on the FT_Face thru a dedicated
ivar, so at least, we don't free the FT_Face twice, and we don't free it
until we free the cairo_ft_face
When finalizatoin occurs, I'm not sure that the finalization order is
guaranteed but that does not matter.
What matters is that the cairo_ft_face could still be referenced internally
by cairo.
So what can happen is that:
1) we don't reference anymore the CairoFontFace from within Smalltalk
2) finalization happens we call cairo_font_face_destroy ()
3) there is no more pointer on the FTFace from within Smalltalk (because we
just reclaimed the CairoFontFace pointing on it)
4) finalization happens and we call FT_Done_Face()
BUT: cairo was still using the cairo_font_face internally, (the reference
count did not reach zero) and is now pointing on freed memory due to
FT_Done_Face()...
We should have tested the status before invoking FT_Done():
status = cairo_font_face_set_user_data (font_face, &key,
ft_face, (cairo_destroy_func_t) FT_Done_Face);
That means that we would have to performa that status test in the
finalization, and if not ready, keep a reference to both cairo_font_face
handle ft_face handle
But then there is no other mean than storing those reference in a safe
place and regularly poll for readiness
If my understanding is correct, this is absolutely garbage collector
unfriendly!
>
>>> Stack backtrace:
>>> [7791E43E] RtlInitializeGenericTable + 0x196 in ntdll.dll
>>> [7791E0A3] RtlGetCompressionWorkSpaceSize + 0x7e in ntdll.dll
>>> [751F98CD] free + 0x39 in msvcrt.dll
>>> [6CD60D43] git_tree_cache_write + 0x2ac in libgit2.dll
>>> [6CD62073] git_tree__free + 0x53 in libgit2.dll
>>> [6CD1A563] git_object__free + 0x52 in libgit2.dll
>>> [6CCD0D78] git_cached_obj_decref + 0x4c in libgit2.dll
>>> [6CD1A7D9] git_object_free + 0x17 in libgit2.dll
>>> [6CD1B0D3] git_tree_free + 0x11 in libgit2.dll
>>> [6CD0BE4F] git_iterator_for_nothing + 0x8aa in libgit2.dll
>>> [6CD0C053] git_iterator_for_nothing + 0xaae in libgit2.dll
>>> [6CCEADEF] git_diff_file_content__clear + 0x31d in libgit2.dll
>>> [6CCECC3F] git_diff__oid_for_entry + 0xc29 in libgit2.dll
>>> [6CCED2B2] git_diff__oid_for_entry + 0x129c in libgit2.dll
>>> [6CCED495] git_diff__from_iterators + 0x1db in libgit2.dll
>>> [6CCED6DE] git_diff_tree_to_tree + 0x1e3 in libgit2.dll
>>> [004DE7C8] ??? + 0xde7c8 in Pharo.exe
>>> [0044FE08] ??? + 0x4fe08 in Pharo.exe
>>> [004516A7] ??? + 0x516a7 in Pharo.exe
>>> [00446051] ??? + 0x46051 in Pharo.exe
>>> [0049936E] ??? + 0x9936e in Pharo.exe
>>>
>>>
>>> Smalltalk stack dump:
>>> 0xafa86c I LGitDiff>diff_tree_to_tree:repo:old_tree:new_tree:opts:
>>> 0xe585410: a(n) LGitDiff
>>> 0xafa8a4 M [] in LGitDiff>diffTree:toTree:options: 0xe585410: a(n)
>>> LGitDiff
>>> 0xafa8bc M LGitDiff(LGitExternalObject)>withReturnHandlerDo:
>>> 0xe585410: a(n) LGitDiff
>>> 0xafc678 I LGitDiff>diffTree:toTree:options: 0xe585410: a(n) LGitDiff
>>> 0xafc6a4 I LGitDiff>diffTree:toTree: 0xe585410: a(n) LGitDiff
>>> 0xafc6d0 I LGitTree>diffTo: 0xe583e00: a(n) LGitTree
>>> 0xafc6fc M [] in IceLibgitLocalRepository>changedFilesBetween:and:
>>> 0x1055afc0: a(n) IceLibgitLocalRepository
>>> 0xafc720 M [] in IceLibgitLocalRepository>withRepoDo: 0x1055afc0:
>>> a(n) IceLibgitLocalRepository
>>> 0xafc73c M [] in LGitGlobal class>runSequence: 0xfb96188: a(n)
>>> LGitGlobal class
>>> 0xafc760 M [] in LGitActionSequence(DynamicVariable)>value:during:
>>> 0x102109f8: a(n) LGitActionSequence
>>> 0xafc780 M BlockClosure>ensure: 0xe582890: a(n) BlockClosure
>>> 0xafc7ac I LGitActionSequence(DynamicVariable)>value:during:
>>> 0x102109f8: a(n) LGitActionSequence
>>> 0xafc7cc M LGitActionSequence class(DynamicVariable
>>> class)>value:during: 0xfbb81e0: a(n) LGitActionSequence class
>>> 0xafc7f4 I LGitGlobal class>runSequence: 0xfb96188: a(n) LGitGlobal
>>> class
>>> 0xafc818 I IceLibgitLocalRepository>withRepoDo: 0x1055afc0: a(n)
>>> IceLibgitLocalRepository
>>> 0xafc840 I IceLibgitLocalRepository>changedFilesBetween:and:
>>> 0x1055afc0: a(n) IceLibgitLocalRepository
>>> 0xafc874 I IceCommitInfo>changedPackagesToCommitInfo: 0x113b80e0:
>>> a(n) IceCommitInfo
>>> 0xafc898 I IceCommitInfo>changedPackagesTo: 0x113b80e0: a(n)
>>> IceCommitInfo
>>> 0xafc8c0 I IceDiff>initialElements 0xe4c48f8: a(n) IceDiff
>>> 0xaf9664 I IceDiff(IceAbstractDiff)>elements 0xe4c48f8: a(n) IceDiff
>>> 0xaf9684 I IceDiffChangeTreeBuilder>elements 0xe4b9c80: a(n)
>>> IceDiffChangeTreeBuilder
>>> 0xaf969c M [] in IceDiffChangeTreeBuilder>buildOn: 0xe4b9c80: a(n)
>>> IceDiffChangeTreeBuilder
>>>
>>> Dimitris:
>>>
>>> I won't argument, I've learnt C in 1987, so it gave me enough time to
>>> learn my own limits.
>>> Working with pointers is like carrying a gun without engaging the safety
>>> catch.
>>> I came to think that shooting own foot was a feature ;)
>>>
>>> 2017-11-06 11:04 GMT+01:00 Dimitris Chloupis <kilon.alios(a)gmail.com>:
>>>
>>>> Its the usual case of not being able to have your cake and eat it too.
>>>>
>>>> If you want top performance you have to manage memory yourself plus the
>>>> abilitiy to access thousands of C libraries is not such a bad excuse for a
>>>> compromise. The FFI is not a problem is a solution to many problems and
>>>> people using it its not as if Smalltalk offers them any alternative choice.
>>>>
>>>> Not to forget that Slang itself relies heavily on C, which is only the
>>>> core of the VM and the very core of the implementation.
>>>>
>>>> Understanding how to work with pointers in C is pretty much
>>>> understanding how to works with Objects in Smalltalk. Both are nuclear
>>>> weapons that those two languages are build around. If ones does not
>>>> understand their usage he will shoot his foot in the end.
>>>>
>>>> The important thing to remember is that C's goal is not the same as of
>>>> Smalltalk. Its not there to hold your hand and make coding easy for you. C
>>>> is there to offer low level access combined with top performance. It may
>>>> have started as a general purpose language decades ago when coding in
>>>> Assembly was still a pleasant experience. Nowdays C has completely replaced
>>>> Assembly as the top performance language for low level coding.
>>>>
>>>> C may appear as a problematic language to a Smalltalker but only
>>>> because he sees it from the Smalltalk point of view. The harsh reality of
>>>> the world is that as much as one may want to shoehorn it , not everything
>>>> can be elegantly mapped to a object. Smalltalk may be OO to the bone , but
>>>> the world we live in, cannot afford such simple structures to accomodate of
>>>> varied immense complexity.
>>>>
>>>> On the subject of pointers, the general rule of thumb is to keep things
>>>> as simple as possible and avoide trying to do weird "magic" with them.
>>>> There is a ton of things that C does under the hood to generate highly
>>>> optimised machine code that can fry the brain , as the usual case with low
>>>> level coding, so keeping it simple is the way to go.
>>>>
>>>> Oh and dont try to shoehorn the Live coding enviroment in debugging C
>>>> code, as much as one may want to brag of Smalltalk's elegant debugger, C
>>>> development tools are light years ahead in dealing with C problems.
>>>>
>>>> May advice to people is that if you do it via FFI first, you do it
>>>> wrong.
>>>>
>>>> Do it always first with C with a powerful C IDE like Visual Studio,
>>>> make sure your code works there and then use the UFFI. Will make life
>>>> thousand times easier. I learned that the hard way when I was playing
>>>> around with Pharo and shared memory.
>>>>
>>>> So yes having a FFI that does not help you avoid coding in C first, is
>>>> a big plus, not a minus. Sometimes it makes sense to live outside the
>>>> image, this is an excellent case to prove why that is a great idea. .
>>>>
>>>> On Mon, Nov 6, 2017 at 11:10 AM Nicolas Cellier <
>>>> nicolas.cellier.aka.nice(a)gmail.com> wrote:
>>>>
>>>>> Hi Ben,
>>>>> It's a super bad idea to copy an ExternalAddress.
>>>>> It's common knowledge in C++ copy operator & copy constructors...
>>>>>
>>>>> But it's not obvious to me that you'll have double freeing (unless you
>>>>> explicitely free the pointer by yourself).
>>>>> If you use gcallocate: then only the original is registered for
>>>>> magical auto-deallocation at garbage collection...
>>>>>
>>>>> What you will have is more somthing like dangling pointer: continue to
>>>>> use pointer xa2->a1 when a1 was already freed.
>>>>>
>>>>> FFI is great, it introduces the problem of C in Smalltalk, augmented
>>>>> with the problems of wrapping C in Smalltalk.
>>>>>
>>>>>
>>>>> 2017-11-06 4:23 GMT+01:00 Ben Coman <btc(a)openinworld.com>:
>>>>>
>>>>>> My current employment work hours and roster have severely curtailed
>>>>>> the time I have hacking Pharo, so I've not dug enough to be sure of my
>>>>>> observations a few months ago, and this is from memory, but I was starting
>>>>>> to develop a suspicion about the uniqueness of ExternalAddress(s).
>>>>>>
>>>>>> A while ago, in order to fix some stability issues on Windows, a
>>>>>> guard was added somewhere that slowed down some operations. Looking into
>>>>>> this and experimenting with removing the guard I seem to remember VM
>>>>>> crashes due to a double-free() of an address, due to there being two
>>>>>> ExternalAddresses holding the same external address.
>>>>>>
>>>>>> My intuition is that that somewhere an ExternalAddress(a1) pointing
>>>>>> at a particular external resource address "xa1" was being copied, so we end
>>>>>> up with ExternalAddress(a2) also pointing at "xa1", with and object b1
>>>>>> holding a1 and object b2 holding a2. During finalization of b1,
>>>>>> ExternalAddress a1 free()d xa1, and a1 was flagged to avoid
>>>>>> double-free()ing. But that didn't help when b2 was finalized, since a2 had
>>>>>> no indication that xa1 had been free()d.
>>>>>>
>>>>>> That is...
>>>>>> b1-->a1-->xa1
>>>>>> b2 := b1 copy.
>>>>>> b2-->a2-->xa1
>>>>>> b1 finalize a1 --> free(xa1)
>>>>>> b2 finalize a2 --> free(xa1) --> General Protection Fault
>>>>>>
>>>>>> It was hard to follow this through and I didn't succeed in tracking
>>>>>> down where such a copy might have been made, but the idea simmering in my
>>>>>> mind since then is to propose that...
>>>>>>
>>>>>> ExternalAddresses be unique in the image and behave like Symbols,
>>>>>> such that trying to copy one returns the identical object.
>>>>>>
>>>>>> The idea being that when b2 is finalized, a1 would notice that xa1
>>>>>> had already been free()d and raise a Smalltalk exception rather than a
>>>>>> general protection fault.
>>>>>> b1-->a1-->xa1
>>>>>> b2 := b1 copy.
>>>>>> b2-->a1-->xa1
>>>>>> ^^
>>>>>> b1 finalize a1 --> free(xa1)
>>>>>> b2 finalize a1 --> Smalltalk exception
>>>>>>
>>>>>>
>>>>>> I write now in response to Stef since I vaguely remember it being
>>>>>> Freetype related. But I also remember the issue being FFI related and
>>>>>> Freetype is a plugin not FFI. So I'm not sure my memory is clear and
>>>>>> perhaps I have the "wrong end of the stick" but anyway, rather than hold
>>>>>> back longer because of that, perhaps this can stimulate some discussion and
>>>>>> at least I learn something to clarify my understanding here.
>>>>>>
>>>>>> cheers -ben
>>>>>>
>>>>>>
>>>>>> On Sat, Oct 28, 2017 at 4:48 PM, Stephane Ducasse <
>>>>>> stepharo.self(a)gmail.com> wrote:
>>>>>> >
>>>>>> > Hi all
>>>>>> >
>>>>>> > I'm and I guess many of you are fedup about the instability that the
>>>>>> > FreeType plugin produces.
>>>>>> >
>>>>>> > So we need help because clement and esteban are fully booked.
>>>>>> >
>>>>>> > We have three options:
>>>>>> >
>>>>>> > - drop Freetype alltogether
>>>>>> > - rewrite the plugin
>>>>>> > - create a binding using raffaillac sketch
>>>>>> >
>>>>>> > Now we need help. Who is willing to help us?
>>>>>> > Should we try to set up a bounty?
>>>>>> >
>>>>>> > Stef
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>
>>
>
Nov. 8, 2017
Re: [Pharo-dev] [IMPORTANT] Is there a bug in Tonel with category:
by Dale Henrichs
Poster child for the porting pain[1] of symbols and strings - from this
morning:)
The dictionary was created using symbols as the keys, but the code that
I had to change used mixed symbols and strings as keys ... and of course
I was left wondering why the class vars weren't being defined properly ...
Dale
[1]
https://github.com/GsDevKit/tonel/commit/b00565685586630452a9de3d4f90f16571…
On 11/6/17 11:15 AM, Dale Henrichs wrote:
>
>
> On 11/06/2017 08:23 AM, Sven Van Caekenberghe wrote:
>>
>>> On 6 Nov 2017, at 17:13, Dale Henrichs
>>> <dale.henrichs(a)gemtalksystems.com> wrote:
>>>
>>>
>>>
>>> On 11/6/17 7:07 AM, Sven Van Caekenberghe wrote:
>>>>> On 6 Nov 2017, at 15:43, Dale Henrichs
>>>>> <dale.henrichs(a)gemtalksystems.com> wrote:
>>>>>
>>>>> of course with Pharo's implementation of Symbol it is not
>>>>> practical to use asString nor type checks - things that are not
>>>>> necessary in other Smalltalk implementations
>>>> How so ?
>>>>
>>>> What is the problem with Symbol>>#asString ?
>>> I am not going to go to every field in the api that is supposed to
>>> be a String and add asString. There are too many places to worry
>>> about ... I would prefer that Pharo be ANSI compliant:)
>>>
>>> It's not just Metacello.
>>>
>>> It's an annoying issue that has to be dealt with every time a Pharo
>>> application is ported to another dialect of Smalltalk and an
>>> annoying barrier for folks running on other dialects to move their
>>> application to Pharo - in this case the bugs that are introduced by
>>> Pharo's behavior with respect to Symbols can be very hard to
>>> diagnose --
>>>
>>> Making things harder to share code between dialects is a bad thing
>>> for Smalltalk overall -- just another reason for non-Smalltalk
>>> programmers to question the whether they should use Smalltalk or not...
>>>
>>> And I don't need to hear about how Pharo is not Smalltalk:)
>>>
>>> Dale
>> So there is nothing 'wrong', you just want Pharo to remain the same
>> as every other non-changing Smalltalk out there.
> Did I say that?
>
> I support the direction that Pharo is going, but I reserve the right
> to disagree with some of the details.
>
> This is just one detail ... nothing more nothing less ... For those of
> us that work in multiple dialects, it IS annoying and I take an
> opportunity every year or so to remind you guys of the things that I
> find annoying, just to keep you guys honest:)
>
>>
>> Â From one perspective you are right, it makes some cross platform
>> porting in either direction harder. Seaside has many rules to help
>> portability. Not mixing Strings and Symbol is probably one of them.
> ... and as I mentioned, this problem can be one of the more annoying
> issues to track down, when a developer is not careful ... Honestly
> there are two sides to the issue ... when developers use Symbols in
> tests to drive an API that is supposed to use Strings (this happens
> the most often) things break pretty quickly and the tests can be fixed
> pretty easily ... but when the code itself is written with mixed
> Symbols and Strings, the tests might actually pass after the port, and
> the bugs will only show up in subtle cases ... I've hit a handful of
> these over the years and they are hard to track down...
>>
>> But you know very well that Pharo was started so that we would be
>> able to make changes, in any area or aspect of the system, without
>> the burden of backwards or cross platform compatibility, even if some
>> of these changes are taste based.
> Agree with your statement -- most of the changes that Pharo has made
> have not been difficult to accommodate, but Symbol/String is at a
> fundamental level and I'm not sure that it would be "illegal" to make
> this accommodation --- I AM pretty certain that it would cause some
> short term pain, but probably no more pain (and likely less pain) than
> is caused by trying to move an application to a new version of Pharo:)
>> And I happen to like the ability to mix and match Strings and Symbols
>> (we discussed about this before).
>>
> I won't argue with taste, it's is simply the portability for this
> particular problem that I am highlighting ...
>
> Dale
Nov. 8, 2017
Re: [Pharo-dev] How should I load Seaside/Bootstrap in Pharo 7 ?
by Pavel Krivanek
hmm, I suppose it is related to the latest Metacello update.
-- Pavel
2017-11-07 23:45 GMT+01:00 Sven Van Caekenberghe <sven(a)stfx.eu>:
>
>
> > On 7 Nov 2017, at 22:59, Denis Kudriashov <dionisiydk(a)gmail.com> wrote:
> >
> > Hi Sven
> >
> > 2017-11-07 21:35 GMT+01:00 Sven Van Caekenberghe <sven(a)stfx.eu>:
> >
> > Like I said in another email, for example STON adds methods to Class,
> MetaClass and ClassDescription *Traits*. Now it has to add to the classes
> itself (right ?). So a single code base cannot deal with Pharo 7 and older
> version without splitting. I like to keep simple projects like STON simple
> (Seaside is huge in comparison and deals with this stuff all the time and
> already has the complex infrastructure for it).
> >
> > I think it should not be problem for compatibility. Because with
> flattening you will just has duplication of code for classes and traits but
> classes and traits existed in Pharo all the time. So flattened version of
> STON will correctly work in older Pharo's.
>
> I didn't look careful enough to realise you made your own fork.
>
> Still, trying
>
> Metacello new
> baseline:'Seaside3';
> repository: 'github://pavel-krivanek/Seaside:minimalPharo/repository';
> load.
>
> In full Pharo 7, I get:
>
> MetacelloNameNotDefinedError: project group, or package named:
> 'Seaside-Pharo-Development' not found when used in requires: or includes:
> field of package: 'Seaside-Tests-Pharo-Development' for version: baseline
> of BaselineOfSeaside3.
>
> Thanks for helping out.
>
> Sven
>
>
>
Nov. 8, 2017
Re: [Pharo-dev] Critics; as yet unclassified
by Nicolas Cellier
case of blindness
2017-11-08 15:37 GMT+01:00 Denis Kudriashov <dionisiydk(a)gmail.com>:
> Hi Nicolas.
>
> It exists for methods. If you select unclassified method in Nautilus you
> will see "unclassified methods" in critiques bottom pane.
>
> 2017-11-08 15:12 GMT+01:00 Nicolas Cellier <nicolas.cellier.aka.nice@
> gmail.com>:
>
>> Is there or could we create a code critic for 'as yet unclassified'?
>>
>
>
Nov. 8, 2017
Re: [Pharo-dev] Critics; as yet unclassified
by Denis Kudriashov
Hi Nicolas.
It exists for methods. If you select unclassified method in Nautilus you
will see "unclassified methods" in critiques bottom pane.
2017-11-08 15:12 GMT+01:00 Nicolas Cellier <
nicolas.cellier.aka.nice(a)gmail.com>:
> Is there or could we create a code critic for 'as yet unclassified'?
>
Nov. 8, 2017
Re: [Pharo-dev] ExternalAddress uniqueness (was Re: Call for help for stability and rewrite of FreeType)
by Nicolas Cellier
2017-11-08 14:53 GMT+01:00 Nicolas Cellier <
nicolas.cellier.aka.nice(a)gmail.com>:
>
>
> 2017-11-08 14:42 GMT+01:00 Nicolas Cellier <nicolas.cellier.aka.nice@
> gmail.com>:
>
>>
>> Ben,
>>
>> This is my fresh crash.dmp
>> it sounds very related to your analysis!!!
>>
>> In fact we are not freeing by ourselves, but telling libgit2 to do it...
>>
>>
> Oh worse than that, it sounds like git implemented its own mechanism of
> counted pointers...
> So we don't tell anything, he guesses by himself.
> I would search for places where we #gcallocate: or manually #free a
> pointer on a structure passed back by git...
>
>
and of course, it's not gcallocate: because this was a very old wheel...
It's rather somewhere in UFFI equivalent
FFIExternalResourceExecutor <- FFIExternalResourceManager <-
LGitExternalStructure autoRelease
Among the senders, we see (tiens, tiens...):
LGitTree>>...
So this is where I would search the origin of my own crash dump...
But also (tiens, tiens...):
CairoFontFace>>initializeWithFreetypeFace:
What if FreeType plugin was not the problem per se, but its usage in cairo
was?
cairo_font_face_destroy ()
void cairo_font_face_destroy (cairo_font_face_t
*font_face);
Decreases the reference count on font_face by one. If the result is zero, *then
font_face and all associated resources are freed*. See
cairo_font_face_reference().
font_face :
a cairo_font_face_t
Since we pass a pointer to the free type font at creation:
fromFreetypeFace: aFace
| handle cairoFace |
handle := aFace handle pointerAt: 1.
cairoFace := self primFtFace: handle loadFlags: ( LoadNoHinting |
LoadTargetLCD | LoadNoAutohint | LoadNoBitmap).
^ cairoFace initializeWithFreetypeFace: aFace
Isn't it possible that we somehow double free the free type font too?
>> Stack backtrace:
>> [7791E43E] RtlInitializeGenericTable + 0x196 in ntdll.dll
>> [7791E0A3] RtlGetCompressionWorkSpaceSize + 0x7e in ntdll.dll
>> [751F98CD] free + 0x39 in msvcrt.dll
>> [6CD60D43] git_tree_cache_write + 0x2ac in libgit2.dll
>> [6CD62073] git_tree__free + 0x53 in libgit2.dll
>> [6CD1A563] git_object__free + 0x52 in libgit2.dll
>> [6CCD0D78] git_cached_obj_decref + 0x4c in libgit2.dll
>> [6CD1A7D9] git_object_free + 0x17 in libgit2.dll
>> [6CD1B0D3] git_tree_free + 0x11 in libgit2.dll
>> [6CD0BE4F] git_iterator_for_nothing + 0x8aa in libgit2.dll
>> [6CD0C053] git_iterator_for_nothing + 0xaae in libgit2.dll
>> [6CCEADEF] git_diff_file_content__clear + 0x31d in libgit2.dll
>> [6CCECC3F] git_diff__oid_for_entry + 0xc29 in libgit2.dll
>> [6CCED2B2] git_diff__oid_for_entry + 0x129c in libgit2.dll
>> [6CCED495] git_diff__from_iterators + 0x1db in libgit2.dll
>> [6CCED6DE] git_diff_tree_to_tree + 0x1e3 in libgit2.dll
>> [004DE7C8] ??? + 0xde7c8 in Pharo.exe
>> [0044FE08] ??? + 0x4fe08 in Pharo.exe
>> [004516A7] ??? + 0x516a7 in Pharo.exe
>> [00446051] ??? + 0x46051 in Pharo.exe
>> [0049936E] ??? + 0x9936e in Pharo.exe
>>
>>
>> Smalltalk stack dump:
>> 0xafa86c I LGitDiff>diff_tree_to_tree:repo:old_tree:new_tree:opts:
>> 0xe585410: a(n) LGitDiff
>> 0xafa8a4 M [] in LGitDiff>diffTree:toTree:options: 0xe585410: a(n)
>> LGitDiff
>> 0xafa8bc M LGitDiff(LGitExternalObject)>withReturnHandlerDo:
>> 0xe585410: a(n) LGitDiff
>> 0xafc678 I LGitDiff>diffTree:toTree:options: 0xe585410: a(n) LGitDiff
>> 0xafc6a4 I LGitDiff>diffTree:toTree: 0xe585410: a(n) LGitDiff
>> 0xafc6d0 I LGitTree>diffTo: 0xe583e00: a(n) LGitTree
>> 0xafc6fc M [] in IceLibgitLocalRepository>changedFilesBetween:and:
>> 0x1055afc0: a(n) IceLibgitLocalRepository
>> 0xafc720 M [] in IceLibgitLocalRepository>withRepoDo: 0x1055afc0: a(n)
>> IceLibgitLocalRepository
>> 0xafc73c M [] in LGitGlobal class>runSequence: 0xfb96188: a(n)
>> LGitGlobal class
>> 0xafc760 M [] in LGitActionSequence(DynamicVariable)>value:during:
>> 0x102109f8: a(n) LGitActionSequence
>> 0xafc780 M BlockClosure>ensure: 0xe582890: a(n) BlockClosure
>> 0xafc7ac I LGitActionSequence(DynamicVariable)>value:during:
>> 0x102109f8: a(n) LGitActionSequence
>> 0xafc7cc M LGitActionSequence class(DynamicVariable
>> class)>value:during: 0xfbb81e0: a(n) LGitActionSequence class
>> 0xafc7f4 I LGitGlobal class>runSequence: 0xfb96188: a(n) LGitGlobal
>> class
>> 0xafc818 I IceLibgitLocalRepository>withRepoDo: 0x1055afc0: a(n)
>> IceLibgitLocalRepository
>> 0xafc840 I IceLibgitLocalRepository>changedFilesBetween:and:
>> 0x1055afc0: a(n) IceLibgitLocalRepository
>> 0xafc874 I IceCommitInfo>changedPackagesToCommitInfo: 0x113b80e0: a(n)
>> IceCommitInfo
>> 0xafc898 I IceCommitInfo>changedPackagesTo: 0x113b80e0: a(n)
>> IceCommitInfo
>> 0xafc8c0 I IceDiff>initialElements 0xe4c48f8: a(n) IceDiff
>> 0xaf9664 I IceDiff(IceAbstractDiff)>elements 0xe4c48f8: a(n) IceDiff
>> 0xaf9684 I IceDiffChangeTreeBuilder>elements 0xe4b9c80: a(n)
>> IceDiffChangeTreeBuilder
>> 0xaf969c M [] in IceDiffChangeTreeBuilder>buildOn: 0xe4b9c80: a(n)
>> IceDiffChangeTreeBuilder
>>
>> Dimitris:
>>
>> I won't argument, I've learnt C in 1987, so it gave me enough time to
>> learn my own limits.
>> Working with pointers is like carrying a gun without engaging the safety
>> catch.
>> I came to think that shooting own foot was a feature ;)
>>
>> 2017-11-06 11:04 GMT+01:00 Dimitris Chloupis <kilon.alios(a)gmail.com>:
>>
>>> Its the usual case of not being able to have your cake and eat it too.
>>>
>>> If you want top performance you have to manage memory yourself plus the
>>> abilitiy to access thousands of C libraries is not such a bad excuse for a
>>> compromise. The FFI is not a problem is a solution to many problems and
>>> people using it its not as if Smalltalk offers them any alternative choice.
>>>
>>> Not to forget that Slang itself relies heavily on C, which is only the
>>> core of the VM and the very core of the implementation.
>>>
>>> Understanding how to work with pointers in C is pretty much
>>> understanding how to works with Objects in Smalltalk. Both are nuclear
>>> weapons that those two languages are build around. If ones does not
>>> understand their usage he will shoot his foot in the end.
>>>
>>> The important thing to remember is that C's goal is not the same as of
>>> Smalltalk. Its not there to hold your hand and make coding easy for you. C
>>> is there to offer low level access combined with top performance. It may
>>> have started as a general purpose language decades ago when coding in
>>> Assembly was still a pleasant experience. Nowdays C has completely replaced
>>> Assembly as the top performance language for low level coding.
>>>
>>> C may appear as a problematic language to a Smalltalker but only because
>>> he sees it from the Smalltalk point of view. The harsh reality of the world
>>> is that as much as one may want to shoehorn it , not everything can be
>>> elegantly mapped to a object. Smalltalk may be OO to the bone , but the
>>> world we live in, cannot afford such simple structures to accomodate of
>>> varied immense complexity.
>>>
>>> On the subject of pointers, the general rule of thumb is to keep things
>>> as simple as possible and avoide trying to do weird "magic" with them.
>>> There is a ton of things that C does under the hood to generate highly
>>> optimised machine code that can fry the brain , as the usual case with low
>>> level coding, so keeping it simple is the way to go.
>>>
>>> Oh and dont try to shoehorn the Live coding enviroment in debugging C
>>> code, as much as one may want to brag of Smalltalk's elegant debugger, C
>>> development tools are light years ahead in dealing with C problems.
>>>
>>> May advice to people is that if you do it via FFI first, you do it wrong.
>>>
>>> Do it always first with C with a powerful C IDE like Visual Studio, make
>>> sure your code works there and then use the UFFI. Will make life thousand
>>> times easier. I learned that the hard way when I was playing around with
>>> Pharo and shared memory.
>>>
>>> So yes having a FFI that does not help you avoid coding in C first, is a
>>> big plus, not a minus. Sometimes it makes sense to live outside the image,
>>> this is an excellent case to prove why that is a great idea. .
>>>
>>> On Mon, Nov 6, 2017 at 11:10 AM Nicolas Cellier <
>>> nicolas.cellier.aka.nice(a)gmail.com> wrote:
>>>
>>>> Hi Ben,
>>>> It's a super bad idea to copy an ExternalAddress.
>>>> It's common knowledge in C++ copy operator & copy constructors...
>>>>
>>>> But it's not obvious to me that you'll have double freeing (unless you
>>>> explicitely free the pointer by yourself).
>>>> If you use gcallocate: then only the original is registered for magical
>>>> auto-deallocation at garbage collection...
>>>>
>>>> What you will have is more somthing like dangling pointer: continue to
>>>> use pointer xa2->a1 when a1 was already freed.
>>>>
>>>> FFI is great, it introduces the problem of C in Smalltalk, augmented
>>>> with the problems of wrapping C in Smalltalk.
>>>>
>>>>
>>>> 2017-11-06 4:23 GMT+01:00 Ben Coman <btc(a)openinworld.com>:
>>>>
>>>>> My current employment work hours and roster have severely curtailed
>>>>> the time I have hacking Pharo, so I've not dug enough to be sure of my
>>>>> observations a few months ago, and this is from memory, but I was starting
>>>>> to develop a suspicion about the uniqueness of ExternalAddress(s).
>>>>>
>>>>> A while ago, in order to fix some stability issues on Windows, a guard
>>>>> was added somewhere that slowed down some operations. Looking into this
>>>>> and experimenting with removing the guard I seem to remember VM crashes due
>>>>> to a double-free() of an address, due to there being two ExternalAddresses
>>>>> holding the same external address.
>>>>>
>>>>> My intuition is that that somewhere an ExternalAddress(a1) pointing at
>>>>> a particular external resource address "xa1" was being copied, so we end up
>>>>> with ExternalAddress(a2) also pointing at "xa1", with and object b1 holding
>>>>> a1 and object b2 holding a2. During finalization of b1, ExternalAddress a1
>>>>> free()d xa1, and a1 was flagged to avoid double-free()ing. But that didn't
>>>>> help when b2 was finalized, since a2 had no indication that xa1 had been
>>>>> free()d.
>>>>>
>>>>> That is...
>>>>> b1-->a1-->xa1
>>>>> b2 := b1 copy.
>>>>> b2-->a2-->xa1
>>>>> b1 finalize a1 --> free(xa1)
>>>>> b2 finalize a2 --> free(xa1) --> General Protection Fault
>>>>>
>>>>> It was hard to follow this through and I didn't succeed in tracking
>>>>> down where such a copy might have been made, but the idea simmering in my
>>>>> mind since then is to propose that...
>>>>>
>>>>> ExternalAddresses be unique in the image and behave like Symbols,
>>>>> such that trying to copy one returns the identical object.
>>>>>
>>>>> The idea being that when b2 is finalized, a1 would notice that xa1 had
>>>>> already been free()d and raise a Smalltalk exception rather than a general
>>>>> protection fault.
>>>>> b1-->a1-->xa1
>>>>> b2 := b1 copy.
>>>>> b2-->a1-->xa1
>>>>> ^^
>>>>> b1 finalize a1 --> free(xa1)
>>>>> b2 finalize a1 --> Smalltalk exception
>>>>>
>>>>>
>>>>> I write now in response to Stef since I vaguely remember it being
>>>>> Freetype related. But I also remember the issue being FFI related and
>>>>> Freetype is a plugin not FFI. So I'm not sure my memory is clear and
>>>>> perhaps I have the "wrong end of the stick" but anyway, rather than hold
>>>>> back longer because of that, perhaps this can stimulate some discussion and
>>>>> at least I learn something to clarify my understanding here.
>>>>>
>>>>> cheers -ben
>>>>>
>>>>>
>>>>> On Sat, Oct 28, 2017 at 4:48 PM, Stephane Ducasse <
>>>>> stepharo.self(a)gmail.com> wrote:
>>>>> >
>>>>> > Hi all
>>>>> >
>>>>> > I'm and I guess many of you are fedup about the instability that the
>>>>> > FreeType plugin produces.
>>>>> >
>>>>> > So we need help because clement and esteban are fully booked.
>>>>> >
>>>>> > We have three options:
>>>>> >
>>>>> > - drop Freetype alltogether
>>>>> > - rewrite the plugin
>>>>> > - create a binding using raffaillac sketch
>>>>> >
>>>>> > Now we need help. Who is willing to help us?
>>>>> > Should we try to set up a bounty?
>>>>> >
>>>>> > Stef
>>>>>
>>>>>
>>>>>
>>>>
>>
>
Nov. 8, 2017
Critics; as yet unclassified
by Nicolas Cellier
Is there or could we create a code critic for 'as yet unclassified'?
Nov. 8, 2017
Re: [Pharo-dev] ExternalAddress uniqueness (was Re: Call for help for stability and rewrite of FreeType)
by Nicolas Cellier
2017-11-08 14:42 GMT+01:00 Nicolas Cellier <
nicolas.cellier.aka.nice(a)gmail.com>:
>
> Ben,
>
> This is my fresh crash.dmp
> it sounds very related to your analysis!!!
>
> In fact we are not freeing by ourselves, but telling libgit2 to do it...
>
>
Oh worse than that, it sounds like git implemented its own mechanism of
counted pointers...
So we don't tell anything, he guesses by himself.
I would search for places where we #gcallocate: or manually #free a pointer
on a structure passed back by git...
> Stack backtrace:
> [7791E43E] RtlInitializeGenericTable + 0x196 in ntdll.dll
> [7791E0A3] RtlGetCompressionWorkSpaceSize + 0x7e in ntdll.dll
> [751F98CD] free + 0x39 in msvcrt.dll
> [6CD60D43] git_tree_cache_write + 0x2ac in libgit2.dll
> [6CD62073] git_tree__free + 0x53 in libgit2.dll
> [6CD1A563] git_object__free + 0x52 in libgit2.dll
> [6CCD0D78] git_cached_obj_decref + 0x4c in libgit2.dll
> [6CD1A7D9] git_object_free + 0x17 in libgit2.dll
> [6CD1B0D3] git_tree_free + 0x11 in libgit2.dll
> [6CD0BE4F] git_iterator_for_nothing + 0x8aa in libgit2.dll
> [6CD0C053] git_iterator_for_nothing + 0xaae in libgit2.dll
> [6CCEADEF] git_diff_file_content__clear + 0x31d in libgit2.dll
> [6CCECC3F] git_diff__oid_for_entry + 0xc29 in libgit2.dll
> [6CCED2B2] git_diff__oid_for_entry + 0x129c in libgit2.dll
> [6CCED495] git_diff__from_iterators + 0x1db in libgit2.dll
> [6CCED6DE] git_diff_tree_to_tree + 0x1e3 in libgit2.dll
> [004DE7C8] ??? + 0xde7c8 in Pharo.exe
> [0044FE08] ??? + 0x4fe08 in Pharo.exe
> [004516A7] ??? + 0x516a7 in Pharo.exe
> [00446051] ??? + 0x46051 in Pharo.exe
> [0049936E] ??? + 0x9936e in Pharo.exe
>
>
> Smalltalk stack dump:
> 0xafa86c I LGitDiff>diff_tree_to_tree:repo:old_tree:new_tree:opts:
> 0xe585410: a(n) LGitDiff
> 0xafa8a4 M [] in LGitDiff>diffTree:toTree:options: 0xe585410: a(n)
> LGitDiff
> 0xafa8bc M LGitDiff(LGitExternalObject)>withReturnHandlerDo: 0xe585410:
> a(n) LGitDiff
> 0xafc678 I LGitDiff>diffTree:toTree:options: 0xe585410: a(n) LGitDiff
> 0xafc6a4 I LGitDiff>diffTree:toTree: 0xe585410: a(n) LGitDiff
> 0xafc6d0 I LGitTree>diffTo: 0xe583e00: a(n) LGitTree
> 0xafc6fc M [] in IceLibgitLocalRepository>changedFilesBetween:and:
> 0x1055afc0: a(n) IceLibgitLocalRepository
> 0xafc720 M [] in IceLibgitLocalRepository>withRepoDo: 0x1055afc0: a(n)
> IceLibgitLocalRepository
> 0xafc73c M [] in LGitGlobal class>runSequence: 0xfb96188: a(n)
> LGitGlobal class
> 0xafc760 M [] in LGitActionSequence(DynamicVariable)>value:during:
> 0x102109f8: a(n) LGitActionSequence
> 0xafc780 M BlockClosure>ensure: 0xe582890: a(n) BlockClosure
> 0xafc7ac I LGitActionSequence(DynamicVariable)>value:during:
> 0x102109f8: a(n) LGitActionSequence
> 0xafc7cc M LGitActionSequence class(DynamicVariable class)>value:during:
> 0xfbb81e0: a(n) LGitActionSequence class
> 0xafc7f4 I LGitGlobal class>runSequence: 0xfb96188: a(n) LGitGlobal class
> 0xafc818 I IceLibgitLocalRepository>withRepoDo: 0x1055afc0: a(n)
> IceLibgitLocalRepository
> 0xafc840 I IceLibgitLocalRepository>changedFilesBetween:and:
> 0x1055afc0: a(n) IceLibgitLocalRepository
> 0xafc874 I IceCommitInfo>changedPackagesToCommitInfo: 0x113b80e0: a(n)
> IceCommitInfo
> 0xafc898 I IceCommitInfo>changedPackagesTo: 0x113b80e0: a(n)
> IceCommitInfo
> 0xafc8c0 I IceDiff>initialElements 0xe4c48f8: a(n) IceDiff
> 0xaf9664 I IceDiff(IceAbstractDiff)>elements 0xe4c48f8: a(n) IceDiff
> 0xaf9684 I IceDiffChangeTreeBuilder>elements 0xe4b9c80: a(n)
> IceDiffChangeTreeBuilder
> 0xaf969c M [] in IceDiffChangeTreeBuilder>buildOn: 0xe4b9c80: a(n)
> IceDiffChangeTreeBuilder
>
> Dimitris:
>
> I won't argument, I've learnt C in 1987, so it gave me enough time to
> learn my own limits.
> Working with pointers is like carrying a gun without engaging the safety
> catch.
> I came to think that shooting own foot was a feature ;)
>
> 2017-11-06 11:04 GMT+01:00 Dimitris Chloupis <kilon.alios(a)gmail.com>:
>
>> Its the usual case of not being able to have your cake and eat it too.
>>
>> If you want top performance you have to manage memory yourself plus the
>> abilitiy to access thousands of C libraries is not such a bad excuse for a
>> compromise. The FFI is not a problem is a solution to many problems and
>> people using it its not as if Smalltalk offers them any alternative choice.
>>
>> Not to forget that Slang itself relies heavily on C, which is only the
>> core of the VM and the very core of the implementation.
>>
>> Understanding how to work with pointers in C is pretty much understanding
>> how to works with Objects in Smalltalk. Both are nuclear weapons that those
>> two languages are build around. If ones does not understand their usage he
>> will shoot his foot in the end.
>>
>> The important thing to remember is that C's goal is not the same as of
>> Smalltalk. Its not there to hold your hand and make coding easy for you. C
>> is there to offer low level access combined with top performance. It may
>> have started as a general purpose language decades ago when coding in
>> Assembly was still a pleasant experience. Nowdays C has completely replaced
>> Assembly as the top performance language for low level coding.
>>
>> C may appear as a problematic language to a Smalltalker but only because
>> he sees it from the Smalltalk point of view. The harsh reality of the world
>> is that as much as one may want to shoehorn it , not everything can be
>> elegantly mapped to a object. Smalltalk may be OO to the bone , but the
>> world we live in, cannot afford such simple structures to accomodate of
>> varied immense complexity.
>>
>> On the subject of pointers, the general rule of thumb is to keep things
>> as simple as possible and avoide trying to do weird "magic" with them.
>> There is a ton of things that C does under the hood to generate highly
>> optimised machine code that can fry the brain , as the usual case with low
>> level coding, so keeping it simple is the way to go.
>>
>> Oh and dont try to shoehorn the Live coding enviroment in debugging C
>> code, as much as one may want to brag of Smalltalk's elegant debugger, C
>> development tools are light years ahead in dealing with C problems.
>>
>> May advice to people is that if you do it via FFI first, you do it wrong.
>>
>> Do it always first with C with a powerful C IDE like Visual Studio, make
>> sure your code works there and then use the UFFI. Will make life thousand
>> times easier. I learned that the hard way when I was playing around with
>> Pharo and shared memory.
>>
>> So yes having a FFI that does not help you avoid coding in C first, is a
>> big plus, not a minus. Sometimes it makes sense to live outside the image,
>> this is an excellent case to prove why that is a great idea. .
>>
>> On Mon, Nov 6, 2017 at 11:10 AM Nicolas Cellier <
>> nicolas.cellier.aka.nice(a)gmail.com> wrote:
>>
>>> Hi Ben,
>>> It's a super bad idea to copy an ExternalAddress.
>>> It's common knowledge in C++ copy operator & copy constructors...
>>>
>>> But it's not obvious to me that you'll have double freeing (unless you
>>> explicitely free the pointer by yourself).
>>> If you use gcallocate: then only the original is registered for magical
>>> auto-deallocation at garbage collection...
>>>
>>> What you will have is more somthing like dangling pointer: continue to
>>> use pointer xa2->a1 when a1 was already freed.
>>>
>>> FFI is great, it introduces the problem of C in Smalltalk, augmented
>>> with the problems of wrapping C in Smalltalk.
>>>
>>>
>>> 2017-11-06 4:23 GMT+01:00 Ben Coman <btc(a)openinworld.com>:
>>>
>>>> My current employment work hours and roster have severely curtailed the
>>>> time I have hacking Pharo, so I've not dug enough to be sure of my
>>>> observations a few months ago, and this is from memory, but I was starting
>>>> to develop a suspicion about the uniqueness of ExternalAddress(s).
>>>>
>>>> A while ago, in order to fix some stability issues on Windows, a guard
>>>> was added somewhere that slowed down some operations. Looking into this
>>>> and experimenting with removing the guard I seem to remember VM crashes due
>>>> to a double-free() of an address, due to there being two ExternalAddresses
>>>> holding the same external address.
>>>>
>>>> My intuition is that that somewhere an ExternalAddress(a1) pointing at
>>>> a particular external resource address "xa1" was being copied, so we end up
>>>> with ExternalAddress(a2) also pointing at "xa1", with and object b1 holding
>>>> a1 and object b2 holding a2. During finalization of b1, ExternalAddress a1
>>>> free()d xa1, and a1 was flagged to avoid double-free()ing. But that didn't
>>>> help when b2 was finalized, since a2 had no indication that xa1 had been
>>>> free()d.
>>>>
>>>> That is...
>>>> b1-->a1-->xa1
>>>> b2 := b1 copy.
>>>> b2-->a2-->xa1
>>>> b1 finalize a1 --> free(xa1)
>>>> b2 finalize a2 --> free(xa1) --> General Protection Fault
>>>>
>>>> It was hard to follow this through and I didn't succeed in tracking
>>>> down where such a copy might have been made, but the idea simmering in my
>>>> mind since then is to propose that...
>>>>
>>>> ExternalAddresses be unique in the image and behave like Symbols,
>>>> such that trying to copy one returns the identical object.
>>>>
>>>> The idea being that when b2 is finalized, a1 would notice that xa1 had
>>>> already been free()d and raise a Smalltalk exception rather than a general
>>>> protection fault.
>>>> b1-->a1-->xa1
>>>> b2 := b1 copy.
>>>> b2-->a1-->xa1
>>>> ^^
>>>> b1 finalize a1 --> free(xa1)
>>>> b2 finalize a1 --> Smalltalk exception
>>>>
>>>>
>>>> I write now in response to Stef since I vaguely remember it being
>>>> Freetype related. But I also remember the issue being FFI related and
>>>> Freetype is a plugin not FFI. So I'm not sure my memory is clear and
>>>> perhaps I have the "wrong end of the stick" but anyway, rather than hold
>>>> back longer because of that, perhaps this can stimulate some discussion and
>>>> at least I learn something to clarify my understanding here.
>>>>
>>>> cheers -ben
>>>>
>>>>
>>>> On Sat, Oct 28, 2017 at 4:48 PM, Stephane Ducasse <
>>>> stepharo.self(a)gmail.com> wrote:
>>>> >
>>>> > Hi all
>>>> >
>>>> > I'm and I guess many of you are fedup about the instability that the
>>>> > FreeType plugin produces.
>>>> >
>>>> > So we need help because clement and esteban are fully booked.
>>>> >
>>>> > We have three options:
>>>> >
>>>> > - drop Freetype alltogether
>>>> > - rewrite the plugin
>>>> > - create a binding using raffaillac sketch
>>>> >
>>>> > Now we need help. Who is willing to help us?
>>>> > Should we try to set up a bounty?
>>>> >
>>>> > Stef
>>>>
>>>>
>>>>
>>>
>
Nov. 8, 2017
Re: [Pharo-dev] ExternalAddress uniqueness (was Re: Call for help for stability and rewrite of FreeType)
by Nicolas Cellier
Ben,
This is my fresh crash.dmp
it sounds very related to your analysis!!!
In fact we are not freeing by ourselves, but telling libgit2 to do it...
Stack backtrace:
[7791E43E] RtlInitializeGenericTable + 0x196 in ntdll.dll
[7791E0A3] RtlGetCompressionWorkSpaceSize + 0x7e in ntdll.dll
[751F98CD] free + 0x39 in msvcrt.dll
[6CD60D43] git_tree_cache_write + 0x2ac in libgit2.dll
[6CD62073] git_tree__free + 0x53 in libgit2.dll
[6CD1A563] git_object__free + 0x52 in libgit2.dll
[6CCD0D78] git_cached_obj_decref + 0x4c in libgit2.dll
[6CD1A7D9] git_object_free + 0x17 in libgit2.dll
[6CD1B0D3] git_tree_free + 0x11 in libgit2.dll
[6CD0BE4F] git_iterator_for_nothing + 0x8aa in libgit2.dll
[6CD0C053] git_iterator_for_nothing + 0xaae in libgit2.dll
[6CCEADEF] git_diff_file_content__clear + 0x31d in libgit2.dll
[6CCECC3F] git_diff__oid_for_entry + 0xc29 in libgit2.dll
[6CCED2B2] git_diff__oid_for_entry + 0x129c in libgit2.dll
[6CCED495] git_diff__from_iterators + 0x1db in libgit2.dll
[6CCED6DE] git_diff_tree_to_tree + 0x1e3 in libgit2.dll
[004DE7C8] ??? + 0xde7c8 in Pharo.exe
[0044FE08] ??? + 0x4fe08 in Pharo.exe
[004516A7] ??? + 0x516a7 in Pharo.exe
[00446051] ??? + 0x46051 in Pharo.exe
[0049936E] ??? + 0x9936e in Pharo.exe
Smalltalk stack dump:
0xafa86c I LGitDiff>diff_tree_to_tree:repo:old_tree:new_tree:opts:
0xe585410: a(n) LGitDiff
0xafa8a4 M [] in LGitDiff>diffTree:toTree:options: 0xe585410: a(n)
LGitDiff
0xafa8bc M LGitDiff(LGitExternalObject)>withReturnHandlerDo: 0xe585410:
a(n) LGitDiff
0xafc678 I LGitDiff>diffTree:toTree:options: 0xe585410: a(n) LGitDiff
0xafc6a4 I LGitDiff>diffTree:toTree: 0xe585410: a(n) LGitDiff
0xafc6d0 I LGitTree>diffTo: 0xe583e00: a(n) LGitTree
0xafc6fc M [] in IceLibgitLocalRepository>changedFilesBetween:and:
0x1055afc0: a(n) IceLibgitLocalRepository
0xafc720 M [] in IceLibgitLocalRepository>withRepoDo: 0x1055afc0: a(n)
IceLibgitLocalRepository
0xafc73c M [] in LGitGlobal class>runSequence: 0xfb96188: a(n) LGitGlobal
class
0xafc760 M [] in LGitActionSequence(DynamicVariable)>value:during:
0x102109f8: a(n) LGitActionSequence
0xafc780 M BlockClosure>ensure: 0xe582890: a(n) BlockClosure
0xafc7ac I LGitActionSequence(DynamicVariable)>value:during: 0x102109f8:
a(n) LGitActionSequence
0xafc7cc M LGitActionSequence class(DynamicVariable class)>value:during:
0xfbb81e0: a(n) LGitActionSequence class
0xafc7f4 I LGitGlobal class>runSequence: 0xfb96188: a(n) LGitGlobal class
0xafc818 I IceLibgitLocalRepository>withRepoDo: 0x1055afc0: a(n)
IceLibgitLocalRepository
0xafc840 I IceLibgitLocalRepository>changedFilesBetween:and: 0x1055afc0:
a(n) IceLibgitLocalRepository
0xafc874 I IceCommitInfo>changedPackagesToCommitInfo: 0x113b80e0: a(n)
IceCommitInfo
0xafc898 I IceCommitInfo>changedPackagesTo: 0x113b80e0: a(n) IceCommitInfo
0xafc8c0 I IceDiff>initialElements 0xe4c48f8: a(n) IceDiff
0xaf9664 I IceDiff(IceAbstractDiff)>elements 0xe4c48f8: a(n) IceDiff
0xaf9684 I IceDiffChangeTreeBuilder>elements 0xe4b9c80: a(n)
IceDiffChangeTreeBuilder
0xaf969c M [] in IceDiffChangeTreeBuilder>buildOn: 0xe4b9c80: a(n)
IceDiffChangeTreeBuilder
Dimitris:
I won't argument, I've learnt C in 1987, so it gave me enough time to learn
my own limits.
Working with pointers is like carrying a gun without engaging the safety
catch.
I came to think that shooting own foot was a feature ;)
2017-11-06 11:04 GMT+01:00 Dimitris Chloupis <kilon.alios(a)gmail.com>:
> Its the usual case of not being able to have your cake and eat it too.
>
> If you want top performance you have to manage memory yourself plus the
> abilitiy to access thousands of C libraries is not such a bad excuse for a
> compromise. The FFI is not a problem is a solution to many problems and
> people using it its not as if Smalltalk offers them any alternative choice.
>
> Not to forget that Slang itself relies heavily on C, which is only the
> core of the VM and the very core of the implementation.
>
> Understanding how to work with pointers in C is pretty much understanding
> how to works with Objects in Smalltalk. Both are nuclear weapons that those
> two languages are build around. If ones does not understand their usage he
> will shoot his foot in the end.
>
> The important thing to remember is that C's goal is not the same as of
> Smalltalk. Its not there to hold your hand and make coding easy for you. C
> is there to offer low level access combined with top performance. It may
> have started as a general purpose language decades ago when coding in
> Assembly was still a pleasant experience. Nowdays C has completely replaced
> Assembly as the top performance language for low level coding.
>
> C may appear as a problematic language to a Smalltalker but only because
> he sees it from the Smalltalk point of view. The harsh reality of the world
> is that as much as one may want to shoehorn it , not everything can be
> elegantly mapped to a object. Smalltalk may be OO to the bone , but the
> world we live in, cannot afford such simple structures to accomodate of
> varied immense complexity.
>
> On the subject of pointers, the general rule of thumb is to keep things as
> simple as possible and avoide trying to do weird "magic" with them. There
> is a ton of things that C does under the hood to generate highly optimised
> machine code that can fry the brain , as the usual case with low level
> coding, so keeping it simple is the way to go.
>
> Oh and dont try to shoehorn the Live coding enviroment in debugging C
> code, as much as one may want to brag of Smalltalk's elegant debugger, C
> development tools are light years ahead in dealing with C problems.
>
> May advice to people is that if you do it via FFI first, you do it wrong.
>
> Do it always first with C with a powerful C IDE like Visual Studio, make
> sure your code works there and then use the UFFI. Will make life thousand
> times easier. I learned that the hard way when I was playing around with
> Pharo and shared memory.
>
> So yes having a FFI that does not help you avoid coding in C first, is a
> big plus, not a minus. Sometimes it makes sense to live outside the image,
> this is an excellent case to prove why that is a great idea. .
>
> On Mon, Nov 6, 2017 at 11:10 AM Nicolas Cellier <nicolas.cellier.aka.nice@
> gmail.com> wrote:
>
>> Hi Ben,
>> It's a super bad idea to copy an ExternalAddress.
>> It's common knowledge in C++ copy operator & copy constructors...
>>
>> But it's not obvious to me that you'll have double freeing (unless you
>> explicitely free the pointer by yourself).
>> If you use gcallocate: then only the original is registered for magical
>> auto-deallocation at garbage collection...
>>
>> What you will have is more somthing like dangling pointer: continue to
>> use pointer xa2->a1 when a1 was already freed.
>>
>> FFI is great, it introduces the problem of C in Smalltalk, augmented with
>> the problems of wrapping C in Smalltalk.
>>
>>
>> 2017-11-06 4:23 GMT+01:00 Ben Coman <btc(a)openinworld.com>:
>>
>>> My current employment work hours and roster have severely curtailed the
>>> time I have hacking Pharo, so I've not dug enough to be sure of my
>>> observations a few months ago, and this is from memory, but I was starting
>>> to develop a suspicion about the uniqueness of ExternalAddress(s).
>>>
>>> A while ago, in order to fix some stability issues on Windows, a guard
>>> was added somewhere that slowed down some operations. Looking into this
>>> and experimenting with removing the guard I seem to remember VM crashes due
>>> to a double-free() of an address, due to there being two ExternalAddresses
>>> holding the same external address.
>>>
>>> My intuition is that that somewhere an ExternalAddress(a1) pointing at a
>>> particular external resource address "xa1" was being copied, so we end up
>>> with ExternalAddress(a2) also pointing at "xa1", with and object b1 holding
>>> a1 and object b2 holding a2. During finalization of b1, ExternalAddress a1
>>> free()d xa1, and a1 was flagged to avoid double-free()ing. But that didn't
>>> help when b2 was finalized, since a2 had no indication that xa1 had been
>>> free()d.
>>>
>>> That is...
>>> b1-->a1-->xa1
>>> b2 := b1 copy.
>>> b2-->a2-->xa1
>>> b1 finalize a1 --> free(xa1)
>>> b2 finalize a2 --> free(xa1) --> General Protection Fault
>>>
>>> It was hard to follow this through and I didn't succeed in tracking down
>>> where such a copy might have been made, but the idea simmering in my mind
>>> since then is to propose that...
>>>
>>> ExternalAddresses be unique in the image and behave like Symbols,
>>> such that trying to copy one returns the identical object.
>>>
>>> The idea being that when b2 is finalized, a1 would notice that xa1 had
>>> already been free()d and raise a Smalltalk exception rather than a general
>>> protection fault.
>>> b1-->a1-->xa1
>>> b2 := b1 copy.
>>> b2-->a1-->xa1
>>> ^^
>>> b1 finalize a1 --> free(xa1)
>>> b2 finalize a1 --> Smalltalk exception
>>>
>>>
>>> I write now in response to Stef since I vaguely remember it being
>>> Freetype related. But I also remember the issue being FFI related and
>>> Freetype is a plugin not FFI. So I'm not sure my memory is clear and
>>> perhaps I have the "wrong end of the stick" but anyway, rather than hold
>>> back longer because of that, perhaps this can stimulate some discussion and
>>> at least I learn something to clarify my understanding here.
>>>
>>> cheers -ben
>>>
>>>
>>> On Sat, Oct 28, 2017 at 4:48 PM, Stephane Ducasse <
>>> stepharo.self(a)gmail.com> wrote:
>>> >
>>> > Hi all
>>> >
>>> > I'm and I guess many of you are fedup about the instability that the
>>> > FreeType plugin produces.
>>> >
>>> > So we need help because clement and esteban are fully booked.
>>> >
>>> > We have three options:
>>> >
>>> > - drop Freetype alltogether
>>> > - rewrite the plugin
>>> > - create a binding using raffaillac sketch
>>> >
>>> > Now we need help. Who is willing to help us?
>>> > Should we try to set up a bounty?
>>> >
>>> > Stef
>>>
>>>
>>>
>>
Nov. 8, 2017
Re: [Pharo-dev] LayoutFrame bug
by Sven Van Caekenberghe
Yeah, I just got in trouble too by looking at class comments.
Heroic debugging, Nicolas !
> On 8 Nov 2017, at 13:47, Nicolas Cellier <nicolas.cellier.aka.nice(a)gmail.com> wrote:
>
> Hi,
> don't you get nice red-cross when opening a browser and selecting comment?
> (Pharo7.0-32bit-b5ec533.image)
>
> The problem is LayoutFrame having a Point instead of Number in fraction/offset inst. var.
>
> So I defined two horrible hacks in order to be able to work with Pharo
>
> Point>>@ n ^x @ n
> Point>>asInteger ^x asInteger
>
> then could instrument the LayoutFrame inst. var. setters with horrible checks like:
> aNumber isNumber ifFalse: [ self halt].
>
> And after a few seconds of IDE usage:
>
> AbstractNautilusUI>>buildCodePanelWithCommentOnRight
> ...snip...
> sourceCodePanel
> addMorph: commentWidget
> fullFrame: (LayoutFrame identity leftFraction: 0.5@0 ;
> leftOffset: delta).
>
> Huh! it's as pleasant as not eating own dog food
> I think this comes from a recent refactoring. I can hardly use in image tools to trace it.
> Iceberg bugs, MC has lost ancestry and is just good at synchronizing disk working copy with image working copy, but there is github & git API:
>
> https://github.com/pharo-project/pharo/commit/042baad47fddb63db2dd0beefeec6…
>
> As it's nearly impossible to make giant refactorings like this without human error,
> and as it's as impossible to review pull request with many lines of code,
> I wonder if it is possible to automate those with rewrite rules...
>
> I let you finish the work (open issue, patch, commit, etc...)
>
>
Nov. 8, 2017