Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by Mathieujofis · Sep 05, 2013 at 06:58 PM · errorserverpluginmemory

Segfault in native plugin code, only with Unity

I'm running a native plugin that starts a Live555 media server on a separate thread. The server waits for a client to connect, then starts transmitting (empty, for now) data to the client. When I run this code by loading the .bundle in a C++ program, it runs and transmits fine, however when I run it by calling from Unity, it segfaults 4/5 times in random places deep within the server code. Only every once in a while (1/5 times) does it connect and transmit the data correctly.

I have also tried without starting a thread which causes the same issue in addition to completely freezing Unity because the server is in an infinite loop.

What could be causing these random memory issues with native plugins? Seems like a race condition but I have no idea why. As an alternative, is there possibly another way I could start this server from Unity but keep only the data I want transmitted in shared memory, keeping the Unity editor/application and Live555 server out of shared memory?

In case there is another way to call it, I've copied my C# code below-- I call the thread like this:

 void Awake()
 {
     ServerThread server = new ServerThread();
     Thread st = new Thread(new ThreadStart(server.startServer));
     st.Start();
     
 }


The thread code:

 public class ServerThread : MonoBehaviour
 {
     [DllImport ("RenderingPlugin")]
     private static extern int startStream();
     // This method that will be called when the thread is started
    public void startServer()
    {
         Debug.Log ("Thread started.");
         startStream (); // Starts the server in native code
    }
 };
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 Mathieujofis · Sep 06, 2013 at 03:08 PM 0
Share

I "solved" the problem by working around it. I still have no idea what was causing the segfault, maybe it was too much thread unsafe code operating in the same shared memory. So ins$$anonymous$$d of starting a new Live 555 server thread from Unity, I started a separate Live 555 server process. I used inter-process communication via boost libraries to establish a spot in memory that can be shared by the server and Unity.

0 Replies

· Add your reply
  • Sort: 

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

15 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

Related Questions

A node in a childnode? 1 Answer

Unity running out of memory 1 Answer

Unity3d + SmartFox dll + Windows 8 Store Build produces errors 0 Answers

WebGl build on Server has load memory error 6 Answers

Object Reference Not Set As Instance error from ngui code 1 Answer


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