1 2 Previous Next 20 Replies Latest reply: Mar 8, 2011 8:44 AM by 842476 RSS

    Problem at using showleaks (dbx) on multithreaded process

    842476
      Hi,
      I'm using dbx for checking memory leaks and it works fine.
      The problem turns out when I apply the same tool for multithreaded process.
      I cause some leaks intentionally in order to verify the tool, and the showleaks command doesn't report any leak.
      I checked out that the test code works by analizing traces: the 'unfreed' malloc are called by some threads.

      Data:
      * Sun Dbx Debugger 7.5 2005/10/13
      * I am linking files with libthread_db library

      Any hint?
      Thank you in advance,
      Ignacio
        • 1. Re: Problem at using showleaks (dbx) on multithreaded process
          janitor
          Leaks checking is supported for multi-threaded programs. I am not aware of any open bugs in this area. Does the test program use standard heap management functions in libc? Is there a way to send us a test case? Thanks.
          • 2. Re: Problem at using showleaks (dbx) on multithreaded process
            842476
            I'm afraid that it is not possible to send the test code since it is, in fact, part of our application where I intentionally inserted a malloc call.
            The process that I'am checking, is linking with standard llibraries as well as a commercial one (free code for parsing messages).
            Anyway the dbx multithread commands work fine.
            Thank you.
            • 3. Re: Problem at using showleaks (dbx) on multithreaded process
              Ivanigorovich-Oracle
              Are you sure you're generating a "leak" as defined by RTC? It's different from
              the usage of the term which arose after RTC was first designed.
              Does the 'showmemuse' command show the right thing?

              For the record ...
              A memory use:
              char *p = strdup();
              // no free
              A leak:
              char *p = strdup();
              p = strdup();
              free(p)l
              // the memory allocated by first strdup is unfreeable, lost, leaked.
              • 4. Re: Problem at using showleaks (dbx) on multithreaded process
                842476
                Hi,
                In order to generate an intentional leak I'am just doing:
                char *p;
                ...
                p=malloc(3);

                It works for non-multithreaded processes using the 'showleaks' command, so I supposed it should be work on multithreaded too.
                Thanks
                • 5. Re: Problem at using showleaks (dbx) on multithreaded process
                  Ivanigorovich-Oracle
                  Do you see the "leak" using 'showmemuse' in the MT case?
                  • 6. Re: Problem at using showleaks (dbx) on multithreaded process
                    842476
                    Hi,
                    Not even in non-MT process, I don't see the 'leak' at using showmemuse but with showleaks.
                    I send both reports (non-MT and MT processes)

                    Non-threaded process:

                    # /opt/SUNWspro/bin/dbx
                    For information about new features see `help changes'
                    To remove this message, put `dbxenv suppress_startup_message 7.5' in your .dbxrc
                    (dbx) debug pmtLogic
                    Reading pmtLogic
                    Reading ld.so.1
                    Reading libcommonLibraries.so
                    Reading libfmrdb.so
                    Reading libdbConfiguration.so
                    Reading libdbCommon.so
                    Reading libdbSession.so
                    Reading libdbPmoSession.so
                    Reading libdbRestriccion.so
                    Reading libdbCachePortal.so
                    Reading libpmtCodes.so
                    Reading libnsl.so.1
                    Reading libsocket.so.1
                    Reading libCstd.so.1
                    Reading libCrun.so.1
                    Reading libm.so.1
                    Reading libc.so.1
                    Reading libdl.so.1
                    Reading libmp.so.2
                    Reading libc_psr.so.1
                    (dbx) check -memuse
                    memuse checking - ON
                    (dbx) check -leaks
                    leaks checking - ON
                    (dbx) run
                    Running: pmtLogic
                    (process id 22707)
                    Reading rtcapihook.so
                    Reading rtcaudit.so
                    Reading libmapmalloc.so.1
                    Reading libgen.so.1
                    Reading rtcboot.so
                    Reading librtc.so
                    RTC: Enabling Error Checking...
                    RTC: Running program...
                    ^Cdbx: warning: Interrupt ignored but forwarded to child.
                    signal INT (Interrupt) in libcpoll at 0xffffffff5c1a740c
                    0xffffffff5c1a740c: libcpoll+0x0004: ta 64
                    (dbx) showmemuse -a
                    Checking for memory use...

                    Blocks in use report (blocks in use: 1291 total size: 3471768 bytes)

                    Total % of Num of Avg Allocation call stack
                    Size All Blocks Size
                    ========== ==== ====== ====== =======================================
                    1050624 30% 1 1050624 CONS_init < STMT_init < initDBSystem < connectDB < CONFIGURATION_DB_init < CONF_DB_init < main
                    1050624 30% 1 1050624 CONS_init < XDML_init < initDBSystem < connectDB < CONFIGURATION_DB_init < CONF_DB_init < main
                    208384 6% 16 13024 initChannel < msgAccept
                    208384 6% 16 13024 initChannel < openMsgInitSockChannel
                    27600 <1% 1 27600 prepareDmlDB < TB_PMO_SESSION_prepare_select_statement < PMO_SES_DB_init < main
                    27600 <1% 1 27600 prepareDmlDB < TB_PROVIDER_RESTRICT_prepare_select_statement < RES_DB_init < main
                    27600 <1% 1 27600 prepareDmlDB < TB_PMO_SESSION_prepare_insert_statement < PMO_SES_DB_init < main
                    27600 <1% 1 27600 prepareDmlDB < TB_ERROR_CONFIG_prepare_selectAll_statement < CONF_DB_init < main
                    27600 <1% 1 27600 prepareDmlDB < TB_TS22_prepare_select_statement < RES_DB_init < main

                    (dbx) showleaks -a
                    Checking for memory leaks...

                    Actual leaks report (actual leaks: 3 total size: 21 bytes)

                    Total Num of Leaked Allocation call stack
                    Size Blocks Block
                    Address
                    ========== ====== =========== =======================================
                    21 3 - eventMtReceivedFromTheThird < RELAY_MT_LOGIC


                    Possible leaks report (possible leaks: 0 total size: 0 bytes)


                    (dbx) threads
                    dbx: thread related commands not available
                    (dbx) quit






                    Threaded processs:

                    # /opt/SUNWspro/bin/dbx
                    For information about new features see `help changes'
                    To remove this message, put `dbxenv suppress_startup_message 7.5' in your .dbxrc
                    (dbx) debug pmtHttpServer
                    Reading pmtHttpServer
                    Reading ld.so.1
                    Reading libmtmalloc.so.1
                    Reading libpthread.so.1
                    Reading libthread_db.so.1
                    Reading libproc.so.1
                    Reading librt.so.1
                    Reading libxml2.so.2
                    Reading libz.so.1
                    Reading libm.so.1
                    Reading libcommonLibraries.so
                    Reading libdbCommon.so
                    Reading libdbConfiguration.so
                    Reading libdbTerceros.so
                    Reading libdbSession.so
                    Reading libfmrdb_mt.so
                    Reading libnsl.so.1
                    Reading libsocket.so.1
                    Reading libCstd.so.1
                    Reading libCrun.so.1
                    Reading libthread.so.1
                    Reading libc.so.1
                    Reading libdl.so.1
                    Reading librtld_db.so.1
                    Reading libelf.so.1
                    Reading libaio.so.1
                    Reading libmd5.so.1
                    Reading libmp.so.2
                    Reading libc_psr.so.1
                    (dbx) check -leaks
                    leaks checking - ON
                    (dbx) check -memuse
                    memuse checking - ON
                    (dbx) run
                    Running: pmtHttpServer
                    (process id 11880)
                    Reading rtcapihook.so
                    Reading rtcaudit.so
                    Reading libmapmalloc.so.1
                    Reading libgen.so.1
                    Reading rtcboot.so
                    Reading librtc.so
                    RTC: Enabling Error Checking...
                    RTC: Running program...

                    ^Cdbx: warning: Interrupt ignored but forwarded to child.
                    t@1 (l@1) signal INT (Interrupt) in __lwp_park at 0xffffffff56d17dac
                    0xffffffff56d17dac: __lwp_park+0x0010: ta 64
                    (dbx) showmemuse -a
                    Checking for memory use...

                    Blocks in use report (blocks in use: 0 total size: 0 bytes)


                    (dbx) showleaks -a
                    Checking for memory leaks...

                    Actual leaks report (actual leaks: 0 total size: 0 bytes)



                    Possible leaks report (possible leaks: 0 total size: 0 bytes)


                    (dbx) threads
                    o> t@1 a l@1 ?() sleep on 0x100880e28 in __lwp_park()
                    t@2 a l@2 amta_handle_timers() running in libcpoll()
                    t@3 a l@3 amta_handle_channels() running in libcpoll()
                    t@4 a l@4 amta_handle_threads() sleep on 0x100411b20 in __lwp_park()
                    t@5 a l@5 amta_handle_threads() sleep on 0x100411b20 in __lwp_park()
                    t@6 a l@6 amta_handle_threads() sleep on 0x100411b20 in __lwp_park()
                    t@7 a l@7 amta_handle_threads() sleep on 0x100411b20 in __lwp_park()
                    t@8 a l@8 amta_handle_threads() sleep on 0x100411b20 in __lwp_park()
                    t@9 a l@9 amta_handle_threads() sleep on 0x100411b20 in __lwp_park()
                    t@10 a l@10 amta_handle_threads() sleep on 0x100411b20 in __lwp_park()
                    t@11 a l@11 amta_handle_threads() sleep on 0x100411b20 in __lwp_park()
                    t@12 a l@12 amta_handle_threads() sleep on 0x100411b20 in __lwp_park()
                    t@13 a l@13 amta_handle_threads() sleep on 0x100411b20 in __lwp_park()
                    t@14 a l@14 plat_run() running in libcpoll()
                    (dbx) quit



                    Thank you.
                    • 7. Re: Problem at using showleaks (dbx) on multithreaded process
                      Darryl Gove-Oracle
                      Can you try a more recent version of dbx? Or take a look at discover in OSS12.2?

                      Regards,

                      Darryl.
                      • 8. Re: Problem at using showleaks (dbx) on multithreaded process
                        janitor
                        I suspect that RTC may not recognize the malloc call in this case. Please post the stack trace when malloc is called in the multi-threaded case. Also issue showmemuse/showleaks after the malloc call. Thanks.

                        Edited by: janitor on Mar 1, 2011 3:45 PM
                        • 9. Re: Problem at using showleaks (dbx) on multithreaded process
                          janitor
                          Reading libmtmalloc.so.1
                          RTC does not interpose libmtmalloc and therefore the malloc calls are not detected. As a workaround, please do not use libmtmalloc for leaks checking.
                          • 10. Re: Problem at using showleaks (dbx) on multithreaded process
                            janitor
                            The following bug has been filed:
                            7023836 RTC cannot detect leaks if app is linked with libmtmalloc

                            Do not link with libmtmalloc should workaround this problem.
                            • 11. Re: Problem at using showleaks (dbx) on multithreaded process
                              800381
                              janitor wrote:
                              The following bug has been filed:
                              7023836 RTC cannot detect leaks if app is linked with libmtmalloc

                              Do not link with libmtmalloc should workaround this problem.
                              If the OP has any LD_PRELOAD environment variables set to load libmtmalloc, and given where the load appeared in the list that's quite possible, there's not really a bug to fix, IMO.
                              • 12. Re: Problem at using showleaks (dbx) on multithreaded process
                                janitor
                                RTC should be able to redirect heap management calls (malloc, realloc, ... ) from libmtmalloc to libc.
                                • 13. Re: Problem at using showleaks (dbx) on multithreaded process
                                  800381
                                  janitor wrote:
                                  RTC should be able to redirect heap management calls (malloc, realloc, ... ) from libmtmalloc to libc.
                                  That's all well and good, but when someone explicitly breaks interposing and library ordering by setting LD_* envvals, the system worked exactly as designed.

                                  So what are you going to do about LD_PRELOAD, then? Wipe it out under dbx? Then what about someone who wants to preload some other library for some legitimate but unpredicable reason? FWIW, I've seen systems that use LD_PRELOAD wrappers around dbx so debugging sessions could automatically find the proper source code for the running binary from within a large and multi-branched source code tree.
                                  • 14. Re: Problem at using showleaks (dbx) on multithreaded process
                                    janitor
                                    when someone explicitly breaks interposing and library ordering by setting LD_* env vals, the system worked exactly as designed.
                                    Agree. But what are the options when this happens? As a user, all I want to do is to find memory leaks by running the leaks checking under dbx. I don't want to modify my makefiles or scripts unless it is absolutely necessary. If dbx/rtc can provide a way to workaround this interposition issue and find the leaks for me, I can spend my time fixing the leaks instead of trying to find out why leaks checking doesn't work with my runs.

                                    The LD_PRELOAD issues have been addressed (in some extend) in dbx7.5 or newer versions where RTC is switched to use LD_AUDIT from LD_PRELOAD.
                                    1 2 Previous Next