Skip to content

Conversation

@theraininsky
Copy link
Contributor

@theraininsky theraininsky commented Feb 12, 2025

Global variable initialize sequence is undefined across multiple components, and could introduce unexpected behaviors.
In my case, llama-bench is completely broken with my MSVC compiler.
In short, the initialize sequence of these two global variable causes the problem:
const std::string test::cpu_info = get_cpu_info(); and static vk_instance_t vk_instance;
Here's the detailed calling sequence:
1.Firstly, const std::string test::cpu_info = get_cpu_info(); getting initialized, and get_cpu_info() uses the uninitialized global variable static vk_instance_t vk_instance; unexpectedly:
vk_instance.instance = vk::createInstance(instance_create_info);
2.Then static vk_instance_t vk_instance; getting initialized, and zeroed out the previous filled vk_instance.instance, and causing all the following calling sequence failed.

@slaren slaren merged commit a7b8ce2 into ggml-org:master Feb 14, 2025
1 check passed
orca-zhang pushed a commit to orca-zhang/llama.cpp that referenced this pull request Feb 26, 2025
ggml-org#11832)

* llama-bench : fix unexpected global variable initialize sequence issue

* Update examples/llama-bench/llama-bench.cpp

---------

Co-authored-by: Diego Devesa <[email protected]>
arthw pushed a commit to arthw/llama.cpp that referenced this pull request Feb 26, 2025
ggml-org#11832)

* llama-bench : fix unexpected global variable initialize sequence issue

* Update examples/llama-bench/llama-bench.cpp

---------

Co-authored-by: Diego Devesa <[email protected]>
mglambda pushed a commit to mglambda/llama.cpp that referenced this pull request Mar 8, 2025
ggml-org#11832)

* llama-bench : fix unexpected global variable initialize sequence issue

* Update examples/llama-bench/llama-bench.cpp

---------

Co-authored-by: Diego Devesa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants