Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyJQ memory corruption #1059

Closed
mfeit-internet2 opened this issue Aug 25, 2020 · 2 comments
Closed

PyJQ memory corruption #1059

mfeit-internet2 opened this issue Aug 25, 2020 · 2 comments
Assignees

Comments

@mfeit-internet2
Copy link
Member

The following test for jqfilter causes memory corruption in the Py2 and Py3 versions.

def test_args(self):
    f = JQFilter({"script": "."}, args={"value": 123})
python3 -m nose
.............*** Error in `python3': malloc(): memory corruption (fast): 0x000000000226048f ***
======= Backtrace: =========
/lib64/libc.so.6(+0x7f3e4)[0x7f51fd9a53e4]
/lib64/libc.so.6(+0x82b20)[0x7f51fd9a8b20]
/lib64/libc.so.6(__libc_calloc+0xb4)[0x7f51fd9ac184]
/lib64/libjq.so.1(jv_mem_calloc+0x9)[0x7f51ed62ac19]
/lib64/libjq.so.1(+0x157ae)[0x7f51ed6207ae]
/lib64/libjq.so.1(+0x1607b)[0x7f51ed62107b]
/lib64/libjq.so.1(jq_compile_args+0x30d)[0x7f51ed62412d]
/usr/lib64/python3.6/site-packages/_pyjq.cpython-36m-x86_64-linux-gnu.so(+0x71e5)[0x7f51ed85f1e5]
/lib64/libpython3.6m.so.1.0(+0xf71e2)[0x7f51fe7101e2]
/lib64/libpython3.6m.so.1.0(_PyObject_FastCallDict+0x90)[0x7f51fe6c1160]
/lib64/libpython3.6m.so.1.0(_PyObject_FastCallKeywords+0x9c)[0x7f51fe6c17ec]
/lib64/libpython3.6m.so.1.0(+0x15098c)[0x7f51fe76998c]
/lib64/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x162b)[0x7f51fe75f37b]
/lib64/libpython3.6m.so.1.0(+0x14f987)[0x7f51fe768987]
/lib64/libpython3.6m.so.1.0(+0x15067a)[0x7f51fe76967a]
/lib64/libpython3.6m.so.1.0(+0x150903)[0x7f51fe769903]
/lib64/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x162b)[0x7f51fe75f37b]
/lib64/libpython3.6m.so.1.0(+0x14f987)[0x7f51fe768987]
/lib64/libpython3.6m.so.1.0(_PyFunction_FastCallDict+0x24f)[0x7f51fe76a9ff]
/lib64/libpython3.6m.so.1.0(_PyObject_FastCallDict+0x10e)[0x7f51fe6c11de]
/lib64/libpython3.6m.so.1.0(_PyObject_Call_Prepend+0x61)[0x7f51fe6c12f1]
/lib64/libpython3.6m.so.1.0(PyObject_Call+0x43)[0x7f51fe6c0f63]
/lib64/libpython3.6m.so.1.0(+0xfa7e5)[0x7f51fe7137e5]
/lib64/libpython3.6m.so.1.0(+0xf71e2)[0x7f51fe7101e2]
/lib64/libpython3.6m.so.1.0(_PyObject_FastCallDict+0x90)[0x7f51fe6c1160]
/lib64/libpython3.6m.so.1.0(_PyObject_FastCallKeywords+0x9c)[0x7f51fe6c17ec]
/lib64/libpython3.6m.so.1.0(+0x15098c)[0x7f51fe76998c]
/lib64/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x162b)[0x7f51fe75f37b]
/lib64/libpython3.6m.so.1.0(+0x1505ca)[0x7f51fe7695ca]
/lib64/libpython3.6m.so.1.0(+0x150903)[0x7f51fe769903]
/lib64/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x3a7)[0x7f51fe75e0f7]
/lib64/libpython3.6m.so.1.0(+0x14f987)[0x7f51fe768987]
/lib64/libpython3.6m.so.1.0(_PyFunction_FastCallDict+0x24f)[0x7f51fe76a9ff]
/lib64/libpython3.6m.so.1.0(_PyObject_FastCallDict+0x10e)[0x7f51fe6c11de]
/lib64/libpython3.6m.so.1.0(_PyObject_Call_Prepend+0x61)[0x7f51fe6c12f1]
/lib64/libpython3.6m.so.1.0(PyObject_Call+0x43)[0x7f51fe6c0f63]
/lib64/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x2067)[0x7f51fe75fdb7]
/lib64/libpython3.6m.so.1.0(+0x14f987)[0x7f51fe768987]
/lib64/libpython3.6m.so.1.0(_PyFunction_FastCallDict+0x24f)[0x7f51fe76a9ff]
/lib64/libpython3.6m.so.1.0(_PyObject_FastCallDict+0x10e)[0x7f51fe6c11de]
/lib64/libpython3.6m.so.1.0(_PyObject_Call_Prepend+0x61)[0x7f51fe6c12f1]
/lib64/libpython3.6m.so.1.0(PyObject_Call+0x43)[0x7f51fe6c0f63]
/lib64/libpython3.6m.so.1.0(+0xfbb2d)[0x7f51fe714b2d]
/lib64/libpython3.6m.so.1.0(_PyObject_FastCallDict+0x90)[0x7f51fe6c1160]
/lib64/libpython3.6m.so.1.0(+0x15098c)[0x7f51fe76998c]
/lib64/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x3a7)[0x7f51fe75e0f7]
/lib64/libpython3.6m.so.1.0(+0x1505ca)[0x7f51fe7695ca]
/lib64/libpython3.6m.so.1.0(+0x150903)[0x7f51fe769903]
/lib64/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x3a7)[0x7f51fe75e0f7]
/lib64/libpython3.6m.so.1.0(_PyFunction_FastCallDict+0x15a)[0x7f51fe76a90a]
/lib64/libpython3.6m.so.1.0(_PyObject_FastCallDict+0x10e)[0x7f51fe6c11de]
/lib64/libpython3.6m.so.1.0(_PyObject_Call_Prepend+0x61)[0x7f51fe6c12f1]
/lib64/libpython3.6m.so.1.0(PyObject_Call+0x43)[0x7f51fe6c0f63]
/lib64/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x2067)[0x7f51fe75fdb7]
/lib64/libpython3.6m.so.1.0(+0x14f987)[0x7f51fe768987]
/lib64/libpython3.6m.so.1.0(_PyFunction_FastCallDict+0x24f)[0x7f51fe76a9ff]
/lib64/libpython3.6m.so.1.0(_PyObject_FastCallDict+0x10e)[0x7f51fe6c11de]
/lib64/libpython3.6m.so.1.0(_PyObject_Call_Prepend+0x61)[0x7f51fe6c12f1]
/lib64/libpython3.6m.so.1.0(PyObject_Call+0x43)[0x7f51fe6c0f63]
/lib64/libpython3.6m.so.1.0(+0xfbb2d)[0x7f51fe714b2d]
/lib64/libpython3.6m.so.1.0(_PyObject_FastCallDict+0x90)[0x7f51fe6c1160]
/lib64/libpython3.6m.so.1.0(+0x15098c)[0x7f51fe76998c]
/lib64/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x3a7)[0x7f51fe75e0f7]
======= Memory map: ========
00400000-00401000 r-xp 00000000 fd:00 13544                              /usr/bin/python3.6
00601000-00602000 r--p 00001000 fd:00 13544                              /usr/bin/python3.6
00602000-00603000 rw-p 00002000 fd:00 13544                              /usr/bin/python3.6
01dd3000-02343000 rw-p 00000000 00:00 0                                  [heap]
7f51e0000000-7f51e0021000 rw-p 00000000 00:00 0
7f51e0021000-7f51e4000000 ---p 00000000 00:00 0
7f51e695a000-7f51e695b000 ---p 00000000 00:00 0
7f51e695b000-7f51e715b000 rw-p 00000000 00:00 0
7f51e715b000-7f51e7172000 r-xp 00000000 fd:00 34199861                   /usr/lib64/libelf-0.176.so
7f51e7172000-7f51e7371000 ---p 00017000 fd:00 34199861                   /usr/lib64/libelf-0.176.so
7f51e7371000-7f51e7372000 r--p 00016000 fd:00 34199861                   /usr/lib64/libelf-0.176.so
7f51e7372000-7f51e7373000 rw-p 00017000 fd:00 34199861                   /usr/lib64/libelf-0.176.so
7f51e7373000-7f51e7377000 r-xp 00000000 fd:00 33597599                   /usr/lib64/libattr.so.1.1.0
7f51e7377000-7f51e7576000 ---p 00004000 fd:00 33597599                   /usr/lib64/libattr.so.1.1.0
7f51e7576000-7f51e7577000 r--p 00003000 fd:00 33597599                   /usr/lib64/libattr.so.1.1.0
7f51e7577000-7f51e7578000 rw-p 00004000 fd:00 33597599                   /usr/lib64/libattr.so.1.1.0
7f51e7578000-7f51e758d000 r-xp 00000000 fd:00 33554508                   /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7f51e758d000-7f51e778c000 ---p 00015000 fd:00 33554508                   /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7f51e778c000-7f51e778d000 r--p 00014000 fd:00 33554508                   /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7f51e778d000-7f51e778e000 rw-p 00015000 fd:00 33554508                   /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7f51e778e000-7f51e77dc000 r-xp 00000000 fd:00 33748781                   /usr/lib64/libdw-0.176.so
7f51e77dc000-7f51e79dc000 ---p 0004e000 fd:00 33748781                   /usr/lib64/libdw-0.176.so
7f51e79dc000-7f51e79de000 r--p 0004e000 fd:00 33748781                   /usr/lib64/libdw-0.176.so
7f51e79de000-7f51e79df000 rw-p 00050000 fd:00 33748781                   /usr/lib64/libdw-0.176.so
7f51e79df000-7f51e79e3000 r-xp 00000000 fd:00 33597601                   /usr/lib64/libcap.so.2.22
7f51e79e3000-7f51e7be2000 ---p 00004000 fd:00 33597601                   /usr/lib64/libcap.so.2.22
7f51e7be2000-7f51e7be3000 r--p 00003000 fd:00 33597601                   /usr/lib64/libcap.so.2.22
7f51e7be3000-7f51e7be4000 rw-p 00004000 fd:00 33597601                   /usr/lib64/libcap.so.2.22
7f51e7be4000-7f51e7bf6000 r-xp 00000000 fd:00 33603905                   /usr/lib64/libnss_myhostname.so.2
7f51e7bf6000-7f51e7df5000 ---p 00012000 fd:00 33603905                   /usr/lib64/libnss_myhostname.so.2
7f51e7df5000-7f51e7df8000 r--p 00011000 fd:00 33603905                   /usr/lib64/libnss_myhostname.so.2
7f51e7df8000-7f51e7df9000 rw-p 00014000 fd:00 33603905                   /usr/lib64/libnss_myhostname.so.2
7f51e7df9000-7f51e7dff000 r-xp 00000000 fd:00 33806572                   /usr/lib64/libnss_dns-2.17.so
7f51e7dff000-7f51e7ffe000 ---p 00006000 fd:00 33806572                   /usr/lib64/libnss_dns-2.17.so
7f51e7ffe000-7f51e7fff000 r--p 00005000 fd:00 33806572                   /usr/lib64/libnss_dns-2.17.so
7f51e7fff000-7f51e8000000 rw-p 00006000 fd:00 33806572                   /usr/lib64/libnss_dns-2.17.so
7f51e8000000-7f51e8021000 rw-p 00000000 00:00 0
7f51e8021000-7f51ec000000 ---p 00000000 00:00 0
7f51ec1a6000-7f51ec1b2000 r-xp 00000000 fd:00 33806574                   /usr/lib64/libnss_files-2.17.so
7f51ec1b2000-7f51ec3b1000 ---p 0000c000 fd:00 33806574                   /usr/lib64/libnss_files-2.17.so
7f51ec3b1000-7f51ec3b2000 r--p 0000b000 fd:00 33806574                   /usr/lib64/libnss_files-2.17.so
7f51ec3b2000-7f51ec3b3000 rw-p 0000c000 fd:00 33806574                   /usr/lib64/libnss_files-2.17.so
7f51ec3b3000-7f51ec3b9000 rw-p 00000000 00:00 0 make[1]: *** [test] Aborted
@mfeit-internet2
Copy link
Member Author

Worked around this in the batch processor by prepending script to set the variables:

def jq_filter(script, args={}):

    if isinstance(script, list):
        script = "\n".join(script)

    arg_lines = "".join([
        "%s as $%s | " % (pscheduler.json_dump(value), name)
        for name, value in args.items()
    ])

    return pscheduler.JQFilter(arg_lines + script)

@mfeit-internet2
Copy link
Member Author

Closing, but will revisit once I get notification that PyJQ is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant