Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Solved] Debian Linux | "Speicherzugriffsfehler" segmentation fault
28-12-2014, 11:27 PM (This post was last modified: 04-01-2015 10:50 PM by ChriD.)
Post: #1
[Solved] Debian Linux | "Speicherzugriffsfehler" segmentation fault
Hi,

I've created an application with ohNet.
The windows build runs without any error.

The Debian Linux build throws a "segmentation fault" error while starting up the ControlPoint Device

Error on
Code:
OpenHome::Net::UpnpLibrary::StartCp(subnet);
where subnet ist subnet of eth0

Any suggestions?
Thanks!
Find all posts by this user
29-12-2014, 09:53 AM
Post: #2
RE: Debian Linux | "Speicherzugriffsfehler" segmentation fault
The problem is likely to be in code before the line you've highlighted. Can you post a complete and short program that demonstrates this crash please?
Find all posts by this user
29-12-2014, 04:46 PM
Post: #3
RE: Debian Linux | "Speicherzugriffsfehler" segmentation fault
Here is the code.
Is from my "InitUPNP" Method.

i hope it doesnt hurt your eyes Blush


Code:
OpenHome::Net::InitialisationParams*        initParams;
        std::vector<OpenHome::NetworkAdapter*>*        subnetList;
        std::string                                    networkAdapterNameLocal, networkAdapterFullNameLocal;
        TIpAddress                                    subnet, ipAddressClient;
        boost::int16_t                                subnetListIdx = -1;

        try
        {
            initParams = OpenHome::Net::InitialisationParams::Create();                        
            OpenHome::Net::UpnpLibrary::Initialise(initParams);            
            subnetList = OpenHome::Net::UpnpLibrary::CreateSubnetList();

            // find network adapterto use with the UPNP control stack
            if (networkAdapterName.empty())
            {                
                subnetListIdx = 0;
            }
            else
            {
                for (boost::uint16_t i = 0; i < (*subnetList).capacity(); i++)
                {
                    networkAdapterNameLocal = (*subnetList)[i]->Name();
                    if (networkAdapterNameLocal == networkAdapterName)
                    {
                        subnetListIdx = i;
                        break;
                    }
                }
            }

            if (subnetListIdx < 0)
            {                
                subnetListIdx = 0;
            }

            networkAdapterFullNameLocal = (*subnetList)[subnetListIdx]->FullName();
            networkAdapterNameLocal = (*subnetList)[subnetListIdx]->Name();
            ipAddressClient = (*subnetList)[subnetListIdx]->Address();
            subnet = (*subnetList)[subnetListIdx]->Subnet();            
            OpenHome::Net::UpnpLibrary::DestroySubnetList(subnetList);
        
            OpenHome::Net::UpnpLibrary::StartCp(subnet);

        }
        catch (const std::exception& ex)
        {    
        }
Find all posts by this user
29-12-2014, 06:49 PM (This post was last modified: 29-12-2014 06:52 PM by ChriD.)
Post: #4
RE: Debian Linux | "Speicherzugriffsfehler" segmentation fault
And here the simplest one which has the segment fault...
The "10" on the StartCp is the subnet value. (looked it up in the debugger)
To be sure that nothing else causes the Segment fault i used it directly

Code:
#include <OpenHome/Net/Cpp/OhNet.h>
#include <OpenHome/Net/Cpp/CpDevice.h>
#include <OpenHome/Net/Cpp/CpDeviceDv.h>
#include <OpenHome/Net/Cpp/CpDeviceUpnp.h>
#include <OpenHome/Net/Cpp/CpUpnpOrgConnectionManager1.h>

using namespace std;

int main()
{
    OpenHome::Net::InitialisationParams*        initParams;    

    initParams = OpenHome::Net::InitialisationParams::Create();
    OpenHome::Net::UpnpLibrary::Initialise(initParams);
    OpenHome::Net::UpnpLibrary::StartCp(10);
    return 0;
}


EDIT:
Maybe one thing to mention is, that i am working in an OracleVM on Debian Wheezy
Find all posts by this user
29-12-2014, 09:57 PM
Post: #5
RE: Debian Linux | "Speicherzugriffsfehler" segmentation fault
Open SUSE throws the same error Sad
Find all posts by this user
30-12-2014, 11:28 AM
Post: #6
RE: Debian Linux | "Speicherzugriffsfehler" segmentation fault
Your code looks fine. The call to StartCp() tries to create a TCP server on the network interface you specify (this'll later receive evented updates from UPnP devices). I wonder whether the problem is that your VM isn't allowing this?

Is there any message printed to console - either "Assertion failed - ..." or "Unhandled exception - ..." just before the segfault? If there is, can you post a complete copy of the message please? If not, can you use gdb to step through the code inside StartCp() until you find the line that fails?
Find all posts by this user
30-12-2014, 05:15 PM
Post: #7
RE: Debian Linux | "Speicherzugriffsfehler" segmentation fault
Thank you for your help simonc
There are no any other messages.

GDB shows up this:
Code:
Program received signal SIGSEGV, Segmentaion fault.
0xb7d43344 in OpenHome::Environment::NetworkAdapterList (this=0x0) at OpenHome/Env.cpp:185
185        return *iNetworkAdapterList;

stepped through
Code:
OpenHome::Net::UpnpLibrary::startCp (aSubnet=10) at OpenHome/Net/OhNetCp.cpp:16
{ // static
    gEnv->NetworkAdapterList().SetCurrentSubnet(aSubnet);

and in "->NetworkAdapterList()" there is "return *iNetworkAdapterList" and this does the segmentation fault Huh
Find all posts by this user
31-12-2014, 12:17 PM
Post: #8
RE: Debian Linux | "Speicherzugriffsfehler" segmentation fault
The call to OpenHome::Net::UpnpLibrary::Initialise() in your program should have initialised iNetworkAdapterList in gEnv. I don't have easy access to a Linux machine at present but have checked that your code works on Windows. Could you try single stepping into the call to Initialise() to see if that gives any hints about what's going wrong?
Find all posts by this user
31-12-2014, 01:47 PM
Post: #9
RE: Debian Linux | "Speicherzugriffsfehler" segmentation fault
iNetworkAdapterList is initialized at "UPNPLibrary::Initialize()" and seems to be okay!
But in the "NetworkAdapterList" Method, where its going to be returend, its not okay anomre.

In UPNPLibrary::StartCp(...) the "gEnv" seems to be wrong/empty (Null pointer) (value=0x0)
In Windows Environment its okay. There is a pointer adressed.
I use "Nemiver" for gdb debugging. Maybee it shows the wrong values here... I'm not sure....
Find all posts by this user
01-01-2015, 05:15 PM (This post was last modified: 01-01-2015 05:27 PM by ChriD.)
Post: #10
RE: Debian Linux | "Speicherzugriffsfehler" segmentation fault
Some more stuff...

Hmm.. i use GNU 4.7.2-8 for compiling my application. I think this is ok.
There were some bugs in older Versions of GNU Compiler
http://stackoverflow.com/questions/20410...d-variable

Another thing is the stackSize defined on the Linux System for global variables. Thisd may cause a seg fault too if the size gets to big. But in my Environment its set to 'unlimited', so this cant be the Problem
http://stackoverflow.com/questions/11977...-variables
Find all posts by this user


Forum Jump: