Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compile-time refcount bug hunt build mode #952

Merged
merged 5 commits into from
Mar 8, 2025

Conversation

bnoordhuis
Copy link
Contributor

@bnoordhuis bnoordhuis commented Mar 6, 2025

See #944.

Not fully done yet - still some 400 warnings left to fix 🤦 - but already uncovered a RC bug in js_date_setYear.

Done. Caught a further two or three RC buglets.

Reintroduce JSValueConst and add a JS_CHECK_JSVALUE build mode that
catches reference counting bugs by making JSValue and JSValueConst
different types.

The *vast* majority of this commit is rote work to make our own sources
compile cleanly in said mode.

Refs: quickjs-ng#944
@bnoordhuis bnoordhuis changed the title Reintroduce JSValueConst Add compile-time refcount bug hunt build mode Mar 7, 2025
@bnoordhuis bnoordhuis marked this pull request as ready for review March 7, 2025 21:15
@bnoordhuis
Copy link
Contributor Author

D:\a\quickjs\quickjs\quickjs.c(46685,27): error C2440: 'type cast': cannot convert from 'JSValue' to 'JSValue' [D:\a\quickjs\quickjs\build\qjs.vcxproj]

msvc, man 🤦

Copy link
Contributor

@saghul saghul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Damn! I hope you found a way not to type all that by hand...

Copy link
Contributor

@bptato bptato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, thank you!
I've skimmed through the diff and then the public API, some suggestions (I have no idea how to do this through GH UI, sorry...):

  • JS_MarkValue, JSClassFinalizer, JSClassGCMark, and JS_IsPromise take a JSValueConst for val
  • JS_PromiseResult takes JSValueConst for promise
  • JS_IsLiveObject, JS_GetOwnPropertyNames take JSValueConst for obj
  • JS_IsEqual, JS_IsStrictEqual, JS_IsSameValue, JS_IsSameValueZero take JSValueConst for both params (they all dup the params first)
  • JS_GetPrototypePrimitive returns a JSValueConst

@saghul
Copy link
Contributor

saghul commented Mar 8, 2025

@bnoordhuis Do you want me to hold on the release until this lands? It does seem worthy.

@bnoordhuis
Copy link
Contributor Author

Yes, please. I'll incorporate @bptato's suggestions where possible.

@bnoordhuis bnoordhuis merged commit 297a911 into quickjs-ng:master Mar 8, 2025
62 checks passed
@bnoordhuis bnoordhuis deleted the vc branch March 8, 2025 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants