DaemonForums  

Go Back   DaemonForums > NetBSD > NetBSD Package System (pkgsrc)

NetBSD Package System (pkgsrc) Installation and upgrading of packages on NetBSD.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 30th January 2016
pinswats pinswats is offline
New User
 
Join Date: Jan 2016
Posts: 4
Default tor on evbarmv6 (raspberry-pi)

As there are no 2015Q4 binary packages for evbarmv6hf I compiled Tor (tor-0.2.7.6) natively on my Raspberry (first generation Model-B 256MB) from the 2015Q4-Sources.
When I try to start the service via, for example

Code:
# /etc/rc.d/tor (one)start
Just nothing happens and the CPU-usage from tor goes above 90%. I already tried waiting for hours, turning debugging on in the torrc file, compiling from latest CURRENT-sources (although it is the same tor version tor-0.2.7.6) so far without success.
I have no idea how to solve or how to debug this problem from here on.

Thanks in advance

EDIT: Forgot to mention: Tried NetBSD 7.0 release and NetBSD-7 stable without any differences. No problems on NetBSD-7 amd64

Last edited by pinswats; 30th January 2016 at 02:54 PM. Reason: More OS information
Reply With Quote
  #2   (View Single Post)  
Old 30th January 2016
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 5,798
Default

Hello and welcome!
Quote:
Originally Posted by pinswats View Post
I have no idea how to solve or how to debug this problem from here on.
Perhaps, since debugging was enabled in your build, you could attach gdb(1) to the process while it is looping, to try and figure out which function(s) it may be looping through. You can also kill(1) or pkill(1) with a SIGABRT signal(7) to produce a core file for post-processing with gdb().

My advice is generic because I have neither NetBSD nor RPi experience, and can't help with anything specific.
Reply With Quote
  #3   (View Single Post)  
Old 30th January 2016
pinswats pinswats is offline
New User
 
Join Date: Jan 2016
Posts: 4
Default

Quote:
Originally Posted by jggimi View Post
Perhaps, since debugging was enabled in your build, you could attach gdb(1) to the process while it is looping, [...]
I guess I was a bit disambiguous before, by turning on debugging I meant to enable debug messages in tor logfiles. But since there are no tor logmessages at all, i get nothing.

How to enable debugging during building?
Code:
make show-options
gives me no such option for tor.
Reply With Quote
  #4   (View Single Post)  
Old 30th January 2016
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 5,798
Default

There are generally three types of debugging:
  1. Application debug messages, written into the application by a developer. These may be turned on by various application dependent flags, from things like a "-v" option for "verbose," or by tokens set with the -D compiler flag, used at compiler pre-processing time.
  2. Debugging symbols inserted into the compiled object code, for use with a debugger. I mentioned one in my first reply: the GNU debugger, gdb(). With a debugger you can step through the operation at a source code level, or, even at a machine code level. You can set breakpoints, look at variable and structure values, assign new variable values, and watch an application as it runs step by step.
  3. OS-specific system call ("syscall") tracing tools.
Your debugging was type 1. I'd thought you meant type 2. To enable type 2 debugging:
  • We tell the compiler to enable debugging symbols in the object produced, so that source code file names, source code line numbers, and source code variable names and types are all recorded in the compiled object. This is done with the -g compiler flag.
  • We may also tell the compiler to turn off all optimizations. The program will run more slowly, but variable values won't be hidden from a debugger by having been "optimized out" through storing their values in CPU registers, or other shortcuts the compiler may apply. This is done with the -O0 flag. Capital "Oh" for optimization, and zero for none.
  • We may also tell the install script that packages and/or installs the final program not to strip symbols from the final executable. Most standard packaging tools will do that with a strip(1) command. My OS doesn't use pkgsrc, we use different tools, and to disable stripping of symbols at install, I set a line in my port Makefile with
    Code:
    INSTALL_STRIP=
    so that it doesn't run the strip(1) command. I don't need to do this when I run the binary out of the build directory, rather than installing it. You may not need to disable strip(1) if you do not install the binary.
I don't know much about tor, but I know it uses GNU-style configuration tools. You can add C compiler flags and C++ compiler flags with options such as:
Code:
CFLAGS+=-g -O0
CXXFLAGS+=-g -O0
when the GNU configure script is run. You may need to quote the options, depending how the script is called. I always use "+=" rather than "=" and place them after other compiler flags, if any. This is because the last -O level used wins. If you place -O0 before the makefile requested -O2, level 2 optimization will be used by the compiler.

Last edited by jggimi; 30th January 2016 at 05:21 PM. Reason: clarity, and one thinko
Reply With Quote
  #5   (View Single Post)  
Old 30th January 2016
pinswats pinswats is offline
New User
 
Join Date: Jan 2016
Posts: 4
Default

First of all thanks for the extensive and fast answer. It is really helpful since I am now out of my usual Linux/BSD comfort zone . Since I'm no programmer at all I am not sure if debugging even can help me, but I guess it will be worth a try.
For the next debugging step it will likely take some time since I have a lot of reading manpages, trying and compiling (on raspberry, cross-compiling is no options because of perl dependency ) to do.
Reply With Quote
  #6   (View Single Post)  
Old 30th January 2016
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 5,798
Default

The most helpful thing the debugger can do is display the stack trace. You can see them using gdb's backtrace command, shortened to "bt", or its wonderful synonym, "where".

Every time a function gets called, a new stack frame is created, and the calling one gets saved. It contains saved values, such as variables and instruction pointers, so that when the called function returns, the calling one picks up where it left off.

The top of the stack trace is the most recent function called -- it will be frame number 0. And all of the other calls to that point will be in the trace. You don't need to know much about programming to use it to see what functions call what, and the code paths taken by the program. The gdb frame command will let you inspect any of them for variable values, too. And you can go up and down through the frames with the up and down commands.

Your loop will either be looping through multiple functions, or stuck inside a single function. Either way, you should be able to watch it progress. The gdb() "step" command will move a program one line at a time through a program, including any called functions, while the "next" command will treat a function call as if it is a single instruction. Both may be helpful.

See this recent rant from a non-programmer who increased the security of an unreadable, confusing application, primarily by using stack traces from core files.
Reply With Quote
  #7   (View Single Post)  
Old 2nd March 2016
pinswats pinswats is offline
New User
 
Join Date: Jan 2016
Posts: 4
Default

I did in the meanwhile build tor on the latest Raspbian distribution on the same Rpi, no problems there. So it is likely a NetBSD/pkgsrc issue. But I "solved" it on NetBSD, or better found a workaround, by using clang.
Reply With Quote
  #8   (View Single Post)  
Old 2nd March 2016
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 5,798
Default

A different compiler in your toolchain circumvented the problem? Then the issue is compiler related, whatever it is. Was. You're past it. Congrats!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
alternatives to raspberry pi osw94k OpenBSD General 2 15th February 2015 04:58 AM
Raspberry Pi 2 B bsdnut82 FreeBSD General 3 12th February 2015 08:54 PM
Raspberry Pi-like Box That Runs OpenBSD? raindog308 General Hardware 3 31st August 2013 08:37 AM
OpenBSD availablitity for Raspberry Pi? dbach OpenBSD General 9 23rd April 2013 06:56 PM
FreeBSD on Raspberry Pi Beastie News 0 24th January 2013 01:53 PM


All times are GMT. The time now is 09:14 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick