Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix/default stack size on osx too small #5265

Merged
merged 8 commits into from May 7, 2018

Conversation

kvahed
Copy link
Contributor

@kvahed kvahed commented May 4, 2018

OSX default stack size for threads is at 512k, needs tweaking.

Copy link
Member

@mchacki mchacki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please:

  1. Add Proper ErrorHandling in Production Code
    TRI_ASSERT(false) alone is no option.
  2. Fix variable name convention
  3. Where is thread.join()

auto err = pthread_attr_init (&stackSizeAttribute);
if (err) {
// We should never be here
TRI_ASSERT(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a proper exception here please.
This will fail in our tests, but in delivered versions if it shows up (even if it is super unlikely obviously it is still possible) we will end up in undefined behaviour otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I also considered this as ultra unlikely and

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

err = pthread_attr_getstacksize(&stackSizeAttribute, &stackSize);
if (err) {
// We should never be here
TRI_ASSERT(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here add Proper error handling

err = pthread_attr_setstacksize (&stackSizeAttribute, 8388608);
if (err) {
// We should never be here
TRI_ASSERT(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

tests/main.cpp Outdated
}
int result() {return result_;}
private:
Function f_;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i thought our convention for private variables is:
_private
not:
private_

please fix

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

std::thread subthread(runTests, argc, argv);
subthread.join();
TestThread<decltype(tests)> t(std::move(tests), argc, argv);
result = t.result();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our of curiousity don't we need the join() some where?
I do not see any place waiting for the test to complete. On the old we did wait for the subthread.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No don't need join. The thread is joined or detatched in destruction of arangodb::Thread.

@dothebart
Copy link
Contributor


/Users/jenkins/buws/workspace/RELEASE__BuildTest/tests/main.cpp:15:27: error: unknown class name 'Thread'; did you mean 'std::thread'?
class TestThread : public arangodb::Thread {
                          ^~~~~~~~~~~~~~~~
                          std::thread
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/thread:293:24: note: 'std::thread' declared here
class _LIBCPP_TYPE_VIS thread
                       ^
/Users/jenkins/buws/workspace/RELEASE__BuildTest/tests/main.cpp:19:15: error: initializer 'Thread' does not name a non-static data member or base class; did you mean the base class 'thread'?
    arangodb::Thread("catch"), f_(f), i_(i), c_(c) {
              ^~~~~~
              thread
/Users/jenkins/buws/workspace/RELEASE__BuildTest/tests/main.cpp:15:20: note: base class 'std::thread' specified here
class TestThread : public arangodb::Thread {
                   ^~~~~~~~~~~~~~~~~~~~~~~
In file included from /Users/jenkins/buws/workspace/RELEASE__BuildTest/tests/main.cpp:5:
In file included from /Users/jenkins/buws/workspace/RELEASE__BuildTest/arangod/Cluster/ServerState.h:28:
In file included from /Users/jenkins/buws/workspace/RELEASE__BuildTest/lib/Basics/ReadWriteLock.h:31:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/thread:347:5: error: attempt to use a deleted function
    __invoke(_VSTD::move(_VSTD::get<0>(__t)), _VSTD::move(_VSTD::get<_Indices>(__t))...);
    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/thread:357:5: note: in instantiation of function template specialization 'std::__1::__thread_execute<const char *>' requested here
    __thread_execute(*__p, _Index());
    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/thread:369:42: note: in instantiation of function template specialization 'std::__1::__thread_proxy<std::__1::tuple<const char *> >' requested here
    int __ec = pthread_create(&__t_, 0, &__thread_proxy<_Gp>, __p.get());
                                         ^
/Users/jenkins/buws/workspace/RELEASE__BuildTest/tests/main.cpp:19:5: note: in instantiation of function template specialization 'std::__1::thread::thread<char const (&)[6], void>' requested here
    arangodb::Thread("catch"), f_(f), i_(i), c_(c) {
    ^
/Users/jenkins/buws/workspace/RELEASE__BuildTest/tests/main.cpp:60:31: note: in instantiation of member function 'TestThread<(lambda at /Users/jenkins/buws/workspace/RELEASE__BuildTest/tests/main.cpp:57:16)>::TestThread' requested here
  TestThread<decltype(tests)> t(std::move(tests), argc, argv);
                              ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/type_traits:1089:5: note: '~__nat' has been explicitly marked deleted here
    ~__nat() = delete;
    ^

3 errors generated.
make[2]: *** [tests/CMakeFiles/arangodbtests.dir/main.cpp.o] Error 1```

@mchacki mchacki added this to the devel milestone May 7, 2018
Copy link
Member

@mchacki mchacki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mchacki
Copy link
Member

mchacki commented May 7, 2018

Is the error reported by @dothebart sorted out as well?

@mchacki
Copy link
Member

mchacki commented May 7, 2018

ok from internal discussion this has been sorted out, was an issue on the machine.

@mchacki mchacki merged commit 012718d into devel May 7, 2018
@fceller fceller deleted the bug-fix/default-stack-size-on-osx-too-small branch June 5, 2018 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants