Segfault when using -gen llvm (SOLVED)

General FreeBASIC programming questions.
AGS
Posts: 1284
Joined: Sep 25, 2007 0:26
Location: the Netherlands

Segfault when using -gen llvm (SOLVED)

Postby AGS » Jun 02, 2015 22:34

I tried to compile the following code using the llvm back end

Code: Select all

Type Hello extends object
    Declare virtual Sub hi( )
End Type

Type HelloEnglish extends Hello
    Declare Sub hi( )
End Type

Type HelloFrench extends Hello
    Declare Sub hi( )
End Type

Type HelloGerman extends Hello
    Declare Sub hi( )
End Type


Sub Hello.hi( )
    Print "hi!"
End Sub

Sub HelloEnglish.hi( )
    Print "hello!"
End Sub

Sub HelloFrench.hi( )
    Print "Salut!"
End Sub

Sub HelloGerman.hi( )
    Print "Hallo!"
End Sub


    Randomize( Timer( ) )

    Dim As Hello Ptr h

    For i As Integer = 0 To 9
        Select Case( Int( Rnd( ) * 4 ) + 1 )
        Case 1
            h = New HelloEnglish
        Case 2
            h = New HelloFrench
        Case 3
            h = New HelloGerman
        Case Else
            h = New Hello
        End Select

        h->hi( )
        Delete h
    Next


When compiling the above code using -gen llvm -v I get the following message

Code: Select all

FreeBASIC Compiler - Version 1.02.1 (04-25-2015), built for win32 (32bit)
Copyright (C) 2004-2015 The FreeBASIC development team.
standalone
target:       win32, 486, 32bit
compiling:    .\virtual_functions.bas -o .\virtual_functions.ll (main module)

Aborting due to runtime error 12 ("segmentation violation" signal)


Other code compiled as expected when using -gen llvm so there must be something in the example code that evokes the segfault.
OS used: windows 7 64bit (pro)
FBC version: FreeBASIC Compiler - Version 1.02.1 (04-25-2015), built for win32 (32bit)
Last edited by AGS on Jun 04, 2015 0:49, edited 1 time in total.
dkl
Site Admin
Posts: 3212
Joined: Jul 28, 2005 14:45
Location: Germany

Re: Segfault when using -gen llvm

Postby dkl » Jun 03, 2015 18:04

Looks like the LLVM backend's struct emitting is still a bit buggy. I don't remember if I even worked on that yet; there's some big remaining TODOs regarding -gen llvm.

Thanks for testing it nevertheless, I'll probably get more work done on that at some point.
dkl
Site Admin
Posts: 3212
Joined: Jul 28, 2005 14:45
Location: Germany

Re: Segfault when using -gen llvm (SOLVED)

Postby dkl » Jun 20, 2015 20:23

Hi,

The particular issue that caused the fbc crash with this code should be fixed in Git now.

I've also worked on some other things (global variable initializers, arrays), but this example still isn't quite yet working with -gen llvm. There's still an issue with variable initializers' interaction with string literals that I haven't gotten figured out yet...

Return to “General”

Who is online

Users browsing this forum: Bing [Bot] and 11 guests