v
v copied to clipboard
V0.3.1 (or weekly.2022.37) Breaks code that worked on V 0.3
The code base for the project this happened in is too large for me to hunt through to fix this error and V0.3 worked fine so I'm just going to go back to that version, but I have a strong suspicion that the broken code is in the "net.websocket" module, so if someone with more time than myself wishes to figure out what's actually going on, that's where I'd start.
If you wish to use my code base to test the error, feel free. Code - https://github.com/AlfieRan/MonoChain (Although the network has no completely static nodes atm as the project is still in early development so you'll only know if it works based upon if V compiles it without error or not.)
V Doctor
OS: macos, macOS, 12.5.1, 21G83 Processor: 8 cpus, 64bit, little endian, Apple M1 Pro CC version: Apple clang version 13.1.6 (clang-1316.0.21.2.5)
getwd: /Users/alfier/WebstormProjects/A-Level-Project/packages/node vmodules: /Users/alfier/.vmodules vroot: /Users/alfier/v vexe: /Users/alfier/v/v vexe mtime: 2022-09-19 20:39:44 is vroot writable: true is vmodules writable: true V full version: V 0.3.1 fcde631.e6e3751
Git version: git version 2.32.1 (Apple Git-133) Git vroot status: weekly.2022.37-42-ge6e37519 .git/config present: true thirdparty/tcc status: thirdparty-macos-arm64 173c526e
What did you do?
The code that this breaks is over a thousand lines long and as it is a compiler issue I have no idea where it came from, although I have a strong suspicion it was the websocket module.
What did you expect to see?
Code that worked in V0.3 to work in V0.3.1
What did you see instead?
A compiler error with the message:
error: implicit declaration of function 'I_voidptr_to_Interface_log__Logger' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
Have just realised that I'm not sure if it's V0.3.1 or the newest weekly version that broke the code as I haven't updated since V0.3 but either way it's something since then.
Which 0.3? What was the SHA value? There were quite a few changes made to V just since the official version change to 0.3.1. Almost all of them have been bug fixes.
It is possible you were relying on a bug that is now handled properly.
If it possible you were relying on a bug that is now handled properly. 👍
Very accurate, there is a great probability that this is the reason. Projects in my own production environment also encountered similar situations. After suspicion, diagnosis and debugging, I finally found that I passed non pointer values to the pointer parameters of the function. At that time, the V checker missed some checks. My own errors were exposed only after the V checker fixed some problems.
Of course, there is also a small possibility that there may be a "regenerative bug" in the process of repairing the bug of V, which is unavoidable, but not very likely.
Sadly I cannot tell you what version of 0.3 it worked on as it turns out downgrading version in V is annoyingly hard (downloading and compiling the compiler isn’t bad, just after actually running the code I’ve had compiler errors warning me my compiler is out of date and preventing compiling my actual code - probably due to not deleting the newer version properly).
Regardless, I know that the code runs on V 0.2.4 on a commit from somewhere around early June because this is the version I have on a different computer and it runs fine on this - I can get the hash for this one if anyone is interested but I’ll assume you’re not for now.
Based upon this and your suggestions it probably is a bug that’s been patched that’s broken my code, It just appears to be something to do with the net.websocket module because as far as I’m aware that’s the only place I’ve initiated an object with a logger. So from this information I think it’s probably something to do with not feeding a value into generating a client/server or feeding an empty value incorrectly and that’s what’s breaking it.
I’m going to check my code later today and see if it is something like that and if so I’ll close this issue.
Thank you for your responses.
Based upon extensive testing on my side I am 99% sure this was due to the unsafe default declaration of the logger for both the net.websocket client and server as unsafe { nil }.
This was probably a thing before the newer versions of V so it's probably just been uncovered by something else being rewritten slightly but as far as I can tell replacing this default with a suitable replacement (such as &log.Logger(&log.Log{level: .info}) which is the default Server/Client Opts that get fed in and set this value anyway) fixed all my problems and passed the autobahn + v tests for me.
I'v submitted that change as a pr (here) and if anyone else has the same issue open up {v_path}/vlib/net/websocket/websocket_server.v and {v_path}/vlib/net/websocket/websocket_client.v and replace the lines logger &log.Logger = unsafe { nil } with logger &log.Logger = &log.Logger(&log.Log{level: .info}) in the Server struct and Client struct respectively and this should hopefully fix this for you too.
Keep this issue opened until your PR isn't merged.
Closing this issue as https://github.com/vlang/v/pull/15836 is merged.