Skip to content

String and ByteString implementations have desynchronized #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ezyang opened this issue Aug 9, 2016 · 1 comment · Fixed by #228
Closed

String and ByteString implementations have desynchronized #68

ezyang opened this issue Aug 9, 2016 · 1 comment · Fixed by #228
Milestone

Comments

@ezyang
Copy link
Contributor

ezyang commented Aug 9, 2016

I've been Backpack'ifying unix on the suggestion of @hvr, and I have realized that the String and ByteString implementations have desynchronized in a few cases. I'm still working my way through the modules but here are the ones I've noticed:

System.Posix.Env

  • ByteString does not implement/export setEnvironment
  • ByteString: unsetEnv name = putEnv (name ++ "=") Pretty sure this is a type error
  • ByteString: putEnv uses useAsCString to allocate the string passed to putenv, but String has a comment indicating we must not free the string after putenv according to SUSv2

Actually, amazingly enough, I checked the rest of the implementations and this was the only desynchronization.

@hasufell hasufell added this to the 2.8.0.0 milestone Jul 10, 2022
@hasufell
Copy link
Member

The third point causes a serious bug:

With String:

Prelude> import System.Posix.Env
Prelude System.Posix.Env> putEnv "foo=bar"
Prelude System.Posix.Env> getEnv "foo"
Just "bar"
Prelude System.Posix.Env> getEnv "foo"
Just "bar"

With ByteString:

Prelude> import System.Posix.Env.ByteString
Prelude System.Posix.Env.ByteString> :set -XOverloadedStrings
Prelude System.Posix.Env.ByteString> putEnv "foo=bar"
Prelude System.Posix.Env.ByteString> getEnv "foo"
Just "bar"
Prelude System.Posix.Env.ByteString> getEnv "foo"
Nothing

hasufell added a commit to hasufell/unix that referenced this issue Jul 16, 2022
And fix free-bug in 'putEnv'. Fixes haskell#68
hasufell added a commit to hasufell/unix that referenced this issue Jul 16, 2022
And fix free-bug in 'putEnv'. Fixes haskell#68
hasufell added a commit to hasufell/unix that referenced this issue Jul 17, 2022
And fix free-bug in 'putEnv'. Fixes haskell#68
hasufell added a commit to hasufell/unix that referenced this issue Jul 17, 2022
And fix free-bug in 'putEnv'. Fixes haskell#68
hasufell added a commit to hasufell/unix that referenced this issue Jul 17, 2022
And fix free-bug in 'putEnv'. Fixes haskell#68
hasufell added a commit to hasufell/unix that referenced this issue Jul 17, 2022
hasufell added a commit to hasufell/unix that referenced this issue Jul 17, 2022
And fix free-bug in 'putEnv'. Fixes haskell#68
Bodigrim pushed a commit that referenced this issue Jul 17, 2022
And fix free-bug in 'putEnv'. Fixes #68
hasufell added a commit to hasufell/unix that referenced this issue Jul 19, 2022
hasufell added a commit to hasufell/unix that referenced this issue Jul 19, 2022
And fix free-bug in 'putEnv'. Fixes haskell#68
hasufell added a commit that referenced this issue Jul 20, 2022
* Add regression test for #218

#218

Error was:

uncaught exception: IOException of type InvalidArgument
semTrywait: invalid argument (Bad file descriptor)

* Fix 'semTrywait: invalid argument (Bad file descriptor)' wrt #218

* Add regression test for putEnv wrt #68

* Synchronize ByteString and String modules

And fix free-bug in 'putEnv'. Fixes #68

* Add cabal.project

* Fix the error handling of posix_fallocate other than FreeBSD

This commit introduces a CPP guard to take care of the difference
between OSes of the errors of posix_fallocate.

On Linux and NetBSD, posix_fallocate reports error by returning an error
number. errno is not set.
On the other hand, on FreeBSD, posix_fallocate returns -1 and sets
errno.

The existing code could handle FreeBSD-style errors only.

* Remove obsolete FreeBSD-style error handling

The FreeBSD-style error (return -1, set errno) is obsolete as of
FreeBSD 11.0; it now reports errors as same as the other OSes.

* Future-proof glibc version check

* Resource: Fix warning in case of no RLIM_SAVED_{CUR,MAX}

This previously failed to build with a warning on FreeBSD 11.2

* Bump to 2.7.3

* Add Eq and Show instance to BaudRate

Needed for test suite

* Add CI

* Tighten lower base bound to only allow GHC-8.2+

Co-authored-by: matil019 <[email protected]>
Co-authored-by: Viktor Dukhovni <[email protected]>
Co-authored-by: Ben Gamari <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants