[PR #346] fixed:issues #292 fatal error: concurrent map iteration and map write #462

Open
opened 2026-02-16 01:16:02 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langgenius/dify-plugin-daemon/pull/346
Author: @wodeshijie33941
Created: 6/15/2025
Status: 🔄 Open

Base: mainHead: fix/crashbug


📝 Commits (1)

  • 8cea50c fixed:issues #292 fatal error: concurrent map iteration and map write

📊 Changes

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

View changed files

📝 internal/utils/stream/stream.go (+3 -0)

📄 Description

As described by # 292 Issuse, using both 'output_Schema' and 'create_variable_message' will verify whether the format of the data is correct.
However, the problem is that the read() and close() of the stream are executed by different goroutines. At this point, the plugin daemon receives an error message from the plugin ("SESSION_MESSAGE_TYPE_ERROR"), and then executes the stream's close(). Close() internally calls the stream's before Close callback function, while stream's read() calls the filter callback function. The problem lies here, the stream's before Close callback function and read () callback function access the critical resource variables (a map variable). This critical resource variable was accessed in multiple goroutines but was not protected, resulting in a 'concurrent map iteration and map write' error and ultimately causing the daemon to crash.
Simply put, the error message sent by dify-plugin triggered the crash bug of dify-plugin-daemon
Solution:
Use locks to protect critical resources


🔄 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/langgenius/dify-plugin-daemon/pull/346 **Author:** [@wodeshijie33941](https://github.com/wodeshijie33941) **Created:** 6/15/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/crashbug` --- ### 📝 Commits (1) - [`8cea50c`](https://github.com/langgenius/dify-plugin-daemon/commit/8cea50cf7aa7ff13f395d41350e70b67ec825ef6) fixed:issues #292 fatal error: concurrent map iteration and map write ### 📊 Changes **1 file changed** (+3 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `internal/utils/stream/stream.go` (+3 -0) </details> ### 📄 Description As described by # 292 Issuse, using both 'output_Schema' and 'create_variable_message' will verify whether the format of the data is correct. However, the problem is that the read() and close() of the stream are executed by different goroutines. At this point, the plugin daemon receives an error message from the plugin ("SESSION_MESSAGE_TYPE_ERROR"), and then executes the stream's close(). Close() internally calls the stream's before Close callback function, while stream's read() calls the filter callback function. The problem lies here, the stream's before Close callback function and read () callback function access the critical resource variables (a map variable). This critical resource variable was accessed in multiple goroutines but was not protected, resulting in a 'concurrent map iteration and map write' error and ultimately causing the daemon to crash. Simply put, the error message sent by dify-plugin triggered the crash bug of dify-plugin-daemon Solution: Use locks to protect critical resources --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 01:16:02 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-plugin-daemon#462