v icon indicating copy to clipboard operation
v copied to clipboard

segmentation fault when running vweb application compiled with -autofree

Open Bewalticus opened this issue 4 years ago • 0 comments

OS: linux, Linux version 5.15.18-200.fc35.x86_64 ([email protected]) (gcc (GCC) 11.2.1 20211203 (Red Hat 11.2.1-7), GNU ld version 2.37-10.fc35) #1 SMP Sat Jan 29 13:54:17 UTC 2022 (VM) Processor: 1 cpus, 64bit, little endian, 06/46 CC version: cc (Alpine 9.3.0) 9.3.0

getwd: /v/src/headertest vmodules: /root/.vmodules vroot: /opt/vlang vexe: /opt/vlang/v vexe mtime: 2022-02-21 14:17:14 is vroot writable: true is vmodules writable: true V full version: V 0.2.4 04654ed.83cdd8b env VFLAGS: "-cc gcc"

Git version: git version 2.24.4 Git vroot status: weekly.2022.07-59-g83cdd8be .git/config present: true thirdparty/tcc status: thirdparty-linux-amd64 3654d6a8

What did you do? I compiled the following application with -autofree option and ran it.

The headertest.v file:

module main

import vweb

struct App {
	vweb.Context
}

fn main() {
	app := App{}
	vweb.run(app, 8080)
}

['/index']
pub fn (mut app App) index() vweb.Result {
	headers := app.req.header
	mut h_map := map[string]string
	for header in headers.keys() {
		h_map[header] = headers.get_custom(header) or {''}
	}
	return $vweb.html()
}

and the index.html:

<html>
    <head>
        <title>Request Info</title>
    </head>
    <body>
        <h2>Headers</h2>
        <ul>
            @for key, val in h_map
                <li>
                    <b>@key</b>: @val
                </li>
            @end
            </ul>
    </body>
</html>

What did you expect to see? The application should run and serve the webpage showing request header information.

What did you see instead? The application starts but crashes at first request:

[Vweb] Running app on http://localhost:8080/
signal 11: segmentation fault
C.backtrace returned less than 2 frames

PS: The application runs w/o problems when -autofree is not specified or when using -gc boehm.

Bewalticus avatar Feb 21 '22 14:02 Bewalticus