vlang / v

Simple, fast, safe, compiled language for developing maintainable software. Compiles itself in <1s with zero library dependencies. Supports automatic C => V translation. https://vlang.io
MIT License
35.8k stars 2.17k forks source link

VWeb crashes #16700

Open Eliyaan opened 1 year ago

Eliyaan commented 1 year ago

Describe the bug

The vweb localhost crashes somethimes it's right when I start the program sometimes it works well sometimes it's two minutes after the start

Expected Behavior

Vweb localhost

Current Behavior

Error: (spytheman asked me for this error)

Unhandled Exception 0xC0000005
Unhandled Exception 0xC0000005
C:/Users/PACHECON/AppData/Local/Temp/v_0/../../../../../..C:\Users\PACHECON\v\vlib\builtin\builtin_windows.c.v:199: at print_backtrace_skipping_top_frames_tcc: Backtrace
C:/Users/PACHECON/AppData/Local/Temp/v_0/../../../../../..C:\Users\PACHECON\v\vlib\builtin\builtin_windows.c.v:199: at print_backtrace_skipping_top_frames_tcc: Backtrace
C:/Users/PACHECON/AppData/Local/Temp/v_0/../../../../../..C:\Users\PACHECON\v\vlib\builtin\builtin_windows.c.v:110: by print_backtrace_skipping_top_frames    
C:/Users/PACHECON/AppData/Local/Temp/v_0/../../../../../..C:\Users\PACHECON\v\vlib\builtin\builtin_windows.c.v:110: by print_backtrace_skipping_top_frames    
C:/Users/PACHECON/AppData/Local/Temp/v_0/../../../../../..C:\Users\PACHECON\v\vlib\builtin\builtin_windows.c.v:251: by unhandled_exception_handlerC:/Users/PACHECON/AppData/Local/Temp/v_0/../../../../../..C:\Users\PACHECON\v\vlib\builtin\builtin_windows.c.v:251: by unhandled_exception_handler

7ff895688b4c : by ???
RUNTIME ERROR: invalid memory access

(other errors)

[Vweb] Running app on http://localhost:8080/
Unhandled Exception 0xC0000005
Unhandled Exception 0xC0000005
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.5098470411768190130.tmp.c:11758: at print_backtrace_skipping_top_frames_tcc: Backtrace
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.5098470411768190130.tmp.c:11758: at print_backtrace_skipping_top_frames_tcc: Backtrace
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.5098470411768190130.tmp.c:11725: by print_backtrace_skipping_top_frames
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.5098470411768190130.tmp.c:11725: by print_backtrace_skipping_top_frames
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.5098470411768190130.tmp.c:11783: by unhandled_exception_handler
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.5098470411768190130.tmp.c:11783: by unhandled_exception_handler
7ffc05068b4c : by ???
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.5098470411768190130.tmp.c:12795: at map_key_to_index: RUNTIME ERROR: invalid memory access        
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.5098470411768190130.tmp.c:5982: by vweb__handle_conn_T_main__App_thread_wrapper
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.5098470411768190130.tmp.c:12980: by map_get
0052abde : by ???
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.5098470411768190130.tmp.c:31127: by vweb__serve_if_static_T_main__App
00526e0e : by ???
by vweb__handle_conn_T_main__App
7ffc03107614 : by ???
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.5098470411768190130.tmp.c:5982: by vweb__handle_conn_T_main__App_thread_wrapper
RUNTIME ERROR: invalid memory access0052abde :
PS C:\Users\PACHECON\_cv\livet_notes_server> v run .
[Vweb] Running app on http://localhost:8080/
Unhandled Exception 0xC0000005
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.12908179018095229149.tmp.c:11758: at print_backtrace_skipping_top_frames_tcc: Backtrace
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.12908179018095229149.tmp.c:11725: by print_backtrace_skipping_top_frames
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.12908179018095229149.tmp.c:11783: by unhandled_exception_handler
7ffc05068b4c : by ???
RUNTIME ERROR: invalid memory access
PS C:\Users\PACHECON\_cv\livet_notes_server> v run .
[Vweb] Running app on http://localhost:8080/
Unhandled Exception 0xC0000005
Unhandled Exception 0xC0000005
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.13282051691670760731.tmp.c:11758: at print_backtrace_skipping_top_frames_tcc: Backtrace
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.13282051691670760731.tmp.c:11758: at print_backtrace_skipping_top_frames_tcc: Backtrace
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.13282051691670760731.tmp.c:11725: by print_backtrace_skipping_top_framesC:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.13282051691670760731.tmp.c:11725: by print_backtrace_skipping_top_frames
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.13282051691670760731.tmp.c:11783: 
by unhandled_exception_handlerC:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.13282051691670760731.tmp.c:11783: by unhandled_exception_handler
7ffc05068b4c : by ???
7ffc05068b4c : RUNTIME ERROR: invalid memory accessby ???
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.13282051691670760731.tmp.c:5982: by vweb__handle_conn_T_main__App_thread_wrapper

or

[Vweb] Running app on http://localhost:8080/
Unhandled Exception 0xC0000005
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.12908179018095229149.tmp.c:11758: at print_backtrace_skipping_top_frames_tcc: Backtrace
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.12908179018095229149.tmp.c:11725: by print_backtrace_skipping_top_frames
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.12908179018095229149.tmp.c:11783: by unhandled_exception_handler
7ffc05068b4c : by ???
RUNTIME ERROR: invalid memory access

or

[Vweb] Running app on http://localhost:8080/
Unhandled Exception 0xC0000005
Unhandled Exception 0xC0000005
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.5098470411768190130.tmp.c:11758: at print_backtrace_skipping_top_frames_tcc: Backtrace
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.5098470411768190130.tmp.c:11758: at print_backtrace_skipping_top_frames_tcc: Backtrace
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.5098470411768190130.tmp.c:11725: by print_backtrace_skipping_top_frames
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.5098470411768190130.tmp.c:11725: by print_backtrace_skipping_top_frames
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.5098470411768190130.tmp.c:11783: by unhandled_exception_handler
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.5098470411768190130.tmp.c:11783: by unhandled_exception_handler
7ffc05068b4c : by ???
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.5098470411768190130.tmp.c:12795: at map_key_to_index: RUNTIME ERROR: invalid memory access        
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.5098470411768190130.tmp.c:5982: by vweb__handle_conn_T_main__App_thread_wrapper
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.5098470411768190130.tmp.c:12980: by map_get
0052abde : by ???
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.5098470411768190130.tmp.c:31127: by vweb__serve_if_static_T_main__App
00526e0e : by ???
by vweb__handle_conn_T_main__App
7ffc03107614 : by ???
C:/Users/PACHECON/AppData/Local/Temp/v_0/livet_notes_server.5098470411768190130.tmp.c:5982: by vweb__handle_conn_T_main__App_thread_wrapper
RUNTIME ERROR: invalid memory access0052abde :

Reproduction Steps

Code :

import vweb
import os

struct App {
    vweb.Context
}

fn main() {
    mut app := App{}
    app.mount_static_folder_at(os.resource_abs_path('.'), '/')
    vweb.run(app, 8080)
}

pub fn (app &App) index() vweb.Result {
    return $vweb.html()
}

['/mentions_legales']
pub fn (mut app App) mentionslegales() vweb.Result {
    return $vweb.html()
}

['/world_map']
pub fn (mut app App) worldmap() vweb.Result {
    return $vweb.html()
}

['/connexion']
pub fn (mut app App) connexion() vweb.Result {
    return $vweb.html()
}

['/creer_un_compte']
pub fn (mut app App) creercompte() vweb.Result {
    return $vweb.html()
}

['/contact']
pub fn (mut app App) contact() vweb.Result {
    return $vweb.html()
}
<!DOCTYPE html>
<html lang="fr">
<head>
    <title>LBM - LivetBlocMap</title>
    <!--Fichiers liés à la page-->
    @css '/style.css'
    <script src="home.js"></script>
    <meta charset="UTF-8">
</head>

<body>
    <!--Header-->
    <header>
        Livet NoteMap ヾ(≧ ▽ ≦)ゝ
    </header>

    <!--NavBar-->
    <nav>
        <a><button><img src="/livet-notes_icone.png" id="b-img">Livet Notes</button></a>
        <a href="/world_map"><button><img src="/worldmap_icone.png" id="b-img">WorldMap</button></a>
        <a href="/connexion"><button><img src="/connexion_icone.png" id="b-img">Connexion</button></a>
        <a href="/creer_un_compte"><button><img src="/inscription_icone.png" id="b-img">Inscription</button></a>
    </nav>

    <div id="corps">
    <!--Corps de la page-->
    <textarea name="Notes" cols="40" rows="40"></textarea><br>
    <img src="carte_lycee_temporaire.png" width="653" height="159" alt="Carte simplifiée du lycée Livet">
    </div>

    <!--Footer-->
    <footer>
        <a href="/contact"><button><img src="/contact_icone.png" id="b-img">Nous Contacter</button></a>
        <a href="/mentions_legales"><button><img src="/mentions_legales_icone.png" id="b-img">Mentions Légales</button></a>
        <a href="/contact"><button><img src="/signaler_un_probleme_icone.png" id="b-img">Signaler un problème</button></a>
    </footer>
