[Bug 35061] GoldCoin 0.7.1.7 shows assertion on startup (needs ntdll.NtQuerySemaphore implementation)

wine-bugs at winehq.org wine-bugs at winehq.org
Fri Dec 6 16:52:53 CST 2013


http://bugs.winehq.org/show_bug.cgi?id=35061

--- Comment #3 from Anastasius Focht <focht at gmx.net> 2013-12-06 16:52:53 CST ---
Hello folks,

fortunately the assert gives some hints at the code base and how the semaphore
wrapper is implemented/being used.

http://www.boost.org/doc/libs/1_55_0/boost/interprocess/detail/windows_intermodule_singleton.hpp

--- snip ---
...
class windows_semaphore_based_map
{
   typedef std::map<std::string, ref_count_ptr> map_type;

   public:
   windows_semaphore_based_map()
   {
...
      bool created = false;
      const permissions & perm = permissions();
      std::string pid_creation_time, name;
      get_pid_creation_time_str(pid_creation_time);
      name = "bipc_gmap_sem_lock_";
      name += pid_creation_time;
      bool success = m_mtx_lock.open_or_create(name.c_str(), perm);
      name = "bipc_gmap_sem_count_";
      name += pid_creation_time;
      scoped_lock<winapi_mutex_wrapper> lck(m_mtx_lock);
      {
         success = success && m_sem_count.open_or_create
            ( name.c_str(), static_cast<long>(0),
winapi_semaphore_wrapper::MaxCount, perm, created);
         name = "bipc_gmap_sem_map_";
         name += pid_creation_time;
         success = success && m_sem_map.open_or_create
            (name.c_str(), initial_count, max_count, perm, created);
         if(!success){
            delete m;
            //winapi_xxx wrappers do the cleanup...
            throw int(0);
         }
         if(!created){
            delete m;
         }
         else{
            BOOST_ASSERT(&get_map_unlocked() == m);
         }
         m_sem_count.post();
      }
   }
...
   map_type &get_map_unlocked()
   {
      if(sizeof(void*) == sizeof(boost::uint32_t)){
         union caster_union
         {
            void *addr;
            boost::uint32_t addr_uint32;
         } caster;
         caster.addr = 0;
         caster.addr_uint32 = m_sem_map.limit();
         caster.addr_uint32 = caster.addr_uint32 << 2;
         return *static_cast<map_type*>(caster.addr);
      }
      else{
         union caster_union
         {
            void *addr;
            boost::uint64_t addr_uint64;
         } caster;
         boost::uint32_t max_count(m_sem_map.limit()),
initial_count(m_sem_map.value());
         //Clear quasi-top bit
         max_count &= boost::uint32_t(0xBFFFFFFF);
         caster.addr_uint64 = max_count;
         caster.addr_uint64 =  caster.addr_uint64 << 32;
         caster.addr_uint64 |= boost::uint64_t(initial_count) << 2;
         return *static_cast<map_type*>(caster.addr);
      }
   }

--- snip ---

http://www.boost.org/doc/libs/1_55_0/boost/interprocess/sync/windows/winapi_semaphore_wrapper.hpp

--- snip ---
class winapi_semaphore_functions
{
...
  long limit() const
   {
      long l_count, l_limit;
      if(!winapi::get_semaphore_info(m_sem_hnd, l_count, l_limit))
         return 0;
      return l_limit;
   }
...
--- snip ---

http://www.boost.org/doc/libs/1_55_0/boost/interprocess/detail/win32_api.hpp

--- snip ---
inline bool get_semaphore_info(void *handle, long &count, long &limit)
{
   winapi::interprocess_semaphore_basic_information info;
   winapi::NtQuerySemaphore_t pNtQuerySemaphore =
        
(winapi::NtQuerySemaphore_t)dll_func::get(winapi::dll_func::NtQuerySemaphore);
   unsigned int ret_len;
   long status = pNtQuerySemaphore(handle, winapi::semaphore_basic_information,
&info, sizeof(info), &ret_len);
   count = info.count;
   limit = info.limit;
   return !status;
}
--- snip ---

Wine source:
http://source.winehq.org/git/wine.git/blob/4af4df5af3cffd3e1b18932e4fbedbae10c8b2b6:/dlls/ntdll/sync.c#l214

--- snip ---
214 NTSTATUS WINAPI NtQuerySemaphore(
215         HANDLE SemaphoreHandle,
216         SEMAPHORE_INFORMATION_CLASS SemaphoreInformationClass,
217         PVOID SemaphoreInformation,
218         ULONG Length,
219         PULONG ReturnLength)
220 {
221         FIXME("(%p,%d,%p,0x%08x,%p) stub!\n",
222         SemaphoreHandle, SemaphoreInformationClass, SemaphoreInformation,
Length, ReturnLength);
223         return STATUS_SUCCESS;
224 }
--- snip ---

Regards

-- 
Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email
Do not reply to this email, post in Bugzilla using the
above URL to reply.
------- You are receiving this mail because: -------
You are watching all bug changes.



More information about the wine-bugs mailing list