Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Oct 2005 15:15:13 -0700
From:      "Michael C. Shultz" <ringworm01@gmail.com>
To:        "Mark J. Sommer" <msommer@argotsoft.com>, hackers@freebsd.org, RW <list-freebsd-2004@morbius.sent.com>
Subject:   Re: portmanager
Message-ID:  <200510121515.14805.ringworm01@gmail.com>
In-Reply-To: <200510122033.j9CKX5uo040708@argotsoft.com>
References:  <200510122033.j9CKX5uo040708@argotsoft.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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. =20

What is really frustrating is I can't get gdb to step through anything in=20
function main ie. whatever is in portmanager.c, every function located in a=
=20
library is no problem, this also renders the core file useless  Guess I'll=
=20
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=20

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=
=20
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 condition=
s.
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=20
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=3D2, argv=3D0xbfbfee7c) at=20
PMGRrInitialize.c:136
136             if( !strncmp( getenv("TERM"), "xterm", 5 ) &&=20
isatty(fileno(stdout)) )
(gdb) bt
#0  0x2808a336 in portmanager (argc=3D2, argv=3D0xbfbfee7c) at=20
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=3D2, argv=3D0xbfbfee7c) at=20
PMGRrInitialize.c:136
136             if( !strncmp( getenv("TERM"), "xterm", 5 ) &&=20
isatty(fileno(stdout)) )
(gdb) info locals
handle =3D (FILE *) 0x2809031f
id =3D "portmanager"
ignorePortDir =3D "\030\006(=EF=BF=BD'$\005(\200\a(D\203\004\b\000#\a(\030\=
006(\030\006
(\000\b(=EF=BF=BDt=EF=BF=BD004(=EF=BF=BD\006
(\001\000\000\000=EF=BF=BD\001\000\000\000\000\000\000\000\001\000\000\000\=
000#\a(\002\000\000\000|
=EE=BF=BF"
s =3D "-s"
showLeaves =3D "--show-leaves"
sl =3D "-sl"
slidDelete =3D "--show-leaves-interactive-delete"
slid =3D "-slid"
status =3D "--status"
u =3D "-u"
upgrade =3D "--upgrade"
ui =3D "-ui"
upgradeInteractive =3D "--upgrade-interactive"
v =3D "-v"
version =3D "--version"
buffer =3D 0x2806be18 "-\002"
command =3D 0x2809031f "xterm"
xtermTitle =3D 0x0
bufferSize =3D 0
errorCode =3D 0
idx =3D -1077941208
selection =3D 0
stringSize =3D 0
property =3D {cacheDbFileName =3D 0x0, commandLineDbFileName =3D 0x8000 <Ad=
dress=20
0x8000 out of bounds>,
  configConfFileName =3D 0x3 <Address 0x3 out of bounds>, configDbFileName =
=3D=20
0x280531ce "\201=EF=BF=BD\214\001",
  dependencyPortsDbFileName =3D 0xffffffff <Address 0xffffffff out of bound=
s>,=20
helpFile =3D 0x0,
  ignoreDbFileName =3D 0x20 <Address 0x20 out of bounds>,=20
installedPortsDbFileName =3D 0x28051443 "\205=EF=BF=BD.\213E=EF=BF=BD\203x\=
016",
  oldPortsFileName =3D 0x280a6c1c "tsd_lock", strikesDbFileName =3D 0x280a6=
c1c=20
"tsd_lock",
  field3strikesPortDir =3D 0xbfbfec58 "\210=EC=BF=BFg\023\005(\034l\n(+2\t"=
,=20
fieldStrikes =3D 0x28053186 "\213\024",
  fieldCommandLineKey =3D 0x2 <Address 0x2 out of bounds>, fieldCommandLine=
Value=20
=3D 0x280a29bc "PB",
  fieldIgnorePortDir =3D 0xf50 <Address 0xf50 out of bounds>, fieldIgnoreRe=
ason=20
=3D 0x2806be18 "-\002", fieldOldPortDir =3D 0x280732b0 "",
  fieldOldPortName =3D 0x0, fieldReason =3D 0xbfbfec88 "\b=ED=BF=BFv\021\005
(\034l\n(+2\tP\006(=EF=BF=BD",
  fieldNewPortName =3D 0x28051367=20
"\211=EF=BF=BD205=EF=BF=BD#\205t\v\017@\f=EF=BF=BD\004<\002t\024\211=EF=BF=
=BD213F\004\211E=EF=BF=BD017B\f=EF=BF=BD\004<\002u\a\220\2136\205=EF=BF=BD\=
232\205t\b\213E\024\213U=EF=BF=BD211\020\211\203=EF=BF=BD034
[^_=EF=BF=BD\215t&", fieldKey =3D 0x280a6c1c "tsd_lock",
  fieldValue =3D 0x9a6322b <Address 0x9a6322b out of bounds>, fieldChildPor=
tName=20
=3D 0x28072400 "zP=EF=BF=BD001", fieldDependencyPortName =3D 0x0,
  fieldDependencyPortDir =3D 0x28049000 <Address 0x28049000 out of bounds>,=
=20
fieldCachePortDir =3D 0x28072400 "zP=EF=BF=BD001",
  fieldAvailablePortName =3D 0xbfec98 <Address 0xbfec98 out of bounds>,=20
fieldMakeFileSize =3D 0x2806be18 "-\002", fieldMakeFileTime =3D 0x0,
  fieldInstalledPortName =3D 0x280a29bc "PB", fieldInstalledPortDir =3D 0xb=
fbfed08=20
"\030\006(\001",
  fieldUpgradePortDir =3D 0x28051176 "\211=EF=BF=BD205=EF=BF=BD\032\203}=EF=
=BF=BD, fieldUpgradePortName=20
=3D 0x280a6c1c "tsd_lock", strikesDb =3D 0x9a6322b,
  cacheDb =3D 0x2806aa50, commandLineDb =3D 0xbfbfecdc, configDb =3D 0x0,=20
dependencyPortsDb =3D 0xbfbfece0, ignoreDb =3D 0x0,
  installedPortsDb =3D 0x2805106e, outOfDatePortsDb =3D 0x28072000, portTre=
e =3D=20
0x28072200, objIdx =3D 671421507,
  portManagerUpdated =3D 134513476, verbose =3D 671640963, interactive =3D=
=20
671555840}



>
> -----Original Message-----
> From: owner-freebsd-questions@freebsd.org
> [mailto:owner-freebsd-questions@freebsd.org] On Behalf Of Michael C. Shul=
tz
> Sent: 10/12/2005 1:43 PM
> To: Michael Lednev; freebsd-questions@freebsd.org; hackers@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      =3D strlen( id )
>                                + 1
>                                + strlen( VERSION )
>                                + 1;
>                xtermTitle      =3D malloc( stringSize );
>                xtermTitle[0]   =3D 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 portmanag=
er
> 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@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to
> "freebsd-questions-unsubscribe@freebsd.org"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200510121515.14805.ringworm01>