</body>
</html>

Possible Solution

No response

Additional Information/Context

No response

V version

Current V version: V 0.3.2 65a020e, timestamp: 2022-12-16 16:53:04 +0300

Environment details (OS name and version, etc.)

OS: windows, Microsoft Windows 10 Education v19045 64 bits

amirhossein-fzl commented 1 year ago

I have the same error. When I try to benchmark with wrk, it crashes ...

bjones1 commented 1 year ago

I also have these problems with my vweb-based application. My tracebacks are similar. What other information would help track this down? Do you have any idea for where to look in terms of debugging?

This crashes rarely under Linux (Ubuntu 20.04 under WSL). My (Windows) environment:

C:\Users\bjones\Documents\git\CodeChat_Editor\server>v doctor
OS: windows, Microsoft Windows 10 Pro v19045 64-bit
Processor: 8 cpus, 64bit, little endian, Intel(R) Core(TM) i7-8705G CPU @ 3.10GHz
CC version: Error: exec failed (CreateProcess) with code 2: The system cannot find the file specified.
 cmd: cc --version

getwd: C:\Users\bjones\Documents\git\CodeChat_Editor\server
vmodules: C:\Users\bjones\.vmodules
vroot: C:\Users\bjones\Documents\git\v
vexe: C:\Users\bjones\Documents\git\v\v.exe
vexe mtime: 2022-12-21 17:57:47
is vroot writable: true
is vmodules writable: true
V full version: V 0.3.2 c3ee26f.88e33a8

Git version: git version 2.35.0.windows.1
Git vroot status: weekly.2022.50-51-g88e33a83-dirty (4 commit(s) behind V master)
.git/config present: true
thirdparty/tcc status: thirdparty-windows-amd64 cb89a4fe
Open http://localhost:8080/ in a browser.
[Vweb] Running app on http://localhost:8080/
Unhandled Exception 0xC0000005
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.14496493209200559487.tmp.c:12574: at print_backtrace_skipping_top_frames_tcc: Backtrace
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.14496493209200559487.tmp.c:12541: by print_backtrace_skipping_top_frames
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.14496493209200559487.tmp.c:12599: by unhandled_exception_handler
7ff83e8c8b4c : by ???
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.14496493209200559487.tmp.c:29061: at net__TcpConn_write_ptr: RUNTIME ERROR: invalid memory access
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.14496493209200559487.tmp.c:29095: by net__TcpConn_write
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.14496493209200559487.tmp.c:34052: by vweb__send_string
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.14496493209200559487.tmp.c:32900: by vweb__Context_send_response_to_client
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.14496493209200559487.tmp.c:33944: by vweb__serve_if_static_T_main__App
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.14496493209200559487.tmp.c:33364: by vweb__handle_conn_T_main__App
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.14496493209200559487.tmp.c:6328: by vweb__handle_conn_T_main__App_thread_wrapper
0054555e : by ???
0054178e : by ???
00545598 : by ???
7ff83d617614 : by ???

Unhandled Exception 0xC0000005
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.1714630348971032079.tmp.c:12578: at print_backtraUnhandled Exception 0xC0000005ce_
skipping_top_frames_tcc: Backtrace
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.1714630348971032079.tmp.c:12578: at print_backtrace_skipping_top_frames_tcc: Backtrace
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.1714630348971032079.tmp.c:12545: by print_backtrace_skipping_top_frames
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.1714630348971032079.tmp.c:12545: by print_backtrace_skipping_top_frames
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.1714630348971032079.tmp.c:12603: by unhandled_exception_handler
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.1714630348971032079.tmp.c:12603: by unhandled_exception_handler
7ff9e08a8b4c : by ???
7ff9e08a8b4c : by ???
0052f2ce : at ???: RUNTIME ERROR: invalid memory access
0053677f : by ???
0052f608 : by ???
005370b2 : by ???
0052e886 : by ???
005373a1 : by ???
005305f3 : by ???
005373d9 : by ???
0053677f : 00537404 : by ???
by ???
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.1714630348971032079.tmp.c:12211: by malloc_noscan
005370b2 : by ???
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.1714630348971032079.tmp.c:24442: by os__read_file
005373a1 : by ???
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.1714630348971032079.tmp.c:33961: by vweb__serve_if_static_T_main__App
005373d9 : by ???
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.1714630348971032079.tmp.c:33368: by vweb__handle_conn_T_main__App
00537404 : by ???
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.1714630348971032079.tmp.c:6328: by vweb__handle_conn_T_main__App_thread_wrapper
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.1714630348971032079.tmp.c:12211: by malloc_noscan
00545b2e : by ???
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.1714630348971032079.tmp.c:24442: by os__read_file
00541d5e : by ???
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.1714630348971032079.tmp.c:33961: by vweb__serve_if_static_T_main__App
00545b68 : by ???
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.1714630348971032079.tmp.c:33368: by vweb__handle_conn_T_main__App
7ff9df7f7614 : by ???
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.1714630348971032079.tmp.c:6328: by vweb__handle_conn_T_main__App_thread_wrapper

