Skip to content

return fail!() interacts badly with while loop continuation #7714

Closed

Description

@MarkJr94

I unfortunately cannot seem to isolate the issue into a small test case, but I am filing a bug for some help until I can.

Output of rustc --version

rustc 0.8-pre (9239d69 2013-07-10 23:37:40 -0700)
host: x86_64-unknown-linux-gnu

The relevant code is in file: https://github.com/MarkJr94/bzip2rs/blob/master/bzip2.rs

Specifically, the Bzip2Compressor::compress method failes with a segmentation fault. I checked using good old printf debugging, and the segfault is caused by the loop continuing to execute even though the condition here: https://github.com/MarkJr94/bzip2rs/blob/master/bzip2.rs#L180 is no longer true. Notably, an explicit break; statement, located here: https://github.com/MarkJr94/bzip2rs/blob/master/bzip2.rs#L207-L210 did not fix the issue.

The data I am compressing is the file itself, which you can see in the main function here: https://github.com/MarkJr94/bzip2rs/blob/master/bzip2.rs#L481-L502

When I perform rustc --bin bzip2.rs && ./bzip2 I get a segmentation fault.

I tracked down the error with some help from the lovely folks on IRC, and noticed if I changed this line: https://github.com/MarkJr94/bzip2rs/blob/master/bzip2.rs#L193
from return fail!(); to fail!(); the code worked as expected. Simply commenting out this entire block https://github.com/MarkJr94/bzip2rs/blob/master/bzip2.rs#L191-L194 also makes things work. The issue seems to be with the return fail!(); and I was told on IRC to file this issue, as it seems seperate from #6675.

I am continuing to work on isolating the issue.

Activity

  1. emberian commented on Aug 29, 2013

    @emberian
    Contributor

    @MarkJr94 unless you have any update on this, I'm going to close it as there's nothing really actionable here.

  2. added a commit that references this issue on Dec 29, 2022
    4f1bae0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions