Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Ogdy · Nov 03, 2016 at 10:37 AM · crashexceptionmonopipe

Unhandled exception crashes the game : A heap has been corrupted

Hello,

I make a Windows game that uses named pipes to communicate with the outside. I can successfully receive data, but the game keeps crashing when I send ~5 messages (yes, 4 is fine but the fifth one makes everything crash, even if messages are identical.. I don't know why).

What happens is a small delay of a second and then the game just closes itself, with no information.

I tried :

  • Running a "development build" standalone, but the error is not catched into the output log.

  • Different ways of sending my message (ASync, normal, by disposing NamedPipeClientStream ...) unsuccessfull.

  • Running from the Editor. In this case I can use Visual Studio to debug and I get the error

    "Unhandled exception at ...... (ntdll.dll) in Unity.exe: .....: A heap has been corrupted (parameters: ....)."

I have no idea what is happening here. My hypothesis is that unity's System.IO.Pipes is broken.

I would like to find a workaround or if possible to ignore this error. I am already using try-catch when sending messages and it seems like it does nothing. When running from the editor and debugging with VS, I was able to ignore the error and continue the execution. Maybe I can do that to automatically ?

Here is the send method I use now :

 public void send(PipeMessage message)
 {
     try {
         pipeClient = new NamedPipeClientStream(".", sendPipeName, PipeDirection.Out, PipeOptions.Asynchronous);
         pipeClient.Connect(timeOut);
         pipeClient.BeginWrite(message.bytes, 0, message.bytes.Length, aSyncSend, pipeClient);
     }
         catch (Exception e) {
     }
 }

 private void aSyncSend(IAsyncResult iar)
 {
     try
     {
         NamedPipeClientStream sApipeClient = (NamedPipeClientStream)iar.AsyncState;
         sApipeClient.EndWrite(iar);
         sApipeClient.Flush();
     }
         catch (Exception e) {
     }
 }
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ogdy · Nov 03, 2016 at 12:39 PM 0
Share

I just noticed. If I Close() the stream after Flush(), it will crash at the first message sent. This is very weird and validates my hypothesis

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Ogdy · Nov 03, 2016 at 01:35 PM

I solved it. There is clearly an issue with Unity's pipes or streams, but I made it working by creating a single instance of NamedPipeServerStream and NamedPipeClientStream and reusing them on each iteration.

Imo, this would be the way to do, but on every example I found a new instance was created each time.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

78 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Got a SIGSEGV while executing native code. On Android app 1 Answer

Can't open Unity Editor anymore after editing scripts 0 Answers

Unity Editor crashes when loading managed Plug-in (external DLL) 1 Answer

AppCallbacks constructor throws FileNotFound exception and then crashes W10mobile 1 Answer

/SOLVED /il2cpp makes my app crash 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges