Skip to content

Avoid AnalyticFunction segfaults in debug mode by asserting valid pointers#4445

Open
jwpeterson wants to merge 2 commits intolibMesh:develfrom
jwpeterson:analytic_function_asserts
Open

Avoid AnalyticFunction segfaults in debug mode by asserting valid pointers#4445
jwpeterson wants to merge 2 commits intolibMesh:develfrom
jwpeterson:analytic_function_asserts

Conversation

@jwpeterson
Copy link
Copy Markdown
Member

There are two ways of constructing an AnalyticFunction (either with a scalar-valued or a vector-valued function), but System::reinit_constraints() expects to be able to use the latter. Previously, it was a segfault even in debug mode when you attempted to use a scalar-valued AnalyticFunction. With this patch, at least in debug mode, we now get an assert with a more informative error message.

…r before using

It is currently possible to construct an AnalyticFunction with either
an OutputFunction pointer or an OutputVectorFunction pointer, but
System::reinit_constraints() expects to be able to use the
void-returning AnalyticFunction::operator(), which in turn uses
_vector_fptr without first asserting it is valid. I guess we never did
this combination of things before, but it came up for me recently in
an example created by claude.

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt

(gdb) f 1
127	  this->_vector_fptr(output, p, time);

(gdb) p _vector_fptr
$1 = (libMesh::AnalyticFunction<double>::OutputVectorFunction) 0x0
@moosebuild
Copy link
Copy Markdown

Job Coverage, step Generate coverage on fc0e1bc wanted to post the following:

Coverage

505ce4 #4445 fc0e1b
Total Total +/- New
Rate 65.47% 65.47% +0.00% -
Hits 78230 78232 +2 0
Misses 41256 41254 -2 0

Diff coverage report

Full coverage report

This comment will be updated on new commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants