wendelin.core:c02776e95a098cb45e244dd26312cbe2aef030c7 commitshttps://lab.nexedi.com/kirr/wendelin.core/-/commits/c02776e95a098cb45e244dd26312cbe2aef030c72019-12-18T15:28:15+03:00https://lab.nexedi.com/kirr/wendelin.core/-/commit/c02776e95a098cb45e244dd26312cbe2aef030c7bigfile/zodb: Factor-out LivePersistent into -> lib/zodb2019-12-18T15:28:15+03:00Kirill Smelkovkirr@nexedi.com
It was from long-ago marked as "XXX move to common place".https://lab.nexedi.com/kirr/wendelin.core/-/commit/8c32c9f677fa5188c310d02c235f84751486678abigfile/zodb: FIXME invalidations are not working correctly on blocks topolog...2019-12-18T15:28:15+03:00Kirill Smelkovkirr@nexedi.com
I noticed this while working on WCFS: if file blocks topology change,
the invalidation process is not working correctly. It is also not
correct with respect to live cache pressure.
Add FIXME in the code and test for live cache pressure.
<a href="https://lab.nexedi.com/kirr/wendelin.core/commit/5a4562fc" data-original="https://lab.nexedi.com/kirr/wendelin.core/commit/5a4562fc" data-link="false" data-link-reference="true" data-project="20" data-commit="5a4562fcea5f8f79c7c76d93fe8ab6c8b24fb85e" data-reference-type="commit" data-container="body" data-placement="top" data-html="true" title="X found bug in wc 1 invalidation" class="gfm gfm-commit has-tooltip">5a4562fc</a>
<a href="https://lab.nexedi.com/kirr/wendelin.core/commit/48eb692f" data-original="https://lab.nexedi.com/kirr/wendelin.core/commit/48eb692f" data-link="false" data-link-reference="true" data-project="20" data-commit="48eb692f01aa18099b49d0a35302e84c0978f2d5" data-reference-type="commit" data-container="body" data-placement="top" data-html="true" title="X found another bug in wc 1 invalidation" class="gfm gfm-commit has-tooltip">48eb692f</a>
<a href="https://lab.nexedi.com/kirr/wendelin.core/commit/d1a579b2" data-original="https://lab.nexedi.com/kirr/wendelin.core/commit/d1a579b2" data-link="false" data-link-reference="true" data-project="20" data-commit="d1a579b23e921a07c5b57437c90aedc4799f925b" data-reference-type="commit" data-container="body" data-placement="top" data-html="true" title="X another example of wc1 invalidation bug related to ZBlk pinning to #blk" class="gfm gfm-commit has-tooltip">d1a579b2</a>
<a href="https://lab.nexedi.com/kirr/wendelin.core/commit/69c94fbc" data-original="https://lab.nexedi.com/kirr/wendelin.core/commit/69c94fbc" data-link="false" data-link-reference="true" data-project="20" data-commit="69c94fbc1bbb1154e6f8b176941f8a956291e875" data-reference-type="commit" data-container="body" data-placement="top" data-html="true" title="X test that ZBlk objects can be actually removed from ZODB Connection cache..." class="gfm gfm-commit has-tooltip">69c94fbc</a>https://lab.nexedi.com/kirr/wendelin.core/-/commit/d27ade8e6c7a14205a6b3f2f91f6e0f0c094a430bigfile/zodb: Explain why we always mark ZBlk object changed if block data ch...2019-12-18T15:27:58+03:00Kirill Smelkovkirr@nexedi.com
For ZBlk0 this is trivial, but for ZBlk1 it may seem that we could avoid
changing ZBlk object itself and mark only pointed-to ZData object as
changed. However that would be not correct to do if we consider
invalidations.
Noticed while working on WCFS.https://lab.nexedi.com/kirr/wendelin.core/-/commit/d5e0d2f90701bf31944aafbbe0fe20f0684980ae*: Add package-level documentation to ZODB-related packages2019-12-18T15:27:16+03:00Kirill Smelkovkirr@nexedi.com
Add package-level documentation to
- bigfile/file_zodb.py,
- bigarray/array_zodb.py, and
- lib/zodb.py
The most interesting read is file_zodb.py .
Slightly improve documenation for functions in a couple of places.
Improving documentation was long overdue and it is improved only slightly by this commit.https://lab.nexedi.com/kirr/wendelin.core/-/commit/70c998c1448e58a853762b53e8a1104b54273da9tests: Keep ZEO test database on /tmp/2019-12-18T15:24:06+03:00Kirill Smelkovkirr@nexedi.com
We already keep FileStorage test database on /tmp/ and NEO itself (via
neo.tests.functional.NEOCluster) also keeps test data on tmpfs. However
test database for ZEO was created in current directory and was wearing
out SSD unnecessarily.
FIXME zeo_forker currently does not provide API to keep all server files
in particular place. This way server conf and log are still emitted in
current directory, but at least we move data.fs away. Since conf and log
are uniquely named, e.g. server-<ΧΧΧ>.conf and tmpYYY.log, and it was
only that Data.fs was named non-uniquely, by moving Data.fs into unique
per-server place, this also helps with-ZEO tests to execute correctly in
parallel with `tox -p`.https://lab.nexedi.com/kirr/wendelin.core/-/commit/6af25d90752e1e7a0f8997f3ace91842533f1393bigfile/virtmem: Forward-decl bitmap2019-12-04T19:58:01+03:00Kirill Smelkovkirr@nexedi.com
Else it won't compile with C++. This needs my patch to CCAN to work.
Patch description and problem details are here:
<a href="http://git.ozlabs.org/?p=ccan;a=commitdiff;h=39b46a02b719" rel="nofollow noreferrer noopener" target="_blank">http://git.ozlabs.org/?p=ccan;a=commitdiff;h=39b46a02b719</a>https://lab.nexedi.com/kirr/wendelin.core/-/commit/4d7723909c1c28b9ffbc1e22d8ba637b1a2bac72*: Use `extern "C"` in all headers2019-12-04T19:51:58+03:00Kirill Smelkovkirr@nexedi.com
We are going to add C++ parts to wendelin.core soon.
Mark all current functionality with `extern "C"` as a preparatory step.https://lab.nexedi.com/kirr/wendelin.core/-/commit/47507e63c73a0f15b7806c099ce07d862ec12b0a.gitignore += editor's temps; tags2019-09-29T19:01:47+03:00Kirill Smelkovkirr@nexedi.comhttps://lab.nexedi.com/kirr/wendelin.core/-/commit/13661dfd2344555ad8b02d37012c0fa752aea762readme: wendelin.io moved -> wendelin.nexedi.com2019-09-18T11:20:50+03:00Kirill Smelkovkirr@nexedi.comhttps://lab.nexedi.com/kirr/wendelin.core/-/commit/7ee02038c0af9140e925d2bc50584f32f1502cbcbigfile/py: It is ok to have .fileh_open() as BigFile method2019-07-15T18:04:32+03:00Kirill Smelkovkirr@nexedi.com
There was an XXX of whether fileh_open should be a BigFile method or
global function. However if it would be a global function it will need
to anyway accept file parameter to indicate which file is opened, and
that in turn suggests that it should be a file method. Remove XXX.https://lab.nexedi.com/kirr/wendelin.core/-/commit/2b4576400654cb40eeebc918f9e360e7ef44c4d2*/tests: Use defer instead of finally2019-07-12T20:23:26+03:00Kirill Smelkovkirr@nexedi.com
try/finally was used in a couple of places to save/restore default ZBlk
format setting. Move the restore part close to save with the help of
defer.https://lab.nexedi.com/kirr/wendelin.core/-/commit/5c8340d2db18791279c546de5c885a780423cc01*: Use defer for dbclose & friends2019-07-12T20:19:24+03:00Kirill Smelkovkirr@nexedi.com
For tests this makes sure that if one test fails, it won't make following
tests fail just because the next test will fail trying to lock test database.
For regular code (demo_zbigarray.py) this is also a good thing to do -
to always close the database irregardless of whether an exception was
raised before program reached end of main.
Pygolang becomes regular - not test only - dependency. Being regular
dependency is currently required only by demo_zbigarray.py, but it will
be also used in upcoming wcfs, so adding pygolang into wendelin.core
dependencies aligns with the plan.
dbclose now uses defer almost everywhere - there are still few places in
tests, where one test function is opening/closing test database multiple
times - those were not (yet ?) converted.https://lab.nexedi.com/kirr/wendelin.core/-/commit/b12e319e0f1b0d62e4b1b05454a93c219dca02aa*/tests: Use pytest.raises in modern way2019-07-12T16:40:33+03:00Kirill Smelkovkirr@nexedi.com
Instead of
raises(Exception, 'code')
do
with raises(Exception):
code
This removes lots of warnings, similar to below example:
bigfile/tests/test_basic.py::test_basic
/home/kirr/src/wendelin/wendelin.core/bigfile/tests/test_basic.py:79: PytestDeprecationWarning: raises(..., 'code(as_a_string)') is deprecated, use the context manager form or use `exec()` directly
See <a href="https://docs.pytest.org/en/latest/deprecations.html#raises-warns-exec" rel="nofollow noreferrer noopener" target="_blank">https://docs.pytest.org/en/latest/deprecations.html#raises-warns-exec</a>
raises(ROAttributeError, "f.blksize = 1") # RO attributehttps://lab.nexedi.com/kirr/wendelin.core/-/commit/7001a495c1dcebb39d2a860942fcc9f49dd0dd2ainclude: Fix typos2019-07-11T17:32:24+03:00Kirill Smelkovkirr@nexedi.comhttps://lab.nexedi.com/kirr/wendelin.core/-/commit/49fd66ad3029bc32ee87d943b5d13927955f96d0bigfile: Fix typos2019-07-11T12:43:29+03:00Kirill Smelkovkirr@nexedi.comhttps://lab.nexedi.com/kirr/wendelin.core/-/commit/d970744677d72e8cde108b6d0e8bcc5af1405179bigfile/virtmem/test: Factor-out asserting on ram->lru_list and fileh->dirty_...2019-07-11T12:24:35+03:00Kirill Smelkovkirr@nexedi.com
-> into CHECK_MRU and CHECK_DIRTY.
Besides improving signal/noise ratio in tests, it also gives more
details by printing full lists when things are found to be different
from expected.https://lab.nexedi.com/kirr/wendelin.core/-/commit/60c7080bd130da42eb66d447129912b6bb1e196dbigfile/virtmem/test: Fix test_file_access_pagefault's undef place2019-07-10T20:30:13+03:00Kirill Smelkovkirr@nexedi.com
The undef defined in that function were placed in next function going
after it which does not define any macro.https://lab.nexedi.com/kirr/wendelin.core/-/commit/e5e9557be1cc2de294468de71d254aacdee13bacbigfile/tests: Fix typos2019-07-10T20:24:31+03:00Kirill Smelkovkirr@nexedi.comhttps://lab.nexedi.com/kirr/wendelin.core/-/commit/82383d1e1aff33084091a1a5663ba69f96967209bigfile: Note that ramh_alloc_page does not add the page to any lists2019-07-09T10:22:34+03:00Kirill Smelkovkirr@nexedi.com
It was already said there that allocated page is not associated with
fileh. However the code is doing more - it does not add the page to
ram->lru_list and (obviously) to fileh->dirty_pages lists.
Document that explicitly.https://lab.nexedi.com/kirr/wendelin.core/-/commit/d91ef8fbff385b45451c9703f4dfe899b5dee555bigfile: Unstub ram_close2019-07-09T10:22:23+03:00Kirill Smelkovkirr@nexedi.com
It should release resources associated with RAM. Make it call .ram_close
from RAM ops. Add corresponding .ram_close to ram_shmfs. This fixes
SHMFS_RAM->prefix leak.https://lab.nexedi.com/kirr/wendelin.core/-/commit/e8eca379e72caa6a9ff1a68d13fac5a0b2e8be0cbigfile/test/test_ram: Don't forget to free allocated Page structs2019-07-08T15:32:45+03:00Kirill Smelkovkirr@nexedi.com
test_ram is low-level test that tests RAM pages allocation/mmapping.
As allocated pages are not integrated with virtmem (not added to any
file mapping and RAM->lru_list) the Page structs have to be explicitly
freed. Fixes e.g.
Direct leak of 80 byte(s) in 1 object(s) allocated from:
#0 0x7ff29af46518 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
<a href="/nexedi/wendelin.core/-/issues/1" data-original="#1" data-link="false" data-link-reference="false" data-project="21" data-issue="53" data-reference-type="issue" data-container="body" data-placement="top" data-html="true" title="wendline.core cannot be build on Python 3.5.1" class="gfm gfm-issue has-tooltip">#1</a> 0x56131dc22289 in zalloc include/wendelin/utils.h:67
<a href="/nexedi/wendelin.core/-/issues/2" data-original="#2" data-link="false" data-link-reference="false" data-project="21" data-issue="58" data-reference-type="issue" data-container="body" data-placement="top" data-html="true" title="just created ZBigArray cannot be used before transaction.commit()" class="gfm gfm-issue has-tooltip">#2</a> 0x56131dc225d6 in ramh_alloc_page bigfile/tests/../ram.c:41
<a href="/nexedi/wendelin.core/-/issues/3" data-original="#3" data-link="false" data-link-reference="false" data-project="21" data-issue="60" data-reference-type="issue" data-container="body" data-placement="top" data-html="true" title="NEO / w.c test -> RAM leak" class="gfm gfm-issue has-tooltip">#3</a> 0x56131dc2a19e in main bigfile/tests/test_ram.c:130
<a href="/nexedi/wendelin.core/-/issues/4" data-original="#4" data-link="false" data-link-reference="false" data-project="21" data-issue="66" data-reference-type="issue" data-container="body" data-placement="top" data-html="true" title="fallocate problem on kernel 3.2.60-1+deb7u3" class="gfm gfm-issue has-tooltip">#4</a> 0x7ff29ac9f09a in __libc_start_main ../csu/libc-start.c:308https://lab.nexedi.com/kirr/wendelin.core/-/commit/f688a31de386f4226e5b529ee1d4cdc316e9ae0bbigfile: RAM must be explicitly free'ed after close2019-07-08T15:32:37+03:00Kirill Smelkovkirr@nexedi.com
Else on-heap allocated RAM object is leaked. Fixes e.g. the following
error on ASAN:
Direct leak of 56 byte(s) in 1 object(s) allocated from:
#0 0x7fc9ef390518 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
#1 0x555ca792f309 in zalloc include/wendelin/utils.h:67
#2 0x555ca7935f9a in ram_limited_new bigfile/tests/../../t/t_utils.c:35
#3 0x555ca793a0ba in test_file_access_synthetic bigfile/tests/test_virtmem.c:292
#4 0x555ca7967bc4 in main bigfile/tests/test_virtmem.c:1121
#5 0x7fc9ef0e909a in __libc_start_main ../csu/libc-start.c:308https://lab.nexedi.com/kirr/wendelin.core/-/commit/f1931264289fa5f89dc8c98c2ce905e3285ba19bbigfile/test: Don't forget to close opened RAM2019-07-08T14:25:04+03:00Kirill Smelkovkirr@nexedi.com
Only one place that was using ram_new was missing to call ram_close in
the end.https://lab.nexedi.com/kirr/wendelin.core/-/commit/e87d68018c76bf897d70fd1702715040242b0e3btests: TSAN no longer fails on test_virtmem2019-07-08T13:27:00+03:00Kirill Smelkovkirr@nexedi.com
For failing case compiler-rt support was added in 2014 - 5 years ago
(see links in removed code).https://lab.nexedi.com/kirr/wendelin.core/-/commit/7c4669cdc3bbad92c35148b80d9ffbeba9479e8dtox: Don't duplicate setup.py on which for-tests dependencies we need2019-07-08T13:10:53+03:00Kirill Smelkovkirr@nexedi.com
-> Use .[test] to refer to them.
<a href="https://stackoverflow.com/a/41398850/9456786" rel="nofollow noreferrer noopener" target="_blank">https://stackoverflow.com/a/41398850/9456786</a>https://lab.nexedi.com/kirr/wendelin.core/-/commit/b3636a0817859aa76d2011f6fc2790ce0b1d14da3rdparty/ccan: Update2019-07-08T12:08:53+03:00Kirill Smelkovkirr@nexedi.com
Just an update to latest CCAN - there is actually no changes to modules
that we use (tap, array_size, minmax, bitmap, build_assert)https://lab.nexedi.com/kirr/wendelin.core/-/commit/b26ba558f192d4cbf2cfe18c668dac92e6ea816ewendelin.core v0.132019-06-18T17:05:39+03:00Kirill Smelkovkirr@nexedi.comhttps://lab.nexedi.com/kirr/wendelin.core/-/commit/76e8dc34f031a83e9eb0afc0b62e0453f521138dtox -= Python3.52019-06-18T16:45:16+03:00Kirill Smelkovkirr@nexedi.com
Let's keep on test coverage for last 2 stable Python releases.https://lab.nexedi.com/kirr/wendelin.core/-/commit/bca5f79e6ffdc3109753e7d0afb2a23bcce3a87fFix build for Python 3.72019-06-18T16:42:34+03:00Kirill Smelkovkirr@nexedi.com
Starting from Python 3.7 the place to keep exception state was changed:
<a href="https://github.com/python/cpython/commit/ae3087c638" rel="nofollow noreferrer noopener" target="_blank">https://github.com/python/cpython/commit/ae3087c638</a>
NOTE ZEO4 does not wok with Python3.7, because ZEO4 uses "async" for a
variable and that breaks because starting from Python3.7 "async" became
a keyword.
After the fix wendelin.core tests pass under all python2.7, python3.6
and python3.7.https://lab.nexedi.com/kirr/wendelin.core/-/commit/6b5384ae50b04ebf147d0082c939f58958702df6tox: ZODB5.test.util needs mock2019-06-18T15:58:20+03:00Kirill Smelkovkirr@nexedi.com
Dependency added here:
<a href="https://github.com/zopefoundation/ZODB/commit/e0bc8bd567" rel="nofollow noreferrer noopener" target="_blank">https://github.com/zopefoundation/ZODB/commit/e0bc8bd567</a>
If we don't provide mock, e.g. py27-ZODB5-*-zeo-* breaks:
def setup_module():
global testdb
> testdb = getTestDB()
bigarray/tests/test_arrayzodb.py:38:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py27-ZODB5-zblk1-zeo-numpy115/lib/python2.7/site-packages/wendelin/lib/testing.py:342: in getTestDB
testdb = testdb_factory(testdb_uri)
.tox/py27-ZODB5-zblk1-zeo-numpy115/lib/python2.7/site-packages/wendelin/lib/testing.py:245: in __init__
from ZEO.tests import forker
.tox/py27-ZODB5-zblk1-zeo-numpy115/lib/python2.7/site-packages/ZEO/tests/forker.py:29: in <module>
import ZODB.tests.util
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
"""
from ZODB.MappingStorage import DB
import atexit
import os
import persistent
import re
import tempfile
import time
import transaction
import unittest
import warnings
import ZODB.utils
from ZODB.Connection import TransactionMetaData
import zope.testing.setupstack
from zope.testing import renormalizing
try:
from unittest import mock
except ImportError:
> import mock
E ImportError: No module named mock
.tox/py27-ZODB5-zblk1-zeo-numpy115/lib/python2.7/site-packages/ZODB/tests/util.py:35: ImportErrorhttps://lab.nexedi.com/kirr/wendelin.core/-/commit/7fd83b615a27c782f92cad7d83afaa19b14e7199tox: v↑ NumPy to 2 latest releases2019-05-23T22:25:34+03:00Kirill Smelkovkirr@nexedi.comhttps://lab.nexedi.com/kirr/wendelin.core/-/commit/d9d6adec1beedb8f547b5b93977b7b021795936bbigfile/zodb: Resync _ZBigFileH to Connection.transaction_manager on every co...2019-05-23T21:55:54+03:00Kirill Smelkovkirr@nexedi.com
This continues <a href="/jwolf083/wendelin.core/-/commit/c7c01ce4771b2915a08c6b38068365053e620d70" data-original="c7c01ce477" data-link="false" data-link-reference="false" data-project="1140" data-commit="c7c01ce4771b2915a08c6b38068365053e620d70" data-reference-type="commit" data-container="body" data-placement="top" data-html="true" title="bigfile/zodb: ZODB.Connection can migrate between threads on close/open and we have to care" class="gfm gfm-commit has-tooltip">c7c01ce4</a> (bigfile/zodb: ZODB.Connection can migrate
between threads on close/open and we have to care): Until now we were
retrieving zconn.transaction_manager on _ZBigFileH init, and further using
that transaction manager for every connection reopen. However that is
not correct because on every reopen connection can be given new
transaction manager.
We were not practically hitting the bug because until recently ZODB was,
by default, using the same ThreadTransactionManager manager instance as
Connection.transaction_manager for all connections, and not doing all
steps needed to keep _ZBigFileH.transaction_manager in sync to
Connection was forgiven - a particular transaction manager that was used
was TransactionManager instance implicitly associated with current
thread by global threading.Local transaction.manager . However starting
from ZODB 5.5.0 Connection code was changed to remember as
.transaction_manager the particular TransactionManager instance without
any threading.Local games:
<a href="https://github.com/zopefoundation/ZODB/commit/b6ac40f153" rel="nofollow noreferrer noopener" target="_blank">https://github.com/zopefoundation/ZODB/commit/b6ac40f153</a>
<a href="https://github.com/zopefoundation/ZODB/issues/208" rel="nofollow noreferrer noopener" target="_blank">https://github.com/zopefoundation/ZODB/issues/208</a>
<a href="https://github.com/zopefoundation/ZODB/pull/226" rel="nofollow noreferrer noopener" target="_blank">https://github.com/zopefoundation/ZODB/pull/226</a>
Given that we were not syncing properly that broke wendelin.core tests, for
example:
bigfile/tests/test_filezodb.py::test_bigfile_filezodb_vs_conn_migration Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/home/kirr/src/wendelin/wendelin.core/bigfile/tests/test_filezodb.py", line 401, in T11
transaction.commit() # should be nothing
File "/home/kirr/src/wendelin/venv/z-dev/local/lib/python2.7/site-packages/transaction/_manager.py", line 252, in commit
return self.manager.commit()
File "/home/kirr/src/wendelin/venv/z-dev/local/lib/python2.7/site-packages/transaction/_manager.py", line 131, in commit
return self.get().commit()
File "/home/kirr/src/wendelin/venv/z-dev/local/lib/python2.7/site-packages/transaction/_transaction.py", line 298, in commit
self._synchronizers.map(lambda s: s.beforeCompletion(self))
File "/home/kirr/src/wendelin/venv/z-dev/local/lib/python2.7/site-packages/transaction/weakset.py", line 61, in map
f(elt)
File "/home/kirr/src/wendelin/venv/z-dev/local/lib/python2.7/site-packages/transaction/_transaction.py", line 298, in <lambda>
self._synchronizers.map(lambda s: s.beforeCompletion(self))
File "/home/kirr/src/wendelin/wendelin.core/bigfile/file_zodb.py", line 671, in beforeCompletion
assert txn is zconn.transaction_manager.get()
AssertionError
What is happening here is that one thread used the connection and
ZBigFile/_ZBigFileH associated with it, then the connection was closed
and released to DB pool. Then the connection was reopened but by another
thread and thus with different TransactionManager instance and oops -
_ZBigFileH.transaction_manager is different because it is
TransactionManager instance that was used by the first thread.
Fix it by resyncing _ZBigFileH.transaction_manager on every
connection reopen. No new test as existing tests already cover the
problem when run with ZODB >= 5.5.0 .https://lab.nexedi.com/kirr/wendelin.core/-/commit/89fb89929aa400460d0c1c5992dedc2ca729d822t/qemu-runlinux: Issue terminal init before running program2019-05-03T19:20:33+03:00Kirill Smelkovkirr@nexedi.com
This continues <a href="/nexedi/wendelin.core/-/commit/6ab952207e4785d517c4d68ef4676c4993280976" data-original="6ab952207e" data-link="false" data-link-reference="false" data-project="21" data-commit="6ab952207e4785d517c4d68ef4676c4993280976" data-reference-type="commit" data-container="body" data-placement="top" data-html="true" title="t/qemu-runlinux: Issue terminal resize before running program" class="gfm gfm-commit has-tooltip">6ab95220</a> (t/qemu-runlinux: Issue terminal resize before
running program) and fully initializes terminal before spawning user
application.
This has practical effect to restore line wrapping for xterm, as kernel,
initially assuming it has "linux" type terminal, somehow messes xterm
settings: before the patch lines that were wider than terminal width were
not wrapped and characters in the last position were printed over each
other. After the patch printed lines are automatically wrapped and test
output is not lost.
Tput hint found here:
<a href="https://unix.stackexchange.com/questions/105958" rel="nofollow noreferrer noopener" target="_blank">https://unix.stackexchange.com/questions/105958</a>https://lab.nexedi.com/kirr/wendelin.core/-/commit/208aca62ae4e09d4722a1a0a6c9b7e0d8f758647t/qemu-runlinux: Kernel verbosity control via -v2019-03-17T13:00:13+03:00Kirill Smelkovkirr@nexedi.com
0: ERROR+ on boot/run
1: INFO+ on run
2: INFO+ on boot/run
3: DEBUG+ on boot/run
It is convenient not to see large kernel boot log on every test run. "1"
(single -v) is also convenient: one can skip the boot log but still see
details of what is going on when test workload is run. -vv and -vvv are
there to see full picture.https://lab.nexedi.com/kirr/wendelin.core/-/commit/a568d6d999179ed47928b37b4df5ab87e42f4b65t/qemu-runlinux: Mount bpf and fusectl filesystems2019-02-27T23:11:06+03:00Kirill Smelkovkirr@nexedi.com
bpf is needed for tools like bpftrace.
fusectl is needed to observe things like /sys/fs/fuse/connections/X/waiting.https://lab.nexedi.com/kirr/wendelin.core/-/commit/6ab952207e4785d517c4d68ef4676c4993280976t/qemu-runlinux: Issue terminal resize before running program2019-02-27T23:08:49+03:00Kirill Smelkovkirr@nexedi.com
Else program inside sees default terminal settings to be 80x25,
while after the patch it sees correct settings.
Still something is not completely right with terminal settings, as e.g.
vsplit is not working correctly in vim (vertical ruler is not straight).https://lab.nexedi.com/kirr/wendelin.core/-/commit/ccca055cfec4aaad1b87126a9a0290faae9be4f1t/qemu-runlinux: Don't propagate $TERM in graphics mode2019-02-27T23:06:57+03:00Kirill Smelkovkirr@nexedi.com
Graphics mode runs in another window with its own terminal emulation,
so propagating e.g. TERM=xterm to where it is emulated as TERM=linux is
not correct.https://lab.nexedi.com/kirr/wendelin.core/-/commit/fe541453f8275757b57d9aa5ee5fb1c1a02d4dd4t/qemu-runlinux: Update2019-02-13T11:11:16+03:00Kirill Smelkovkirr@nexedi.com
Continuing <a href="/kirr/wendelin.core/-/commit/76d8f76dc16c866889ae81cf48f5bf4fced29e15" data-original="76d8f76d" data-link="false" data-link-reference="false" data-project="20" data-commit="76d8f76dc16c866889ae81cf48f5bf4fced29e15" data-reference-type="commit" data-container="body" data-placement="top" data-html="true" title="Script to run compiled linux kernel with root fs mounted from host" class="gfm gfm-commit has-tooltip">76d8f76d</a> (Script to run compiled linux kernel with root fs
mounted from host) update the script to run/debug linux inside QEMU:
- teach it to run specified program + args, instead of hardcoded /bin/sh;
- before tailing to user program, builtin init mounts /proc, /sys, ...
inside - previously it was /proc, /sys from host seen on those
mountpoints and it was very misleading - e.g. ps was showing processes
from host, not inside, etc.
- builtin init also cares to run specified program with the same current
directory that was current on host, and environments such as $HOME,
$PATH, $TERM, ... are also propagated.
- allow to optionally run QEMU with graphics, instead of stdout only;
- increase available RAM from 128M to 512M (with 128M running py.test
inside is failing with fork: not enough memory).
This updated version was useful to debug WCFS(*) & FUSE issues by running
kirr@deco:~/src/wendelin/wendelin.core/wcfs$ ../t/qemu-runlinux ~/src/linux/linux/arch/x86_64/boot/bzImage py.test -vsx -k test_wcfs
See <a href="https://marc.info/?l=linux-fsdevel&m=155000277921155&w=2" rel="nofollow noreferrer noopener" target="_blank">https://marc.info/?l=linux-fsdevel&m=155000277921155&w=2</a> for details.
(*) WCFS is still being draft and worked on t branch.https://lab.nexedi.com/kirr/wendelin.core/-/commit/d97641d2ba4318e0e087ac1114feacae0e09754dbigfile/py: Properly untrack PyVMA from GC before dealloc2019-01-11T18:35:11+03:00Kirill Smelkovkirr@nexedi.com
On a testing instance we started to see segfaults in pyvma_dealloc()
with inside calls to vma_unmap but with NULL pyvma->fileh. That was
strange, becuse before calling vma_unmap(), the code explicitly checks
whether pyvma->fileh is !NULL.
That was, as it turned out, due to pyvma_dealloc being called twice at the
same time from two python threads. Here is how that was possible:
T1 decrefs pyvma and finds its reference count drops to zero. It calls
pyvma_dealloc. From there vma_unmap() is called, which calls virt_lock()
and that releases GIL first. Another thread T2 was waiting for GIL, it
acquires it, does some work at python level and somehow triggers GC.
Since PyVMA supports cyclic GC, it was on GC list and thus GC calls
dealloc for the same vma again. Here is how it looks in the backtraces:
T1:
#0 0x00007f6aefc57827 in futex_abstimed_wait_cancelable (private=0, abstime=0x0, expected=0, futex_word=0x1e011d0) at ../sysdeps/unix/sysv/linux/futex-internal.h:205
#1 do_futex_wait (sem=sem@entry=0x1e011d0, abstime=0x0) at sem_waitcommon.c:111
#2 0x00007f6aefc578d4 in __new_sem_wait_slow (sem=0x1e011d0, abstime=0x0) at sem_waitcommon.c:181
#3 0x00007f6aefc5797a in __new_sem_wait (sem=<optimized out>) at sem_wait.c:29
#4 0x00000000004ffbc4 in PyThread_acquire_lock ()
#5 0x00000000004dbe8a in PyEval_RestoreThread ()
#6 0x00007f6ac6d3b8fc in py_gil_retake_if_waslocked (arg=0x4f18f00) at bigfile/_bigfile.c:1048
#7 0x00007f6ac6d3dcfc in virt_gil_retake_if_waslocked (gilstate=0x4f18f00) at bigfile/virtmem.c:78
#8 0x00007f6ac6d3dd30 in virt_lock () at bigfile/virtmem.c:92
#9 0x00007f6ac6d3e724 in vma_unmap (vma=0x7f6a7e0c4100) at bigfile/virtmem.c:271
#10 0x00007f6ac6d3a0bc in pyvma_dealloc (pyvma0=0x7f6a7e0c40e0) at bigfile/_bigfile.c:284
...
#13 0x00000000004d76b0 in PyEval_EvalFrameEx ()
T2:
#5 0x00007f6ac6d3a081 in pyvma_dealloc (pyvma0=0x7f6a7e0c40e0) at bigfile/_bigfile.c:276
#6 0x0000000000500450 in ?? ()
#7 0x00000000004ffd82 in _PyObject_GC_New ()
#8 0x0000000000485392 in PyList_New ()
#9 0x00000000004d3bff in PyEval_EvalFrameEx ()
T2 does the work of vma_unmap and clears C-level vma. Then, when T1 wakes up and
returns to vma_unmap, it sees vma->file and all other fields cleared -> oops
segfault.
Fix it by removing pyvma from GC list before going to do actual destruction.
This way if a concurrent GC triggers, it won't see the vma object on its list,
and thus won't have a chance to invoke its destructor the second time.
The bug was introduced in <a href="/jwolf083/wendelin.core/-/commit/450ad804625080d69b646126d1e015abe98889b7" data-original="450ad804" data-link="false" data-link-reference="false" data-project="1140" data-commit="450ad804625080d69b646126d1e015abe98889b7" data-reference-type="commit" data-container="body" data-placement="top" data-html="true" title="bigarray: ArrayRef support for BigArray" class="gfm gfm-commit has-tooltip">450ad804</a> (bigarray: ArrayRef support for BigArray)
when PyVMA was changed to be cyclic-GC aware. However at that time, even Python
documentation itself was not saying PyObject_GC_UnTrack is needed, as it was
added only in 2.7.15 after finding that many types in CPython itself are
vulnerable to similar segfaults:
<a href="https://github.com/python/cpython/commit/4cde4bdcc86" rel="nofollow noreferrer noopener" target="_blank">https://github.com/python/cpython/commit/4cde4bdcc86</a>
<a href="https://bugs.python.org/issue31095" rel="nofollow noreferrer noopener" target="_blank">https://bugs.python.org/issue31095</a>
It is pity, that CPython took the approach to force all type authors to
care to invoke PyObject_GC_UnTrack explicitly, instead of doing that
automatically in Python runtime before calling tp_dealloc.
/cc <a href="/Tyagov" data-user="15" data-reference-type="user" data-container="body" data-placement="top" data-html="true" class="gfm gfm-project_member" title="Ivan Tyagov">@Tyagov</a>, <a href="/klaus" data-user="7" data-reference-type="user" data-container="body" data-placement="top" data-html="true" class="gfm gfm-project_member" title="Klaus Wölfel">@klaus</a>
/reviewed-on <a href="https://lab.nexedi.com/nexedi/wendelin.core/merge_requests/11" data-original="https://lab.nexedi.com/nexedi/wendelin.core/merge_requests/11" data-link="false" data-link-reference="true" data-project="21" data-merge-request="2674" data-project-path="nexedi/wendelin.core" data-iid="11" data-mr-title="bigfile/py: Properly untrack PyVMA from GC before dealloc" data-reference-type="merge_request" data-container="body" data-placement="top" data-html="true" title="" class="gfm gfm-merge_request">nexedi/wendelin.core!11</a>https://lab.nexedi.com/kirr/wendelin.core/-/commit/32ca80e2d5c237a50e180e535d8701cd492b8e27lib.xnumpy.structured: New utility to create structured view of an array2018-10-29T16:02:32+01:00Kirill Smelkovkirr@nexedi.com
Structured creates view of the array interpreting its minor axis as fully covered by a dtype.
It is similar to arr.view(dtype) + corresponding reshape, but does
not have limitations of ndarray.view(). For example:
In [1]: a = np.arange(3*3, dtype=np.int32).reshape((3,3))
In [2]: a
Out[2]:
array([[0, 1, 2],
[3, 4, 5],
[6, 7, 8]], dtype=int32)
In [3]: b = a[:2,:2]
In [4]: b
Out[4]:
array([[0, 1],
[3, 4]], dtype=int32)
In [5]: dtxy = np.dtype([('x', np.int32), ('y', np.int32)])
In [6]: dtxy
Out[6]: dtype([('x', '<i4'), ('y', '<i4')])
In [7]: b.view(dtxy)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-66-af98529aa150> in <module>()
----> 1 b.view(dtxy)
ValueError: To change to a dtype of a different size, the array must be C-contiguous
In [8]: structured(b, dtxy)
Out[8]: array([(0, 1), (3, 4)], dtype=[('x', '<i4'), ('y', '<i4')])
Structured always creates view and never copies data.
Here is original context where separately playing with .shape and .dtype
was not enough, since it was creating array copy and OOM'ing the machine:
<a href="https://lab.nexedi.com/klaus/wendelin/commit/cbe4938b" data-original="https://lab.nexedi.com/klaus/wendelin/commit/cbe4938b" data-link="false" data-link-reference="true" data-project="74" data-commit="cbe4938b5957424adb35a8fcd6ad1bcf9f8d99f1" data-reference-type="commit" data-container="body" data-placement="top" data-html="true" title="make sure to return view" class="gfm gfm-commit has-tooltip">klaus/wendelin@cbe4938b</a>