Thread 'Can't compile boinc client on NetBSD'

Message boards : Questions and problems : Can't compile boinc client on NetBSD
Message board moderation

To post messages, you must log in.

Previous · 1 · 2

AuthorMessage
Juha
Volunteer developer
Volunteer tester
Help desk expert

Send message
Joined: 20 Nov 12
Posts: 801
Finland
Message 72888 - Posted: 4 Oct 2016, 19:11:28 UTC - in response to Message 72884.  

It could be something like using uninitialised stack variable. Calling fprintf() then changes the stack in a way that the code is still using garbage but doesn't crash. Letting the compiler optimise code again changes things.

According to the compiler output you posted earlier hw_addr is used uninitialised in get_mac_address(), maybe because of the problem with net/if_arp.h . I can't see how that would be a problem, it's just six bytes and you'll just get garbage MAC address but it shouldn't crash.

You could add the fprintf() after functions calls, one at a time.
ID: 72888 · Report as offensive
jusavard
Avatar

Send message
Joined: 28 Sep 16
Posts: 16
Canada
Message 72904 - Posted: 4 Oct 2016, 21:03:37 UTC - in response to Message 72888.  

Hi, funny you ask this... I continued to dig and I think I found it (in this exact function )..

In client/mac_address.cpp line 266 :

fprintf(stderr, "I'm here before strcpy \n");
        strcpy(address, ether_ntoa(hw_addr));
fprintf(stderr, "I'm here after strcpy \n");


Trace :

sparc3# ./client/boinc
04-Oct-2016 16:50:23 [---] cc_config.xml not found - using defaults
04-Oct-2016 16:50:23 [---] Starting BOINC client version 7.7.0 for sparc64-unknown-netbsd
04-Oct-2016 16:50:23 [---] This a development version of BOINC and may not function properly
04-Oct-2016 16:50:23 [---] log flags: file_xfer, sched_ops, task
04-Oct-2016 16:50:23 [---] Libraries: libcurl/7.50.1 OpenSSL/1.0.1p zlib/1.2.3 libidn/1.30
04-Oct-2016 16:50:23 [---] Data directory: /root/boinc
04-Oct-2016 16:50:23 [---] No usable GPUs found
04-Oct-2016 16:50:23 [---] Creating new client state file
I'm here at the beginning of generate_host_cpid
I'm here 1
I'm here at the beginning of get_mac_address
I'm here at the beginning of SIOCGIFCONF
I'm here in ifedf else HAVE_STRUCT_LIFCONF 1
I'm here between 2 ifdef
I'm here in ifedf else HAVE_STRUCT_LIFCONF 2
I'm here in ifedf else HAVE_STRUCT_LIFCONF 3
I'm here in ifedf else HAVE_STRUCT_LIFCONF 4
I'm here after ifedf else HAVE_STRUCT_LIFCONF 4
I'm here before struct ether_addr *hw_addr
I'm here after struct ether_addr *hw_addr
I'm here before strcpy
SIGSEGV: segmentation violation
ID: 72904 · Report as offensive
ProfileAgentb
Avatar

Send message
Joined: 30 May 15
Posts: 265
United Kingdom
Message 72907 - Posted: 4 Oct 2016, 21:36:32 UTC - in response to Message 72888.  
Last modified: 4 Oct 2016, 21:36:51 UTC

Juha wrote:
It could be something like using uninitialised stack variable. Calling fprintf() then changes the stack in a way that the code is still using garbage but doesn't crash. Letting the compiler optimise code again changes things.

According to the compiler output you posted earlier hw_addr is used uninitialised in get_mac_address(), maybe because of the problem with net/if_arp.h . I can't see how that would be a problem, it's just six bytes and you'll just get garbage MAC address but it shouldn't crash.


jusavard wrote:

In client/mac_address.cpp line 266 :

fprintf(stderr, "I'm here before strcpy \n");
        strcpy(address, ether_ntoa(hw_addr));
fprintf(stderr, "I'm here after strcpy \n");



My C is a little old now, just looking at the Free BSD man page for ether_ntoa seems that you can get a null

If it is unable to convert the supplied ether_addr structure, it returns a
NULL pointer.


This seems different or not mentioned on the equivalent linux page.
ID: 72907 · Report as offensive
jusavard
Avatar

Send message
Joined: 28 Sep 16
Posts: 16
Canada
Message 72916 - Posted: 5 Oct 2016, 4:33:44 UTC - in response to Message 72907.  

Not sure but I don't see anything like that in the NetBSD man :
http://nixdoc.net/man-pages/NetBSD/man3/ether_ntoa.3.html
The ether_ntoa() function converts this structure into an ASCII string of
the form ``xx:xx:xx:xx:xx:xx'', consisting of 6 hexadecimal numbers separated
by colons. It returns a pointer to a static buffer that is reused
for each call.

I must say that I just reach my "maximum level of incompetence". I'm mostly sysadmin not a developer. I did some java and php but C++ is out of my level of knowledge. I can build and test any suggestion and provide a "miraculous" working build in a tar format however I can't reproduce it.
You can have it at this link :
https://www.neiluj.ca/boinc-netbsd-working.tar.gz
You will have to rebuild it for your architecture. This one has been compiled for sparc64.
ID: 72916 · Report as offensive
Juha
Volunteer developer
Volunteer tester
Help desk expert

Send message
Joined: 20 Nov 12
Posts: 801
Finland
Message 72930 - Posted: 5 Oct 2016, 15:53:34 UTC - in response to Message 72917.  

I'm an idiot, or at least blind. In the strcpy() line hw_addr is uninitialised pointer. That's why it's crashing.

You can comment out the line for now. I'll see if I can make a more permanent fix some day. I have an old laptop I was going to burn down with BOINC. I was going to install some Linux other than Debian like on it but I suppose I could try NetBSD first.
ID: 72930 · Report as offensive
jusavard
Avatar

Send message
Joined: 28 Sep 16
Posts: 16
Canada
Message 72964 - Posted: 5 Oct 2016, 20:31:29 UTC - in response to Message 72930.  

IT'S WORKING !!!

In client/mac_address.cpp :
#elif  defined(SIOCGIFARP)
        if(ioctl(sck, SIOCGIFARP, item) < 0) {
            perror("ioctl(SIOCGIFARP)");
            close(sck);
            return -1;
        }
        hw_addr = (struct ether_addr *)&(item->lifr_lifru.lifru_enaddr);
#endif
        //strcpy(address, ether_ntoa(hw_addr));
        //Line up there commented by me
#ifdef HAVE_STRUCT_LIFCONF
        if (strstr(item->lifr_name, "eth")) break;
#else
        if (strstr(item->ifr_name, "eth")) break;
#endif


Stdout :

sparc3# ./client/boinc
05-Oct-2016 16:20:32 [---] cc_config.xml not found - using defaults
05-Oct-2016 16:20:32 [---] Starting BOINC client version 7.7.0 for sparc64-unknown-netbsd
05-Oct-2016 16:20:32 [---] This a development version of BOINC and may not function properly
05-Oct-2016 16:20:32 [---] log flags: file_xfer, sched_ops, task
05-Oct-2016 16:20:32 [---] Libraries: libcurl/7.50.1 OpenSSL/1.0.1p zlib/1.2.3 libidn/1.30
05-Oct-2016 16:20:32 [---] Data directory: /root/boinc
05-Oct-2016 16:20:32 [---] No usable GPUs found
05-Oct-2016 16:20:32 [---] Creating new client state file
I'm here at the beginning of generate_host_cpid
I'm here 1
I'm here 2
I'm here in the if
05-Oct-2016 16:20:32 [---] Host name: sparc3.neiluj.intra
05-Oct-2016 16:20:32 [---] Processor: 1 sparc64 SUNW,UltraAX-i2 (SUNW,UltraSPARC-IIe @ 548 MHz)
05-Oct-2016 16:20:32 [---] Processor features:
05-Oct-2016 16:20:32 [---] OS: NetBSD: 7.0
05-Oct-2016 16:20:32 [---] Memory: 1.50 GB physical, 2.00 GB virtual
05-Oct-2016 16:20:32 [---] Disk: 34.19 GB total, 22.50 GB free
05-Oct-2016 16:20:32 [---] Local time is UTC -4 hours
05-Oct-2016 16:20:32 [---] No general preferences found - using defaults
05-Oct-2016 16:20:32 [---] Preferences:
05-Oct-2016 16:20:32 [---]    max memory usage when active: 768.00MB
05-Oct-2016 16:20:32 [---]    max memory usage when idle: 1382.40MB
05-Oct-2016 16:20:32 [---]    max disk usage: 22.41GB
05-Oct-2016 16:20:32 [---]    don't use GPU while active
05-Oct-2016 16:20:32 [---]    suspend work if non-BOINC CPU load exceeds 25%
05-Oct-2016 16:20:32 [---]    (to change preferences, visit a project web site or select Preferences in the Manager)
05-Oct-2016 16:20:32 [---] This computer is not attached to any projects
05-Oct-2016 16:20:32 [---] Visit http://boinc.berkeley.edu for instructions
05-Oct-2016 16:20:32 Initialization completed


Thanks a lot ! I looking forward to see this in an official patch or update
ID: 72964 · Report as offensive
Previous · 1 · 2

Message boards : Questions and problems : Can't compile boinc client on NetBSD

Copyright © 2025 University of California.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.