Lcos-000 opened a new issue, #3865:
URL: https://github.com/apache/dubbo-go/issues/3865

   ### Problem
   
   ```text
   What happened?
   
   When fsnotify.NewWatcher() fails, for example because inotify instances or 
file
   descriptors are exhausted, the file config center logs the error but 
continues
   initialization. It then starts a goroutine that dereferences the nil watcher 
and
   panics, which may terminate the process.
   
   Expected:
   
   Watcher initialization failures should be returned to the caller. No watcher
   goroutine or shutdown callback should be started when watcher creation fails,
   and closing the listener should remain safe.
   
   Actual:
   
   The error is logged, but initialization continues and the process panics 
with:
   
   panic: runtime error: invalid memory address or nil pointer dereference
   ```
   
   ### Steps to reproduce
   
   ```text
   1. Run on Linux.
   2. Exhaust the process file-descriptor limit or inotify instance limit.
   3. Initialize the file config center.
   4. Observe the initialization error followed by a nil-pointer panic.
   ```
   
   A deterministic reproduction can lower `RLIMIT_NOFILE` after process startup 
and
   then call `file.NewCacheListener("")`.
   
   ### Environment
   
   ```text
   - Repository: apache/dubbo-go
   - Target branch: develop
   - Commit checked: 2b68845f
   - Go: go1.27.1
   - OS: Linux amd64
   ```
   
   ### Additional context
   
   ```text
   fsnotify.NewWatcher() returns a nil watcher together with an error. The 
current
   implementation logs the error but still starts the event goroutine, which 
reads
   watch.Events.
   
   The shutdown callback, Close, AddListener, and RemoveListener paths can also
   dereference the nil watcher.
   
   The issue was reproduced with the error "too many open files", followed by a
   panic at config_center/file/listener.go:94.
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to