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

3087 malloc.c: No such file or directory. when using memray attach. #309

Closed
1 task done
rkooo567 opened this issue Jan 30, 2023 · 13 comments · Fixed by #310
Closed
1 task done

3087 malloc.c: No such file or directory. when using memray attach. #309

rkooo567 opened this issue Jan 30, 2023 · 13 comments · Fixed by #310
Labels
bug Something isn't working

Comments

@rkooo567
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

No lldb executable found
Debugger command line: ['gdb', '-batch', '-p', '3009', '-nx', '-nw', '-iex=set auto-solib-add off', '-ex=set $rtld_now=2', '-ex=set $libpath="/opt/miniconda/lib/python3.7/site-packages/memray/_inject.abi3.so"', '-ex=set $port=58095', '-x=/opt/miniconda/lib/python3.7/site-packages/memray/commands/_attach.gdb']
debugger return code: 0
debugger output:
[New LWP 3020]
[New LWP 3021]
[New LWP 3022]
[New LWP 3024]
[New LWP 3025]
[New LWP 3026]
[New LWP 3027]
[New LWP 3028]
[New LWP 3029]
[New LWP 3030]
[New LWP 3031]
[New LWP 3037]
[New LWP 3038]
[New LWP 3039]
[New LWP 3040]
[New LWP 3041]
[New LWP 3042]
[New LWP 3043]
[New LWP 3044]
[New LWP 3045]
[New LWP 3046]
[New LWP 3047]
[New LWP 3048]
[New LWP 3049]
[New LWP 3050]
[New LWP 3051]
[New LWP 3052]
[New LWP 3053]
[New LWP 3054]
[New LWP 3055]
[New LWP 3069]
[New LWP 3070]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007fa836efafcb in ?? () from /lib/x86_64-linux-gnu/libc.so.6
$1 = "MEMRAY: Attached to process."
From                To                  Syms Read   Shared Object Library
0x00007fa836fdeae0  0x00007fa836fee535  Yes         /lib/x86_64-linux-gnu/libpthread.so.0
0x00007fa836e08630  0x00007fa836f7d27d  Yes         /lib/x86_64-linux-gnu/libc.so.6
0x00007fa836de1220  0x00007fa836de2179  Yes         /lib/x86_64-linux-gnu/libdl.so.2
0x00007fa836ddc3e0  0x00007fa836ddcd90  No          /lib/x86_64-linux-gnu/libutil.so.1
0x00007fa836dd3720  0x00007fa836dd6d70  No          /lib/x86_64-linux-gnu/librt.so.1
0x00007fa836c8f3c0  0x00007fa836d35fa8  No          /lib/x86_64-linux-gnu/libm.so.6
0x00007fa837008100  0x00007fa83702a684  No          /lib64/ld-linux-x86-64.so.2
0x00007fa8364e2040  0x00007fa8364e3d5c  No          /opt/miniconda/lib/python3.7/lib-dynload/_heapq.cpython-37m-x86_64-linux-gnu.so
0x00007fa836415040  0x00007fa83641a094  No          /opt/miniconda/lib/python3.7/lib-dynload/_struct.cpython-37m-x86_64-linux-gnu.so
0x00007fa83640b040  0x00007fa83640dd19  No          /opt/miniconda/lib/python3.7/lib-dynload/binascii.cpython-37m-x86_64-linux-gnu.so
0x00007fa8363ec040  0x00007fa8363ff7f5  No          /opt/miniconda/lib/python3.7/lib-dynload/../../libz.so.1
0x00007fa8363d7040  0x00007fa8363e4561  No          /opt/miniconda/lib/python3.7/lib-dynload/_json.cpython-37m-x86_64-linux-gnu.so
0x00007fa8365c8040  0x00007fa8365c9487  No          /opt/miniconda/lib/python3.7/lib-dynload/_posixsubprocess.cpython-37m-x86_64-linux-gnu.so
0x00007fa8365be040  0x00007fa8365c1897  No          /opt/miniconda/lib/python3.7/lib-dynload/select.cpython-37m-x86_64-linux-gnu.so
0x00007fa8365b1040  0x00007fa8365b656e  No          /opt/miniconda/lib/python3.7/lib-dynload/math.cpython-37m-x86_64-linux-gnu.so
0x00007fa83626e040  0x00007fa83627f1a7  No          /opt/miniconda/lib/python3.7/lib-dynload/_ctypes.cpython-37m-x86_64-linux-gnu.so
0x00007fa83625c040  0x00007fa8362612fb  No          /opt/miniconda/lib/python3.7/lib-dynload/../../libffi.so.7
0x00007fa83536a540  0x00007fa835e1d242  No          /ray/python/ray/_raylet.so
0x00007fa834e7bd90  0x00007fa834ef3211  No          /opt/miniconda/bin/../lib/libstdc++.so.6
0x00007fa834dc22d8  0x00007fa834dcdb79  No          /opt/miniconda/bin/../lib/libgcc_s.so.1
0x00007fa834d66040  0x00007fa834d73ef3  No          /opt/miniconda/lib/python3.7/lib-dynload/_socket.cpython-37m-x86_64-linux-gnu.so
0x00007fa834d09040  0x00007fa834d13c49  No          /opt/miniconda/lib/python3.7/lib-dynload/_ssl.cpython-37m-x86_64-linux-gnu.so
0x00007fa834c8e040  0x00007fa834cd7dfc  No          /opt/miniconda/lib/python3.7/lib-dynload/../../libssl.so.1.1
0x00007fa834a1f000  0x00007fa834bb07cd  Yes         /opt/miniconda/lib/python3.7/lib-dynload/../../libcrypto.so.1.1
0x00007fa8365aa040  0x00007fa8365aa2c7  No          /opt/miniconda/lib/python3.7/lib-dynload/_opcode.cpython-37m-x86_64-linux-gnu.so
0x00007fa83491f040  0x00007fa83491f295  No          /opt/miniconda/lib/python3.7/lib-dynload/_contextvars.cpython-37m-x86_64-linux-gnu.so
0x00007fa83490c040  0x00007fa8349155e2  No          /opt/miniconda/lib/python3.7/lib-dynload/_asyncio.cpython-37m-x86_64-linux-gnu.so
0x00007fa8347ef040  0x00007fa8347feb59  No          /opt/miniconda/lib/python3.7/lib-dynload/_datetime.cpython-37m-x86_64-linux-gnu.so
0x00007fa8347c9820  0x00007fa8347de57f  No          /opt/miniconda/lib/python3.7/site-packages/msgpack/_cmsgpack.cpython-37m-x86_64-linux-gnu.so
0x00007fa8347a9040  0x00007fa8347bbd86  No          /opt/miniconda/lib/python3.7/lib-dynload/_pickle.cpython-37m-x86_64-linux-gnu.so
0x00007fa83479f230  0x00007fa8347a0272  No          /ray/python/ray/thirdparty_files/setproctitle.cpython-37m-x86_64-linux-gnu.so
0x00007fa8346c3880  0x00007fa8346d4b27  No          /ray/python/ray/pickle5_files/pickle5/_pickle.cpython-37m-x86_64-linux-gnu.so
0x00007fa8363d1070  0x00007fa8363d119b  No          /opt/miniconda/lib/python3.7/site-packages/google/protobuf/internal/_api_implementation.cpython-37m-x86_64-linux-gnu.so
0x00007fa834422a80  0x00007fa834567d8a  No          /opt/miniconda/lib/python3.7/site-packages/google/protobuf/pyext/_message.cpython-37m-x86_64-linux-gnu.so
0x00007fa834336040  0x00007fa8343383a6  No          /opt/miniconda/lib/python3.7/lib-dynload/mmap.cpython-37m-x86_64-linux-gnu.so
0x00007fa834325040  0x00007fa83432bbb2  No          /opt/miniconda/lib/python3.7/lib-dynload/array.cpython-37m-x86_64-linux-gnu.so
0x00007fa8342da040  0x00007fa8342dcd8d  No          /opt/miniconda/lib/python3.7/lib-dynload/_hashlib.cpython-37m-x86_64-linux-gnu.so
0x00007fa8342cc040  0x00007fa8342d38eb  No          /opt/miniconda/lib/python3.7/lib-dynload/_blake2.cpython-37m-x86_64-linux-gnu.so
0x00007fa8342b2040  0x00007fa8342c40d6  No          /opt/miniconda/lib/python3.7/lib-dynload/_sha3.cpython-37m-x86_64-linux-gnu.so
0x00007fa8342ab040  0x00007fa8342ab8b7  No          /opt/miniconda/lib/python3.7/lib-dynload/_bisect.cpython-37m-x86_64-linux-gnu.so
0x00007fa8342a5040  0x00007fa8342a6ce7  No          /opt/miniconda/lib/python3.7/lib-dynload/_random.cpython-37m-x86_64-linux-gnu.so
0x00007fa83429a040  0x00007fa83429d7d4  No          /opt/miniconda/lib/python3.7/lib-dynload/zlib.cpython-37m-x86_64-linux-gnu.so
0x00007fa834283040  0x00007fa834291d83  No          /opt/miniconda/lib/python3.7/lib-dynload/_bz2.cpython-37m-x86_64-linux-gnu.so
0x00007fa834277040  0x00007fa83427a214  No          /opt/miniconda/lib/python3.7/lib-dynload/_lzma.cpython-37m-x86_64-linux-gnu.so
0x00007fa83424f040  0x00007fa834265a48  No          /opt/miniconda/lib/python3.7/lib-dynload/../../liblzma.so.5
0x00007fa834247040  0x00007fa83424787c  No          /opt/miniconda/lib/python3.7/lib-dynload/grp.cpython-37m-x86_64-linux-gnu.so
0x00007fa83417f430  0x00007fa834181481  No          /ray/python/ray/thirdparty_files/psutil/_psutil_linux.abi3.so
0x00007fa834178270  0x00007fa8341796d1  No          /ray/python/ray/thirdparty_files/psutil/_psutil_posix.abi3.so
0x00007fa834172040  0x00007fa83417287f  No          /opt/miniconda/lib/python3.7/lib-dynload/resource.cpython-37m-x86_64-linux-gnu.so
0x00007fa83377d380  0x00007fa833ec32f3  No          /opt/miniconda/lib/python3.7/site-packages/grpc/_cython/cygrpc.cpython-37m-x86_64-linux-gnu.so
0x00007fa832f735a0  0x00007fa833284ba8  No          /opt/miniconda/lib/python3.7/site-packages/numpy/core/_multiarray_umath.cpython-37m-x86_64-linux-gnu.so
0x00007fa8310ef000  0x00007fa832ac7154  No          /opt/miniconda/lib/python3.7/site-packages/numpy/core/../../numpy.libs/libopenblasp-r0-2d23e62b.3.17.so
0x00007fa830beb850  0x00007fa830da9378  No          /opt/miniconda/lib/python3.7/site-packages/numpy/core/../../numpy.libs/libgfortran-2e0d59d6.so.5.0.0
0x00007fa8309923b0  0x00007fa8309b913c  No          /opt/miniconda/lib/python3.7/site-packages/numpy/core/../../numpy.libs/libquadmath-2d0c479f.so.0.0.0
0x00007fa8287efb50  0x00007fa828804a5c  No          /opt/miniconda/lib/python3.7/site-packages/numpy/core/_multiarray_tests.cpython-37m-x86_64-linux-gnu.so
0x00007fa8285620d0  0x00007fa8285632c8  No          /opt/miniconda/lib/python3.7/site-packages/numpy/linalg/lapack_lite.cpython-37m-x86_64-linux-gnu.so
0x00007fa828338a10  0x00007fa828355898  No          /opt/miniconda/lib/python3.7/site-packages/numpy/linalg/_umath_linalg.cpython-37m-x86_64-linux-gnu.so
0x00007fa82805bbf0  0x00007fa82806e9a4  No          /opt/miniconda/lib/python3.7/site-packages/numpy/fft/_pocketfft_internal.cpython-37m-x86_64-linux-gnu.so
0x00007fa827d404b0  0x00007fa827d84d0c  No          /opt/miniconda/lib/python3.7/site-packages/numpy/random/mtrand.cpython-37m-x86_64-linux-gnu.so
0x00007fa827b0c310  0x00007fa827b23c74  No          /opt/miniconda/lib/python3.7/site-packages/numpy/random/bit_generator.cpython-37m-x86_64-linux-gnu.so
0x00007fa8278cfd70  0x00007fa8278fee38  No          /opt/miniconda/lib/python3.7/site-packages/numpy/random/_common.cpython-37m-x86_64-linux-gnu.so
0x00007fa82767b2f0  0x00007fa8276bdb1c  No          /opt/miniconda/lib/python3.7/site-packages/numpy/random/_bounded_integers.cpython-37m-x86_64-linux-gnu.so
0x00007fa82745ea90  0x00007fa82746c8fc  No          /opt/miniconda/lib/python3.7/site-packages/numpy/random/_mt19937.cpython-37m-x86_64-linux-gnu.so
0x00007fa827249510  0x00007fa827254f7c  No          /opt/miniconda/lib/python3.7/site-packages/numpy/random/_philox.cpython-37m-x86_64-linux-gnu.so
0x00007fa8270316e0  0x00007fa82703eb7c  No          /opt/miniconda/lib/python3.7/site-packages/numpy/random/_pcg64.cpython-37m-x86_64-linux-gnu.so
0x00007fa826e23f20  0x00007fa826e2a918  No          /opt/miniconda/lib/python3.7/site-packages/numpy/random/_sfc64.cpython-37m-x86_64-linux-gnu.so
0x00007fa826b62740  0x00007fa826bc743c  No          /opt/miniconda/lib/python3.7/site-packages/numpy/random/_generator.cpython-37m-x86_64-linux-gnu.so
0x00007fa826781c20  0x00007fa8267c6524  No          /opt/miniconda/lib/python3.7/site-packages/yaml/_yaml.cpython-37m-x86_64-linux-gnu.so
0x00007fa826737040  0x00007fa826737a8c  No          /opt/miniconda/lib/python3.7/lib-dynload/_queue.cpython-37m-x86_64-linux-gnu.so
0x00007fa834639040  0x00007fa83463a5c1  No          /opt/miniconda/lib/python3.7/lib-dynload/fcntl.cpython-37m-x86_64-linux-gnu.so
0x00007fa8261f0040  0x00007fa8261f4a51  No          /opt/miniconda/lib/python3.7/lib-dynload/unicodedata.cpython-37m-x86_64-linux-gnu.so
0x00007fa8345ef040  0x00007fa8345f2f27  No          /opt/miniconda/lib/python3.7/lib-dynload/_csv.cpython-37m-x86_64-linux-gnu.so
0x00007fa825fb3040  0x00007fa825fdd438  No          /opt/miniconda/lib/python3.7/lib-dynload/pyexpat.cpython-37m-x86_64-linux-gnu.so
0x00007fa825ab9040  0x00007fa825afb3b3  No          /opt/miniconda/lib/python3.7/site-packages/brotli/_brotli.abi3.so
0x00007fa825a8e040  0x00007fa825aa2cd0  No          /opt/miniconda/lib/python3.7/site-packages/_cffi_backend.cpython-37m-x86_64-linux-gnu.so
0x00007fa8258ba040  0x00007fa8258c060e  No          /opt/miniconda/lib/python3.7/lib-dynload/_multibytecodec.cpython-37m-x86_64-linux-gnu.so
0x00007fa825772040  0x00007fa825772bc0  No          /opt/miniconda/lib/python3.7/lib-dynload/termios.cpython-37m-x86_64-linux-gnu.so
0x00007fa8255945c0  0x00007fa82559aa1c  No          /lib/x86_64-linux-gnu/libnss_files.so.2
0x00007fa8255a8340  0x00007fa8255aaa45  No          /opt/miniconda/lib/python3.7/site-packages/pydantic/__init__.cpython-37m-x86_64-linux-gnu.so
0x00007fa8240836f0  0x00007fa8240a31e6  No          /opt/miniconda/lib/python3.7/site-packages/pydantic/dataclasses.cpython-37m-x86_64-linux-gnu.so
0x00007fa824042730  0x00007fa82406eb60  No          /opt/miniconda/lib/python3.7/site-packages/pydantic/class_validators.cpython-37m-x86_64-linux-gnu.so
0x00007fa81c3c5610  0x00007fa81c3e9de6  No          /opt/miniconda/lib/python3.7/site-packages/pydantic/errors.cpython-37m-x86_64-linux-gnu.so
0x00007fa81c333040  0x00007fa81c367b32  No          /opt/miniconda/lib/python3.7/lib-dynload/_decimal.cpython-37m-x86_64-linux-gnu.so
0x00007fa81c2ec720  0x00007fa81c31eaa5  No          /opt/miniconda/lib/python3.7/site-packages/pydantic/typing.cpython-37m-x86_64-linux-gnu.so
0x00007fa81c286850  0x00007fa81c2cfb4d  No          /opt/miniconda/lib/python3.7/site-packages/pydantic/utils.cpython-37m-x86_64-linux-gnu.so
0x00007fa82402c570  0x00007fa824034a66  No          /opt/miniconda/lib/python3.7/site-packages/pydantic/version.cpython-37m-x86_64-linux-gnu.so
0x00007fa824006700  0x00007fa82401dbc8  No          /opt/miniconda/lib/python3.7/site-packages/pydantic/error_wrappers.cpython-37m-x86_64-linux-gnu.so
0x00007fa81c2255f0  0x00007fa81c2335b8  No          /opt/miniconda/lib/python3.7/site-packages/pydantic/json.cpython-37m-x86_64-linux-gnu.so
0x00007fa81c1dc830  0x00007fa81c2116bc  No          /opt/miniconda/lib/python3.7/site-packages/pydantic/color.cpython-37m-x86_64-linux-gnu.so
0x00007fa81c1917b0  0x00007fa81c1c3a3f  No          /opt/miniconda/lib/python3.7/site-packages/pydantic/networks.cpython-37m-x86_64-linux-gnu.so
0x00007fa81c117740  0x00007fa81c176414  No          /opt/miniconda/lib/python3.7/site-packages/pydantic/validators.cpython-37m-x86_64-linux-gnu.so
0x00007fa81c0ef680  0x00007fa81c106cec  No          /opt/miniconda/lib/python3.7/site-packages/pydantic/datetime_parse.cpython-37m-x86_64-linux-gnu.so
0x00007fa81c040840  0x00007fa81c090812  No          /opt/miniconda/lib/python3.7/site-packages/pydantic/types.cpython-37m-x86_64-linux-gnu.so
0x00007fa80036d820  0x00007fa8003e442e  No          /opt/miniconda/lib/python3.7/site-packages/pydantic/fields.cpython-37m-x86_64-linux-gnu.so
0x00007fa8002c9870  0x00007fa80034c9cd  No          /opt/miniconda/lib/python3.7/site-packages/pydantic/main.cpython-37m-x86_64-linux-gnu.so
0x00007fa81c01f5f0  0x00007fa81c02b49c  No          /opt/miniconda/lib/python3.7/site-packages/pydantic/config.cpython-37m-x86_64-linux-gnu.so
0x00007fa81c00b560  0x00007fa81c0142fd  No          /opt/miniconda/lib/python3.7/site-packages/pydantic/parse.cpython-37m-x86_64-linux-gnu.so
0x00007fa8001e07b0  0x00007fa800269c50  No          /opt/miniconda/lib/python3.7/site-packages/pydantic/schema.cpython-37m-x86_64-linux-gnu.so
0x00007fa8001c94e0  0x00007fa8001d0c39  No          /opt/miniconda/lib/python3.7/site-packages/pydantic/annotated_types.cpython-37m-x86_64-linux-gnu.so
0x00007fa8001996c0  0x00007fa8001bcf0b  No          /opt/miniconda/lib/python3.7/site-packages/pydantic/decorator.cpython-37m-x86_64-linux-gnu.so
0x00007fa800160750  0x00007fa800187471  No          /opt/miniconda/lib/python3.7/site-packages/pydantic/env_settings.cpython-37m-x86_64-linux-gnu.so
0x00007fa800148530  0x00007fa8001539d6  No          /opt/miniconda/lib/python3.7/site-packages/pydantic/tools.cpython-37m-x86_64-linux-gnu.so
0x00007fa7e41634e0  0x00007fa7e43542e7  No          /opt/miniconda/lib/python3.7/site-packages/pyarrow/lib.cpython-37m-x86_64-linux-gnu.so
0x00007fa69e0e0000  0x00007fa69f70523a  No          /opt/miniconda/lib/python3.7/site-packages/pyarrow/libarrow.so.600
0x00007fa7cc2ffd40  0x00007fa7cc3babc9  No          /opt/miniconda/lib/python3.7/site-packages/pyarrow/libarrow_python.so.600
0x00007fa7e40728d0  0x00007fa7e408b0f7  No          /opt/miniconda/lib/python3.7/site-packages/pyarrow/_hdfsio.cpython-37m-x86_64-linux-gnu.so
0x00007fa7e401d5c0  0x00007fa7e4025776  No          /opt/miniconda/lib/python3.7/site-packages/pyarrow/_json.cpython-37m-x86_64-linux-gnu.so
$2 = "MEMRAY: Checking if process is Python 3.7+."
$3 = {void *(size_t)} 0x55d8d988ab40 <PyMem_Malloc>
$4 = {void *(size_t, size_t)} 0x55d8d988c670 <PyMem_Calloc>
$5 = {void *(void *, size_t)} 0x55d8d988aab0 <PyMem_Realloc>
$6 = {void (void *)} 0x55d8d98827b0 <PyMem_Free>
$7 = "MEMRAY: Process is Python 3.7+."
Breakpoint 1 at 0x7fa836e800e0: file malloc.c, line 3023.
Breakpoint 2 at 0x7fa836e81b10: file malloc.c, line 3366.
Breakpoint 3 at 0x7fa836e80e80: file malloc.c, line 3131.
Breakpoint 4 at 0x7fa836e806d0: file malloc.c, line 3087.
Breakpoint 5 at 0x55d8d988ab40: file /tmp/build/80754af9/python_1598874792229/work/Objects/obmalloc.c, line 549.
Breakpoint 6 at 0x55d8d988c670: file /tmp/build/80754af9/python_1598874792229/work/Objects/obmalloc.c, line 558.
Breakpoint 7 at 0x55d8d988aab0: file /tmp/build/80754af9/python_1598874792229/work/Objects/obmalloc.c, line 567.
Breakpoint 8 at 0x55d8d98827b0: file /tmp/build/80754af9/python_1598874792229/work/Objects/obmalloc.c, line 577.
[Switching to Thread 0x7fa7ce1fc700 (LWP 3052)]

