View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002645 | OpenFOAM | Bug | public | 2017-08-02 09:18 | 2017-08-03 10:48 |
Reporter | tniemi | Assigned To | henry | ||
Priority | low | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | dev | ||||
Summary | 0002645: fileHandler option missing due to wrong static initialization order | ||||
Description | I was trying to test the recent fileHandler-option, but I found out that it was missing from the list of valid options. It appears that our compiler (gcc 4.8.3) seems to first process the static/global code in fileOperation.C before it goes to argList.C. What happens is that the fileHandler-option which is added by the dummy "addArgsOptions intObj" will be cleared away when the HashTable validOptions is properly initialized in the beginning of argList.C. I further investigated and googled about this and it was mentioned here (https://stackoverflow.com/a/39442081) that at around gcc 4.7 the processing order of files has changed. In older gccs the order is reversed, so that the static code in objects which are listed last in the linking phase will be processed first. In newer gccs it is the opposite. (strange that in our 4.8.3. the order is still reversed, in gcc 4.8.4 coming with ubuntu 14.04 the order is not reversed) I was able to get the fileHandler-option working by moving it to initValidTables in argList.C. In that location it is guaranteed that validOptions is properly initialized as it is in the same file/translation unit. Now it may be that this issue is limited to only a small subset of compilers, but I guess it would be wise not to rely that argList.C will be always processed first? (I don't know what clang/intel does) | ||||
Tags | No tags attached. | ||||
|
It is not clear from your description what code you want changed to what and no patch or replacement files are provided. Also I cannot reproduce the problem and hence cannot test any potential fixes so will require a patch which has been tested. |
|
patch.diff (1,377 bytes)
diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index 9d5ca42..d2507c3 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -72,6 +72,13 @@ Foam::argList::initValidTables::initValidTables() "do not execute functionObjects" ); + argList::addOption + ( + "fileHandler", + "handler", + "override the fileHandler" + ); + Pstream::addValidParOptions(validParOptions); } diff --git a/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C b/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C index 5d65cf2..5949754 100644 --- a/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C +++ b/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C @@ -43,22 +43,6 @@ namespace Foam defineTypeNameAndDebug(fileOperation, 0); defineRunTimeSelectionTable(fileOperation, word); - class addArgsOptions - { - public: - addArgsOptions() - { - argList::addOption - ( - "fileHandler", - "handler", - "override the fileHandler" - ); - } - }; - - addArgsOptions intObj; - word fileOperation::defaultFileHandler ( debug::optimisationSwitches().lookupOrAddDefault |
|
I have attached the patch as git diff. Basically remove addArgsOptions dummy from fileOperation.C and put its contents to argList.C initValidTables dummy. This should work on any valid compiler as it is guaranteed that static data will be initialized on the order they appear on a single file. |
|
Thanks Timo, this change makse sense. Resolved in OpenFOAM-dev by commit ec585137376bb88844fcb3e8fa0c227add4d3756 Resolved in OpenFOAM-5.x by commit ef412e1b83e19b86d7c377d903945c869691b10e |
Date Modified | Username | Field | Change |
---|---|---|---|
2017-08-02 09:18 | tniemi | New Issue | |
2017-08-02 09:35 | henry | Note Added: 0008494 | |
2017-08-02 09:50 | tniemi | File Added: patch.diff | |
2017-08-02 09:52 | tniemi | Note Added: 0008495 | |
2017-08-03 10:48 | henry | Assigned To | => henry |
2017-08-03 10:48 | henry | Status | new => resolved |
2017-08-03 10:48 | henry | Resolution | open => fixed |
2017-08-03 10:48 | henry | Fixed in Version | => 5.x |
2017-08-03 10:48 | henry | Note Added: 0008501 |