facebook / hhvm

A virtual machine for executing programs written in Hack.
https://hhvm.com
Other
18.06k stars 2.99k forks source link

Invalid conversion in cmd_thread.cpp when building on OS X #188

Closed ArloL closed 11 years ago

ArloL commented 13 years ago

Running Mac OS X 10.6.4 Intel 64bit with current MacPorts + requirements installed as described by Hui Chen here: http://huichen.org/en/2010/08/hiphop-for-mac/

At 50% during make I get this error: hiphop-php/src/runtime/eval/debugger/cmd/cmd_thread.cpp: In member function 'virtual void HPHP::Eval::CmdThread::debuggerInfo(std::vector<std::pair<const char, std::basic_string<char, std::char_traits, std::allocator > >, std::allocator<std::pair<const char, std::basic_string<char, std::char_traits, std::allocator > > > >&)': hiphop-php/src/runtime/eval/debugger/cmd/cmd_thread.cpp:171: error: invalid conversion from '_opaque_pthreadt' to 'HPHP::int64' hiphop-php/src/runtime/eval/debugger/cmd/cmdthread.cpp:171: error: initializing argument 2 of 'static std::string HPHP::IDebuggable::FormatNumber(const char, HPHP::int64)'

Edit:

The code from the line is:

Add(info, "Thread ID", FormatNumber("0x%llx", Process::GetThreadId()));

and when I grep'ed through the code i found:

./src/util/stack_trace.cpp: dprintf(fd, "ThreadID: %llx\n", (int64)Process::GetThreadId());

So I guess it is possible to just cast. However then I ran into problems in /src/runtime/eval/debugger/debugger_proxy.cpp: error: invalid conversion from 'HPHP::int64' to '_opaque_pthread_t*' on lines 82 and 94. Here I would guess that it is not possible to just cast (I am no C/C++ developer so I am just guessing from a PHP/Java Background).

A google search for opaque_pthread_t brought some minor insight that this is a problem of handling the thread id from different systems as the type is truely opaque.

Some of the links I found interesting: http://stackoverflow.com/questions/558469/how-do-i-get-a-thread-id-from-an-arbitrary-pthread-t http://fixunix.com/unix/84437-how-print-out-thread-id-pthread_t.html Post 7 & 9 http://dev.ryzom.com/boards/1/topics/952#message-1008

From what I've learnt I think this means that you can not use int64 reliably to pass threadIds as it may not be recognized by every system and one should therefore use an "opaque pointer" instead.

ptarjan commented 11 years ago

We're closing out all bugs older than 2 months. http://www.hiphop-php.com/wp/?p=575

If this is still an issue, please re-open it, and in order of goodness:

  1. Give detailed repro steps
  2. Write a test case in hphp/tests/quick (run it with hphp/tests/run) and send the pull request
  3. Fix it in a pull request