segfault with inquire()
Andrew Benson
abenson@carnegiescience.edu
Fri Dec 6 03:17:00 GMT 2019
I've open a PR for this:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92836
I've answered your questions there but I'll put the answers here also:
> 1) Are you opening a unique file (by file name) in each thread?
No. The code is operating on many files, but in the specific case that causes
the problem it's a file which is shared by all threads. Specifically, it's a file
which is generated by the code if the file does not already exist (it stores
solutions to a time-consuming calculation), or is read by the code if it does
exist. All threads write/read the same file.
> 2) Are you trying to synchronize these threads using the inquire?
No. The inquire() is used only to see if the file exists already. If it does,
the code branches to read the file, if it does not, the code branches to
generate the data for the file and then write it.
Synchronization of the file accesses are being handled using file locks, i.e. I
use ISO_C_Binding to allow me to call fcntl(). Since the Linux kernel on the
machine I'm using is too old to support OFD locks I'm using POSIX locks plus
OpenMP locks (since POSIX locks are per processes so I have to separately
synchronize the OpenMP threads).
> 3) or, trying to ensure a unique filename for each file or avoid the same
> file in two or more threads?
No. The problem always seems to occur when a thread inquires() on one
particular file, and the file name is the same across all threads.
There are other places in my code where inquire() is being used on other file
names. But in all cases the filename is the same for all threads.
-Andrew
On Thursday, December 5, 2019 5:52:35 PM PST Jerry DeLisle wrote:
> On 12/4/19 10:38 AM, Andrew Benson wrote:
> > Thanks for that suggestion. Running the code from my previous email with -
>
> > fsanitize=thread I get a lot of warnings about potential deadlocks:
> Can you move this discussion to a bug report in bugzilla. Also I have some
> questions about your application.
>
> 1) Are you opening a unique file (by file name) in each thread?
>
> 2) Are you trying to synchronize these threads using the inquire?
>
> 3) or, trying to ensure a unique filename for each file or avoid the same
> file in two or more threads?
>
> I am just trying to get a sense of what you are trying to do so we can maybe
> reproduce it. I have been looking closely at the inquire code vs the other
> file operations to see if I can visuallize a problem, obviously not an
> obvious problem.
>
> Regards,
>
> Jerry
--
* Andrew Benson: http://users.obs.carnegiescience.edu/abenson/contact.html
* Galacticus: https://github.com/galacticusorg/galacticus
More information about the Fortran
mailing list