Comments (8)
This is even simpler:
package require oo
class t { val 0 }
t method setval {v} { set val $v }
proc final {ref value} { puts "Destroy $ref" }
set l1 [list 99 96 98]
set entries [lmap i $l1 {
set tt [t new]
finalize $tt final
puts "Create $tt"
$tt setval $i
list $tt
}]
puts "Collect A"
collect
puts "Display"
set e [lindex $entries 1]
puts $e
puts [$e classname]
puts "Collect B"
collect
and generates this (with a slight mod. to the GC debugging to show refCount):
Create ::<reference.<t______>.00000000000000000000>
Create ::<reference.<t______>.00000000000000000002>
Create ::<reference.<t______>.00000000000000000004>
Collect A
MARK: 4 (type=command) refCount=3
MARK: 2 (type=command) refCount=2
MARK: 0 (type=command) refCount=2
Display
::<reference.<t______>.00000000000000000002>
t
Collect B
MARK: 4 (type=command) refCount=3
No MARK: 2 objPtr->refCount=2 - command with refcount=1
No MARK: 2 objPtr->refCount=1 - command with refcount=1
MARK: 0 (type=command) refCount=2
COLLECTING 2
Destroy <reference.<t______>.00000000000000000002>
It seems that reading any property of $e causes the problem, as it goes away if commented out.
Changing the value of the lindex index to 2 doesn't break it, but 0 and 1 do.
Not sure why object "4" has different refCount to the other two either, but probably explains the preceding sentence.
All this seems to have started on 5 Jun 2020 with 5d44077.
from jimtcl.
It does look like there is something not quite right there. I pushed a tentative fix to the branch garbage-collection-fix. Would you mind trying it out and let me know what you think?
from jimtcl.
The output is now not showing any destruction, which is good:
Create ::<reference.<t______>.00000000000000000000>
Create ::<reference.<t______>.00000000000000000002>
Create ::<reference.<t______>.00000000000000000004>
Collect A
MARK: 4 (type=command) refCount=3
MARK: 2 (type=command) refCount=2
MARK: 0 (type=command) refCount=2
Display
::<reference.<t______>.00000000000000000002>
t
Collect B
MARK: 4 (type=command) refCount=3
MARK: 2 (type=command) refCount=2
No MARK: 2 - command with refcount=1
MARK: 0 (type=command) refCount=2
Still not sure if the refCount stuff is correct as I don't understand it (I tried selected old versions, back to about 2011 until they wouldn't compile, and it's always done that), but certainly the big problem is apparently fixed.
from jimtcl.
Thanks. I'll try to come up with some unit tests that show both original problems before I merge it
from jimtcl.
Not sure why me merging this fix into my personal fork should have closed the issue in the upstream repository when it hasn't been committed to upstream master.
from jimtcl.
Sure. I don't know why either. I still want to create some unit tests to confirm that the fix is correct before I merge.
from jimtcl.
from jimtcl.
I believe I now have a better fix for this problem (garbage-collection-fix-take2) taking into account that there can be multiple objects that refer to the same reference. I think it will end up the same, but this approach makes more sense to me.
from jimtcl.
Related Issues (20)
- SH_SOFULLPATH not working HOT 1
- load.test does not use correct jimsh (via build-jim-ext) HOT 1
- Pointer cast issues when building jimtcl under MinGW64 HOT 1
- getref behaviour change from 0.79 to 0.81 HOT 3
- Build issues HOT 2
- Documentation for 'defer'
- Strange results (duplicates) from [info commands] HOT 7
- "undefined reference to `utf8_*"issues when packaging on Debian HOT 5
- Mailing list link broken HOT 2
- No way to measure time accurately and reliably HOT 6
- `dict with` returns the dict HOT 2
- Appveyor build warnings HOT 2
- regexp: end of word match is broken. HOT 1
- Buffer overflow when building jimtcl with jimtcl installed HOT 1
- Confusing error message from oo.tcl
- CRTSCTS: requires _GNU_SOURCE or _BSD_SOURCE HOT 3
- Bug in regexp library may lead to out-of-bounds read HOT 1
- vi key bindings in jimsh HOT 3
- file.test fail on 32 bit systems HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jimtcl.