Segmentation Fault when doing UpdateBeliefs

The engine.
Post Reply
fvadillo
Posts: 8
Joined: Wed Jan 11, 2017 6:41 am

Segmentation Fault when doing UpdateBeliefs

Post by fvadillo »

Hello,

I started working with SMILE a couple of months ago. I implemented some learning and inference using Visual Studio and it had all been working fine. However, I recently had the need to do inference in Linux (Ubuntu) so I ported my code from Windows (which was basically a copy/paste) and used the same library version (but gcc binaries). Everything compiles just fine but the DSL_network::UpdateBeliefs() function is causing a segmentation fault. I'm feeding the program the same XDSL for the trained network and the exact same evidence in both Windows and Linux but, as I mentioned, it crashes on the latter one.

Since the crash is happening inside the SMILE library, I am at a loss. Your help will be immensely appreciated.

Thank you.

This is the call stack:

Code: Select all

#0  0x000000000062f428 in TsClique::SortNodes() ()
#1  0x000000000057ada8 in TsTriangulator::Triangulate(unsigned int) ()
#2  0x0000000000578258 in TsJoinTree::Triangulate(unsigned int) ()
#3  0x0000000000578e50 in TsJoinTree::UpdateBeliefsEx(bool*, unsigned int) ()
#4  0x0000000000576622 in (anonymous namespace)::DoClustering(DSL_network*, bool*, int, int&) ()
#5  0x0000000000576e3e in TsClustering(DSL_network*) ()
#6  0x000000000055f92f in DSL_network::CallBNAlgorithm() ()
#7  0x000000000055d9f0 in DSL_network::UpdateBeliefs() ()
And this is how the code looks like (simplified for it to fit better):

Code: Select all

DSL_network cwNetwork;
cwNetwork.ReadFile("data/Network-Learned.xdsl", DSL_XDSL_FORMAT);

cwNetwork.SetDefaultBNAlgorithm(DSL_ALG_BN_LAURITZEN);

int node1 = cwNetwork.FindNode("Node1");
int node2 = cwNetwork.FindNode("Node2");
int resNode = cwNetwork.FindNode("ResNode");

cwNetwork.ClearAllEvidence();

cwNetwork.GetNode(node1)->Value()->SetEvidence(5);
cwNetwork.GetNode(node2)->Value()->SetEvidence(1);

cwNetwork.UpdateBeliefs();
fvadillo
Posts: 8
Joined: Wed Jan 11, 2017 6:41 am

Re: Segmentation Fault when doing UpdateBeliefs

Post by fvadillo »

Update: I changed the default algorithm to be DSL_ALG_BN_HENRION and the segmentation fault is not being hit. However I found a different issue.

When using the exact same evidence, Windows consistently returns 0.75 as the probability I'm evaluating.
On Linux, exact same code, exact same XDSL, exact same evidence each run... I'm getting 0.5145, 0.5109, 0.509. I could maybe blame the difference between the 3 results to floating point error but... why isn't the result 0.75 as in Windows? That is the right result :(

To be clear, I would still prefer to use DSL_ALG_BN_LAURITZEN if possible, as it is faster.

Thank you once again.
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Segmentation Fault when doing UpdateBeliefs

Post by shooltz[BayesFusion] »

Can you send the network and specify the evidence which causes the crash? If you don't want your XDSL to be visible on the forum, send me a private message.
fvadillo
Posts: 8
Joined: Wed Jan 11, 2017 6:41 am

Re: Segmentation Fault when doing UpdateBeliefs

Post by fvadillo »

Thank you SO much for the quick reply shooltz. Sent you a PM with the network and source code. The PM showed up in my outbox but it now seems to be gone. Please let me know if you got it. Thank you again!
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Segmentation Fault when doing UpdateBeliefs

Post by shooltz[BayesFusion] »

I have downloaded the files you linked in your PM. I'm investigating the issue now. Which Linux distro and which gcc version are you using?
fvadillo
Posts: 8
Joined: Wed Jan 11, 2017 6:41 am

Re: Segmentation Fault when doing UpdateBeliefs

Post by fvadillo »

gcc 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04)
Ubuntu 14.04.2 LTS

Thank you.
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Segmentation Fault when doing UpdateBeliefs

Post by shooltz[BayesFusion] »

gcc 4.8.4
I believe this is the root cause of the problem. Our publicly available SMILE binaries for Linux are currently compiled with gcc 4.4.5; you can't use them with 4.8.x.

I have Ubuntu 16.04 TLS VM somewhere, but no 14.04. If you can switch to 16.04 I can build SMILE for you using compiler native for this Linux version.
fvadillo
Posts: 8
Joined: Wed Jan 11, 2017 6:41 am

Re: Segmentation Fault when doing UpdateBeliefs

Post by fvadillo »

That would be awesome. I'm attempting to perform the update now.
fvadillo
Posts: 8
Joined: Wed Jan 11, 2017 6:41 am

Re: Segmentation Fault when doing UpdateBeliefs

Post by fvadillo »

After upgrading to 16.04, the rest of the project (which is huge) started giving me compiler errors. I was able to correct them but now I'm running into runtime errors which have been much harder to track down. I'll try to debug it more tomorrow. If I can't get my project to run, I'll try to downgrade my gcc version instead and cross my fingers that it works.

Thank you.
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Segmentation Fault when doing UpdateBeliefs

Post by shooltz[BayesFusion] »

Don't downgrade the gcc - I'll compile SMILE with gcc 5.4.0 (default compiler in Ubuntu 16.04 TLS). Watch this thread for the notification once new binaries are available.
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Segmentation Fault when doing UpdateBeliefs

Post by shooltz[BayesFusion] »

The 64-bit binaries compiled with gcc 5.4.0 are available for download now (I assume you're an academic user, I've only updated the academic build list).
fvadillo
Posts: 8
Joined: Wed Jan 11, 2017 6:41 am

Re: Segmentation Fault when doing UpdateBeliefs

Post by fvadillo »

I really appreciate all the investigation and work you did to try to help me solve this issue. Unfortunately, it seems I cannot upgrade to gcc 5.4.0. I am adding SMILE to a project that is pretty big and complex. I successfully updated to 16.04 and made the project compile but the runtime errors were pretty bad and I couldn't solve all of them. I tried instead downgrading my gcc version to 4.4 while using Ubuntu 14.04 but the complex project I'm working on has a dependency on using at least 4.7 :( so... unless I can somehow help you compile SMILE for gcc 4.8.. I think I'll have to come up with some workaround or something.

Once again, thank you so so much for your help.
And really, if I can do something to get SMILE libs compiled with 4.8... let me know. I can maybe provide you with a VM with 14.04 and gcc 4.8 or something. Anyway.... thank you!
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Segmentation Fault when doing UpdateBeliefs

Post by shooltz[BayesFusion] »

SMILE binaries for gcc 4.8.4 (64-bit) are available at our academic downloads page.
fvadillo
Posts: 8
Joined: Wed Jan 11, 2017 6:41 am

Re: Segmentation Fault when doing UpdateBeliefs

Post by fvadillo »

I just tried it and it works perfectly. Thank you so so much for your help!
Post Reply