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

开启asan时,包会自动使用debug版本 #6139

Open
limibo777 opened this issue Feb 7, 2025 · 20 comments
Open

开启asan时,包会自动使用debug版本 #6139

limibo777 opened this issue Feb 7, 2025 · 20 comments
Labels

Comments

@limibo777
Copy link

limibo777 commented Feb 7, 2025

Xmake 版本

2.9.6

操作系统版本和架构

Linux debian 6.1.0-28-amd64

描述问题

set_policy("build.sanitizer.address", true)
add_requires("fmt =10.2.1", { system = false, debug=false, configs = { shared = true}})
add_requires("zeromq =4.3.4", { system = false, configs = { shared = true}})

target ("test")
add_packages("fmt")
add_packages("zeromq")
set_kind("binary")
add_files("test.cpp")

xmake f -m asan
xmake -av
添加的so为debug版本

换成tsan的方式set_policy("build.sanitizer.thread", true)使用的则是release版本的so

工程配置

xmake.lua
set_policy("build.sanitizer.address", true)

add_requires("fmt =10.2.1", { system = false, debug=false, configs = { shared = true}})
add_requires("zeromq =4.3.4", { system = false, configs = { shared = true}})

target ("test")

add_packages("fmt")
add_packages("zeromq")

set_kind("binary")
add_files("test.cpp")
set_targetdir("bin")
set_basename("test")

test.cpp
#include <fmt/format.h>
#include
#include <assert.h>
static void test() {
std::string s = fmt::format("{}", "hello");
assert(s == "hello");
}

int main()
{
test();
return 0;
}

附加信息和错误日志

/usr/bin/g++ -o bin/test build/.objs/test/linux/x86_64/asan/test.cpp.o -m64 -L/home/qwqe/.xmake/packages/f/fmt/10.2.1/3b4266b216a9438eb7a3de6ef0d67a72/lib -L/home/qwqe/.xmake/packages/z/zeromq/4.3.4/653b8975302f43ab9b0e57200b529ebb/lib -lfmtd -lzmq -lpthread -fsanitize=address

@limibo777 limibo777 added the bug label Feb 7, 2025
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Title: When asan is enabled, the package fmt will automatically use the debug version

@limibo777 limibo777 reopened this Feb 7, 2025
@limibo777 limibo777 changed the title 开启asan时,包fmt会自动使用debug版本 开启asan时,包会自动使用debug版本 Feb 7, 2025
@waruqi
Copy link
Member

waruqi commented Feb 7, 2025

是否 debug 只跟 debug = true 配置有关。

https://github.com/xmake-io/xmake-repo/blob/d7a0779921ae2ce42700398f1ecaa0995fca491b/packages/f/fmt/xmake.lua#L72

没有根据 asan 去设置 debug 的逻辑,除非 cmake 自己切了。你可以调下 包

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Whether debugging is only related to the debug = true configuration.

https://github.com/xmake-io/xmake-repo/blob/d7a0779921ae2ce42700398f1ecaa0995fca491b/packages/f/fmt/xmake.lua#L72

There is no logic to set debug based on asan, unless cmake cuts it by itself. You can adjust the package

@limibo777
Copy link
Author

是否 debug 只跟 debug = true 配置有关。

https://github.com/xmake-io/xmake-repo/blob/d7a0779921ae2ce42700398f1ecaa0995fca491b/packages/f/fmt/xmake.lua#L72

没有根据 asan 去设置 debug 的逻辑,除非 cmake 自己切了。你可以调下 包

并不只是fmt的问题,貌似是开启asan会设置debug=true,对项目和packages都生效了,但是tsan只对项目生效了,对packages不生效

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Whether debugging is only related to the debug = true configuration.

https://github.com/xmake-io/xmake-repo/blob/d7a0779921ae2ce42700398f1ecaa0995fca491b/packages/f/fmt/xmake.lua#L72

There is no logic to set debug based on asan, unless cmake cuts it by itself. You can adjust the package

It's not just a problem with fmt. It seems that if you enable asan, you will set debug=true, which will take effect on both the project and packages, but tsan only takes effect on the project and does not take effect on packages.

@waruqi
Copy link
Member

waruqi commented Feb 7, 2025

并不只是fmt的问题,貌似是开启asan会设置debug=true,对项目和packages都生效了,但是tsan只对项目生效了,对packages不生效

那跟 debug 是两个问题,目前包仅仅支持 asan 不支持 tsan

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


It's not just a problem with fmt. It seems that if you enable asan, you will set debug=true, which will take effect on both the project and packages, but tsan only takes effect on the project and does not take effect on packages.

That is two different problems with debug. Currently, the package only supports asan but not tsan.

@star-hengxing
Copy link
Contributor

目前实现

-- is debug package?
function _instance:is_debug()
return self:config("debug") or self:config("asan")
end

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Currently implemented

-- is debug package?
function _instance:is_debug()
return self:config("debug") or self:config("asan")
end

@waruqi
Copy link
Member

waruqi commented Feb 7, 2025

哦,目前 asan 是默认 debug 的,因为要看栈,否则跑出来也看不到栈。除非单独加 -g ,tsan 目前包不支持,不会去处理

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Oh, currently asan is the default debug because you have to look at the stack, otherwise you won’t be able to see the stack even if you run out. Unless -g is added separately, the tsan package is not supported at present and will not be processed.

@limibo777
Copy link
Author

哦,目前 asan 是默认 debug 的,因为要看栈,否则跑出来也看不到栈。除非单独加 -g ,tsan 目前包不支持,不会去处理

谢谢,我已经了解这个现象出现的原因。
还有两个问题想请教下
1.AddressSanitizer官方推荐的编译配置是 -O1 -fno-omit-frame-pointer 是能看到栈信息的,为何这里asan要强制debug
2.tsan也会强制debug,但是对应的包不会强制debug,这不合理,后续是否会增加tsan(同时msan,ubsan也是一样)对包的支持

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Oh, currently asan is the default debug because you have to look at the stack, otherwise you won’t be able to see the stack even if you run out. Unless -g is added separately, the tsan package is not supported at present and will not be processed.

Thank you, I already understand the reason for this phenomenon.
There are two more questions I would like to ask

  1. The official recommended compilation configuration of AddressSanitizer is -O1 -fno-omit-frame-pointer. You can see the stack information. Why does asan force debugging here?
    2.tsan will also force debugging, but the corresponding package will not force debugging. This is unreasonable. Will tsan be added in the future (at the same time, msan and ubsan are the same) support for packages.

1 similar comment
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Oh, currently asan is the default debug because you have to look at the stack, otherwise you won’t be able to see the stack even if you run out. Unless -g is added separately, the tsan package is not supported at present and will not be processed.

Thank you, I already understand the reason for this phenomenon.
There are two more questions I would like to ask

  1. The official recommended compilation configuration of AddressSanitizer is -O1 -fno-omit-frame-pointer. You can see the stack information. Why does asan force debugging here?
    2.tsan will also force debugging, but the corresponding package will not force debugging. This is unreasonable. Will tsan be added in the future (at the same time, msan and ubsan are the same) support for packages.

@waruqi
Copy link
Member

waruqi commented Feb 10, 2025

哦,目前 asan 是默认 debug 的,因为要看栈,否则跑出来也看不到栈。除非单独加 -g ,tsan 目前包不支持,不会去处理

谢谢,我已经了解这个现象出现的原因。 还有两个问题想请教下 1.AddressSanitizer官方推荐的编译配置是 -O1 -fno-omit-frame-pointer 是能看到栈信息的,为何这里asan要强制debug 2.tsan也会强制debug,但是对应的包不会强制debug,这不合理,后续是否会增加tsan(同时msan,ubsan也是一样)对包的支持

-O1 -fno-omit-frame-pointer 是能看到栈信息的

这只是能取栈把,没加 -g 哪来的符号?怎么还原栈 定位到具体代码行号?

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Oh, currently asan is the default debug because you have to look at the stack, otherwise you won’t be able to see the stack even if you run out. Unless -g is added separately, the tsan package is not supported at present and will not be processed.

Thank you, I already understand the reason for this phenomenon. There are two more questions I would like to ask about 1. The official compilation configuration recommended by AddressSanitizer is -O1 -fno-omit-frame-pointer. You can see the stack information. Why does asan force debugging here? 2.tsan also force debugging, but The corresponding package will not force debugging, which is unreasonable. Will tsan be added in the future (at the same time, msan and ubsan are the same) support for packages

-O1 -fno-omit-frame-pointer can see stack information

This is just a stack handle, without adding -g where does the symbol come from? How to restore the stack and locate the specific code line number?

@limibo777
Copy link
Author

哦,目前 asan 是默认 debug 的,因为要看栈,否则跑出来也看不到栈。除非单独加 -g ,tsan 目前包不支持,不会去处理

谢谢,我已经了解这个现象出现的原因。 还有两个问题想请教下 1.AddressSanitizer官方推荐的编译配置是 -O1 -fno-omit-frame-pointer 是能看到栈信息的,为何这里asan要强制debug 2.tsan也会强制debug,但是对应的包不会强制debug,这不合理,后续是否会增加tsan(同时msan,ubsan也是一样)对包的支持

-O1 -fno-omit-frame-pointer 是能看到栈信息的

这只是能取栈把,没加 -g 哪来的符号?怎么还原栈 定位到具体代码行号?

是的,需要加-g来定位具体代码行号,请问下tsan msan ubsan也都是按照debug方式编译的,但是引入的包还是用的release版本,后续会增加对包的支持吗

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Oh, currently asan is the default debug because you have to look at the stack, otherwise you won’t see the stack even if you run out. Unless -g is added separately, the tsan package is not supported at present and will not be processed.

Thank you, I already understand the reason for this phenomenon. There are two more questions I would like to ask about 1. The official compilation configuration recommended by AddressSanitizer is -O1 -fno-omit-frame-pointer. You can see the stack information. Why does asan force debugging here? 2.tsan also force debugging, but The corresponding package will not force debugging, which is unreasonable. Will tsan be added in the future (at the same time, msan and ubsan are the same) support for packages

-O1 -fno-omit-frame-pointer can see stack information

This is just a stack handle, without adding -g where does the symbol come from? How to restore the stack and locate the specific code line number?

Yes, you need to add -g to locate the specific code line number. Can you ask if tsan msan ubsan is also compiled according to debug mode, but the packages introduced still use the release version. Will the package support be added in the future?

@waruqi
Copy link
Member

waruqi commented Feb 10, 2025

这几个不太常用,目前不考虑,后面看情况。 可以自己直接传 cxflags ldflags 给 add_requires 来开启

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


These are not commonly used, so I won’t consider it at the moment, and it depends on the situation later. You can directly pass cxflags ldflags to add_requires to start

@limibo777 limibo777 reopened this Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants