Issue 1914 Too late to use atexit

Title Too late to use atexit
Priority bug Status given-up
Milestone Resolved in
Superseder Nosy List dixiecko, dmitry.kurochkin, jaredj, kowey, simonpj
Assigned To
Topics Control-C, UI

Created on 2010-08-10.09:47:11 by simonpj, last changed 2017-07-31.00:25:01 by gh.

File name Uploaded Type Edit Remove
unnamed simonpj, 2010-08-10.09:47:10 text/html
msg12082 (view) Author: simonpj Date: 2010-08-10.09:47:10
What does "Its too late to use atexit" mean?


bash$ darcs get http://code.haskell.org/SLPJ-collaborative-papers/flatpar
Copying patches, to get lazy repository hit ctrl-C...
Finished getting.
It's too late to use atexit
msg12088 (view) Author: kowey Date: 2010-08-10.17:16:15
Simon: I think it's very likely harmless

Darcs developers:  At the very least, exposing these sorts of developer-
oriented messages to the user is a UI bug.

The subtlety here being that we need to ask ourselves why we're emitting 
these errors so that we're not just sweeping any fundamental problems 
under the rug.  How exactly does it happen that Darcs tries to call 
atexit when it's already too late?  We need-action somebody to 
understand the Darcs.Global code and explain what could cause this to 
arise.  I'm afraid it's not super clear to me.  Although by process of 
elimination below, I think it's probably checkWaitToStart, which seems 
plausible if we have this speculation mechanism... Can somebody confirm?

The atexit function is just a trick Darcs provides to register actions 
that should happen when Darcs is exiting 
<http://darcs.net/src/Darcs/Global.hs>, normally along the lines of 
removing temporary files or directories.

Grepping the code, I see XXX uses of atexit:
1. killing the SSH control master (probably not Simon)
2. Darcs.URL.checkWaitToStart - not sure what this is, but seems to be 
removing some temporary file
3. Emitting a gzcrcs warning (not Simon?)
4. Darcs.Lock.withDir Delayed - creates a temporary directory and 
(depending on flags), deletes it on darcs exit (I can only see one 
instance where this is used [in darcs show files])
5. Listing bad caches (new feature to be introduced in Darcs 2.8, so not 

Also, one implementation suggestion.  Maybe atexit should take a String 
description along with the action being registered.  At least then we 
could have a better idea what it's too late to call atexit on?
msg12089 (view) Author: kowey Date: 2010-08-10.17:19:40
Note: some possible outcomes of this investigation:

 * we suppress the error message and move it to debug level
 * we extend the error message with more description (as I suggested)
 * we add an optional "don't tell me if it's too late" flag that each 
user of atexit could choose

I think this could actually be quite easy to work on.  It does involve 
thinking about a little bit about concurrency, but it seems fairly self-
contained otherwise
msg12820 (view) Author: tux_rocker Date: 2010-10-24.13:30:50
I think this is because the URL handling stuff happens in a separate
thread. So while one thread is still happily downloading stuff from
URLs, the main thread is running atexit actions.

This causes two kinds of error messages:

   * The atexit actions try to delete files that have not yet been fully
downloaded ("renameFile: does not exist (No such file or directory)")

   * The URL handler thread calls atexit while the exit procedure as
already been started ("It's too late to use atexit")
msg13591 (view) Author: dixiecko Date: 2011-01-26.18:09:22
I just got the same message. No interruption from my side on console but
I used very slow connection to internet (Wireless EDGE).
I can reproduce it again on demand, just ask me what to collect/trace.

[dixie@archthink ../read-happstack-tutorial]$ darcs get
Copying patches, to get lazy repository hit ctrl-C...     
Finished getting.                                 
It's too late to use atexit      

And $ darcs --version                 
2.5 (release)
msg14499 (view) Author: stulli Date: 2011-06-06.14:26:51
I just got this message aswell:

darcs get http://darcsden.com/stulli/couchnews
Copying patches, to get lazy repository hit ctrl-C...
Finished getting.                         
It's too late to use atexit

I rm -Rf'ed the couchnews directory and did a darcs get again and the
error message was gone...

I noticed a .darcs directory in my home directory and deleted it. Then i
removed couchnews directory again and run a darcs get and the error
message reappeared. I tought this was reproducable but it seems there is
just a good chance to get this error when deleting .darcs.

Also sometimes i got this error after deleting .darcs:

Copying patches, to get lazy repository hit ctrl-C...
Finished getting.                         
getSymbolicLinkStatus: does not exist (No such file or directory)

All this was on a stable and fast connection.
version: 2.5.2
Date User Action Args
2010-08-10 09:47:11simonpjcreate
2010-08-10 17:16:17koweysetpriority: bug
status: unknown -> needs-reproduction
topic: + UI
messages: + msg12088
nosy: + kowey
2010-08-10 17:19:42koweysettopic: + ProbablyEasy
nosy: + jaredj
messages: + msg12089
2010-08-25 17:38:56koweylinkissue1927 superseder
2010-10-24 13:26:40tux_rockersettopic: + Control-C, - ProbablyEasy
2010-10-24 13:27:00tux_rockerlinkissue1980 superseder
2010-10-24 13:27:31tux_rockerunlinkissue1980 superseder
2010-10-24 13:28:20tux_rockerlinkissue1983 superseder
2010-10-24 13:30:50tux_rockersetmessages: + msg12820
2011-01-26 18:09:23dixieckosetnosy: + dixiecko
messages: + msg13591
2011-06-06 14:26:52stullisetmessages: + msg14499
2017-07-31 00:25:01ghsetstatus: needs-reproduction -> given-up