On Sun, Apr 09, 2023 at 07:53:31AM +0200, Sebastien Marie wrote:
> On Fri, Apr 07, 2023 at 09:52:52AM +0200, Otto Moerbeek wrote:
> > > Hi,
> > >
> > > This is work in progress. I have to think if the flags to kdump I'm
> > > introducing should be two or a single one.
> > >
> > > Currently, malloc.c can be compiled with MALLOC_STATS defined. If run
> > > with option D it dumps its state to a malloc.out file at exit. This
> > > state can be used to find leaks amongst other things.
> > >
> > > This is not ideal for pledged processes, as they often have no way to
> > > write files.
> > >
> > > This changes malloc to use utrace(2) for that.
> > >
> > > As kdump has no nice way to show those lines without all extras it
> > > normally shows, so add two options to it to just show the lines.
> > >
> > > To use, compile and install libc with MALLOC_STATS defined.
> > >
> > > Run :
> > >
> > > $ MALLOC_OPTIONS=D ktrace -tu your_program
> > > ...
> > > $ kdump -hu
> > >
> > > Feedback appreciated.
>
> I can't really comment on malloc(3) stuff, but I agree that utrace(2) is a
> good
> way to get information outside a pledged process.
>
> I tend to think it is safe to use it, as the pledged process need cooperation
> from outside to exfiltrate informations (a process with permission to call
> ktrace(2) on this pid).
>
> Please note it is a somehow generic problem: at least profiled processes
> would
> also get advantage of using it.
>
>
> Regarding kdump options, I think that -u option should implies -h (no header).
>
> Does it would make sens to considere a process using utrace(2) with several
> interleaved records for different sources ? A process with MALLOC_OPTIONS=D
> and
> profiling enabled for example ? An (another) option on kdump to filter on
> utrace
> label would be useful in such case, or have -u mandate a label to filter on.
>
> $ MALLOC_OPTIONS=D ktrace -tu your_program
> $ kdump -u mallocdumpline
>
> and for profiling:
>
> $ kdump -u profil > gmon.out
> $ gprof your_program gmon.out
>
> Thanks.
Thanks! Your suggestions make a lot of sense. I'll rework the kdump
part to make it more flexable for different purposes.
-Otto
> --
> Sebastien Marie