Thread 28 "ray::IDLE" hit Breakpoint 4, __GI___libc_free (mem=0x7fa698001110) at malloc.c:3087
3087	malloc.c: No such file or directory.
[Inferior 1 (process 3009) detached]

When I ran $(which memray) attach -o /tmp/pytest-of-root/pytest-5/test_memory_profiler0/profile/3009_memory_profiling.bin --verbose 3803 inside a ubuntu container, it fails with the following error.

Expected Behavior

It should attach successfully (It worked on my local Mac).

Steps To Reproduce

python 3.7.9

pip install ray
Run ray start --head

# test.py
import ray
ray.init()
@ray.remote
class A:
    pass

a = A.options(lifetime="detached").remote()
import time
time.sleep(5)

python test.py
ray list actors and get the pid. Note that ray actor is just a python process.

$(which memray) attach -o /tmp/pytest-of-root/pytest-5/test_memory_profiler0/profile/3009_memory_profiling.bin --verbose

We use the container based off of ubuntu:focal

Some deps we downloaded;

RUN apt-get update -qq && apt-get upgrade -qq
RUN apt-get install -y -qq \
    curl python-is-python3 git build-essential \
    sudo unzip unrar apt-utils dialog tzdata wget rsync \
    language-pack-en tmux cmake gdb vim htop \
    libgtk2.0-dev zlib1g-dev libgl1-mesa-dev \
    liblz4-dev libunwind-dev libncurses5 \
    clang-format-12 jq \
    clang-tidy-12 clang-12
# Make using GCC 9 explicit.
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90 --slave /usr/bin/g++ g++ /usr/bin/g++-9 \
    --slave /usr/bin/gcov gcov /usr/bin/gcov-9
RUN ln -s /usr/bin/clang-format-12 /usr/bin/clang-format && \
    ln -s /usr/bin/clang-tidy-12 /usr/bin/clang-tidy && \
    ln -s /usr/bin/clang-12 /usr/bin/clang

RUN curl -o- https://get.docker.com | sh

Memray Version

1.6.0. But I also tried 1.5.0

Python Version

3.7

Operative System

Linux

Anything else?

No response

@rkooo567 rkooo567 added the bug Something isn't working label Jan 30, 2023
@rkooo567
Copy link
Author

Also, I tried download lldb and tried. When I used that, it hangs instead of failing immediately like gdb

@rkooo567
Copy link
Author

oh also, I think this environment (it is our CI) may use dind (docker in docker).

@godlygeek
Copy link
Contributor

godlygeek commented Jan 30, 2023

Hm. It's not a problem that it couldn't find malloc.c. It doesn't need it, and that shouldn't make it fail.

But, there should be more output after that. When I follow your reproduction steps above, sometimes everything works fine, and the output shows:

Thread 29 "worker.io" hit Breakpoint 1, __GI___libc_malloc (bytes=88) at malloc.c:3023
3023    malloc.c: No such file or directory.
$8 = (void *) 0x7f877003ce50
$9 = 0x0
[New Thread 0x7f865bfff700 (LWP 7751)]
$10 = "SUCCESS"

