Skip to content

Raw: make the output directory creation more robust. - #6458

Merged
davidrohr merged 3 commits into
AliceO2Group:devfrom
aphecetche:digit2raw-assert-output-directory
Jun 22, 2021
Merged

Raw: make the output directory creation more robust.#6458
davidrohr merged 3 commits into
AliceO2Group:devfrom
aphecetche:digit2raw-assert-output-directory

Conversation

@aphecetche

Copy link
Copy Markdown
Collaborator

Turns out that std::filesystem::create_directories on some platforms/compilers does not return true even when actually
creating the directory. So this PR changes a bit the logic used to force creation of output directory : call std::filesystem::create_directories but do not rely on the boolean return value. Make an explicit std::filesystem::exists call instead.

Discovered that while trying to get the FST working on macOS. The symptom was that the rawXXX.log showed a fatal due to the impossibility to create the raw/XXX directory. But in fact the directory was created just fine.

Turns out that `std::filesystem::create_directories` on some
platforms/compilers does not return true even when actually
creating the directory.
Comment thread Detectors/Raw/src/RawFileWriter.cxx Outdated

void o2::raw::assertOutputDirectory(std::string_view outDirName)
{
std::filesystem::create_directories(outDirName);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the logic here should be:

if (!exists) {
#ifdef MACOS
  create();
  if (!exists) error;
#else
  if (!create()) error;
#endif
}

with some comment that this is broken on mac OS currently and that the workaround should be reverted once it works. I like merging all the checks into this one function.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, yes, that's another option. But I believe the check should be done on the compiler, not the platform, as I think the issue is more a Clang vs GCC one (I understand we're only using Clang on Mac, but the intent of the check would be clearer that way)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sure, my point was just we should document why it is done like this, together with a comment that it should be cleaned up. Is there actually any reference that this is broken on Mac / clang? Clang is usually well-tested, so I would be surprised if create_directories would be misbehaving.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would have to dig a reference if there is one, but can be seen in e.g. https://godbolt.org/z/qcE5fMq36

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, then it is most likely a bug in clang?
Can you open a bug report? The clang developers are usually quite responsive.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And still, could we change it to have the exists check first, and then add a comment with a todo that this is a workaround due to a clang bug?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just added a commit (to be squashed on merge) in that respect : would that be ok for you ?

davidrohr
davidrohr previously approved these changes Jun 21, 2021

@davidrohr davidrohr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perfect, thx, will squash-merge once CI is through

@davidrohr

Copy link
Copy Markdown
Collaborator

@aphecetche : This seems to be a genuine error:

/mnt/mesos/sandbox/sandbox/o2suite-dataflow/sw/SOURCES/O2/6458/0/Detectors/Raw/src/RawFileWriter.cxx: In function 'void o2::raw::assertOutputDirectory(std::string_view)':
/mnt/mesos/sandbox/sandbox/o2suite-dataflow/sw/SOURCES/O2/6458/0/Detectors/Raw/src/RawFileWriter.cxx:749:1: error: expected '}' at end of input

@davidrohr
davidrohr merged commit 1b5d98d into AliceO2Group:dev Jun 22, 2021
@aphecetche
aphecetche deleted the digit2raw-assert-output-directory branch June 22, 2021 08:07
knopers8 pushed a commit to knopers8/AliceO2 that referenced this pull request Jun 28, 2021
* Raw: make the output directory creation more robust.

Turns out that `std::filesystem::create_directories` on some
platforms/compilers does not return true even when actually
creating the directory.

* assertOutputDirectory: change logic and add comment

* put the ending brace in the right place...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants