Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
10420e82
Commit
10420e82
authored
Dec 29, 2016
by
Kirill Smelkov
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X gc.collect on loadblk -> pybuf.ob_refcnt != 1
parent
f1e12596
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
2 deletions
+54
-2
bigfile/_bigfile.c
bigfile/_bigfile.c
+19
-0
bigfile/tests/test_basic.py
bigfile/tests/test_basic.py
+35
-2
No files found.
bigfile/_bigfile.c
View file @
10420e82
...
...
@@ -53,6 +53,7 @@ typedef struct _frame PyFrameObject;
void
PyBufferObject_Unpin
(
PyBufferObject
*
bufo
);
void
PyBuffer_Unpin
(
Py_buffer
*
view
);
static
PyObject
*
gcmodule
;
/*
...
...
@@ -560,6 +561,19 @@ out:
if (pybuf)
BUG_ON(pybuf->ob_refcnt != 1);
#endif
if
(
pybuf
&&
pybuf
->
ob_refcnt
!=
1
)
{
PyObject
*
pybuf_users
=
PyObject_CallMethod
(
gcmodule
,
"get_referrers"
,
"O"
,
pybuf
);
BUG_ON
(
!
pybuf_users
);
//PyObject_Repr(pybuf_users);
fprintf
(
stderr
,
"
\n
"
);
_PyObject_Dump
(
pybuf_users
);
fprintf
(
stderr
,
"
\n
"
);
PyObject_Print
(
pybuf_users
,
stderr
,
0
);
fprintf
(
stderr
,
"curexc_tb:
\t
%p
\n
"
,
x_curexc_traceback
);
fprintf
(
stderr
,
"exc_tb:
\t
%p
\n
"
,
x_exc_traceback
);
Py_DECREF
(
pybuf_users
);
BUG
();
}
/* drop pybuf
*
...
...
@@ -911,6 +925,11 @@ _init_bigfile(void)
CSTi
(
WRITEOUT_STORE
);
CSTi
(
WRITEOUT_MARKSTORED
);
/* import gc */
gcmodule
=
PyImport_ImportModule
(
"gc"
);
if
(
!
gcmodule
)
return
NULL
;
return
m
;
}
...
...
bigfile/tests/test_basic.py
View file @
10420e82
...
...
@@ -124,6 +124,21 @@ def test_basic():
# TODO close f
def
zzz
():
try
:
1
/
0
except
ZeroDivisionError
:
pass
exc_type
,
exc_value
,
exc_traceback
=
sys
.
exc_info
()
if
PY2
:
assert
exc_type
is
ZeroDivisionError
else
:
# on python3 exception state is cleared upon exiting from `except`
assert
exc_type
is
None
# del exc_traceback
# test that python exception state is preserved across pagefaulting
def
test_pagefault_savestate
():
class
BadFile
(
BigFile
):
...
...
@@ -159,12 +174,23 @@ def test_pagefault_savestate():
# # gc.collect() which cannot be perform in pagefault handler.
# #
# # Not breaking this loop will BUG with `buf.refcnt != 1` on return
# del exc_traceback
del
exc_traceback
zzz
()
raise
Exception
(
'eee'
)
assert
len
(
buf
)
>
0
self
.
loadblk_run
=
1
self
.
loadblk_buf
=
buf
#self.loadblk_buf = buf
#self.loadblk_buf2 = buffer(buf)
#self.loadblk_mbuf = memoryview(buf)
#print
#print
#print '111'
#print `buf`
#print `self.loadblk_buf2`
#print `self.loadblk_mbuf`
f
=
BadFile
(
PS
)
...
...
@@ -189,7 +215,14 @@ def test_pagefault_savestate():
assert
exc_tb
is
exc_tb2
# TODO check f.loadblk_buf for access -- len=0, read/write - index error
print
print
'222'
print
`f.loadblk_buf`
print
`f.loadblk_buf2`
print
`f.loadblk_mbuf`
assert
len
(
f
.
loadblk_buf
)
==
0
assert
len
(
f
.
loadblk_buf2
)
==
0
assert
len
(
f
.
loadblk_mbuf
)
==
0
raises
(
IndexError
,
"f.loadblk_buf[0]"
)
raises
(
IndexError
,
"f.loadblk_buf[0] = b'1'"
)
...
...
Kirill Smelkov
@kirr
mentioned in issue
nexedi/wendelin.core#7 (closed)
·
Dec 29, 2016
mentioned in issue
nexedi/wendelin.core#7 (closed)
mentioned in issue nexedi/wendelin.core#7
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment