Skip to content

Conversation

ReneSac
Copy link
Contributor

@ReneSac ReneSac commented Apr 18, 2014

The result section was almost rewritten. Please check the grammar/spelling.

doc/tut1.txt Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be mentioned that referential data types, such as sequences, need to be initialized manually.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now .add and .len accept nil don't they? So this isn't really necessary for sequences anymore. But it is probably a good idea to put a warning: "Reference types will be nil at the start of the procedure, and thus may require manual initialization."

Araq added a commit that referenced this pull request Apr 20, 2014
Additions and clarifications to tutorial 1.
@Araq Araq merged commit 1205f91 into nim-lang:devel Apr 20, 2014
Clyybber pushed a commit to Clyybber/Nim that referenced this pull request Feb 24, 2024
## Summary

Previously,  `osproc`  would attempt to allocate memory during fork-exec
via the use of  `findExe`  to find programs in  `PATH` . This causes
memory allocation during this sensitive period.

This PR replaces the use of  `findExe` , which was employed due to 
`execvpe`  not being ubiquitous, with  `execvpe` , now that it is widely
available.

## Details

There are a couple problems with allocating memory during fork-exec:

- This is extremely unsafe as this code is also used in  `vfork()`  case
(although disabled by default, thankfully), of which the use of an
allocator would completely mess up the parent process.
- This is super slow, since  `fork()`  has to perform CoW on pages that
are touched by the allocation procedure.
- A deadlock can occur in rare cases due to interaction with the global
allocator lock. This problem was observed in disruptek/balls.

With regard to substituting `findExe` with `execvpe`:

* This API has been available in uClibc since 2013, musl libc since 2014
and Haiku since 2015, removing the need to special case against those
systems.
* We can expect behaviors closer to how other programs perform  `PATH` 
searches. It is expected that there won't be any regression from this
change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants