[SERVER-2751] Many JS types crash shell if "new" is omitted Created: 13/Mar/11  Updated: 12/Jul/16  Resolved: 07/Oct/11

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: 1.8.0-rc1, 1.8.0-rc2
Fix Version/s: 2.1.0

Type: Bug Priority: Minor - P4
Reporter: Scott Hernandez (Inactive) Assignee: Antoine Girbal
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

> BinData(3,"550e8400e29b41d4a716446655440000")
Assertion failure: OBJ_GET_CLASS(cx, obj)->flags & JSCLASS_HAS_PRIVATE, at jsapi.c:2303
Trace/BPT trap
> BinData(3,"1243")
Assertion failure: OBJ_GET_CLASS(cx, obj)->flags & JSCLASS_HAS_PRIVATE, at jsapi.c:2303
Trace/BPT trap

Even when it doesn't crash it doesn't work:

> BinData(0, "22")
Sun Mar 13 09:43:57 Error: BinData could not decode base64 parameter (shell):1



 Comments   
Comment by auto [ 07/Oct/11 ]

Author:

{u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'}

Message: - SERVER-2751: fixed for SM too. Also fixed test typo.
Branch: master
https://github.com/mongodb/mongo/commit/5810ac31bda6588dd2651eecac8bce48c907a827

Comment by auto [ 07/Oct/11 ]

Author:

{u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'}

Message: - SERVER-2751: BinData Asserts and crashes shell
Branch: master
https://github.com/mongodb/mongo/commit/e03ce18ac0ddce659e808256bedcbb4acd8fb080

Comment by Antoine Girbal [ 07/Oct/11 ]

In v8 almost all types would crash shell if "new" was omitted.
Some had a condition to create "this" but it was not done correctly.
Added a test for all types.

Comment by Antoine Girbal [ 28/Apr/11 ]

was just testing this, it seems with master code it now works fine without the "new", so someone must have fixed it.
In general we should probably make sure we dont require the "new" for object creation, because it's annoying to type and many js users are used to omitting it.
The risk is if we dont support it but then we fail silently after modifying the wrong object..
Since we need to check that object is correct we might as well create the correct one if needed.

Comment by Robert Stam [ 28/Apr/11 ]

My interest in whether new is required or not is that I want the C# driver to output JSON that can be pasted into the shell and used without errors (but only when output mode is JsonOutputMode.Shell).

If we aren't going to support BinData without "new" then I need to output JSON that includes the "new" for BinData.

Comment by Eliot Horowitz (Inactive) [ 21/Mar/11 ]

Support for non-new is a bug imo.
When creating an object, you should use new.
But if you forget it, the error message should be clear (and not crash)

Comment by Scott Hernandez (Inactive) [ 20/Mar/11 ]

Yes, it does need new to work in the last case; my mistake.

We should fix both the crashing and the need for "new", if possible.

We support ObjectId("...") without the need for "new".

Comment by Eliot Horowitz (Inactive) [ 19/Mar/11 ]

I think you need new

Generated at Thu Feb 08 03:01:05 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.