portmanager

Michael C. Shultz ringworm01 at gmail.com
Wed Oct 12 15:13:57 PDT 2005


On Wednesday 12 October 2005 13:33, you wrote:
> Just a comment from an on-looker to this post.  From the getenv
>
> The getenv() function obtains the current value of the environment vari-
>      able, name. If the variable name is not in the current environment, a
>      null pointer is returned.
>
> So it could potentially be passing in a null pointer to strncmp which is
> not good.  Is that the problem you're seeing.  Easy enough to test the
> return from getenv before using it.


I tried wrapping it with

if ( getenv("TERM") )
{
	. . .
}

made no difference.  

What is really frustrating is I can't get gdb to step through anything in 
function main ie. whatever is in portmanager.c, every function located in a 
library is no problem, this also renders the core file useless  Guess I'll 
shift the guts from portmanager.c to a library function then see what gdb
says.

************************************************

Weird, after shifting everything from main to a library function and then
wrapping with 

if ( getenv("TERM") )
{
	. . .
}

it works, so looks like you were right Mark. Thank you very much!

If your curious, here is the back trace after moving the guts to a library 
function before testing for an empty env:

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.1...done.
Loaded symbols for /usr/local/lib/libMG.1
Reading symbols from /usr/local/lib/libPMGR.1...done.
Loaded symbols for /usr/local/lib/libPMGR.1
Reading symbols from /lib/libc.so.5...done.
Loaded symbols for /lib/libc.so.5
Reading symbols from /libexec/ld-elf.so.1...done.
Loaded symbols for /libexec/ld-elf.so.1
#0  0x2808a336 in portmanager (argc=2, argv=0xbfbfee7c) at 
PMGRrInitialize.c:136
136             if( !strncmp( getenv("TERM"), "xterm", 5 ) && 
isatty(fileno(stdout)) )
(gdb) bt
#0  0x2808a336 in portmanager (argc=2, argv=0xbfbfee7c) at 
PMGRrInitialize.c:136
#1  0x0804857b in ?? ()
#2  0x00000002 in ?? ()
#3  0xbfbfee7c in ?? ()
#4  0x2804da19 in _rtld_bind_start () from /libexec/ld-elf.so.1
#5  0x28072000 in ?? ()
#6  0x00000001 in ?? ()
#7  0x00000002 in ?? ()
#8  0xbfbfee74 in ?? ()
#9  0x080483c5 in _init ()
#10 0x00000206 in ?? ()
#11 0x28072000 in ?? ()
#12 0xbfbfee74 in ?? ()
#13 0x080484a9 in ?? ()
#14 0x00000002 in ?? ()
#15 0xbfbfee7c in ?? ()
#16 0xbfbfee88 in ?? ()
#17 0x00000000 in ?? ()
#18 0x2804ff80 in find_symdef () from /libexec/ld-elf.so.1
Previous frame inner to this frame (corrupt stack?)
(gdb) frame 0
#0  0x2808a336 in portmanager (argc=2, argv=0xbfbfee7c) at 
PMGRrInitialize.c:136
136             if( !strncmp( getenv("TERM"), "xterm", 5 ) && 
isatty(fileno(stdout)) )
(gdb) info locals
handle = (FILE *) 0x2809031f
id = "portmanager"
ignorePortDir = "\030\006(�'$\005(\200\a(D\203\004\b\000#\a(\030\006(\030\006
(\000\b(�t�004(�\006
(\001\000\000\000�\001\000\000\000\000\000\000\000\001\000\000\000\000#\a(\002\000\000\000|
"
s = "-s"
showLeaves = "--show-leaves"
sl = "-sl"
slidDelete = "--show-leaves-interactive-delete"
slid = "-slid"
status = "--status"
u = "-u"
upgrade = "--upgrade"
ui = "-ui"
upgradeInteractive = "--upgrade-interactive"
v = "-v"
version = "--version"
buffer = 0x2806be18 "-\002"
command = 0x2809031f "xterm"
xtermTitle = 0x0
bufferSize = 0
errorCode = 0
idx = -1077941208
selection = 0
stringSize = 0
property = {cacheDbFileName = 0x0, commandLineDbFileName = 0x8000 <Address 
0x8000 out of bounds>,
  configConfFileName = 0x3 <Address 0x3 out of bounds>, configDbFileName = 
0x280531ce "\201�\214\001",
  dependencyPortsDbFileName = 0xffffffff <Address 0xffffffff out of bounds>, 
helpFile = 0x0,
  ignoreDbFileName = 0x20 <Address 0x20 out of bounds>, 
installedPortsDbFileName = 0x28051443 "\205�.\213E�\203x\016",
  oldPortsFileName = 0x280a6c1c "tsd_lock", strikesDbFileName = 0x280a6c1c 
"tsd_lock",
  field3strikesPortDir = 0xbfbfec58 "\210쿿g\023\005(\034l\n(+2\t", 
fieldStrikes = 0x28053186 "\213\024",
  fieldCommandLineKey = 0x2 <Address 0x2 out of bounds>, fieldCommandLineValue 
= 0x280a29bc "PB",
  fieldIgnorePortDir = 0xf50 <Address 0xf50 out of bounds>, fieldIgnoreReason 
= 0x2806be18 "-\002", fieldOldPortDir = 0x280732b0 "",
  fieldOldPortName = 0x0, fieldReason = 0xbfbfec88 "\b�v\021\005
(\034l\n(+2\tP\006(�",
  fieldNewPortName = 0x28051367 
"\211�205�#\205t\v\017@\f�\004<\002t\024\211�213F\004\211E�017B\f�\004<\002u\a\220\2136\205�\232\205t\b\213E\024\213U�211\020\211\203�034
[^_�\215t&", fieldKey = 0x280a6c1c "tsd_lock",
  fieldValue = 0x9a6322b <Address 0x9a6322b out of bounds>, fieldChildPortName 
= 0x28072400 "zP�001", fieldDependencyPortName = 0x0,
  fieldDependencyPortDir = 0x28049000 <Address 0x28049000 out of bounds>, 
fieldCachePortDir = 0x28072400 "zP�001",
  fieldAvailablePortName = 0xbfec98 <Address 0xbfec98 out of bounds>, 
fieldMakeFileSize = 0x2806be18 "-\002", fieldMakeFileTime = 0x0,
  fieldInstalledPortName = 0x280a29bc "PB", fieldInstalledPortDir = 0xbfbfed08 
"\030\006(\001",
  fieldUpgradePortDir = 0x28051176 "\211�205�\032\203}�, fieldUpgradePortName 
= 0x280a6c1c "tsd_lock", strikesDb = 0x9a6322b,
  cacheDb = 0x2806aa50, commandLineDb = 0xbfbfecdc, configDb = 0x0, 
dependencyPortsDb = 0xbfbfece0, ignoreDb = 0x0,
  installedPortsDb = 0x2805106e, outOfDatePortsDb = 0x28072000, portTree = 
0x28072200, objIdx = 671421507,
  portManagerUpdated = 134513476, verbose = 671640963, interactive = 
671555840}



>
> -----Original Message-----
> From: owner-freebsd-questions at freebsd.org
> [mailto:owner-freebsd-questions at freebsd.org] On Behalf Of Michael C. Shultz
> Sent: 10/12/2005 1:43 PM
> To: Michael Lednev; freebsd-questions at freebsd.org; hackers at freebsd.org
> Subject: Re: portmanager
>
> On Sunday 09 October 2005 07:53, Michael Lednev wrote:
> > Hello, freebsd-questions.
> >
> > anyone  tried  to  run  portmanager  from  crontab?  as for me it just
> > coredumps, what am i doing wrong? its simply 0 0 * * * portmanager -s
>
> I'm not sure how to fix it but I've found where portmanager crashes when
> run from cron, the code is:
>
>
>        if( !strncmp( getenv("TERM"), "xterm", 5 ) && isatty(fileno(stdout))
> )
>        {
>                stringSize      = strlen( id )
>                                + 1
>                                + strlen( VERSION )
>                                + 1;
>                xtermTitle      = malloc( stringSize );
>                xtermTitle[0]   = 0;
>                strcat( xtermTitle, id );
>                strcat( xtermTitle, " " );
>                strcat( xtermTitle, VERSION );
>                printf( "%c]0;%s%c", '\033', xtermTitle, '\007' );
>                free( xtermTitle );
>        }
>
>
> This is used to put information in the xterm title screen while portmanager
> is running, I don't know enough about cron to have a clue how to fix this
> except to remove it and I don't want to do that.  Anyone have any ideas?
> This particualr code snippet is from portmanager/portmanager.c around line
> 137....
>
> -Mike
>
> ps. I've cross posted this to freebsd-hackers because it is a coding
> problem, so you may want to remove freebsd-questions from any replies.
> .
>
>
>
>
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to
> "freebsd-questions-unsubscribe at freebsd.org"


More information about the freebsd-hackers mailing list