# portmanager crashing



## jtl (Oct 1, 2009)

When I run portmanager it crashes with a seg fault.  For example I just tried to run

portmanager net/wireshark -l

and it crashed right after collecting the installed port data. This is where it always crashes for any port I've tried.  Doing a deinstall/reinstall on portmanager doesn't fix this. I can usually cd into net/wireshark (or whatever port I'm trying to install) and do a make deinstall/reinstall successfully, but it seems that there's something very wrong if portmanager is seg faulting.  Thanks for any help with this.

- Jon


----------



## osx-addict (Oct 1, 2009)

You might want to try getting a stackdump as a minimum to determine what the underlying issue is.. You can do that using gdb as a minimum if you've got the source lying around still.  Assuming you get a core-dump you can issue something like :

% gdb portmanager core

Once it comes up, type "bt" for backtrace and send in the results.


----------



## jtl (Oct 1, 2009)

Thanks.  I rebuilt portmanager with debugging enabled, but that didn't help much.  I haven't been able to find libMG in the ports directories, so I haven't been able to try rebuilding it.  Here's the backtrace output for portmanager.core, though there doesn't seem to be a lot of information here.  Do you know what port(s) builds libMG and libMGPM?

```
chablis# gdb portmanager portmanager.core
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-marcel-freebsd"...(no debugging symbols found)...
Core was generated by `portmanager'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/local/lib/libMG.so.2...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libMG.so.2
Reading symbols from /usr/local/lib/libMGPM.so.1...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libMGPM.so.1
Reading symbols from /lib/libc.so.7...(no debugging symbols found)...done.
Loaded symbols for /lib/libc.so.7
Reading symbols from /libexec/ld-elf.so.1...(no debugging symbols found)...done.
Loaded symbols for /libexec/ld-elf.so.1
#0  0x33c80374 in MGdbRead () from /usr/local/lib/libMG.so.2
(gdb) bt
#0  0x33c80374 in MGdbRead () from /usr/local/lib/libMG.so.2
#1  0x33c7ff98 in MGdbOpen () from /usr/local/lib/libMG.so.2
#2  0x33cacd9a in MGPMrStatus () from /usr/local/lib/libMGPM.so.1
#3  0x33c8e440 in MGPMrController () from /usr/local/lib/libMGPM.so.1
#4  0x33c895aa in rParseCommandLine () from /usr/local/lib/libMGPM.so.1
#5  0x33c8a59d in MGPMrCommandLine () from /usr/local/lib/libMGPM.so.1
#6  0x08048724 in ?? ()
#7  0x00000002 in ?? ()
#8  0xbfbfeae0 in ?? ()
#9  0xbfbfeaec in ?? ()
#10 0x00000002 in ?? ()
#11 0xbfbfeaec in ?? ()
#12 0x00000000 in ?? ()
#13 0xbfbfeac0 in ?? ()
#14 0x00000002 in ?? ()
#15 0xbfbfeaec in ?? ()
#16 0x00000000 in ?? ()
#17 0xbfbfead8 in ?? ()
#18 0x08048649 in ?? ()
#19 0x00000000 in ?? ()
#20 0x00000000 in ?? ()
#21 0xbfbfead8 in ?? ()
#22 0x08048649 in ?? ()
#23 0x00000002 in ?? ()
#24 0xbfbfeae0 in ?? ()
#25 0xbfbfeaec in ?? ()
#26 0x00000000 in ?? ()
#27 0xbfbfeac0 in ?? ()
#28 0xbfbfeadc in ?? ()
#29 0x00000000 in ?? ()
#30 0x00000002 in ?? ()
#31 0xbfbfebf4 in ?? ()
#32 0xbfbfec00 in ?? ()
#33 0x00000000 in ?? ()
#34 0xbfbfec0e in ?? ()
#35 0xbfbfec36 in ?? ()
#36 0xbfbfec45 in ?? ()
#37 0xbfbfec50 in ?? ()
#38 0xbfbfec5b in ?? ()
#39 0xbfbfeca2 in ?? ()
#40 0xbfbfecb4 in ?? ()
#41 0xbfbfecc2 in ?? ()
#42 0xbfbfecdb in ?? ()
#43 0xbfbfed0c in ?? ()
#44 0xbfbfed40 in ?? ()
#45 0xbfbfed79 in ?? ()
#46 0xbfbfed84 in ?? ()
#47 0xbfbfed99 in ?? ()
#48 0xbfbfedb1 in ?? ()
#49 0xbfbfee08 in ?? ()
#50 0xbfbfee16 in ?? ()
#51 0xbfbfee22 in ?? ()
#52 0xbfbfee31 in ?? ()
#53 0xbfbfee3b in ?? ()
#54 0xbfbfee43 in ?? ()
#55 0xbfbfee4e in ?? ()
#56 0xbfbfee7a in ?? ()
#57 0xbfbfee8b in ?? ()
.
.
.
#1380 0x00000002 in ?? ()
#1381 0xbfbfeaec in ?? ()
#1382 0x00000023 in ?? ()
Cannot access memory at address 0xbfc00000
(gdb)
```


----------



## osx-addict (Oct 1, 2009)

Ok.. So it sounds like it's a problem with libMG -- whatever that is.. In googling around it appears like you might be able to remove libMG from your system and force portmanager to be reinstalled (rebuilt in this case) and it should try to rebuild libMG -- hopefully with symbols.  Unfortunately, I don't have a FreeBSD box in front of my so I'm just speculating..


----------



## jtl (Oct 1, 2009)

From what I can find, libMG* is from the Mojave Green software company which is well hidden, or more likely doesn't exist anymore.  The libraries are related to database manipulation of some sort.  In any case, portmanager has no dependecies and builds all the libMG* files itself.  I removed them and reinstalled portmanager, which recreated the libMG* files.  When I ran portmanger again it sill seg faulted, but at least the debugging symbols were present this time.  The backtrace is below.  The file /usr/local/share/portmanager/ports_dependencies.db exist, is non-empty, and has read access by all, but maybe the contents are bad?

```
chablis# gdb portmanager portmanager.core 
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-marcel-freebsd"...
Core was generated by `portmanager'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/local/lib/libMG.so.2...done.
Loaded symbols for /usr/local/lib/libMG.so.2
Reading symbols from /usr/local/lib/libMGPM.so.1...done.
Loaded symbols for /usr/local/lib/libMGPM.so.1
Reading symbols from /lib/libc.so.7...done.
Loaded symbols for /lib/libc.so.7
Reading symbols from /libexec/ld-elf.so.1...done.
Loaded symbols for /libexec/ld-elf.so.1
#0  MGdbRead (db=0x33e6d100) at MGdbRead.c:159
159			while( db->dataBuffer[dataBufferIdx] )	/* while db->dataBuffer[dataBufferIdx] isn't NULL */
(gdb) bt
#0  MGdbRead (db=0x33e6d100) at MGdbRead.c:159
#1  0x33c80048 in MGdbOpen (
    dbFileName=0x33e02000 "/usr/local/share/portmanager/ports_dependencies.db")
    at MGdbOpen.c:57
#2  0x33cace5a in MGPMrStatus (property=0xbfbfe918) at MGPMrStatus.c:87
#3  0x33c8e500 in MGPMrController (property=0xbfbfe918, 
    path=0x33e02a00 "/mail/thunderbird", argv=0xbfbfead8) at MGPMrController.c:303
#4  0x33c8966a in rParseCommandLine (property=0xbfbfe918, argc=3, argv=0xbfbfead8)
    at MGPMrCommandLine.c:409
#5  0x33c8a65d in MGPMrCommandLine (argc=3, argv=0xbfbfead8, argp=0xbfbfeae8)
    at MGPMrCommandLine.c:172
#6  0x08048724 in main (argc=3, argv=0xbfbfead8, argp=0xbfbfeae8) at portmanager.c:44
(gdb)
```


----------



## osx-addict (Oct 2, 2009)

Can you print out "db" to ensure it's not null and also check the value of "dataBufferIdx".. One of those is bad -- probably the db is null OR db is bad and points to some address that is out of the process's address space which can cause a core also...

At this point can you take the port_dependencies.db and rename it -- see if it can recreate it from scratch?


----------



## jtl (Oct 6, 2009)

I was a little uncomfortable about trying to recreate port_dependencies.db from scratch because I thought it might take a very long time.  So, in a fit of flailing, I ran pkgdb -F and then pkg -fu, and I also went back and reran the site upgrade command for python:

# cd /usr/ports/lang/python && make upgrade-site-packages

Somehow I got lucky, and portmanager seems to be working fine now.  I'm guessing pkgdb -fu did the trick since I'd tried pkgdb -F before without any luck.  Anyway, I've used portmanager to upgrade several packages now without incident.  Thanks very much for you help with this.


----------



## osx-addict (Oct 7, 2009)

Glad to hear you're no longer stuck!


----------

