|
Bugzilla – Full Text Bug Listing |
| Summary: | System.NullReferenceException when generics used | ||
|---|---|---|---|
| Product: | [Mono] Mono: Runtime | Reporter: | Marek Safar <msafar> |
| Component: | JIT | Assignee: | Mark Probst <mprobst> |
| Status: | RESOLVED FIXED | QA Contact: | Mono Bugs <mono-bugs> |
| Severity: | Normal | ||
| Priority: | P5 - None | CC: | forgotten_vxPDddArjq |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | Other | ||
| OS: | Other | ||
| Whiteboard: | |||
| Found By: | --- | Services Priority: | |
| Business Priority: | Blocker: | --- | |
| Marketing QA Status: | --- | IT Deployment: | --- |
| Bug Depends on: | |||
| Bug Blocks: | 324319 | ||
| Attachments: |
Test
Proposed patch. Updated proposed patch. |
||
|
Description
Marek Safar
2009-01-27 12:47:00 UTC
Created attachment 267890 [details]
Test
Created attachment 267946 [details]
Proposed patch.
The problem is the sequence
IL_0000: ldnull
IL_0001: unbox.any !!0
IL_0006: stloc.0
The code which generates the code for unbox.any just emits a check and then leaves the variable on the stack that ldnull generated. emit_stloc_ir() doesn't take into account that that variable might be in use somewhere else and just destroys it, so the generated code doesn't check NULL but uninitialized data.
Your patch removes a small opt which is trivially avoidable. Instead of removing, it should check if sp[0] is the last ins of the current basic block. And besides that unbox.any should not emit a cast class if sp [0] is a ldnull. Created attachment 268005 [details]
Updated proposed patch.
Updated. Doesn't remove the optimization now. Based on all the code I've run the optimization never makes a difference, though (admittedly, I only compared the generated native code size, not the generated code itself).
The generated castclass is superfluous, but that's a different issue.
This looks ok. Fixed in SVN and backported to 2.2 and 2.4. |