bugMIT/GNU Scheme - Bugs: bug #66690, Deadlock in...

 
 

bug #66690: Deadlock in allocate-temporary-file if file-touch raises an error

Submitter:  Taylor R. Campbell <riastradh>
Submitted:  Tue 21 Jan 2025 04:39:44 PM UTC
   
 
Category:  runtime Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect behavior
Status:  None Privacy:  Public
Assigned to:  None Originator Name: 
Open/Closed:  Open
Keywords: 
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 21 Jan 2025 04:39:44 PM UTC, original submission:  

If the file-touch call inside allocate-temporary-file (e.g., via call-with-temporary-file-pathname) raises an error, and the error handler tries to enter a debugger or print a stack trace, it deadlocks with locking-against-self:

Subproblem level: 0 (this is the lowest subproblem level)
Expression (from stack):
    (file-touch "/home/riastradh/scheme/mit/hacks/helloworld/sch012857_0")
There is no current environment.
There is no execution history for this subproblem.

;Deadlock detected while trying to lock thread mutex: #[%record 12].

This happens because:

1. The condition handler is called inside with-files-to-delete-locked, i.e., with files-to-delete-mutex held locked.
2. Printing a stack trace involves loading debug data which involves creating temporary files to hold decompressed debug info.
3. Creating temporary files requires re-entering allocate-temporary-file which takes files-to-delete-mutex.

Reproducer attached.  Usage (`helloworld' is the name of a directory to create without write permission and then delete as part of the test):

scheme --batch-mode --load tmpfiledeadlock.scm --eval '(test "helloworld")' --eval '(%exit)'

Solution is to make this call to file-touch never raise an error, e.g. by establishing a condition handler that simply aborts and returns #f; the caller already has to handle that as a failure anyway.

Taylor R. Campbell <riastradh>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #56792:  tmpfiledeadlock.scm added by riastradh (574B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by riastradh (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-01-21 riastradh Attached File- Added tmpfiledeadlock.scm, #56792

    Back to the top

    Powered by Savane 3.15-e6e5.
    Corresponding source code