Open joeyjiaojg opened 1 year ago
Can you make the test file available somewhere? Or provide a standalone test? Thanks.
CC @thanm @aclements
vmlinux is too big to share. So I'm searching the first "rcu_read_unlock" and its DW_AT_abstract_origin.
LLVM=1 ARCH=x86_64 SRCARCH=x86 make -j$(nproc)
with CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y
set in .config.$ ./test vmlinux 0x000142a4 0x000160ed
&{82596 Subprogram true [{Lowpc 18446744071578850531 ClassAddress} {Highpc 112 ClassConstant} {FrameBase [87] ClassExprLoc} {CallAllCalls true ClassFlag} {AbstractOrigin 90349 ClassReference}]}
&{90349 Subprogram false [{Name **event_class_initcall_level** ClassString} {DeclFile 232 ClassConstant} {DeclLine 765 ClassConstant} {Prototyped true ClassFlag} {Inline 1 ClassConstant}]}
$ ./test init/main.o 0x00012b27 0x00014970
&{76583 Subprogram true [{Lowpc 1256 ClassAddress} {Highpc 112 ClassConstant} {FrameBase [87] ClassExprLoc} {CallAllCalls true ClassFlag} {AbstractOrigin 84336 ClassReference}]}
&{84336 Subprogram false [{Name **rcu_read_lock** ClassString} {DeclFile 232 ClassConstant} {DeclLine 765 ClassConstant} {Prototyped true ClassFlag} {Inline 1 ClassConstant}]}
Test program
package main
import (
"fmt"
"debug/dwarf"
"debug/elf"
"os"
"strconv"
)
func main() {
file, err := elf.Open(os.Args[1])
if err != nil {
return
}
debugInfo, err := file.DWARF()
if err != nil {
return
}
val, _ := strconv.ParseUint(os.Args[2], 0, 64)
ent, _ := getEntryByOffset(debugInfo, dwarf.Offset(val))
fmt.Printf("%v\n", ent)
val, _ = strconv.ParseUint(os.Args[3], 0, 64)
ent, _ = getEntryByOffset(debugInfo, dwarf.Offset(val))
fmt.Printf("%v\n", ent)
}
func getEntryByOffset(debugInfo *dwarf.Data, offset dwarf.Offset) (*dwarf.Entry, error) {
r := debugInfo.Reader()
r.Seek(offset)
return r.Next()
}
Attach the init/main.o instead https://github.com/joeyjiaojg/go/raw/master/test/dwarf/dwarf5.o
It's going to be difficult for us to fix this problem if we can't recreate it ourselves. Anything you can do to make that possible would be appreciated. Thanks.
you can reproduce
bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)
git clone https://github.qualcomm.com/LinuxSecurity/syzkaller
git clone https://github.com/torvalds/linux
cp syzkaller/src/github.com/google/syzkaller/dashboard/config/linux/upstream-apparmor-kasan.config linux/.config
cd linux
LLVM=1 ARCH=x86_64 SRCARCH=x86 make -j$(nproc) olddefconfig
LLVM=1 ARCH=x86_64 SRCARCH=x86 make -j$(nproc)
To avoid confusion, you can use the test steps below only:
wget https://github.com/joeyjiaojg/go/raw/master/test/dwarf/dwarf5.o
copy code in https://github.com/golang/go/issues/57046#issuecomment-1336625504 to test.go
go build test.go
./test init/main.o 0x00012b27 0x00014970
&{76583 Subprogram true [{Lowpc 1256 ClassAddress} {Highpc 112 ClassConstant} {FrameBase [87] ClassExprLoc} {CallAllCalls true ClassFlag} {AbstractOrigin 84336 ClassReference}]}
&{84336 Subprogram false [{Name **rcu_read_lock** ClassString} {DeclFile 232 ClassConstant} {DeclLine 765 ClassConstant} {Prototyped true ClassFlag} {Inline 1 ClassConstant}]}
Timed out in state WaitingForInfo. Closing.
(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)
Reopening because @joeyjiaojg provided repro instructions.
What version of Go are you using (
go version
)?go 1.19.3
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?What did you do?
Above is extracted from vmlinux (compiled by clang-15) by llvm-dwarfdump-15, when linux kernel compiled with DWARF5 debug info, go debug/dwarf can't decode entry at 0x000160e6 correctly.
Test program
What did you expect to see?
The 2nd printf should print ent name as rcu_read_unlock.
What did you see instead?
The 2nd printf should print ent name of some other subprogram.