[1003.1(2008)/Issue 7 0001153]: fread/fwrite to/from buffer underlying the memory stream

2018-12-13 Thread Austin Group Bug Tracker


The following issue has been UPDATED. 
== 
http://austingroupbugs.net/view.php?id=1153 
== 
Reported By:Villemoes
Assigned To:ajosey
== 
Project:1003.1(2008)/Issue 7
Issue ID:   1153
Category:   System Interfaces
Type:   Clarification Requested
Severity:   Editorial
Priority:   normal
Status: Resolved
Name:   Rasmus Villemoes 
Organization:
User Reference:  
Section:fmemopen 
Page Number: 
Line Number: 
Interp Status:  --- 
Final Accepted Text:See
http://austingroupbugs.net/view.php?id=1153#c4186 
Resolution: Accepted As Marked
Fixed in Version:   
== 
Date Submitted: 2017-06-22 08:02 UTC
Last Modified:  2018-12-13 17:00 UTC
== 
Summary:fread/fwrite to/from buffer underlying the memory
stream
== 

Issue History 
Date ModifiedUsername   FieldChange   
== 
2017-06-22 08:02 Villemoes  New Issue
2017-06-22 08:02 Villemoes  Status   New => Under Review 
2017-06-22 08:02 Villemoes  Assigned To   => ajosey  
2017-06-22 08:02 Villemoes  Name  => Rasmus Villemoes
2017-06-22 08:02 Villemoes  Section   => fmemopen
2018-12-13 16:59 nick   Note Added: 0004186  
2018-12-13 17:00 nick   Interp Status => --- 
2018-12-13 17:00 nick   Status   Under Review =>
Resolved
2018-12-13 17:00 nick   Resolution   Open => Accepted As
Marked
2018-12-13 17:00 nick   Final Accepted Text   => See
http://austingroupbugs.net/view.php?id=1153#c4186
==




[1003.1(2008)/Issue 7 0001153]: fread/fwrite to/from buffer underlying the memory stream

2018-12-13 Thread Austin Group Bug Tracker


The following issue has been RESOLVED. 
== 
http://austingroupbugs.net/view.php?id=1153 
== 
Reported By:Villemoes
Assigned To:ajosey
== 
Project:1003.1(2008)/Issue 7
Issue ID:   1153
Category:   System Interfaces
Type:   Clarification Requested
Severity:   Editorial
Priority:   normal
Status: Resolved
Name:   Rasmus Villemoes 
Organization:
User Reference:  
Section:fmemopen 
Page Number: 
Line Number: 
Interp Status:  --- 
Final Accepted Text: 
Resolution: Accepted As Marked
Fixed in Version:   
== 
Date Submitted: 2017-06-22 08:02 UTC
Last Modified:  2018-12-13 17:00 UTC
== 
Summary:fread/fwrite to/from buffer underlying the memory
stream
== 

Issue History 
Date ModifiedUsername   FieldChange   
== 
2017-06-22 08:02 Villemoes  New Issue
2017-06-22 08:02 Villemoes  Status   New => Under Review 
2017-06-22 08:02 Villemoes  Assigned To   => ajosey  
2017-06-22 08:02 Villemoes  Name  => Rasmus Villemoes
2017-06-22 08:02 Villemoes  Section   => fmemopen
2018-12-13 16:59 nick   Note Added: 0004186  
2018-12-13 17:00 nick   Interp Status => --- 
2018-12-13 17:00 nick   Status   Under Review =>
Resolved
2018-12-13 17:00 nick   Resolution   Open => Accepted As
Marked
==




[1003.1(2008)/Issue 7 0001153]: fread/fwrite to/from buffer underlying the memory stream

2018-12-13 Thread Austin Group Bug Tracker


A NOTE has been added to this issue. 
== 
http://austingroupbugs.net/view.php?id=1153 
== 
Reported By:Villemoes
Assigned To:ajosey
== 
Project:1003.1(2008)/Issue 7
Issue ID:   1153
Category:   System Interfaces
Type:   Clarification Requested
Severity:   Editorial
Priority:   normal
Status: Under Review
Name:   Rasmus Villemoes 
Organization:
User Reference:  
Section:fmemopen 
Page Number: 
Line Number: 
Interp Status:  --- 
Final Accepted Text: 
== 
Date Submitted: 2017-06-22 08:02 UTC
Last Modified:  2018-12-13 16:59 UTC
== 
Summary:fread/fwrite to/from buffer underlying the memory
stream
== 

-- 
 (0004186) nick (manager) - 2018-12-13 16:59
 http://austingroupbugs.net/view.php?id=1153#c4186 
-- 
Add a new paragraph (CX shaded) to page 496 line 17237 section 2.5:

When a standard I/O stream has an associated memory buffer (whether
allocated internally, supplied to setvbuf(), or supplied to
fmemopen()), the behavior is undefined if that buffer overlaps with
the destination buffer passed to a call that reads from the stream or with
the source buffer passed to a call that writes to the stream. 

Issue History 
Date ModifiedUsername   FieldChange   
== 
2017-06-22 08:02 Villemoes  New Issue
2017-06-22 08:02 Villemoes  Status   New => Under Review 
2017-06-22 08:02 Villemoes  Assigned To   => ajosey  
2017-06-22 08:02 Villemoes  Name  => Rasmus Villemoes
2017-06-22 08:02 Villemoes  Section   => fmemopen
2018-12-13 16:59 nick   Note Added: 0004186  
==




[1003.1(2008)/Issue 7 0001153]: fread/fwrite to/from buffer underlying the memory stream

2017-06-22 Thread Austin Group Bug Tracker

The following issue has been SUBMITTED. 
== 
http://austingroupbugs.net/view.php?id=1153 
== 
Reported By:Villemoes
Assigned To:ajosey
== 
Project:1003.1(2008)/Issue 7
Issue ID:   1153
Category:   System Interfaces
Type:   Clarification Requested
Severity:   Editorial
Priority:   normal
Status: Under Review
Name:   Rasmus Villemoes 
Organization:
User Reference:  
Section:fmemopen 
Page Number: 
Line Number: 
Interp Status:  --- 
Final Accepted Text: 
== 
Date Submitted: 2017-06-22 08:02 UTC
Last Modified:  2017-06-22 08:02 UTC
== 
Summary:fread/fwrite to/from buffer underlying the memory
stream
Description: 
In glibc, running the code below under valgrind gives a

  Source and destination overlap in memcpy

Without the setvbuf calls, this doesn't trigger because the reads and
writes happen via an internal buffer.

I cannot find anything that says the application cannot do fread/fwrite
calls on a memory stream, using part of the stream's underlying buffer as
destination/source.


#include 

int main(int argc, char *argv[])
{
char x[4] = "123";
char y[4] = "abc";
FILE *f = fmemopen(x, 3, "r");
FILE *g = fmemopen(y, 3, "w");
setvbuf(f, NULL, _IONBF, 0);
setvbuf(g, NULL, _IONBF, 0);

fread([1], 1, 2, f);
fwrite([1], 1, 2, g);

printf("x = %s\n", x);
printf("y = %s\n", y);

fclose(f);
fclose(g);

printf("x = %s\n", x);
printf("y = %s\n", y);

return 0;
}


Desired Action: 
Clarify whether the implementation must behave as if it was using memmove
internally, or alternatively, that it is up to the application to avoid
fread/fwrite calls on memory streams that will trigger such copies. The
latter seems hard to do in general.
== 

Issue History 
Date ModifiedUsername   FieldChange   
== 
2017-06-22 08:02 Villemoes  New Issue
2017-06-22 08:02 Villemoes  Status   New => Under Review 
2017-06-22 08:02 Villemoes  Assigned To   => ajosey  
2017-06-22 08:02 Villemoes  Name  => Rasmus Villemoes
2017-06-22 08:02 Villemoes  Section   => fmemopen
==