Open http://localhost:8080/ in a browser.
[Vweb] Running app on http://localhost:8080/
Unhandled Exception 0xC0000005
Unhandled Exception 0xC0000005C
:Unhandled Exception 0xC0000005/
Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.3341123842032227809.tmp.c:12578: at print_backtrace_skipping_top_frames_tcc: BacktraceC:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.3341123842032227809.tmp.c:12578: at print_backtrace_skipping_top_frames_tcc: Backtrace
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.3341123842032227809.tmp.c:12578: at print_backtrace_skipping_top_frames_tcc: Backtrace

C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.3341123842032227809.tmp.c:12545: by print_backtrace_skipping_top_frames
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.3341123842032227809.tmp.c:12545: by print_backtrace_skipping_top_frames
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.3341123842032227809.tmp.c:12545: by print_backtrace_skipping_top_frames
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.3341123842032227809.tmp.c:12603: by unhandled_exception_handler
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.3341123842032227809.tmp.c:12603: by unhandled_exception_handler
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.3341123842032227809.tmp.c:12603: by unhandled_exception_handler
7ff9e08a8b4c : by ???
7ff9e08a8b4c : by ???
7ff9e08a8b4c : by ???
7ff9df9a46f8 : at ???: RUNTIME ERROR: invalid memory access
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.3341123842032227809.tmp.c:31887: by net__http__parse_request_head
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.3341123842032227809.tmp.c:31887: by net__http__parse_request_head
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.3341123842032227809.tmp.c:11655: by array_ensure_cap_noscan
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.3341123842032227809.tmp.c:31803: by net__http__parse_request
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.3341123842032227809.tmp.c:31803: by net__http__parse_request
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.3341123842032227809.tmp.c:11799: by array_push_many_noscan
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.3341123842032227809.tmp.c:33258: by vweb__handle_conn_T_main__App
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.3341123842032227809.tmp.c:6328: by vweb__handle_conn_T_main__App_thread_wrapper
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.3341123842032227809.tmp.c:21296: by io__BufferedReader_read_line
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.3341123842032227809.tmp.c:33258: by vweb__handle_conn_T_main__App
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.3341123842032227809.tmp.c:6328: by vweb__handle_conn_T_main__App_thread_wrapper
00545b2e : by ???
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.3341123842032227809.tmp.c:31887: by net__http__parse_request_head
00545b2e : by ???
00541d5e : by ???
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.3341123842032227809.tmp.c:31803: by net__http__parse_request
00541d5e : by ???
00545b68 : by ???
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.3341123842032227809.tmp.c:33258: by vweb__handle_conn_T_main__App
00545b68 : by ???
7ff9df7f7614 : by ???
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.3341123842032227809.tmp.c:6328: by vweb__handle_conn_T_main__App_thread_wrapper
7ff9df7f7614 : by ???
005372fb : at ???: RUNTIME ERROR: invalid memory access
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.3341123842032227809.tmp.c:31803: by net__http__parse_request
00541d5e : by ???
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.3341123842032227809.tmp.c:33258: by vweb__handle_conn_T_main__App
00545b68 : by ???
C:/Users/bjones/AppData/Local/Temp/v_0/CodeChatEditorServer.3341123842032227809.tmp.c:6328: by vweb__handle_conn_T_main__App_thread_wrapper
005373d9 : by ???
7ff9df7f7614 : by ???
00545b2e : by ???
bjones1 commented 1 year ago

Probable duplicate: #16080.

JalonSolov commented 1 year ago

Do you have a copy of the style.css file referenced in the example?

Eliyaan commented 1 year ago

server.zip There you have all the server files I was using I think

JalonSolov commented 1 year ago

So far, I have not been able to make this crash on my Linux system. Running ./wrk -d 10000 -t 100 -c 100 http://localhost:8080 with no problem.

The 0xC0000005 error is often shown with running out of stack. Perhaps try it with adding -thread-stack-size 16777216 to force a 16MiB stack. Default on Windows is around 1MiB, I think.