Commit a0a74f0
committed
[jit] fix segfault in attribute lookup on loaded ScriptModules
The IR emitter looks for attributes on modules like:
1. Check the JIT type for the attribute
2. Check the originating Python class, in order to fulfill requests for, e.g. static methods or ignored methods.
In the case where you do:
```
inner_module = torch.jit.load("inner.pt")
wrapped = Wrapper(inner_module) # wrap the loaded ScriptModule in an nn.Module
torch.jit.script(wrapped)
```
The IR emitter may check for attributes on `inner_module`. There is no
originating Python class for `inner_module`, since it was directly
compiled from the serialized format.
Due to a bug in the code, we don't guard for this case an a segfault
results if the wrapper asks for an undefined attribute. The lookup in
this case looks like:
1. Check the JIT type for the attribute (not there!)
2. Check the originating Python class (this is a nullptr! segfault!)
This PR guards this case and properly just raises an attribute missing
compiler error instead of segfaulting.
ghstack-source-id: a27e4a4
Pull Request resolved: #432841 parent d467ac8 commit a0a74f0
File tree
4 files changed
+44
-11
lines changed- test
- torch/csrc/jit
- frontend
- python
4 files changed
+44
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15158 | 15158 | | |
15159 | 15159 | | |
15160 | 15160 | | |
| 15161 | + | |
| 15162 | + | |
| 15163 | + | |
| 15164 | + | |
| 15165 | + | |
| 15166 | + | |
| 15167 | + | |
| 15168 | + | |
| 15169 | + | |
| 15170 | + | |
| 15171 | + | |
| 15172 | + | |
| 15173 | + | |
| 15174 | + | |
| 15175 | + | |
| 15176 | + | |
| 15177 | + | |
| 15178 | + | |
| 15179 | + | |
| 15180 | + | |
| 15181 | + | |
| 15182 | + | |
| 15183 | + | |
| 15184 | + | |
15161 | 15185 | | |
15162 | 15186 | | |
15163 | 15187 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
132 | 135 | | |
133 | 136 | | |
134 | 137 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| |||
192 | 193 | | |
193 | 194 | | |
194 | 195 | | |
195 | | - | |
| 196 | + | |
196 | 197 | | |
197 | 198 | | |
198 | 199 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
535 | 535 | | |
536 | 536 | | |
537 | 537 | | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
538 | 545 | | |
539 | | - | |
540 | | - | |
541 | | - | |
| 546 | + | |
542 | 547 | | |
543 | 548 | | |
544 | | - | |
545 | | - | |
546 | | - | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
547 | 552 | | |
548 | 553 | | |
549 | 554 | | |
550 | | - | |
551 | | - | |
552 | | - | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
553 | 558 | | |
554 | 559 | | |
555 | 560 | | |
| |||
0 commit comments