<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to bugs</title><link>https://sourceforge.net/p/state-threads/bugs/</link><description>Recent changes to bugs</description><atom:link href="https://sourceforge.net/p/state-threads/bugs/feed.rss" rel="self"/><language>en</language><lastBuildDate>Tue, 16 Dec 2014 09:54:28 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/state-threads/bugs/feed.rss" rel="self" type="application/rss+xml"/><item><title>using va_list in the st_thread under FreeBSD 10.1 should cause signal SIGBUS Error</title><link>https://sourceforge.net/p/state-threads/bugs/17/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;I meet an strange issue under the FreeBSD 10.1 (only on X64 include Amd64 and intel x64), when I use any var-arguments relation function in a state-thread, simple like the printf("Hello State-Threads.\n"), It'll cause signal SIGBUS Error.&lt;/p&gt;
&lt;p&gt;This issue should only occur on my two computre with FreeBSD 10.1 (X64 and Amd64), and never meet it on Mac OSX 10.10.1 (X64), CentOS 7.0 (X64), FreeBSD 10.1 (i386).&lt;/p&gt;
&lt;p&gt;my test case is attached after, please help!&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Bob Jiang</dc:creator><pubDate>Tue, 16 Dec 2014 09:54:28 -0000</pubDate><guid>https://sourceforge.netcc1c5129d9d2e683d8315738eb90f7b1a395a242</guid></item><item><title>#16 arm-linux MD_GET_SP offset is invalid.</title><link>https://sourceforge.net/p/state-threads/bugs/16/?limit=50#7fc4</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Please provide a preprocessor directive for detecting when the index should be 20 vs. when it should be 8, so fixing it for your platform won't break legacy systems.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mike Abbott</dc:creator><pubDate>Fri, 21 Mar 2014 12:12:13 -0000</pubDate><guid>https://sourceforge.net7141a709d305c14511e71f235e3f74aa8f4fafe7</guid></item><item><title>#15 fork process after st_init will got "wrong" state fd to read</title><link>https://sourceforge.net/p/state-threads/bugs/15/?limit=50#da7c</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Sounds like this could be either a misunderstanding about how to use ST, or an OS bug.  Does the problem occur only when accepting a new connection on a socket?  Perhaps you need to use st_netfd_serialize_accept() and/or update that function's implementation for your platform.  If it happens with other functions please provide a small, simplified test program to reproduce the issue, along with the results it produces on your system and the results you expect it to produce.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mike Abbott</dc:creator><pubDate>Fri, 21 Mar 2014 12:08:37 -0000</pubDate><guid>https://sourceforge.neta73abbb1e8b907f9833a9cdac2f3310600394004</guid></item><item><title>arm-linux MD_GET_SP offset is invalid.</title><link>https://sourceforge.net/p/state-threads/bugs/16/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;in the md.h, line 425:&lt;br /&gt;
    #define MD_GET_SP(_t) (_t)-&amp;gt;context&lt;span&gt;[0]&lt;/span&gt;.__jmpbuf&lt;span&gt;[20]&lt;/span&gt;&lt;br /&gt;
it will corrupt on debian armhf, for the sp offset is not 20, bug 8.&lt;/p&gt;
&lt;p&gt;// /usr/arm-linux-gnueabi/include/bits/setjmp.h&lt;/p&gt;
&lt;h1 id="ifndef-_asm"&gt;ifndef _ASM&lt;/h1&gt;
&lt;p&gt;/&lt;em&gt; The exact set of registers saved may depend on the particular core&lt;br /&gt;
   in use, as some coprocessor registers may need to be saved.  The C&lt;br /&gt;
   Library ABI requires that the buffer be 8-byte aligned, and&lt;br /&gt;
   recommends that the buffer contain 64 words.  The first 28 words&lt;br /&gt;
   are occupied by v1-v6, sl, fp, sp, pc, d8-d15, and fpscr.  (Note&lt;br /&gt;
   that d8-15 require 17 words, due to the use of fstmx.)&lt;br /&gt;
&lt;/em&gt;/&lt;br /&gt;
typedef int &lt;strong&gt;jmp_buf&lt;span&gt;&lt;span&gt;[64]&lt;/span&gt;&lt;/span&gt; &lt;/strong&gt;attribute&lt;strong&gt;((&lt;/strong&gt;aligned__ (8)));&lt;/p&gt;
&lt;h1 id="endif"&gt;endif&lt;/h1&gt;
&lt;p&gt;0-5: v1-v6 &lt;br /&gt;
6: sl&lt;br /&gt;
7: fp&lt;br /&gt;
8: sp&lt;br /&gt;
9: pc&lt;br /&gt;
10-26: d8-d15 17words&lt;br /&gt;
27: fpscr&lt;/p&gt;
&lt;p&gt;when I change to:&lt;br /&gt;
    #define MD_GET_SP(_t) (_t)-&amp;gt;context&lt;span&gt;[0]&lt;/span&gt;.__jmpbuf&lt;span&gt;[8]&lt;/span&gt;&lt;br /&gt;
it works!&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">winterserver</dc:creator><pubDate>Sun, 16 Mar 2014 13:19:13 -0000</pubDate><guid>https://sourceforge.netc50c20d980ae81abea2fba3f512f6fdcc8b7fced</guid></item><item><title>fork process after st_init will got "wrong" state fd to read</title><link>https://sourceforge.net/p/state-threads/bugs/15/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;the st has a bug when:&lt;br /&gt;
1. master process start.&lt;br /&gt;
2. st_init, initialize st.&lt;br /&gt;
3. st_netfd_open, or other fd operations.&lt;br /&gt;
4. fork work processes&lt;br /&gt;
5. sometimes got a bug: st_poll detect a fd has data to read, but actually no data and read will be blocked. it seems the fd state is "wrong" whatever.&lt;/p&gt;
&lt;p&gt;workaround: fork processes then use st.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">winterserver</dc:creator><pubDate>Sun, 16 Mar 2014 13:16:58 -0000</pubDate><guid>https://sourceforge.net14f85d2f335589ee5f73f08184eae4314b08b379</guid></item><item><title>Stacks not aligned on non-Linux i386</title><link>https://sourceforge.net/p/state-threads/bugs/14/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;I came across an issue where st would segfault when built with gcc 4.5.0 using -O3&lt;br /&gt;
on Solaris 10 i386.  The issue turned out to be that the stack was not properly&lt;br /&gt;
aligned for the use of MMX/SSE instructions, which require their arguments to be&lt;br /&gt;
16-byte aligned.&lt;/p&gt;
&lt;p&gt;The problem does not occur under linux because of the custom assembly used&lt;br /&gt;
in saving and restoring the context, which has an .align 16.&lt;/p&gt;
&lt;p&gt;At least for GCC, the attached patch addresses the problem; it enables the fix&lt;br /&gt;
on the earliest version of GCC it is possible on (4.2.0).&lt;/p&gt;
&lt;p&gt;Some more details:&lt;/p&gt;
&lt;p&gt;On i386, GCC will ensure the stack is 16-byte aligned if necessary, but will only&lt;br /&gt;
check and re-align in main(), instead of in each function that uses those instructions.&lt;br /&gt;
The stacks created for st threads are not, then, covered by this, and will only be&lt;br /&gt;
word-aligned, which is the default for the i386 ABI.&lt;/p&gt;
&lt;p&gt;GCC provides a force_align_arg_pointer function attribute, which will cause the&lt;br /&gt;
decorated function to ensure that the stack is aligned to the largest degree necessary.&lt;br /&gt;
Decorating st_thread_main() suffices to address the problem, as GCC will automatically&lt;br /&gt;
maintain alignment from there on in.&lt;/p&gt;
&lt;p&gt;This is not required on x86-64, because that ABI explicitly requires that any array of&lt;br /&gt;
at least 16 bytes, or any C99 variable length array, be 16-byte aligned, specifically for&lt;br /&gt;
SSE instructions.  Indeed, the force_align_arg_pointer attribute is not available for&lt;br /&gt;
that architecture.&lt;/p&gt;
&lt;p&gt;References:&lt;br /&gt;
&lt;a href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40838" rel="nofollow"&gt;http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40838&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47842" rel="nofollow"&gt;http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47842&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mail.python.org/pipermail/python-dev/2010-May/100050.html" rel="nofollow"&gt;http://mail.python.org/pipermail/python-dev/2010-May/100050.html&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://www.sco.com/developers/devspecs/abi386-4.pdf" rel="nofollow"&gt;http://www.sco.com/developers/devspecs/abi386-4.pdf&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://www.x86-64.org/documentation/abi.pdf" rel="nofollow"&gt;http://www.x86-64.org/documentation/abi.pdf&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matthew Ryan</dc:creator><pubDate>Mon, 26 Mar 2012 01:53:01 -0000</pubDate><guid>https://sourceforge.net1ac73f14a2414b0766de35411efc1c77cdb52d40</guid></item><item><title>Doc: st_*msg() un-necessarily constrained to UDP</title><link>https://sourceforge.net/p/state-threads/bugs/13/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Both st_sendmsg() and st_recvmsg() caution that "A file descriptor object identifier (see st_netfd_t) representing a UDP socket", but I don't think that constraint is valid. I've long used by st_sendmsg() and st_recvmsg() on a TCP socket to do, inter alia, fd-passing and the st library does just fine.&lt;/p&gt;
&lt;p&gt;My suspicion is that this reference to UDP is just an artifact of a copy/paste of st_sendto() and st_recvfrom().&lt;/p&gt;
&lt;p&gt;In any event, I think that restriction on UDP sockets should be removed from the docs or clarified as to when it does not work for TCP.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">MarkD</dc:creator><pubDate>Sun, 18 Dec 2011 03:13:37 -0000</pubDate><guid>https://sourceforge.nete063ce2418f497912c084a43c01ae64464c422d1</guid></item><item><title>_st_iterate_threads() may cause thread to be re-entered</title><link>https://sourceforge.net/p/state-threads/bugs/12/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;There is a bug in _st_iterate_threads().  The bug can be demonstrated with&lt;br /&gt;
the following program:&lt;/p&gt;
&lt;p&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include "public.h"&lt;/p&gt;
&lt;p&gt;extern _st_iterate_threads_flag;&lt;/p&gt;
&lt;p&gt;int a, *ap = &amp;amp;a;&lt;/p&gt;
&lt;p&gt;static void * thread_fn(void *arg) {&lt;br /&gt;
printf("enter thread_fn\n");&lt;br /&gt;
*ap = 1000;&lt;br /&gt;
ap = NULL;  // re-entry of this thread will cause a core dump&lt;br /&gt;
_st_iterate_threads();&lt;br /&gt;
printf("exit thread_fn\n");&lt;br /&gt;
return NULL;&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;int main(int argc, char *argv[])&lt;br /&gt;
{&lt;br /&gt;
st_init();&lt;br /&gt;
_st_iterate_threads_flag = 1;&lt;br /&gt;
st_thread_t t = st_thread_create(thread_fn, NULL, 1, 0);&lt;br /&gt;
st_thread_join(t, NULL);&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;With release 1.8, the program produces the following outcome:&lt;/p&gt;
&lt;p&gt;my_machine &amp;gt; gcc try.c LINUX_2.6.24.5-smp_DBG/libst.a&lt;br /&gt;
my_machine &amp;gt; ./a.out&lt;br /&gt;
enter thread_fn&lt;br /&gt;
enter thread_fn&lt;br /&gt;
Segmentation fault (core dumped)&lt;/p&gt;
&lt;p&gt;The bug in _st_iterate_threads() causes thread_fn to be re-entered.  The &lt;br /&gt;
following diff fixes the problem.  With this diff, the output of the above&lt;br /&gt;
test program is&lt;/p&gt;
&lt;p&gt;my_machine &amp;gt; ./a.out &lt;br /&gt;
enter thread_fn&lt;br /&gt;
show thread msg: Iteration started&lt;br /&gt;
show thread msg: Iteration: a new thread&lt;br /&gt;
show thread msg: Iteration: a running thread&lt;br /&gt;
show thread msg: Iteration completed&lt;br /&gt;
exit thread_fn&lt;/p&gt;
&lt;p&gt;The diff is explained with the comments in _st_iterate_threads().  I added&lt;br /&gt;
some non-essential messages to show the control flow in the test program.&lt;/p&gt;
&lt;p&gt;--- common.h.save    2009-05-26 14:46:21.000000000 -0400&lt;br /&gt;
+++ common.h         2009-05-26 14:47:05.000000000 -0400&lt;br /&gt;
@@ -310,6 +310,7 @@&lt;br /&gt;
#define _ST_FL_ON_SLEEPQ    0x04&lt;br /&gt;
#define _ST_FL_INTERRUPT    0x08&lt;br /&gt;
#define _ST_FL_TIMEDOUT     0x10&lt;br /&gt;
+#define _ST_FL_STARTING     0x20&lt;/p&gt;
&lt;p&gt;--- sched.c.save        2009-05-26 14:46:00.000000000 -0400&lt;br /&gt;
+++ sched.c             2009-05-26 14:57:29.000000000 -0400&lt;br /&gt;
@@ -168,7 +168,7 @@&lt;br /&gt;
NULL, 0, 0);&lt;br /&gt;
if (!_st_this_vp.idle_thread)&lt;br /&gt;
return -1;&lt;br /&gt;
-  _st_this_vp.idle_thread-&amp;gt;flags = _ST_FL_IDLE_THREAD;&lt;br /&gt;
+  _st_this_vp.idle_thread-&amp;gt;flags |= _ST_FL_IDLE_THREAD;&lt;br /&gt;
_st_active_count--;&lt;br /&gt;
_ST_DEL_RUNQ(_st_this_vp.idle_thread);&lt;/p&gt;
&lt;p&gt;@@ -316,6 +316,9 @@&lt;br /&gt;
{&lt;br /&gt;
_st_thread_t *thread = _ST_CURRENT_THREAD();&lt;/p&gt;
&lt;p&gt;+  assert(thread-&amp;gt;flags &amp;amp; _ST_FL_STARTING);&lt;br /&gt;
+  thread-&amp;gt;flags &amp;amp;= ~_ST_FL_STARTING;&lt;br /&gt;
+&lt;br /&gt;
/*&lt;br /&gt;
* Cap the stack by zeroing out the saved return address register&lt;br /&gt;
* value. This allows some debugging/profiling tools to know when&lt;br /&gt;
@@ -587,6 +590,13 @@&lt;br /&gt;
thread-&amp;gt;start = start;&lt;br /&gt;
thread-&amp;gt;arg = arg;&lt;/p&gt;
&lt;p&gt;+  /*&lt;br /&gt;
+   * _ST_FL_STARTING indicates that the thread has been created but has&lt;br /&gt;
+   * not started its execution yet. See _st_iterate_threads_helper() for more&lt;br /&gt;
+   * info.&lt;br /&gt;
+   */&lt;br /&gt;
+  thread-&amp;gt;flags |= _ST_FL_STARTING;&lt;br /&gt;
+&lt;br /&gt;
#ifndef __ia64__&lt;br /&gt;
_ST_INIT_CONTEXT(thread, stack-&amp;gt;sp, _st_thread_main);&lt;br /&gt;
#else&lt;br /&gt;
@@ -624,7 +634,7 @@&lt;br /&gt;
/* ARGSUSED */&lt;br /&gt;
void _st_show_thread_stack(_st_thread_t *thread, const char *messg)&lt;br /&gt;
{&lt;br /&gt;
-&lt;br /&gt;
+  printf("show thread msg: %s\n", messg);&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;/* To be set from debugger */&lt;br /&gt;
@@ -646,7 +656,7 @@&lt;/p&gt;
&lt;p&gt;if (thread) {&lt;br /&gt;
memcpy(thread-&amp;gt;context, save_jb, sizeof(jmp_buf));&lt;br /&gt;
-    _st_show_thread_stack(thread, NULL);&lt;br /&gt;
+    _st_show_thread_stack(thread, "Iteration: a running thread");&lt;br /&gt;
} else {&lt;br /&gt;
if (MD_SETJMP(orig_jb)) {&lt;br /&gt;
_st_iterate_threads_flag = 0;&lt;br /&gt;
@@ -658,13 +668,28 @@&lt;br /&gt;
_st_show_thread_stack(thread, "Iteration started");&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;-  q = thread-&amp;gt;tlink.next;&lt;br /&gt;
-  if (q == &amp;amp;_ST_THREADQ)&lt;br /&gt;
-    q = q-&amp;gt;next;&lt;br /&gt;
-  ST_ASSERT(q != &amp;amp;_ST_THREADQ);&lt;br /&gt;
-  thread = _ST_THREAD_THREADQ_PTR(q);&lt;br /&gt;
-  if (thread == _ST_CURRENT_THREAD())&lt;br /&gt;
-    MD_LONGJMP(orig_jb, 1);&lt;br /&gt;
+   while (1) {&lt;br /&gt;
+    q = thread-&amp;gt;tlink.next;&lt;br /&gt;
+    if (q == &amp;amp;_ST_THREADQ)  // _ST_THREADQ is part of _st_this_vp, skip&lt;br /&gt;
+      q = q-&amp;gt;next;&lt;br /&gt;
+    ST_ASSERT(q != &amp;amp;_ST_THREADQ);&lt;br /&gt;
+    thread = _ST_THREAD_THREADQ_PTR(q);&lt;br /&gt;
+    if (thread == _ST_CURRENT_THREAD()) {&lt;br /&gt;
+      MD_LONGJMP(orig_jb, 1);  // Looped back to current thread.  Done.&lt;br /&gt;
+    }&lt;br /&gt;
+    /*&lt;br /&gt;
+     * When a thread is created but haven't started running yet (haven't&lt;br /&gt;
+     * got to _st_thread_main), simply longjmp to that thread's context (set&lt;br /&gt;
+     * by MD_INIT_CONTEXT) causes _ST_CURRENT_THREAD's start function to be&lt;br /&gt;
+     * re-executed.  Flag _ST_FL_STARTING is to indicate a thread is in&lt;br /&gt;
+     * such state and we'll avoid longjmp.&lt;br /&gt;
+     */&lt;br /&gt;
+    if (thread-&amp;gt;flags &amp;amp; _ST_FL_STARTING) {&lt;br /&gt;
+      _st_show_thread_stack(thread, "Iteration: a new thread");&lt;br /&gt;
+    } else {&lt;br /&gt;
+      break;&lt;br /&gt;
+    }&lt;br /&gt;
+  }&lt;br /&gt;
memcpy(save_jb, thread-&amp;gt;context, sizeof(jmp_buf));&lt;br /&gt;
MD_LONGJMP(thread-&amp;gt;context, 1);&lt;br /&gt;
}&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Xiaolin (Charlene) Zang</dc:creator><pubDate>Wed, 27 May 2009 02:03:16 -0000</pubDate><guid>https://sourceforge.netc7f670c8da722f9b7f11df1c36271699f924ca16</guid></item><item><title>st-1.8 does not compile on Darwin/Intel</title><link>https://sourceforge.net/p/state-threads/bugs/11/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Make fails as follows:&lt;/p&gt;
&lt;p&gt;$ make darwin-optimized&lt;br /&gt;
make OS="DARWIN" BUILD="OPT"&lt;br /&gt;
cc  -DDARWIN -Wall -O  -c sched.c -o DARWIN_9.6.0_OPT/sched.o&lt;br /&gt;
In file included from common.h:62,&lt;br /&gt;
from sched.c:48:&lt;br /&gt;
md.h:129:2: error: #error Unknown CPU architecture&lt;/p&gt;
&lt;p&gt;On examination of md.h it appears that only PPC has a defined MD_JB_SP. I'm sorry that I don't know what that value shoud be for Intel, nor how to work out what it should be so I can offer no assistance on that front.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Anonymous</dc:creator><pubDate>Thu, 15 Jan 2009 18:52:12 -0000</pubDate><guid>https://sourceforge.net622abf4b4fb59d88f3868898083a31ff0830987c</guid></item><item><title>Check return codes everywhere</title><link>https://sourceforge.net/p/state-threads/bugs/10/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Some checks for return codes are missing.&lt;/p&gt;
&lt;p&gt;Examples:&lt;br /&gt;
Would you like to add more error handling for return values from "close" and "fcntl" in the function "_st_epoll_dispatch"?&lt;br /&gt;
&lt;a href="http://downloads.sourceforge.net/state-threads/st-1.8.tar.gz"&gt;http://downloads.sourceforge.net/state-threads/st-1.8.tar.gz&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Markus Elfring</dc:creator><pubDate>Fri, 23 Mar 2007 21:14:22 -0000</pubDate><guid>https://sourceforge.net147a9a25f4fc12a7992ee0bd7a79bf38acce7235</guid></item></channel></rss>