Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. why cause exception??

why cause exception??

Scheduled Pinned Locked Moved C / C++ / MFC
question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    ttzzgg_80713
    wrote on last edited by
    #1

    :confused:class TaskInfoBase { .... virtual void setSize(int) = 0; }; class NewTaskInfo : public TaskInfoBase { NewTaskInfo() { InitializeCriticalSection(&m_cs); } ~NewTaskInfo() { DeleteCriticalSection(&m_cs); } void setSize(int); static CRITICAL_SECTION m_cs; }; class NewTask : public NewTaskInfo, pubic NewTaskBase { }; class HttpDownload : public DownData , public CHttpDown { public: HttpDownload():NewTaskInfo() {} void write(); NewTask *m_pTask; }; //****************************************************************************** // Implement CRITICAL_SECTION NewTaskInfo::m_cs; void NewTaskInfo::setSize(int i) { EnterCriticalSection(&m_cs); // Exception here . m_nSize = i; LeaveCriticalSection(&m_cs); } void HttpDown::write() { .... m_pTask->setSize(20002); // Enter NewTaskInfo::setSize(); }

    G 1 Reply Last reply
    0
    • T ttzzgg_80713

      :confused:class TaskInfoBase { .... virtual void setSize(int) = 0; }; class NewTaskInfo : public TaskInfoBase { NewTaskInfo() { InitializeCriticalSection(&m_cs); } ~NewTaskInfo() { DeleteCriticalSection(&m_cs); } void setSize(int); static CRITICAL_SECTION m_cs; }; class NewTask : public NewTaskInfo, pubic NewTaskBase { }; class HttpDownload : public DownData , public CHttpDown { public: HttpDownload():NewTaskInfo() {} void write(); NewTask *m_pTask; }; //****************************************************************************** // Implement CRITICAL_SECTION NewTaskInfo::m_cs; void NewTaskInfo::setSize(int i) { EnterCriticalSection(&m_cs); // Exception here . m_nSize = i; LeaveCriticalSection(&m_cs); } void HttpDown::write() { .... m_pTask->setSize(20002); // Enter NewTaskInfo::setSize(); }

      G Offline
      G Offline
      Gary R Wheeler
      wrote on last edited by
      #2

      I would guess that the m_pTask pointer doesn't point to a valid NewTaskInfo object. If that's the case, the this pointer on entry to the setSize function isn't valid, and the resulting m_cs member passed to the EnterCriticalSection function doesn't represent a valid critical section.


      Software Zen: delete this;

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups