Skip to content

Conversation

@markuspf
Copy link
Member

@markuspf markuspf commented Aug 4, 2016

This was submitted as #862 on the master branch.

Description of changes (for the release notes)

So far, FileString only wrote files < 2G and did not indicate
an error in case of larger strings.

With this fix strings of any length can be written and in case of a failure
the corresponding system error is shown.

So far, `FileString` only wrote files < 2G and did not indicate
an error in case of larger strings.

With this fix strings of any length can be written and in case of a failure
the corresponding system error is shown.
Same problem as for FileString in the code which tried to read the whole
file in one chunk. On some (all?) systems this cannot be done if file is
> 2G.

Testfiles should not have code that deals with such big files and strings.
So, here is some example code:

ll:=List([0..255], CHAR_INT);;
smp := "";;
for i in [1..1000000] do Add(smp,Random(ll)); od;
s := "";;
while Length(s) <  2^31+2^28 do
  Append(s, smp{[Random(1,300000)..Random(700000,1000000)]});
od;

Length(s);
FileString("/cache/check", s);
Exec("ls -l /cache/check");
s2 := StringFile("/cache/check");;
Length(s2);
s = s2;
@markuspf markuspf merged commit 29a3adb into gap-system:stable-4.8 Aug 4, 2016
@olexandr-konovalov olexandr-konovalov added this to the GAP 4.8.5 milestone Aug 4, 2016
@olexandr-konovalov
Copy link
Member

@markuspf @frankluebeck this causes warnings when building on Windows:

gcc -I. -DCONFIG_H  -I/cygdrive/c/Users/jenkins/workspace/GAP-dev-compilers/GAPCOPTS/64build/GAPREADLINE/noreadline/label/gcc-cygwin64/GAP-git-snapshot/bin/x86_64-unknown-cygwin-gcc-default64/extern/gmp/include -Wall -g -O2 -m64 -m64 -g -O2 -Werror -o streams.o -c ../../src/streams.c
../../src/streams.c: In function 'FuncREAD_STRING_FILE':
../../src/streams.c:1979:22: error: unused variable 'ptr' [-Werror=unused-variable]
    char            *ptr;
                     ^
../../src/streams.c:1976:31: error: unused variable 'l' [-Werror=unused-variable]
    Int             ret, len, l;
                              ^
cc1: all warnings being treated as errors
Makefile:582: recipe for target 'streams.o' failed
make[1]: *** [streams.o] Error 1
make[1]: Leaving directory '/cygdrive/c/Users/jenkins/workspace/GAP-dev-compilers/GAPCOPTS/64build/GAPREADLINE/noreadline/label/gcc-cygwin64/GAP-git-snapshot/bin/x86_64-unknown-cygwin-gcc-default64'
Makefile:146: recipe for target 'compile' failed
make: *** [compile] Error 2
Build step 'Execute shell' marked build as failure

@frankluebeck
Copy link
Member

@alex-konovalov : since you have a compiler for Windows it would be good it you could fix (and test) this yourself. Hint:
Try to substitute lines 1975-1979 by

    Char            buf[32769];
    Int             ret, len;
    UInt            lstr;
    Obj             str;
#if ! SYS_IS_CYGWIN32
    Int              l;
    char            *ptr;
#endif

I think the Windows code of this function does not need a fix. Maybe you can also check this on Windows, there is example input in the discussion of the original pull request #862.

@olexandr-konovalov
Copy link
Member

@frankluebeck thanks, I will (I don't have a working development environment, but I can login into a Jenkins node and check).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants