Wiki Roadmap Timeline Tickets New Ticket Source Search Help / Guide About Trac Login

Ticket #340 (new defect)

Opened 3 years ago

Last modified 2 years ago

PPC: Switch statement in template broken

Reported by: revcompgeek Assigned to: ChristianK
Priority: blocker Milestone:
Component: unspecified Version: hg tip
Keywords: Cc: revcompgeek+ldc@gmail.com

Description

I first noticed the problem when I any executable I generate using tango.io.Stdout would crash, and eventually tango.text.convert.Layout. I have reduced the problem, originally located in the dispatch function of the Layout class down to a very small test case. I am attaching good and bad versions of the file, along with the generated .s files. The only difference between the two files is one of the chars that the case statements are using. The order of the case statements doesn't matter, and neither does the char in the top switch statement.

Attachments

switch_bad.d (153 bytes) - added by revcompgeek on 07/08/09 02:09:11.
Bad module
switch_good.d (153 bytes) - added by revcompgeek on 07/08/09 02:09:36.
Good module
switch_bad.s (7.3 kB) - added by revcompgeek on 07/08/09 02:10:16.
Generated assembly for bad module
switch_good.s (6.5 kB) - added by revcompgeek on 07/08/09 02:10:44.
Generated assembly for good module
switch_good.ll (12.3 kB) - added by revcompgeek on 07/08/09 13:04:35.
Generated LLVM IR for good module
switch_bad.ll (12.3 kB) - added by revcompgeek on 07/08/09 13:09:07.
Generated LLVM IR for bad module

Change History

07/08/09 02:09:11 changed by revcompgeek

  • attachment switch_bad.d added.

Bad module

07/08/09 02:09:36 changed by revcompgeek

  • attachment switch_good.d added.

Good module

07/08/09 02:10:16 changed by revcompgeek

  • attachment switch_bad.s added.

Generated assembly for bad module

07/08/09 02:10:44 changed by revcompgeek

  • attachment switch_good.s added.

Generated assembly for good module

07/08/09 02:12:04 changed by revcompgeek

I am running on a PowerBook? G4 with a PowerPC processor and Mac OS 10.5.7

07/08/09 03:42:08 changed by ChristianK

Are you sure this is related to the template? switch_bad should throw a SwitchException (because there's no 'a' case) - and if the EH code does not work right, it might very well crash.

07/08/09 05:58:12 changed by revcompgeek

  • cc changed from revcompgeek to revcompgeek+ldc@gmail.com.

I have verified that exception handling works on my computer, after a few modifications I made. Also, the 'a' could be changed to a 'm' or anything else, that doesn't matter. I just tested with Foo not as a template and the crash did not happen. The problem is that the compiler is generating something incorrect because the dynamic runtime linker is crashing. No code from the executable is actually being run.

Would -vv output from the compiler in both cases be helpful?

07/08/09 13:04:35 changed by revcompgeek

  • attachment switch_good.ll added.

Generated LLVM IR for good module

07/08/09 13:09:07 changed by revcompgeek

  • attachment switch_bad.ll added.

Generated LLVM IR for bad module

07/08/09 13:27:52 changed by revcompgeek

If I build from the LLVM IR it doesn't crash.

07/08/09 13:46:06 changed by revcompgeek

If ldc is invoked with any optimization level other than 0 the code runs fine.

07/27/09 05:10:14 changed by ChristianK

  • summary changed from Switch statement in template broken to PPC: Switch statement in template broken.

(follow-up: ↓ 8 ) 08/02/09 10:06:13 changed by lindquist

Could this be related to:

http://llvm.org/bugs/show_bug.cgi?id=4671

That bug also show up when more than one module uses Layout.dispatch, though in this case linking fails.

(in reply to: ↑ 7 ) 11/08/09 07:44:14 changed by revcompgeek

Replying to lindquist:

Could this be related to: http://llvm.org/bugs/show_bug.cgi?id=4671 That bug also show up when more than one module uses Layout.dispatch, though in this case linking fails.

That is possible, I would like to test it, but due to bug #378 I can't test this just yet.

Copyright © 2008, LDC Development Team.