Bug #42524 Function pthread_setschedprio() is defined but seems broken on i5/OS PASE
Submitted: 1 Feb 2009 23:20 Modified: 18 Feb 2009 20:07
Reporter: Kent Boortz Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S1 (Critical)
Version:5.1.31 OS:Other (i5/OS PASE)
Assigned to: Davi Arnaut CPU Architecture:Any

[1 Feb 2009 23:20] Kent Boortz
Description:
In 5.1.31 the produced binaries for i5/OS PASE are not working. Running
the binary (even a simple --help) gives

  090201 22:44:21 - mysqld got signal 4 ;

Running DBX the error is reported as

  Illegal instruction in pth_sched.pthread_setschedprio [/usr/lib/libpthreads.a] at 0xd02be778 ($t1)
  0xd02be778 (pthread_setschedprio+0x220) 80410014        lwz   r2,0x14(r1)

In 5.1.30 this function was not called, at least not early in the
initialization of the server. A change for Bug#38477 in 5.1.31
made pthread_setschedprio() to be called instead of the mysys
function my_pthread_setprio()

How to repeat:
Compile and run the 5.1.31 source on i5/OS PASE

Suggested fix:
The configure script should consider pthread_setschedprio() to be broken
on i5/OS, and the test for it in "include/my_pthread.h" should be changed
to something like

  .
  .
  #elif defined(HAVE_PTHREAD_SETSCHEDPRIO) && !defined(BROKEN_PTHREAD_SETSCHEDPRIO)
  #define my_pthread_setprio(A,B) pthread_setschedprio((A),(B))
  #else
  extern void my_pthread_setprio(pthread_t thread_id,int prior);
  #endif
[2 Feb 2009 2:26] Davi Arnaut
Using a standalone program that creates a thread and calls pthread_setschedprio yields the same problem?
[3 Feb 2009 13:31] Davi Arnaut
To get better debugging instead of SIGILL one can use the PASE_SYSCALL_NOSIGILL environment variable set to ALL:

"The i5/OS PASE kernel exports some system calls that are implemented by the AIX kernel but are unsupported by i5/OS PASE. The default behavior for any unsupported syscall is to send exception message MCH3204, which the system converts to i5/OS PASE signal SIGILL."

It seems that the pthread_setschedprio will return "Function not implemented" (SIGILL) for any priority priority value that is not PTHREAD_PRIO_MIN (1), while pthread_setschedparam will accept any priority value between PTHREAD_PRIO_MIN and PTHREAD_PRIO_MAX and returns EINVAL if the value is not within the range. Furthermore, if pthread_setschedparam is used before pthread_setschedprio, this will cause any calls to pthread_setschedprio to return "Function not implemented" (SIGILL).
[3 Feb 2009 23:53] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/65061

2768 Davi Arnaut	2009-02-03
      Bug#42524: Function pthread_setschedprio() is defined but seems broken on i5/OS PASE
      
      The problem is that MySQL use of pthread_setschedprio is not
      supported i5/OS and the default system behavior for unsupported
      calls is to emit a SIGILL signal which causes the server to
      abort.
      
      The solution is to treat the pthread_setschedprio as inexistent
      when compiling binaries to i5/OS. This also does not invalidate
      the fix for bug 38477 as the only supported dispatch class is
      SCHED_OTHER (which is passed to pthread_setschedparam).
[6 Feb 2009 8:57] Daniel Fischer
Patch looks good, one review to go.

Note that $mysql_cv_sys_os is "Not Solaris" if uname wasn't found... gah. But irrelevant for PASE.
[6 Feb 2009 10:29] Bjørn Munch
Looks reasonable to be, OK to push
[6 Feb 2009 11:00] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/65462

2788 Davi Arnaut	2009-02-06
      Bug#42524: Function pthread_setschedprio() is defined but seems broken on i5/OS PASE
      
      The problem is that MySQL use of pthread_setschedprio is not
      supported by i5/OS and the default system behavior for unsupported
      calls is to emit a SIGILL signal which causes the server to
      abort.
      
      The solution is to treat the pthread_setschedprio as inexistent
      when compiling binaries for i5/OS. This also does not invalidate
      the fix for bug 38477 as the only supported dispatch class is
      SCHED_OTHER (which is passed to pthread_setschedparam).
[6 Feb 2009 11:08] Davi Arnaut
Queued to 5.1-bugteam
[6 Feb 2009 11:25] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/65464

3030 Davi Arnaut	2009-02-06 [merge]
      Bug#42524: Function pthread_setschedprio() is defined but seems broken on i5/OS PASE
      
      Null merge of the fix into 6.0-bugteam and removal of checks for
      functions that are not used anymore.
[9 Feb 2009 22:33] Bugs System
Pushed into 5.1.32 (revid:davi.arnaut@sun.com-20090209214102-gj3sb3ujpnvpiy4c) (version source revid:davi.arnaut@sun.com-20090209214102-gj3sb3ujpnvpiy4c) (merge vers: 5.1.32) (pib:6)
[14 Feb 2009 13:00] Bugs System
Pushed into 6.0.10-alpha (revid:matthias.leich@sun.com-20090212211028-y72faag15q3z3szy) (version source revid:davi.arnaut@sun.com-20090206112445-m7ogqx3tbxd712gz) (merge vers: 6.0.10-alpha) (pib:6)
[17 Feb 2009 14:58] Bugs System
Pushed into 5.1.32-ndb-6.3.23 (revid:tomas.ulin@sun.com-20090217131017-6u8qz1edkjfiobef) (version source revid:tomas.ulin@sun.com-20090216083408-rmvyaxjt6mk8sg1y) (merge vers: 5.1.32-ndb-6.3.23) (pib:6)
[17 Feb 2009 16:46] Bugs System
Pushed into 5.1.32-ndb-6.4.3 (revid:tomas.ulin@sun.com-20090217134419-5ha6xg4dpedrbmau) (version source revid:tomas.ulin@sun.com-20090216083646-m8st11oj1hhfuuh5) (merge vers: 5.1.32-ndb-6.4.3) (pib:6)
[17 Feb 2009 18:22] Bugs System
Pushed into 5.1.32-ndb-6.2.17 (revid:tomas.ulin@sun.com-20090217134216-5699eq74ws4oxa0j) (version source revid:tomas.ulin@sun.com-20090211111208-wf0acl7c1vl5653e) (merge vers: 5.1.32-ndb-6.2.17) (pib:6)
[18 Feb 2009 20:07] Paul DuBois
Noted in 5.1.32, 6.0.10 changelogs.

On the IBM i5 platform, the MySQL configuration process caused the
system version of pthread_setschedprio() to be used. This function
returns SIGILL on i5 because it is not supported, causing the server 
to crash. Now the my_pthread_setprio() function in the mysys library
is used instead.