Re: sig -g and foreach sig -g

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



May be there is a difficulty with free_all_bufs() ?
If i understand well the foreach() function :

Pre process part :
=============
        /*
         *  Filter out any command/option issues.
         */
        if (CRASHDEBUG(1)) {
...
                case FOREACH_SIG:
                        if (fd->flags & (FOREACH_l_FLAG|FOREACH_s_FLAG)) {
                                error(FATAL,
                                 "sig: -l and -s options are not 
applicable\n");
                        }
                        if (fd->flags & FOREACH_g_FLAG)
                                hash_tgid=alloc_hash_tgid(); 
/* Allocation with GETBUF() : hash table initialized*/
                        break;
...

        tc = FIRST_CONTEXT();

Process part :
==========
        for (i = 0; i < RUNNING_TASKS(); i++, tc++) {
                doit = FALSE;
...
                for (k = 0; k < fd->keys; k++) {
                        free_all_bufs(); 
/* All buffers allocated via GETBUF() are killed ? */

...
                        case FOREACH_SIG:
                                pc->curcmd = "sig";
                                if (fd->flags & FOREACH_g_FLAG) {
                                        tgid = task_tgid(tc->task);
                                        if (put_tgid(hash_tgid,tgid)) 
/* More allocations with GETBUF() : nodes added to hash table */
                                                show_tgid_sig_list(tc->task);
                                } else {
                                        do_sig(tc->task, FOREACH_SIG,
                                                fd->reference ? ref : NULL);
                                }
                                break;
...

Post process part
============
...
                case FOREACH_SIG:
                        if (CRASHDEBUG(1))
                                list_hash_tgid(hash_tgid);
                        if (fd->flags & FOREACH_g_FLAG) {
                                pc->curcmd = "sig";
                                free_hash_tgid(hash_tgid);               /* 
FREEBUF() used to release hash table */
                        }
                        break;
....


By the way, a third cleaner version of sig -g and foreach sig -g ... in 
attached file.

----- Original Message ----- 
From: "Dave Anderson" <anderson@xxxxxxxxxx>
To: "Discussion list for crash utility usage, maintenance and development" 
<crash-utility@xxxxxxxxxx>
Sent: Tuesday, October 10, 2006 3:07 PM
Subject: Re:  sig -g and foreach sig -g


Olivier Daudel wrote:

> Hello Dave,
>
> I think sig -g is quite OK.
> I have a problem with foreach sig -g.
> If i use malloc() and free(), it seems to work (may be the algorithmic is
> OK).
> I have tryed to use hashing on tgid to control if we have already 
> displayed
> it.
> If i use GETBUF() and FREEBUF(), it crashes.
> May be i don't understant some conditions in using GETBUF() and FREEBUF() 
> ?
>
> Thanks for any suggestion.

Hi Olivier,

Thanks for the update -- I'll take a look at the patch.

I don't understand off-hand why it would crash with GETBUF()/FREEBUF().
Using malloc/free for temporary buffers has always been a potential
problem because the command can be interrupted mid-stream, and
when that happens, it longjmp()'s back to the main loop, and the memory
is leaked.

GETBUF() is preferred over the malloc() of temporary per-command buffers
because even if you forget to do the FREEBUF(), it will be called 
automatically
prior to the next command.  In other words, the buffer returned from any
GETBUF() call can only be used for a single command, because the
buffer(s) will be subsequently freed in restore_sanity(), which is executed
just prior to the next command line being accessed.

Anyway, I'll take in your sig command changes, and see what I can do
about the foreach part.

Thanks again,
  Dave


>
>
>   ------------------------------------------------------------------------------------------------------------------------
>                 Name: sig.patch
>    sig.patch    Type: unspecified type (application/octet-stream)
>             Encoding: quoted-printable
>
>   ------------------------------------------------------------------------------------------------------------------------
> --
> Crash-utility mailing list
> Crash-utility@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/crash-utility

--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/crash-utility

Attachment: sig3.patch
Description: Binary data

--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/crash-utility

[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux