[Home]

Summary:ASTERISK-28590: utils.c throws repeated warnings; "pthread_attr_setstacksize: Invalid argument"
Reporter:Speed Dial Dave (speeddialdave)Labels:patch
Date Opened:2019-10-17 13:09:54Date Closed:2019-10-21 13:24:27
Priority:MinorRegression?
Status:Closed/CompleteComponents:General
Versions:16.6.0 Frequency of
Occurrence
Frequent
Related
Issues:
Environment:Debian 10.1 Buster aarch64 (Pine64 small board computer with 1GB of RAM)Attachments:( 0) 0001-utils.h-Set-lower-limit-on-thread-stack-size.patch
Description:Linux 4.19.0-6-arm64 #1 SMP Debian 4.19.67-2+deb10u1 (2019-09-20) aarch64 GNU/Linux

16.6.0 built from source: ./configure --disable-xmldoc --with-jansson-bundled --with-pjproject-bundled --without-bluetooth --without-dahdi --without-gtk2

Throws a warning regularly, from a lot of different actions: WARNING[1539]: utils.c:1296 ast_pthread_create_stack: pthread_attr_setstacksize: Invalid argument
Comments:By: Asterisk Team (asteriskteam) 2019-10-17 13:09:54.698-0500

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

Please note that once your issue enters an open state it has been accepted. As Asterisk is an open source project there is no guarantee or timeframe on when your issue will be looked into. If you need expedient resolution you will need to find and pay a suitable developer. Asking for an update on your issue will not yield any progress on it and will not result in a response. All updates are posted to the issue when they occur.

By: Benjamin Keith Ford (bford) 2019-10-17 13:38:31.979-0500

Can you provide some examples of what you do to produce the WARNING message?

Also, on Asterisk 16, pjproject is automatically bundled, so you don't need to worry about passing that option when doing a configure.

By: Speed Dial Dave (speeddialdave) 2019-10-17 14:09:39.210-0500

What I've caught so far:

* always during startup when loading certain modules, for example pbx_spool.so, res_calendar.so, func_lock.so, res_pjsip_sdp_rtp.so, res_pjsip_pubsub.so, res_timing_pthread.so, as well as a few others

* always when I connect to a running Asterisk instance (using `asterisk -r`)

* now and then in the middle of outbound test calls, while Asterisk is busy inside BackGround(), with no other channels up and running

* once or twice while Asterisk was completely idle, with no in- or outbound traffic what so ever (the machine is tucked away behind NAT, no traffic forwarded to it, and does not qualify its peers)

If it's to any help I run an instance of Ast 16.3.0 on a 32-bit Arm platform as well, built the same way but on Arch Linux, and this warning is not present there.

By: Sean Bright (seanbright) 2019-10-17 15:03:30.254-0500

What does {{getconf PAGE_SIZE}} return?

By: Speed Dial Dave (speeddialdave) 2019-10-17 15:18:53.645-0500

4096.

By: Sean Bright (seanbright) 2019-10-17 15:21:32.446-0500

Are you compiling with {{LOW_MEMORY}} defined?

By: Speed Dial Dave (speeddialdave) 2019-10-17 15:26:43.209-0500

Yes. Here's my menuselect.makeopts in case it helps: https://pastebin.com/raw/bfxiEWeX

By: Speed Dial Dave (speeddialdave) 2019-10-17 17:37:06.717-0500

{{utils.c:1296 ast_pthread_create_stack: pthread_attr_setstacksize(114688): Invalid argument}}

By: Sean Bright (seanbright) 2019-10-18 08:10:54.075-0500

According to [the Linux {{man}} page for {{pthread_attr_setstacksize}}|https://linux.die.net/man/3/pthread_attr_setstacksize], it will return {{EINVAL}} if:

bq. The stack size is less than {{PTHREAD_STACK_MIN}} (16384) bytes.

or:

bq. On some systems, *pthread_attr_setstacksize()* can fail with the error *{{EINVAL}}* if _stacksize_ is not a multiple of the system page size.

Neither of those appear to be the case here, so I am not sure how to proceed. I don't have access to the appropriate hardware to test.

By: Sean Bright (seanbright) 2019-10-18 08:12:57.258-0500

Actually, I am seeing a reference that {{PTHREAD_STACK_MIN}} on aarch64 is 128k. I'll have another test patch shortly.

By: Sean Bright (seanbright) 2019-10-18 08:15:44.372-0500

[~speeddialdave], can you try [^0001-utils.h-Set-lower-limit-on-thread-stack-size.patch] and let us know if it fixes the warning?

By: Speed Dial Dave (speeddialdave) 2019-10-18 10:48:27.993-0500

[~seanbright], with your patch the warnings are now gone. I will perform some tests with varying volumes of test calls over the course of a day to see if anything odd pops up. Apart from that I guess we can close this issue, unless you'd like me to try another patch or so.

By: Speed Dial Dave (speeddialdave) 2019-10-18 17:43:20.629-0500

After around 10k test calls over several hours, with your second patch applied, the warning hasn't showed up a single time. Looks like your patch did the trick.

By: Friendly Automation (friendly-automation) 2019-10-21 13:24:28.085-0500

Change 13080 merged by Friendly Automation:
utils.h: Set lower bound for thread stack size to PTHREAD_STACK_MIN

[https://gerrit.asterisk.org/c/asterisk/+/13080|https://gerrit.asterisk.org/c/asterisk/+/13080]

By: Friendly Automation (friendly-automation) 2019-10-21 13:34:32.384-0500

Change 13082 merged by Friendly Automation:
utils.h: Set lower bound for thread stack size to PTHREAD_STACK_MIN

[https://gerrit.asterisk.org/c/asterisk/+/13082|https://gerrit.asterisk.org/c/asterisk/+/13082]

By: Friendly Automation (friendly-automation) 2019-10-21 13:54:25.307-0500

Change 13081 merged by Kevin Harwell:
utils.h: Set lower bound for thread stack size to PTHREAD_STACK_MIN

[https://gerrit.asterisk.org/c/asterisk/+/13081|https://gerrit.asterisk.org/c/asterisk/+/13081]

By: Friendly Automation (friendly-automation) 2019-10-21 13:54:45.559-0500

Change 13083 merged by Kevin Harwell:
utils.h: Set lower bound for thread stack size to PTHREAD_STACK_MIN

[https://gerrit.asterisk.org/c/asterisk/+/13083|https://gerrit.asterisk.org/c/asterisk/+/13083]