[PR #736] fix: return default_value from get_env<int> on unparsable env values #743

Open
opened 2026-10-27 21:05:48 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/deepseek-ai/DeepEP/pull/736
Author: @shoemoney
Created: 8/23/2026
Status: 🔄 Open

Base: main ← Head: fix/get-env-uninitialized


📝 Commits (1)

  • 8686bd5 fix: return default_value from get_env on unparsable env values

📊 Changes

1 file changed (+3 additions, -2 deletions)

View changed files

📝 csrc/utils/system.hpp (+3 -2)

📄 Description

get_env<int> (csrc/utils/system.hpp) declared int value; uninitialized and ignored sscanf's return value. Any env value %d cannot parse (true, false, on, off, empty string) returned indeterminate stack memory instead of falling back to default_value. In practice the garbage is usually non-zero, so EP_BUFFER_DEBUG=false reads as enabled. This helper backs 20+ env reads across the codebase.

The fix initializes value to default_value and returns default_value when sscanf does not report a successful conversion.

Verified with a standalone host build of the header: before the change, EP_X=false with default 7 returned 1 (uninitialized stack); after, it returns 7, EP_X=42 returns 42, and unset still returns the default.

Fixes #733


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/deepseek-ai/DeepEP/pull/736 **Author:** [@shoemoney](https://github.com/shoemoney) **Created:** 8/23/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/get-env-uninitialized` --- ### 📝 Commits (1) - [`8686bd5`](https://github.com/deepseek-ai/DeepEP/commit/8686bd5c365d240767b2e3e6a73664a83e4270db) fix: return default_value from get_env<int> on unparsable env values ### 📊 Changes **1 file changed** (+3 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `csrc/utils/system.hpp` (+3 -2) </details> ### 📄 Description `get_env<int>` (csrc/utils/system.hpp) declared `int value;` uninitialized and ignored sscanf's return value. Any env value `%d` cannot parse (`true`, `false`, `on`, `off`, empty string) returned indeterminate stack memory instead of falling back to `default_value`. In practice the garbage is usually non-zero, so `EP_BUFFER_DEBUG=false` reads as enabled. This helper backs 20+ env reads across the codebase. The fix initializes `value` to `default_value` and returns `default_value` when sscanf does not report a successful conversion. Verified with a standalone host build of the header: before the change, `EP_X=false` with default 7 returned 1 (uninitialized stack); after, it returns 7, `EP_X=42` returns 42, and unset still returns the default. Fixes #733 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
deepseek-ai/DeepEP#743
No description provided.