Other times it fails, with output exactly like you show. It looks like the problem is in gdb. The gdb script that we're running executes this command:

commands 1 2 3 4 5 6 7 8

Which the help built in to the gdb in Focal says is supported syntax!

(gdb) help commands
Set commands to be executed when the given breakpoints are hit.
Give a space-separated breakpoint list as argument after "commands".
A list element can be a breakpoint number (e.g. `5') or a range of numbers
(e.g. `5-7').
With no argument, the targeted breakpoint is the last one set.
The commands themselves follow starting on the next line.
Type a line containing "end" to indicate the end of them.
Give "silent" as the first line to make the breakpoint silent;
then no output is printed when it is hit, except what the commands print.

Despite what the GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2 manual says, the space-separated list is not actually working, and the commands are only getting associated with the first breakpoint, and not the other 7. If I change that line to breakpoint 1-8, things seem to work properly, though I still see an intermittent issue with reporting stack traces that I need to dig into further...

If you want to try that change out yourself, the relevant file is memray/commands/_attach.gdb

@godlygeek
Copy link
Contributor

The lldb one is even weirder. The debugger is exiting without resuming the process that it was attached to. If you manually resume the process by sending it a SIGCONT signal, everything works just fine.

That workaround seems horrific, and this feels like it must be an lldb bug (possibly unique to --batch mode?), but I haven't yet managed to find any other reports of it...

@godlygeek
Copy link
Contributor

I've entered llvm/llvm-project#60408 for what appears to be an lldb bug explaining the hang you get with lldb.

@rkooo567
Copy link
Author

@godlygeek thanks for looking into the issue! Oddly, I found the issue never (or it probably rarely) occurs when I tested on my Mac OS (not sure if this can help your debugging though). Maybe GDB commands work different between mac and linux?

If I change that line to breakpoint 1-8, things seem to work properly, though I still see an intermittent issue with reporting stack traces that I need to dig into further...

Sounds good! Let me know when the fix is merged! I'd love to try it out! We are experimenting to introduce memray as a runtime memory profiling of ray (https://github.com/ray-project/ray/), and this issue seems to be the biggest blocker because I cannot run tests in the CI at all now because of this issue :(

@godlygeek
Copy link
Contributor

I've confirmed that the gdb behavior is a bug - and it's one that was fixed upstream a few years back, by da1df1d - but of course, Focal is a few years old now, too, so it doesn't have that fix.

It seems that the workaround of using a range instead of a list of breakpoint numbers happens to work mostly by chance, but it does work, because of the different way in which ranges of breakpoint numbers are processed.

@rkooo567
Copy link
Author

rkooo567 commented Feb 6, 2023

Awesome! Will this fix be included in the next release? When do you guys plan to have one?

@rkooo567
Copy link
Author

rkooo567 commented Feb 6, 2023

I will also try verifying it with my environment. Can you guide me how I can download the latest master wheel? (or should I wait for next release?)

@godlygeek
Copy link
Contributor

Hey @rkooo567 - this will be included in the next release, which I hope will happen within the next few weeks. We don't have wheels of master, but since this change is in a text file, you can just patch it into the latest Memray wheel yourself:

$ python3.7 -m pip download memray --no-deps
$ unzip ./memray-1.6.0-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
$ sed -i 's/1 2 3 4 5 6 7 8/1-8/' memray/commands/_attach.gdb
$ zip -r memray-1.6.0-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl */

That asks pip to download the wheel for the last release (this is Python version specific, so since you used Python 3.7 in your bug report that's what I used here), then it unzips the wheel (wheels are just zip files in disguise), uses sed to fix up the GDB script, and zips the wheel back up.

If you feel like testing that, I'd love confirmation that it works for you, but if not, I anticipate a release with the fix should be coming pretty soon, once we finish a few other features that we're working on finalizing.

@godlygeek
Copy link
Contributor

(Or instead of modifying the wheel, you can of course just install the wheel and then use sed to just patch the gdb script after it's been installed!)

@rkooo567
Copy link
Author

I will probably try this out next week! Looking forward to the next release

@godlygeek
Copy link
Contributor

The 1.7.0 release from last week includes this fix.

Let us know if you're still seeing any issues with that version, @rkooo567!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants