Skip to content
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

System.IO.EndOfStreamException when building with latest DNVM and Mono 4.0.1 #498

Closed
miguellira opened this issue Apr 29, 2015 · 49 comments
Closed

Comments

@miguellira
Copy link

Running into a System.IO.EndOfStreamException when building the latest sample ConsoleApp using the latest DNVM and the recently released Mono 4.0.1.

Miguels-MBP:~ miguellira$ dnvm list

Active Version              Runtime Arch Location             Alias
------ -------              ------- ---- --------             -----
  *    1.0.0-beta5-11649    mono         ~/.dnx/runtimes      default
Mono JIT compiler version 4.0.1 (tarball Mon Apr 27 01:00:48 PDT 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
    TLS:           normal
    SIGSEGV:       altstack
    Notification:  kqueue
    Architecture:  amd64
    Disabled:      none
    Misc:          softdebug 
    LLVM:          supported, not enabled.
    GC:            sgen
Miguels-MBP:ConsoleApp miguellira$ dnu build

Building ConsoleApp for DNX,Version=v4.5.1
  Using Project dependency ConsoleApp 1.0.0
    Source: /Users/miguellira/Downloads/Home-dev/samples/latest/ConsoleApp/project.json

  Using Assembly dependency framework/mscorlib 4.0.0.0
    Source: /usr/local/Cellar/mono/4.0.1/lib/mono/4.5/mscorlib.dll

  Using Assembly dependency framework/System 4.0.0.0
    Source: /usr/local/Cellar/mono/4.0.1/lib/mono/4.5/System.dll

  Using Assembly dependency framework/System.Core 4.0.0.0
    Source: /usr/local/Cellar/mono/4.0.1/lib/mono/4.5/System.Core.dll

  Using Assembly dependency framework/Microsoft.CSharp 4.0.0.0
    Source: /usr/local/Cellar/mono/4.0.1/lib/mono/4.5/Microsoft.CSharp.dll

System.IO.EndOfStreamException: Failed to read past end of stream.
  at System.IO.BinaryReader.ReadChar () [0x00000] in <filename unknown>:0 
  at Microsoft.CodeAnalysis.CvtResFile.ReadStringOrID (System.IO.BinaryReader fhIn) [0x00000] in <filename unknown>:0 
  at Microsoft.CodeAnalysis.CvtResFile.ReadResFile (System.IO.Stream stream) [0x00000] in <filename unknown>:0 
  at Microsoft.CodeAnalysis.Compilation.MakeWin32ResourceList (System.IO.Stream win32Resources, Microsoft.CodeAnalysis.DiagnosticBag diagnostics) [0x00000] in <filename unknown>:0 
  at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.SetupWin32Resources (Microsoft.CodeAnalysis.CSharp.Emit.PEModuleBuilder moduleBeingBuilt, System.IO.Stream win32Resources, Microsoft.CodeAnalysis.DiagnosticBag diagnostics) [0x00000] in <filename unknown>:0 
  at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.CompileImpl (Microsoft.CodeAnalysis.Emit.CommonPEModuleBuilder moduleBuilder, System.IO.Stream win32Resources, System.IO.Stream xmlDocStream, Boolean generateDebugInfo, Microsoft.CodeAnalysis.DiagnosticBag diagnostics, System.Predicate`1 filterOpt, CancellationToken cancellationToken) [0x00000] in <filename unknown>:0 
  at Microsoft.CodeAnalysis.Compilation.Compile (Microsoft.CodeAnalysis.Emit.CommonPEModuleBuilder moduleBuilder, System.IO.Stream win32Resources, System.IO.Stream xmlDocStream, Boolean generateDebugInfo, Microsoft.CodeAnalysis.DiagnosticBag diagnostics, System.Predicate`1 filterOpt, CancellationToken cancellationToken) [0x00000] in <filename unknown>:0 
  at Microsoft.CodeAnalysis.Compilation.Emit (Microsoft.CodeAnalysis.EmitStreamProvider peStreamProvider, Microsoft.CodeAnalysis.EmitStreamProvider pdbStreamProvider, Microsoft.CodeAnalysis.EmitStreamProvider xmlDocumentationStreamProvider, Microsoft.CodeAnalysis.EmitStreamProvider win32ResourcesStreamProvider, IEnumerable`1 manifestResources, Microsoft.CodeAnalysis.Emit.EmitOptions options, Microsoft.CodeAnalysis.CodeGen.CompilationTestData testData, System.Func`1 getHostDiagnostics, CancellationToken cancellationToken) [0x00000] in <filename unknown>:0 
  at Microsoft.CodeAnalysis.Compilation.Emit (System.IO.Stream peStream, System.IO.Stream pdbStream, System.IO.Stream xmlDocumentationStream, System.IO.Stream win32Resources, IEnumerable`1 manifestResources, Microsoft.CodeAnalysis.Emit.EmitOptions options, Microsoft.CodeAnalysis.CodeGen.CompilationTestData testData, System.Func`1 getHostDiagnostics, CancellationToken cancellationToken) [0x00000] in <filename unknown>:0 
  at Microsoft.CodeAnalysis.Compilation.Emit (System.IO.Stream peStream, System.IO.Stream pdbStream, System.IO.Stream xmlDocumentationStream, System.IO.Stream win32Resources, IEnumerable`1 manifestResources, Microsoft.CodeAnalysis.Emit.EmitOptions options, CancellationToken cancellationToken) [0x00000] in <filename unknown>:0 
  at Microsoft.Framework.Runtime.Roslyn.RoslynProjectReference.EmitAssembly (System.String outputPath) [0x00000] in <filename unknown>:0 
  at Microsoft.Framework.PackageManager.ProjectBuilder.Build (System.String name, System.String outputPath) [0x00000] in <filename unknown>:0 
  at Microsoft.Framework.PackageManager.BuildContext.Build (System.Collections.Generic.List`1 diagnostics) [0x00000] in <filename unknown>:0 
  at Microsoft.Framework.PackageManager.BuildManager.Build () [0x00000] in <filename unknown>:0 
  at Microsoft.Framework.PackageManager.Program+<>c__DisplayClass3_4.<Main>b__8 () [0x00000] in <filename unknown>:0 
  at Microsoft.Framework.Runtime.Common.CommandLine.CommandLineApplication.Execute (System.String[] args) [0x00000] in <filename unknown>:0 
  at Microsoft.Framework.PackageManager.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
  at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute (System.Reflection.Assembly assembly, System.String[] args, IServiceProvider serviceProvider) [0x00000] in <filename unknown>:0 
  at dnx.host.Bootstrapper.RunAsync (System.Collections.Generic.List`1 args) [0x00000] in <filename unknown>:0 
@suhasj
Copy link
Contributor

suhasj commented Apr 29, 2015

This is known issue and we have notified the Mono team
https://bugzilla.xamarin.com/show_bug.cgi?id=29499

@miguellira
Copy link
Author

Thanks @suhasj.

Is there a preferred DNVM/Mono combination at the moment? Since the mono Homebrew formula has been updated to 4.0.1 is there a recommended way to get a stable environment to build/run the samples?

@suhasj
Copy link
Contributor

suhasj commented Apr 29, 2015

/cc @glennc

I am not sure of this since I have hit issues with both 4.0.1 and 4.1.0

@javi830810
Copy link

Same issue here, mono 4.0.1 and dnx 4.5.1, please advice

@davidfowl
Copy link
Member

beta4 + mono 4.0.1 and 4.1 have this issue and there's no known workaround.

@ThorstenHans
Copy link

Issue also appears in the following combination
Mono 4.0.1
dnx and dnu 1.0.0-beta5-11649
dnvm 1.0.0-beta5-10371

@Jabe
Copy link

Jabe commented Apr 30, 2015

😢

@miguellira
Copy link
Author

FWIW...

If you, like me, decided to uninstall Mono 3.x after installing 4.x and will like to get back to a somewhat stable state. You can unlink Mono 4.x and reinstall 3.x by doing the following:

brew unlink mono
brew install https://raw.githubusercontent.com/Homebrew/homebrew/68a18ac660515e313cd175c550e3065320dfadec/Library/Formula/mono.rb

Unfortunately, all of the issues that exist with running Mono 3.x and the latest DNX will continue, but at least you'll be able to play around with Visual Studio Code on Mac :-)

@jamespack
Copy link

Possible workaround? (This is what I did)

  1. clone mono repository, compile and install following the directions here http://www.mono-project.com/docs/compiling-mono/
  2. brew tap aspnet/dnx
  3. brew upgrade
  4. brew install dnvm --without-mono

I had to uninstall everything mono-related that brew installed. But after doing this I was able to run dnu build, dnx . kestrel, etc

@miguellira
Copy link
Author

@jpack61108 I haven't gone as far as building/running Mono from the latest repo. Curious... Did you have Mono installed prior to this, whether via brew or otherwise? Also, where/how did you discover the --without-mono switch? I haven't seen that documented anywhere. Thanks.

@jamespack
Copy link

Yes I did, from brew. I had to remove all of the brew stuff because of all the symlinking that it does. So far it is working as advertised.
James
Sent from Outlook

On Mon, May 4, 2015 at 9:03 PM -0700, "Miguel Lira" notifications@github.com wrote:

@jpack61108 I haven't gone as far as building/running Mono from the latest repo. Curious... Did you have Mono installed prior to this, whether via brew or otherwise? Also, where/how did you discover the --without-mono switch? I haven't seen that documented anywhere. Thanks.


Reply to this email directly or view it on GitHub.

@jamespack
Copy link

Sorry brew options $FORMULA_NAME will show you the available options for install. I believe it is on the brew wiki.
James

Sent from Outlook

On Mon, May 4, 2015 at 9:06 PM -0700, "Jimmy Pack" jpack61108@gmail.com wrote:

Yes I did, from brew. I had to remove all of the brew stuff because of all the symlinking that it does. So far it is working as advertised.
James
Sent from Outlook

On Mon, May 4, 2015 at 9:03 PM -0700, "Miguel Lira" notifications@github.com wrote:

@jpack61108 I haven't gone as far as building/running Mono from the latest repo. Curious... Did you have Mono installed prior to this, whether via brew or otherwise? Also, where/how did you discover the --without-mono switch? I haven't seen that documented anywhere. Thanks.


Reply to this email directly or view it on GitHub.

@miguellira
Copy link
Author

@jpack61108 Thanks for the tip. I'm ready to give this a shot. Quick question, where did you install Mono? The docs suggest /mono but I'd assume you'd run into all sort of permission issues.

@miguellira
Copy link
Author

@jpack61108 Decided to pull the trigger and installed mono from source at /Users/miguellira/mono. Grabbed the latest HelloMvc sample and both beta4 and the latest (beta5-11682 as of this post) have fully functional builds without any errors!

I would like to point out, however, that (as indicated in the Compiling Mono on Mac OS X article) in order to install Mono from source you need Mono installed. Also, in order to ensure the new mono is used I added the path to my ~/.bash_profile:

PATH=/Users/miguellira/mono/bin:$PATH

@jamespack
Copy link

Nice!! I put mine in the same place that brew does. Never really thought about putting it elsewhere

Sent from Outlook

@jpack61108 Decided to pull the trigger and installed mono from source at /Users/miguellira/mono. Grabbed the latest HelloMvc sample and both beta4 and the latest (beta5-11682 as of this post) have fully functional builds without any errors!

I would like to point out, however, that (as indicated in the Compiling Mono on Mac OS X article) in order to install Mono from source you need Mono installed. Also, in order to ensure the new mono is used I added the path to my ~/.bash_profile:

PATH=/Users/miguellira/mono/bin:$PATH


Reply to this email directly or view it on GitHub.

@jamespack
Copy link

To work around having to have mono installed to compile mono, before running make, I ran make get-monolite-latest, then make.
James

Sent from Outlook

Nice!! I put mine in the same place that brew does. Never really thought about putting it elsewhere

Sent from Outlook

@jpack61108 Decided to pull the trigger and installed mono from source at /Users/miguellira/mono. Grabbed the latest HelloMvc sample and both beta4 and the latest (beta5-11682 as of this post) have fully functional builds without any errors!

I would like to point out, however, that (as indicated in the Compiling Mono on Mac OS X article) in order to install Mono from source you need Mono installed. Also, in order to ensure the new mono is used I added the path to my ~/.bash_profile:

PATH=/Users/miguellira/mono/bin:$PATH


Reply to this email directly or view it on GitHub.

@jamespack
Copy link

@miguellira

I am not sure but I think the way I did it breaks the intellisense for c# in VS Code.

Are you still getting Intellisense for c#?

@miguellira
Copy link
Author

@jpack61108 Yep, same here. Statement completion only works if I remove the PATH to my 4.1.0 version of Mono and use the 4.0.1 version installed via brew.

I'm guessing this has to do with how Omnisharp within VSCode looks for Mono. My Atom/Omnisharp setup works just fine against Mono 4.1.0. Going to dig around if I come up with a fix I'll post, please do the same.

@jamespack
Copy link

@miguellira Will do.

@jamespack
Copy link

@miguellira
Super-Hack but what I am doing until they patch everything is leaving the 4.0.1 on the path and when I want to run the build commands that require the 4.1.0 just enter PATH=/Path/to/mono/4.1.0/:$PATH

Then I can build when I want and still get the awesome intellisense that Omnisharp offers.
Im sure that could probably be automated in some way, I am not that clever yet.

@miguellira
Copy link
Author

@jpack61108 Yes. That's what I settled into on my Mac. But I've also been playing with vNext on my surface pro will stick with that until another build of VSCode.

@deevus
Copy link

deevus commented May 7, 2015

Here's what did in the interim until this is resolved. I have mono 4.0.1 and 4.1.0 (compiled from git master) both installed in Homebrew.

~/.bash_profile

source dnvm.sh
alias dnu="brew switch mono 4.1.0 && dnu"

code () {
  brew switch mono 4.0.1
  if [[ $# = 0 ]]
  then
    open -a "Visual Studio Code"
  else
    [[ $1 = /* ]] && F="$1" || F="$PWD/${1#./}"
    open -a "Visual Studio Code" --args "$F"
  fi
}

It's not perfect but it's quick and easy for my use case. You could go further and make sure it resets the brew version after each command but I haven't found I needed to.

@jensg
Copy link

jensg commented May 9, 2015

I have 2 versions of mono compiled from git source mono 4.0.1 and mono 4.1.0; after Visual Studio Code is started I set mono to version 4.1.0 and can execute dnu build
Disadvantage: You need a new window of terminal. Whenever PATH had mono version 4.1.0 referenced, code autocompletion does not work. When you set PATH to include mono 4.1.0 after it is started everything is fine.

This is my ~/.bash_profile

source dnvm.sh
MONO401="/Users/jensg/mono/build"
MONO410="/Users/jensg/mono/git-build"
PREPATH=$PATH

function code {
  PATH="$MONO401/bin:$PREPATH"
  open -a "Visual Studio Code"
  PATH="$MONO410/bin:$PREPATH"
}

@peterblazejewicz
Copy link
Contributor

Hey guys just wanted to add, that despite the fact that 'dnu build' doesnt work on Mono. You can move forward only with 'dnu restore' and 'dnx . run', you're loosing the verbose output of dnu build, but at least you can run and play.

This could not apply in all cases, I (and other people) are stuck after dnx . kestrel:
#515

@borgdylan
Copy link

The latest mono master fixes all issues experienced here.

@brucerchapman
Copy link

@borgdylan I've got my setup in a mess. I just tried getting the latest mono with https://homebrew.bintray.com/bottles/mono-4.0.1.yosemite.bottle using homebrew - still no joy. How do I get the mono master then?

@jamespack
Copy link

clone the repo.
git clone https://github.com/mono/mono.git
Then follow the instructions provided here

@miguellira
Copy link
Author

@brucerchapman I haven't tried to build from master in awhile but as @jamespack mentions it's pretty straightforward. I did, however, run into issues with earlier mono masters so I grabbed a tarball from their Jenkins server that build successfully. The following details the setup I wound up with: #508 (comment)

Both Mono and vNext are moving targets though, so if you wanna to play with the new bits stick to beta4 but subscribe to the Announcements issues repo. Good luck.

@brucerchapman
Copy link

@miguellira thanks I did try building but made things worse I think. This time I'll try in a different path - `/usrs/local/{user}/mono' seems to be the recommended?

@miguellira
Copy link
Author

@brucerchapman The recommendation is not to place it in /usr but you can put in anywhere. I've chosen to place it where the official homebrew version will live. I'll simply delete it and brew install when 4.1 is made official. This is how my setup looks like:

Miguels-MBP:mono miguellira$ pwd
/usr/local/Cellar/mono
Miguels-MBP:mono miguellira$ ls
4.0.1   4.1.0

@akoeplinger
Copy link
Member

FYI, the fix to this problem was commited to the mono 4.0 branch, so it should turn up in the next service release: mono/mono@ed1d3ec. If you don't want to jump straight to master, you can just build and install the 4.0 branch instead.

@miguellira
Copy link
Author

@akoeplinger Do you know if building and running the 4.0 branch of mono will play nice with Visual Studio Code? When I switch to my mono 4.1 build OmniSharp does not start in VSC.

@akoeplinger
Copy link
Member

@miguellira don't know that sorry, but the 4.0 branch only contains fixes on top of the released 4.0, so if VSCode works with that then I don't see why it wouldn't work with the latest from 4.0 branch.

@Yantrio
Copy link

Yantrio commented May 27, 2015

@miguellira If you could post an issue over on http://github.com/omnisharp/omnisharp-roslyn with any details about it not booting on 4.1 then that would be much appreciated :D

@jamespack
Copy link

@Yantrio I believe it is related to the version of Omnisharp that is used within VSCode.

@miguellira
Copy link
Author

@Yantrio VSCode always booted, but the OmniSharp Server would not start.

FWIW, I just cloned and built mono from master (currently reading as 4.3.0)

Miguels-MBP:MiguelLira.Web miguellira$ mono --version
Mono JIT compiler version 4.3.0 (master/65f9215 Wed May 27 13:17:54 EDT 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
    TLS:           normal
    SIGSEGV:       altstack
    Notification:  kqueue
    Architecture:  amd64
    Disabled:      none
    Misc:          softdebug 
    LLVM:          supported, not enabled.
    GC:            sgen

Visual Studio Code/OmniSharp works fine, dnu build runs without errors. Unfortunately, CTRL-C to kill kestrel hangs and throws a System.NullReferenceException but apparently that's a known issue and definitely something I can live with.

@Yantrio
Copy link

Yantrio commented May 27, 2015

There are ways around that which are quite simple :) we can discuss it on the correct repo :) I'm grabbing mono from source to test it now.

@miguellira
Copy link
Author

@Yantrio I already commented on the Announcements thread when this bug appeared on my end aspnet/Announcements#23 (comment)

This bug has been logged several times over, both here and in the KestrelHttpServer repo. I'm sure they're tackling bigger fish right now.

@balneaves
Copy link

For those who already have DNVM/mono installed via Homebrew you can use the 4.0.1-44 release manually without messing about with builds and symlinks (until the main mono brew is upgrade to a fixed version)

brew edit mono

Change line 4 & 5 to the following

    url "http://download.mono-project.com/sources/mono/mono-4.0.1.44.tar.bz2"
    sha256 "eaf5bd9d19818cb89483b3c9cae2ee3569643fd621560da036f6a49f6b3e3a6f"

brew upgrade mono

@jamespack
Copy link

@salerth This is actually the easiest solution. Thanks. Works like a champ!

@cmattson
Copy link

cmattson commented Jun 6, 2015

I submitted a pull request this morning to update Homebrew to 4.0.1.44. It's merged now, so brew update away!

Thanks for @salerth for the tip that .44 was working. I'd last tried .43, which still didn't.

@paullyvenne
Copy link

As far as I know, this bug still exists. I've followed jamespack's instructions many times but it just doesn't resolve the issue (System.IO.EndOfStreamException: Failed to read past end of stream.). I'm thinking there is some issue with that build of mono but I can't be sure, it might also be ASPNET. This issue has been around for along time, so I haven't been able to try out the latest ASPNET and I hear many other users are stuck with this issue (OSX and Linux) as well. Help anyone?

EDIT: I just noticed some new instructions, I will try that.

@paullyvenne
Copy link

Thanks salerth, it worked, I did almost the same thing

  • sudo nano /usr/local/Library/Formula/mono.rb
  • changed line 4 and 5 to

url "http://download.mono-project.com/sources/mono/mono-4.0.1.44.tar.bz2"
sha256 "eaf5bd9d19818cb89483b3c9cae2ee3569643fd621560da036f6a49f6b3e3a6f"

  • sudo brew upgrade mono

@andrenventer
Copy link

paullyvenne: I used your method above, but still got the error below:

I removed the node_modules folder
I removed the files bower installed

Then it worked

mono --version
Mono JIT compiler version 4.0.1 (tarball Fri Sep 11 21:59:54 SAST 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: normal
SIGSEGV: altstack
Notification: kqueue
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen

dnx kestrel
Application started. Press Ctrl+C to shut down.
error : [Microsoft.AspNet.Diagnostics.ErrorHandlerMiddleware] An unhandled exception has occurred: kqueue() FileSystemWatcher has reached the maximum nunmber of files to watch.
System.IO.IOException: kqueue() FileSystemWatcher has reached the maximum nunmber of files to watch.
at System.IO.KqueueMonitor.Add (System.String path, Boolean postEvents, System.Collections.Generic.List1& fds) [0x00000] in <filename unknown>:0 at System.IO.KqueueMonitor.Scan (System.String path, Boolean postEvents, System.Collections.Generic.List1& fds) [0x00000] in :0
at System.IO.KqueueMonitor.Setup () [0x00000] in :0
at System.IO.KqueueMonitor.DoMonitor () [0x00000] in :0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in :0 ...

@dougbu
Copy link
Member

dougbu commented Sep 11, 2015

Looks like Mono is hitting issues similar to what we've seen when running with Core CLR on Linux (fyi: aspnet/Mvc#3066). Try bumping up the limits FileSystemWatcher has likely hit:

sudo sh -c "echo 2048 > /proc/sys/fs/inotify/max_user_instances"
sudo sh -c "echo 131072 > /proc/sys/fs/inotify/max_user_watches"

Note the above numbers are extreme 16x the defaults.

natemcmaster pushed a commit that referenced this issue Nov 21, 2018
IHealthCheckPublisher allows you to configure and run health checks
regularly inside an application, and push the notifications elsewhere.

All publishers are part of a single queue with a configurable period and
timeout.
dougbu pushed a commit to dotnet-maestro-bot/AspNetCore that referenced this issue Sep 11, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests