You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Arthur Naseef (JIRA)" <ji...@apache.org> on 2014/01/02 21:13:51 UTC

[jira] [Comment Edited] (AMQCPP-529) Crash in Threads due to small stack size (set to 32768 bytes)

    [ https://issues.apache.org/jira/browse/AMQCPP-529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13860702#comment-13860702 ] 

Arthur Naseef edited comment on AMQCPP-529 at 1/2/14 8:13 PM:
--------------------------------------------------------------

That's a valid perspective.

On the other hand, aren't these threads created by the activemq-cpp library itself?  It's perfectly reasonable for the library to define the stack size in that case and make that part of the calling contract for onMessage().

Another consideration is that many developers who are not used to programming with threads will easily run into problems setting the default stack too large.  Or, setting it too low, the activemq-cpp library's needs may not be adequately met, leading to mysterious faults in the library itself.

Threaded C/C++ programs with large automatic variables (allocated on the stack) are an antipattern.  When working with libraries that make extensive use of exceptions, I see the desire to use them - that's why the standard C++ library has tools like auto_ptr and unique_ptr.


was (Author: artnaseef):
That's a valid perspective.

On the other hand, aren't these threads are created by the activemq-cpp library itself?  It's perfectly reasonable for the library to define the stack size in that case and make that part of the calling contract for onMessage().

Another consideration is that many developers who are not used to programming with threads will easily run into problems setting the default stack too large.  Or, setting it too low, the activemq-cpp library's needs may not be adequately met, leading to mysterious faults in the library itself.

Threaded C/C++ programs with large automatic variables (allocated on the stack) are an antipattern.  When working with libraries that make extensive use of exceptions, I see the desire to use them - that's why the standard C++ library has tools like auto_ptr and unique_ptr.

> Crash in Threads due to small stack size (set to 32768 bytes)
> -------------------------------------------------------------
>
>                 Key: AMQCPP-529
>                 URL: https://issues.apache.org/jira/browse/AMQCPP-529
>             Project: ActiveMQ C++ Client
>          Issue Type: Bug
>          Components: Decaf
>    Affects Versions: 3.8.1
>         Environment: linux50
>            Reporter: omri zomet
>            Assignee: Timothy Bish
>            Priority: Critical
>
> Using version 3.8.1 of activemq-cpp (after using version 3.4.5) - we have suffered a crash in code running in amq threads.
> Investigation shows that this happens when trying to use a char[] buffer on stack of size > 16384 , probably due to the stack size being of size 32768.
> Thread::Thread() constructors call initializeSelf() with stackSize=(-1), which 
> in turn call createThreadInstance() with negative stackSize value (hence using PLATFORM_DEFAULT_STACK_SIZE).
> Relevant code below:
> ----------------------
>  #define PLATFORM_DEFAULT_STACK_SIZE 0x8000
> -----------------------
> void createThreadInstance(ThreadHandle* thread, long long stackSize, int  priority, bool suspended, threadingTask threadMain, void* threadArg) {
>         if (stackSize <= 0) {
>             stackSize = PLATFORM_DEFAULT_STACK_SIZE;
>         }
> ...
> }
> ----------------------



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)