Menu

#1 Context stack memory problem

Beta (B.x)
closed-fixed
Core (3)
8
2006-12-19
2006-09-13
A. Sundman
No

After compilation on VC8, the context example craches
with an message "Unhandled exception at 0x7c911899 in
context.exe: 0xC0000005: Access violation reading
location 0xcdcdcddd."

Seems to be some kind om memory error related to the
deletion of the context stack.

Possibly related to the bg. threading?

Investigate and fix.

Stack:
context.exe!flogger::context_stack::~context_stack()
+ 0x3f bytes C++
context.exe!flogger::context_stack::`scalar deleting
destructor'() + 0x16 bytes C++
>
context.exe!boost::checked_delete<flogger::context_stack>(flogger::context_stack
* x=0x002e67a8) Line 34 + 0x1c bytes C++

context.exe!boost::detail::sp_counted_impl_p<flogger::context_stack>::dispose()
Line 76 + 0xc bytes C++
context.exe!boost::detail::sp_counted_base::release()
Line 89 + 0xf bytes C++

context.exe!boost::detail::shared_count::~shared_count()
Line 163 C++

context.exe!boost::shared_ptr<flogger::context_stack>::~shared_ptr<flogger::context_stack>()
+ 0x19 bytes C++
context.exe!flogger::log_entry::~log_entry() +
0x5c bytes C++

context.exe!flogger::logger_impl_bg::~logger_impl_bg()
Line 59 + 0xc bytes C++
context.exe!flogger::logger_impl_bg::`scalar deleting
destructor'() + 0x16 bytes C++

context.exe!boost::checked_delete<flogger::logger_impl_bg>(flogger::logger_impl_bg
* x=0x002e6360) Line 34 + 0x23 bytes C++

context.exe!boost::detail::sp_counted_impl_p<flogger::logger_impl_bg>::dispose()
Line 76 + 0xc bytes C++
context.exe!boost::detail::sp_counted_base::release()
Line 89 + 0xf bytes C++

context.exe!boost::detail::shared_count::~shared_count()
Line 163 C++

context.exe!boost::shared_ptr<flogger::logger>::~shared_ptr<flogger::logger>()
+ 0x19 bytes C++

context.exe!boost::shared_ptr<flogger::logger>::reset()
Line 232 C++
context.exe!flogger::logger_factory::destroy_logger()
Line 62 C++
context.exe!shutdown() Line 103 C++
context.exe!main() Line 114 C++
context.exe!__tmainCRTStartup() Line 586 + 0x19 bytes C
context.exe!mainCRTStartup() Line 403 C
kernel32.dll!7c816fd7()

Discussion

  • A. Sundman

    A. Sundman - 2006-09-21

    Logged In: YES
    user_id=1582185

    Fixed (I think). Problem was that the automatically
    generated destructor for the context_stack class didn't wait
    for other threads that were acessing the object.

    Added a lock in destructor and it seems to work fine.

     
  • A. Sundman

    A. Sundman - 2006-09-21
    • status: open --> closed-fixed
     
  • A. Sundman

    A. Sundman - 2006-09-22
    • priority: 7 --> 8
    • status: closed-fixed --> open-accepted
     
  • A. Sundman

    A. Sundman - 2006-09-22

    Logged In: YES
    user_id=1582185

    Hm. After discussion with j_grahn, it seems that the bug
    might still be alive. Investigate further.

     
  • A. Sundman

    A. Sundman - 2006-09-22

    Logged In: YES
    user_id=1582185

    Root cause of problem is that context stack exists in
    logger, and that smartpointers to the context stack are used
    (that delete it) in log_entry.

     
  • A. Sundman

    A. Sundman - 2006-09-22

    Logged In: YES
    user_id=1582185

    Wrong again. A copy exists in log_entry so this can't be it.

     
  • A. Sundman

    A. Sundman - 2006-09-22

    Logged In: YES
    user_id=1582185

    As soon as a NOP destructor is created in context_stack the
    problem dissapears.

     
  • A. Sundman

    A. Sundman - 2006-09-22

    Logged In: YES
    user_id=1582185

    Ah! Finally!

    Problem was that the config.hpp file was not included in
    context_stack.c/hpp. This clashed when multithreaded support
    was enabled (e.g. no mutex was available in the class). It's
    a miracle that it compiled in the first place :)

    Fixed it. Should be tested on Mac before closing the bug.

     
  • A. Sundman

    A. Sundman - 2006-09-22
    • status: open-accepted --> open-fixed
     
  • A. Sundman

    A. Sundman - 2006-12-19
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB