You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by "Robert Lazarski (Jira)" <ji...@apache.org> on 2026/01/20 22:23:00 UTC

[jira] [Comment Edited] (AXIS2C-1663) Race condition in axutil_dir_handler_list_service_or_module_dirs

    [ https://issues.apache.org/jira/browse/AXIS2C-1663?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18053160#comment-18053160 ] 

Robert Lazarski edited comment on AXIS2C-1663 at 1/20/26 10:22 PM:
-------------------------------------------------------------------

Tagging this for possible inclusion into 2.0.1. 

fix requires rewriting dir_select() and the   
  scandir pattern (or adding synchronization), it's non-trivial work.

Fix Options (in order of preference):     

  1. Use opendir/readdir with absolute paths - Eliminate chdir by       
  building full paths for stat calls. Most robust fix.                  
  2. Use fstatat() with dirfd - Open directory with opendir(), get fd   
  with dirfd(), use fstatat(fd, name, ...) instead of stat().           
  POSIX-compliant, avoids chdir.                                        
  3. Add mutex - Quick fix: wrap the getcwd/chdir/scandir/chdir sequence
   in a mutex. Simple but adds locking overhead.                        
  4. Document as not thread-safe - Mark function as single-threaded     
  only.   


was (Author: robertlazarski):
Tagging this for possible inclusion into 2.0.1. 

fix requires rewriting dir_select() and the   
  scandir pattern (or adding synchronization), it's non-trivial work.

  1. Use opendir/readdir with absolute paths - Eliminate chdir by       
  building full paths for stat calls. Most robust fix.                  
  2. Use fstatat() with dirfd - Open directory with opendir(), get fd   
  with dirfd(), use fstatat(fd, name, ...) instead of stat().           
  POSIX-compliant, avoids chdir.                                        
  3. Add mutex - Quick fix: wrap the getcwd/chdir/scandir/chdir sequence
   in a mutex. Simple but adds locking overhead.                        
  4. Document as not thread-safe - Mark function as single-threaded     
  only.   

> Race condition in axutil_dir_handler_list_service_or_module_dirs
> ----------------------------------------------------------------
>
>                 Key: AXIS2C-1663
>                 URL: https://issues.apache.org/jira/browse/AXIS2C-1663
>             Project: Axis2-C
>          Issue Type: Bug
>    Affects Versions: 1.6.0
>            Reporter: mehturt
>            Priority: Major
>             Fix For: 2.0.1
>
>
> I'm calling a web service from multiple threads using the sample code provided (axis2_svc_client_send_receive). When the web service is invoked in parallel in multiple threads, the current working directory of the process changes.  I was able to track this down and I think the problem is in function axutil_dir_handler_list_service_or_module_dirs() which performs getcwd and then changes directory to somewhere and back.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: c-dev-help@axis.apache.org