|
16 | 16 |
|
17 | 17 | from devito.exceptions import CompilationError |
18 | 18 | from devito.ir.iet.nodes import ( |
19 | | - BlankLine, Call, Expression, ExpressionBundle, Iteration, Lambda, ListMajor, Node, |
20 | | - MetaCall, Section |
| 19 | + BlankLine, Call, Expression, ExpressionBundle, Iteration, Lambda, ListMajor, MetaCall, |
| 20 | + Node, Section |
21 | 21 | ) |
22 | 22 | from devito.ir.support.space import Backward |
23 | 23 | from devito.symbolics import ( |
@@ -1593,13 +1593,17 @@ def visit_Operator(self, o, **kwargs): |
1593 | 1593 | # Modify the _func_table to ensure callbacks are specialized |
1594 | 1594 | state['_func_table'] = self._visit(o._func_table) |
1595 | 1595 |
|
1596 | | - try: |
1597 | | - state.pop('ccode') |
1598 | | - except KeyError: |
1599 | | - # C code has not previously been generated for this Operator |
1600 | | - pass |
| 1596 | + state.pop('ccode', None) |
| 1597 | + |
| 1598 | + # The specialized operator must be compiled fresh - strip any pre-existing |
| 1599 | + # compiled binary state inherited from a previously-applied operator. |
| 1600 | + # Without this, __setstate__ reloads the old binary (which expects the full |
| 1601 | + # parameter list), while the new operator has fewer parameters after |
| 1602 | + # specialization, causing a stack corruption (SIGABRT) at call time. |
| 1603 | + state.pop('binary', None) |
| 1604 | + state.pop('soname', None) |
| 1605 | + state.pop('_soname', None) # Clear cached soname so it is recomputed |
1601 | 1606 |
|
1602 | | - # FIXME: These names aren't great |
1603 | 1607 | newargs, newkwargs = o.__getnewargs_ex__() |
1604 | 1608 | newop = o.__class__(*newargs, **newkwargs) |
1605 | 1609 |
|
|
0 commit comments