def Val gives seg fault

Bug #1248217 reported by Jon Hill
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fluidity
Fix Committed
Medium
Jon Hill

Bug Description

Calling your python function Val rather than val causes a seg fault.

We should at least have a nice error!

Jon Hill (jon-hill)
Changed in fluidity:
importance: Undecided → Medium
status: New → Confirmed
assignee: nobody → Jon Hill (jon-hill)
milestone: none → 4.1.12
Revision history for this message
Jon Hill (jon-hill) wrote :

This is the offending line of code (line 79 embed_python.c)
  // Extract the function from the code.
  pFunc=PyDict_GetItemString(pLocals, "val");

If there is no val item, then pFunc is NULL, so when you call it, you get a seg fault...

Edit to:
  // Extract the function from the code.
  pFunc=PyDict_GetItemString(pLocals, "val");
  if (pFunc == NULL) {
      printf("Couldn't find a 'val' function in your Python code.\n");
      *stat=1;
      return;
  }

?

Revision history for this message
Jon Hill (jon-hill) wrote :

Ah, that seems to work nicely. Gives us this:

Couldn't find a 'val' function in your Python code.
 Python error while setting field: Temperature
 Python string was:
 def Val(X,t):
  depth=1000
  dT=10
  return (X[1]+depth)/depth*dT
*** ERROR ***
Error message: Dying

Are people happy for this to be pushed straight into trunk?

Revision history for this message
Christian Jacobs (ctjacobs) wrote :

Looks good to me. I'm happy for this to be shipped straight to the trunk.

Jon Hill (jon-hill)
Changed in fluidity:
status: Confirmed → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.