Skip to content

Reliably print errno from gencore() when DUMP_DBG is defined - #6433

Merged
0xdaryl merged 1 commit into
eclipse-omr:masterfrom
davidjmccann:save_errno_from_gencore
Mar 31, 2022
Merged

0xdaryl merged 1 commit into
eclipse-omr:masterfrom
davidjmccann:save_errno_from_gencore

Conversation

@davidjmccann

Copy link
Copy Markdown
Contributor

If DUMP_DBG is defined, the errno from gencore() might be overridden by the tty_printf function before it is printed. Save the errno value from gencore() so it can be reliably printed.

Signed-off-by: David McCann mccannd@uk.ibm.com

@0xdaryl

0xdaryl commented Mar 25, 2022

Copy link
Copy Markdown
Contributor

@babsingh : please review

@babsingh babsingh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

minor formatting changes

Comment thread port/aix/omrosdump_helpers.c Outdated
struct coredumpinfo coreDumpInfo;
int rc = -1;
#if defined(DUMP_DBG)
int saved_errno;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

camel case recommended as per coding standards; also, to be consistent with the surrounding code. https://github.com/eclipse/omr/blob/master/doc/CodingStandard.md#variables

Suggested change
int saved_errno;
int savedErrno;

Comment thread port/aix/omrosdump_helpers.c Outdated
int rc = -1;
#if defined(DUMP_DBG)
int saved_errno;
#endif

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@babsingh

babsingh commented Mar 27, 2022 •

Copy link
Copy Markdown
Contributor

@AdamBrousseau DUMP_DBG is disabled by default. Running PR builds won't test these changes. Is there an option to run PR builds while specifying compiler options? e.g.

jenkins build cflags="-DDUMP_DBG" cxxflags="-DDUMP_DBG" all

@davidjmccann
davidjmccann force-pushed the save_errno_from_gencore branch from f6c514a to 0eef207 Compare March 28, 2022 14:27
@davidjmccann davidjmccann changed the title Reliably dump errno from gencore() when DUMP_DBG is defined Reliably print errno from gencore() when DUMP_DBG is defined Mar 28, 2022
@davidjmccann

Copy link
Copy Markdown
Contributor Author

@babsingh Thanks. Now amended.

Comment thread port/aix/omrosdump_helpers.c Outdated
portLibrary->tty_printf(portLibrary, "\tomrdump_create: errno: %i %s\n", savedErrno, portLibrary->error_last_error_message(portLibrary));
}
fflush(stdout);
#endif

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some of this code is old, and predates the coding standards. Can I also request you to update the #endif comments for all defined(DUMP_DBG)? There are only 5 locations in this file. As we modify old code, we want to enforce as much of the coding standards as possible. Also, it will be more consistent.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure. Done.

If DUMP_DBG is defined, the errno from gencore() might be overridden by the tty_printf function before it is printed. Save the errno value from gencore() so it can be reliably printed.

Signed-off-by: David McCann mccannd@uk.ibm.com
@davidjmccann
davidjmccann force-pushed the save_errno_from_gencore branch from 0eef207 to 05ccf36 Compare March 28, 2022 15:47
@davidjmccann
davidjmccann requested a review from babsingh March 28, 2022 15:48
@babsingh

Copy link
Copy Markdown
Contributor

Jenkins build all

@babsingh babsingh left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The PR builds will only confirm that the pre-processor statements are correctly defined. The modified code won't be tested by the PR builds since DUMP_DBG is not defined by default. Visually, the modified code looks good to me. @davidjmccann Can you confirm if you have locally tested the code on an AIX machine and noticed no issues?

@davidjmccann

Copy link
Copy Markdown
Contributor Author

@babsingh Apart from the endif changes, I've built the code on AIX and it functions as I intended, with no other issues seen. e.g.
17:04:05.385962 7995698.2 : omrdump_create: gencore/coredump returned: -1
17:04:05.385967 7995698.2 : omrdump_create: errno: 2

@babsingh babsingh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for confirming.

@AdamBrousseau

Copy link
Copy Markdown
Contributor

Is there an option to run PR builds while specifying compiler options?

Not at the moment, but it could probably be added. Not sure when we would have time to do it. Is this an env variable or a make option?
https://github.com/eclipse/omr/blob/master/buildenv/jenkins/omrbuild.groovy

@babsingh

babsingh commented Mar 29, 2022 •

Copy link
Copy Markdown
Contributor

Is this an env variable or a make option?

Both should work. Compiler should accept these options via an env variable or cmake. Supplying as a cmake option will be better than the env variable. Because changes will be isolated (only applied) to the compile job. Env variable can unknowingly influence other things; there is less control over what is impacted.

@davidjmccann

Copy link
Copy Markdown
Contributor Author

@0xdaryl Happy to merge?

@0xdaryl

0xdaryl commented Mar 31, 2022

Copy link
Copy Markdown
Contributor

Jenkins build zos

@0xdaryl 0xdaryl self-assigned this Mar 31, 2022
@0xdaryl
0xdaryl merged commit 4f53d2b into eclipse-omr:master Mar 31, 2022
@davidjmccann
davidjmccann deleted the save_errno_from_gencore branch April 1, 2022 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants