[issue26891] CPython doesn't work when you disable refcounting

2019-05-14 Thread STINNER Victor


STINNER Victor  added the comment:

Well, CPython requires reference counting. This issue looks highly experimental 
with not activity for 3 years, I close it.

--
nosy: +vstinner
resolution:  -> not a bug
stage: needs patch -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26891] CPython doesn't work when you disable refcounting

2016-04-30 Thread Larry Hastings

Larry Hastings added the comment:

Here is my theory: if the code asserts that it's true, and the code normally 
runs fine, then it's normally true, and therefore I can remove the assertion 
and the code will run correctly.  I haven't hit that assertion in the peephole 
optimizer.  But I have assertions turned off.

The checks in unicode / set / bytes (maybe) were not regulated by _NDEBUG, they 
were unconditional "if (refcnt != 1) BadInternalCall();" code.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26891] CPython doesn't work when you disable refcounting

2016-04-30 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Just now I'm reading the code of the peephole optimizer, and it contains such 
assertion since it modifies the lnotab bytes array in-place. May be there are 
other similar cases.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26891] CPython doesn't work when you disable refcounting

2016-04-30 Thread Larry Hastings

Larry Hastings added the comment:

I did as you suggested.  I also discovered that _Py_NewReference is usually a 
macro, and I'd only fixed the version in Objects/object.c (the one not being 
used).  When I fixed both those things, and switched the makefile so it uses a 
different Python interpreter in the build itself, it builds successfully.  The 
interpreter doesn't run though.

The next problem: there are a couple of spots where code asserts the refcount 
of an object must == 1.  This is so they can modify the object in-place.  This 
is usually a sanity-check, so I assume the code knows what it's doing, so I 
removed the refcount assertion.  I did this two or three times: set, unicode, 
and (maybe) bytes.

Now it's segfaulting in lookdict_unicode_nodummy().  mp->ma_keys looks like 
garbage, the keys it refers to are invalid addresses.  I'd be very happy to 
post my patch if someone else wanted to try debugging it.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26891] CPython doesn't work when you disable refcounting

2016-04-29 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

There is other code that sets refcount.

Include/object.h:764:Py_REFCNT(op) = 1)
Objects/moduleobject.c:38:Py_REFCNT(def) = 1;
Objects/longobject.c:5450:Py_REFCNT(op) = refcnt + 1;
Objects/unicodeobject.c:1762:Py_REFCNT(unicode) = 3;
Objects/unicodeobject.c:15044:Py_REFCNT(s) -= 2;
Objects/unicodeobject.c:15103:Py_REFCNT(s) += 1;
Objects/unicodeobject.c:15107:Py_REFCNT(s) += 2;

I would suggest to set initial refcount to 10, define Py_REFCNT(s) as 
returning constant 10, and fix subsequent compiler errors.

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26891] CPython doesn't work when you disable refcounting

2016-04-29 Thread Larry Hastings

Changes by Larry Hastings :


--
versions: +Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26891] CPython doesn't work when you disable refcounting

2016-04-29 Thread Larry Hastings

New submission from Larry Hastings:

So here's a strange one.

I want to do some mysterious experiments with CPython.  So I disabled refcount 
changes in CPython.

I changed Py_INCR and Py_DECR so they expand to nothing.  I had to change some 
other macros to match (SETREF, XSETREF, and the Py_RETURN_* ones) to fix some 
compiler errors and warnings.  Also, to prevent the str object from making 
in-place edits, I changed _Py_NewReference so that the initial reference count 
for all objects is 2.

CPython builds, then gets to the "generate-posix-vars" step and fails with this 
output:

./python -E -S -m sysconfig --generate-posix-vars ;\
if test $? -ne 0 ; then \
echo "generate-posix-vars failed" ; \
rm -f ./pybuilddir.txt ; \
exit 1 ; \
fi
Fatal Python error: Py_Initialize: Unable to get the locale encoding
Traceback (most recent call last):
  File "", line 1078, in 
_path_importer_cache
KeyError: '/usr/local/lib/python36.zip'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "", line 979, in _find_and_load
  File "", line 964, in _find_and_load_unlocked
  File "", line 903, in _find_spec
  File "", line 1137, in find_spec
  File "", line 1108, in _get_spec
  File "", line 1080, in 
_path_importer_cache
  File "", line 1056, in _path_hooks
  File "", line 1302, in 
path_hook_for_FileFinder
  File "", line 96, in _path_isdir
  File "", line 81, in _path_is_mode_type
  File "", line 75, in _path_stat
AttributeError: module 'posix' has no attribute 'stat'
Aborted (core dumped)
generate-posix-vars failed
Makefile:598: recipe for target 'pybuilddir.txt' failed
make: *** [pybuilddir.txt] Error 1

I'm stumped.  Why should CPython be dependent on reference counts actually 
changing?  I figured I'd just leak memory like crazy, not change behavior.

Attached is my patch against current trunk (1ceb91974dc4) in case you want to 
try it yourself.  Testing was done on Ubuntu 15.10 64-bit, gcc 5.2.1.

--
components: Interpreter Core
files: larry.turn.off.refcounts.1.diff.txt
messages: 264541
nosy: brett.cannon, larry
priority: low
severity: normal
stage: needs patch
status: open
title: CPython doesn't work when you disable refcounting
type: behavior
Added file: http://bugs.python.org/file42660/larry.turn.off.refcounts.1.diff.txt

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com