Bug 38248 - Ignored temporary module files manipulation errors
Summary: Ignored temporary module files manipulation errors
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-24 15:19 UTC by Jan Kratochvil
Modified: 2008-12-09 21:38 UTC (History)
2 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Check the file manipulations errors. (435 bytes, patch)
2008-11-24 16:40 UTC, Jan Kratochvil
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Kratochvil 2008-11-24 15:19:10 UTC
Minimal testcase to `use' some module cannot be compiled.
Compilation works fine on Fedora gcc-gfortran-4.3.2-7.x86_64.

GNU Fortran (GCC) version 4.4.0 20081124 (experimental) (x86_64-unknown-linux-gnu)
	compiled by GNU C version 4.4.0 20081124 (experimental), GMP version 4.2.2, MPFR version 2.3.2.
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096

$ gcc-build/gcc/f951 -o gccmod.s gccmod.f90 -Wall -ggdb2
 initFatal Error: Reading module mmm at line 16 column 65: Expected left parenthesis

$ cat gccmod.f90
module mmm
contains
 subroutine init
 end subroutine init
end module mmm

program main
 use mmm
end program main
$ _
(In fact no `module mmm' part needs to be present there.)
Comment 1 Mikael Morin 2008-11-24 15:37:18 UTC
Works for me.

$ /usr/local/bin/gfortran -v 
Utilisation des specs internes.
Target: x86_64-unknown-linux-gnu
Configuré avec: ../src/configure --enable-languages=fortran --enable-maintainer-mode --disable-multilib : (reconfigured) ../src/configure --enable-maintainer-mode --disable-multilib --enable-languages=c,fortran --no-create --no-recursion : (reconfigured) ../src/configure --enable-maintainer-mode --disable-multilib --enable-languages=c,fortran --no-create --no-recursion
Modèle de thread: posix
gcc version 4.4.0 20081123 (experimental) (GCC) 
Comment 2 Tobias Burnus 2008-11-24 16:20:11 UTC
The error message looks as if you are mixing a gfortran 4.3 compiled .mod file with a gfortran 4.4 compiler (or vice versa). While the gfortran 4.3 compiled *.o/*.so/*.a files are supposed to be compatible with 4.4's libgfortran.so, for .mod files this is not the case. (.mod files are not like *.h files compiler independent, but simply a "binary" dump of the interfaces of a single module.)

I think a solution would be to create a version number for the .mod data and add a checking.
Comment 3 Jan Kratochvil 2008-11-24 16:40:21 UTC
Created attachment 16759 [details]
Check the file manipulations errors.

Thanks Tobias B.,
unlink("mmm.mod")                 = -1 EPERM (Operation not permitted)
rename("mmm.mod0", "mmm.mod")     = -1 EPERM (Operation not permitted)
write(2, " init"..., 5)           = 5   
stat("mmm.mod", {st_mode=S_IFREG|0644, st_size=547, ...}) = 0
open("mmm.mod", O_RDONLY)         = 4   

With the attached patch the same command now fails for me:
Fatal Error: Can't delete module file 'mmm.mod': Operation not permitted

I have no GCC SVN write permissions.
Left one unchecked unlink() in an error recovery path there.
Comment 4 Tobias Burnus 2008-11-25 12:53:08 UTC
Subject: Bug 38248

Author: burnus
Date: Tue Nov 25 12:51:44 2008
New Revision: 142190

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142190
Log:
2008-11-25  Jan Kratochvil  <jan.kratochvil@redhat.com>

        PR fortran/38248
        * module.c (gfc_dump_module): Check rename/unlink syscalls errors.


Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/module.c

Comment 5 Mikael Morin 2008-12-08 23:03:50 UTC
Can we close ?
Comment 6 Daniel Franke 2008-12-09 21:38:04 UTC
> Can we close?

Think so. Closing.