Bug #48451 my_seek and my_tell ignore MY_WME flag
Submitted: 31 Oct 2009 13:41 Modified: 11 Jan 2011 16:39
Reporter: Mark Callaghan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Errors Severity:S3 (Non-critical)
Version:5.0,5.1 OS:Any
Assigned to: Ramil Kalimullin CPU Architecture:Any
Tags: error, handling, my_seek, my_tell

[31 Oct 2009 13:41] Mark Callaghan
Description:
my_seek and my_tell ignore MY_WME when they return an error. If the caller then returns an error to the client assuming that my_seek/my_tell called my_error, then the client can hang. Other functions in mysys might ignore it, but I have not investigated that code. Marc Alff has more background on this.

grep unused *.c | grep -i flag

charset-def.c:my_bool init_compiled_charsets(myf flags __attribute__((unused)))
mf_tempfile.c:		      myf MyFlags __attribute__((unused)))
my_fstream.c:		  myf MyFlags __attribute__((unused)))
my_fstream.c:my_off_t my_ftell(FILE *stream, myf MyFlags __attribute__((unused)))
my_largepage.c:void my_large_free(gptr ptr, myf my_flags __attribute__((unused)))
my_largepage.c:my_bool my_large_free_int(byte *ptr, myf my_flags __attribute__((unused)))
my_lib.c:             myf MyFlags __attribute__((unused)))
my_lockmem.c:void my_free_lock(byte *ptr,myf Myflags __attribute__((unused)))
my_seek.c:		 myf MyFlags __attribute__((unused)))
my_seek.c:my_off_t my_tell(File fd, myf MyFlags __attribute__((unused)))
my_symlink.c:		myf MyFlags __attribute__((unused)))

How to repeat:
Add code to the server that calls my_tell/my_seek, gets an error on that call and then returns the the client without first calling my_error. The new code is correct in not calling my_error, because my_tell/my_seek should do that given the flags used (or so I have been told by Marc Alff and Monty on internals). In this case, the client can hang.

Suggested fix:
Do the right thing in my_seek, my_tell and any other functions in mysys that ignore the flags argument.
[31 Oct 2009 13:52] Hartmut Holzgraefe
See also the discussion on http://lists.mysql.com/internals/37459
[1 Mar 2010 7:48] 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/101793

3370 Ramil Kalimullin	2010-03-01
      Fix for bug#48451: my_seek and my_tell ignore MY_WME flag
      
      my_seek() and my_tell() functions now honour MY_WME flag.
     @ include/mysys_err.h
        Fix for bug#48451: my_seek and my_tell ignore MY_WME flag
          - EE_CANT_SEEK added, used in my_seek() and my_tell() functions.
     @ mysys/errors.c
        Fix for bug#48451: my_seek and my_tell ignore MY_WME flag
          - EE_CANT_SEEK added, used in my_seek() and my_tell() functions.
     @ mysys/my_seek.c
        Fix for bug#48451: my_seek and my_tell ignore MY_WME flag
          - my_seek() and my_tell() handle MY_WME flag.
     @ mysys/my_symlink.c
        Fix for bug#48451: my_seek and my_tell ignore MY_WME flag
          - __attribute__((unused)) removed, as myf MyFlags is
        actually used in the my_realpath() function.
     @ storage/myisam/ha_myisam.cc
        Fix for bug#48451: my_seek and my_tell ignore MY_WME flag
          - check my_seek() result.
[3 Mar 2010 8:26] Ingo Strüwing
Approved with request for a test.
[9 Dec 2010 10:01] 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/126397

3513 Ramil Kalimullin	2010-12-09
      Fix for bug#48451: my_seek and my_tell ignore MY_WME flag
      
       my_seek() and my_tell() functions now honour MY_WME flag.
     @ include/mysys_err.h
        Fix for bug#48451: my_seek and my_tell ignore MY_WME flag
          - EE_CANT_SEEK added, used in my_seek() and my_tell() functions.
     @ mysys/errors.c
        Fix for bug#48451: my_seek and my_tell ignore MY_WME flag
          - EE_CANT_SEEK added, used in my_seek() and my_tell() functions.
     @ mysys/my_seek.c
        Fix for bug#48451: my_seek and my_tell ignore MY_WME flag
          - my_seek() and my_tell() handle MY_WME flag.
     @ mysys/my_symlink.c
        Fix for bug#48451: my_seek and my_tell ignore MY_WME flag
          - __attribute__((unused)) removed, as myf MyFlags is
        actually used in the my_realpath() function.
     @ storage/myisam/ha_myisam.cc
        Fix for bug#48451: my_seek and my_tell ignore MY_WME flag
          - check my_seek() result.
[17 Dec 2010 12:48] Bugs System
Pushed into mysql-5.1 5.1.55 (revid:georgi.kodinov@oracle.com-20101217124435-9imm43geck5u55qw) (version source revid:ramil@mysql.com-20101209095912-hsdubceuaapmx9ug) (merge vers: 5.1.55) (pib:24)
[17 Dec 2010 12:52] Bugs System
Pushed into mysql-5.5 5.5.9 (revid:georgi.kodinov@oracle.com-20101217124733-p1ivu6higouawv8l) (version source revid:ramil@mysql.com-20101209104911-ndyv6vh4ry9z5vlq) (merge vers: 5.5.8) (pib:24)
[17 Dec 2010 12:56] Bugs System
Pushed into mysql-trunk 5.6.1 (revid:georgi.kodinov@oracle.com-20101217125013-y8pb3az32rtbplc9) (version source revid:anitha.gopi@sun.com-20101210041312-50t9adyhwwybsm6x) (merge vers: 5.6.1) (pib:24)
[11 Jan 2011 16:39] Paul DuBois
Noted in 5.1.55, 5.5.9 changelogs.

The my_seek() and my_tell() functions ignored the MY_WME flag when
they returned an error, which could cause client programs to hang.