Skip to contentSkip to conversation

LTO breaks tools

tools Marcel Röthke 2 participants 2 messages Jun 21, 2024 – Jul 10, 2024

lore
Share & tools
lore
#0 lore raw

Hi,

I noticed that at least the format subcommand of the bcachefs tools breaks when compiling with LTO. By breaking I mean that it segfaults. I think the cause is commit fc06a0ea5e552663e9e47de941fbc7e621d4ca46 between versions 1.7.0 and 1.9.0.

I noticed this first with the official archlinux package, but can reproduce it by compiling from source with CFLAGS=-flto=auto make

And here is the stacktrace for completeness.
Thread 17 "btree_update" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff78d2680 (LWP 212449)]
bch2_trans_start_alloc_update (trans=0x7fffe4001000, pos=...) at libbcachefs/alloc_background.c:480
480 {
(gdb) bt
#0 bch2_trans_start_alloc_update (trans=0x7fffe4001000, pos=...) at libbcachefs/alloc_background.c:480
#1 0x000055555580249e in bch2_trigger_pointer (trans=<optimized out>, btree_id=<optimized out>, level=<optimized out>, k=..., p=..., entry=<optimized out>,
sectors=<synthetic pointer>, flags=<optimized out>) at libbcachefs/buckets.c:572
#2 __trigger_extent (trans=<optimized out>, btree_id=<optimized out>, level=<optimized out>, k=..., flags=<optimized out>) at libbcachefs/buckets.c:724 #3 0x00005555557f6e5d in bch2_key_trigger (trans=0x7fffe4001000, btree=<optimized out>, level=<optimized out>, old=..., new=...,
flags=(BTREE_TRIGGER_transactional | BTREE_TRIGGER_insert)) at libbcachefs/bkey_methods.h:88

#4  bch2_key_trigger_new (trans=0x7fffe4001000, btree_id=<optimized out>, level=<optimized out>, new=..., flags=BTREE_TRIGGER_transactional) at libbcachefs/bkey_methods.h:116
#5  btree_update_nodes_written_trans (trans=0x7fffe4001000, as=<optimized out>) at libbcachefs/btree_update_interior.c:658
#6  btree_update_nodes_written (as=0x555555e0a800) at libbcachefs/btree_update_interior.c:721
#7  btree_interior_update_work (work=0x7ffff7ace5d0) at libbcachefs/btree_update_interior.c:859
#8  0x00005555558957a0 in worker_thread (arg=0x555555cc0040) at linux/workqueue.c:262
#9  0x000055555588968a in kthread_start_fn (data=<optimized out>) at linux/kthread.c:25

#10 0x00007ffff7be4ded in start_thread (arg=<optimized out>) at pthread_create.c:447 #11 0x00007ffff7c680dc in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

#1 lore raw
Quoted 9 lines

Hi,

I noticed that at least the format subcommand of the bcachefs tools breaks when compiling with LTO. By breaking I mean that it segfaults. I think the cause is commit fc06a0ea5e552663e9e47de941fbc7e621d4ca46 between versions 1.7.0 and 1.9.0.

I noticed this first with the official archlinux package, but can reproduce it by compiling from source with CFLAGS=-flto=auto make

I can reproduce this. Sent a PR fixing it here:
https://github.com/koverstreet/bcachefs-tools/pull/304