bcc
bcc copied to clipboard
Stackcollapse issues with output from bcc's mallocstacks.py
Is there a specific stackcollapse script that works with the output of the mallocstacks.py version in iovisor/bcc? I've run this script and generates stacks like:
malloc+0x0
Attaching to malloc in pid 12744, Ctrl+C to quit.
380928 bytes allocated at:
UnmanagedMemory_malloc_e771cd5a636f1d1ddaa55ba896a102f328c04fda+0x17
Unsafe_allocateMemory_6ab8a5ef1159e68fb35483ee78388b05c345ae44+0x4e
EPollSelectorImpl_constructor_e766728b6679c7c5e8eabbee0cfd0f70e475eb9e+0x303
NioEventLoop_openSelector_a98c4c1fde2d2766fa4075be761910d1644ea8f3+0xc2
NioEventLoop_constructor_028fef7272962462688d7328ac11db5a2121187e+0x2e4
NioEventLoopGroup_newChild_9efbfe1f828b1c5d178f1583c0e1374692b641f4+0x18c
MultithreadEventExecutorGroup_constructor_7ff0062598de99aac4b3b44439aa0eba0a2843f1+0x2ef
MultithreadEventExecutorGroup_constructor_8065881a5eaca808323d46dcb6b44d43723c3c29+0x9d
Transport_eventLoopGroup_ee4a3052dc2152541ce73463072570ddd5994765+0x16b
VertxImpl_constructor_80d00396d68392bbd263011f0698431a464c816c+0x7bc
VertxBuilder_vertx_86c4d260a7bb5352a6d3d8245b7e64b0114eb27a+0xf2
VertxCoreRecorder_initialize_aaf29a27cdf86a993cbc54b4e9974703a6d03613+0x2e5
VertxCoreRecorder$VertxSupplier_get_933aa744d9166b784d03d36421df70bdd55027d1+0x8a
VertxCoreRecorder$VertxSupplier_get_52c96bc8af0bec88a61cfaffe07b92f472ca12ac+0x17
VertxHttpRecorder_initializeRouter_c0e44ca8f166b805ce796ed6560e6c30b5da1274+0x32
VertxHttpProcessor$preinitializeRouter1141331088_deploy_0_eb454017235d0c767bf7a14871e6f0a7102409c7+0x1b1
ApplicationImpl_doStart_4f75ecc76b43645d5297b6092848747808c532c7+0xe6e
Application_start_f0300884f5c38b6448504f5177e19dff60a47b71+0x121
ApplicationLifecycleManager_run_d5cb017ad26675ebbd7be504099501fde301d161+0x128
Quarkus_run_7b200c41008a3c5f18cd42d608d602b518bc6c94+0xd7
JavaMainWrapper_runCore0_030cf55ee73b0e1076836b52cdbbde2ffc0c5232+0x206
JavaMainWrapper_doRun_befa12b002bb2c4ede2c3e72011cc12e1c7fe82a+0x89
main+0x43
__libc_start_call_main+0x80
malloc+0x0
94331 bytes allocated at:
malloc+0x0
12288 bytes allocated at:
UnmanagedMemory_malloc_e771cd5a636f1d1ddaa55ba896a102f328c04fda+0x17
Unsafe_allocateMemory_6ab8a5ef1159e68fb35483ee78388b05c345ae44+0x4e
EPollSelectorImpl_constructor_e766728b6679c7c5e8eabbee0cfd0f70e475eb9e+0x303
NioEventLoop_openSelector_a98c4c1fde2d2766fa4075be761910d1644ea8f3+0xc2
NioEventLoop_constructor_028fef7272962462688d7328ac11db5a2121187e+0x2e4
NioEventLoopGroup_newChild_9efbfe1f828b1c5d178f1583c0e1374692b641f4+0x18c
MultithreadEventExecutorGroup_constructor_7ff0062598de99aac4b3b44439aa0eba0a2843f1+0x28b
MultithreadEventExecutorGroup_constructor_8065881a5eaca808323d46dcb6b44d43723c3c29+0x9d
Transport_eventLoopGroup_ee4a3052dc2152541ce73463072570ddd5994765+0x16b
VertxImpl_constructor_80d00396d68392bbd263011f0698431a464c816c+0x7bc
VertxBuilder_vertx_86c4d260a7bb5352a6d3d8245b7e64b0114eb27a+0xf2
VertxCoreRecorder_initialize_aaf29a27cdf86a993cbc54b4e9974703a6d03613+0x2e5
VertxCoreRecorder$VertxSupplier_get_933aa744d9166b784d03d36421df70bdd55027d1+0x8a
VertxCoreRecorder$VertxSupplier_get_52c96bc8af0bec88a61cfaffe07b92f472ca12ac+0x17
VertxHttpRecorder_initializeRouter_c0e44ca8f166b805ce796ed6560e6c30b5da1274+0x32
VertxHttpProcessor$preinitializeRouter1141331088_deploy_0_eb454017235d0c767bf7a14871e6f0a7102409c7+0x1b1
ApplicationImpl_doStart_4f75ecc76b43645d5297b6092848747808c532c7+0xe6e
Application_start_f0300884f5c38b6448504f5177e19dff60a47b71+0x121
ApplicationLifecycleManager_run_d5cb017ad26675ebbd7be504099501fde301d161+0x128
Quarkus_run_7b200c41008a3c5f18cd42d608d602b518bc6c94+0xd7
JavaMainWrapper_runCore0_030cf55ee73b0e1076836b52cdbbde2ffc0c5232+0x206
JavaMainWrapper_doRun_befa12b002bb2c4ede2c3e72011cc12e1c7fe82a+0x89
main+0x43
__libc_start_call_main+0x80
malloc+0x0
But I can't find a stackcollapse script in FlameGraph that works with that. The output looks a bit the BPF one but if that's the case, it's not formatted as expected.
Thoughts?
Has anyone found a workaround for this?
Edit: It seems like adding a print statement "fixes" the issue, and stackcollapse now recognizes the output format
https://github.com/iovisor/bcc/blob/472f9b3bd6bcc63e6e959148320eb76184c51870/examples/tracing/mallocstacks.py#L68-L72 ➡️
for k, v in reversed(sorted(calls.items(), key=lambda c: c[1].value)):
print("%d bytes allocated at:" % v.value)
if k.value > 0 :
for addr in stack_traces.walk(k.value):
printb(b"\t%s" % b.sym(addr, pid, show_offset=True))
print(" %d\n" % v.value)