Ticket #1107 (closed bug: fixed)

Opened 7 years ago

Last modified 6 years ago

Opcode get_class has failed assertion with garbage input

Reported by: Austin_Hastings Owned by: NotFound
Priority: normal Milestone:
Component: core Version: 1.6.0
Severity: medium Keywords:
Cc: Language:
Patch status: Platform:


This code is wrong:

	sub compile_default_multi($class_name, $multi_name) {
		NOTE("Class name: ", $class_name);
		NOTE("Multi name: ", $multi_name);
		my $class := Q:PIR {
			$P0 = find_lex '$class_name'
			%r = get_class $S0

(Where "NOTE" is a very expensive conditional 'say')

The PIR block references $S0 where is should reference $P0.

The result is an assertion failure. I believe that asking for the class of garbage is valid - it names a class that doesn't exist. The result should be a NULL PMC (or an exception, though the documentation of get_class does not mention any).

| | | | | | | | | +- Dump::Class::compile_default_multi: Class name: Slam::Scope
| | | | | | | | | +- Dump::Class::compile_default_multi: Multi name: attach
src/oo.c:420: failed assertion 'name'
Backtrace - Obtained 18 stack frames (max trace depth is 32).
/usr/local/lib/libparrot.so.1.6.0 [0xb7cdec52]
/usr/local/lib/libparrot.so.1.6.0(Parrot_confess+0x9a) [0xb7cdedba]
/usr/local/lib/libparrot.so.1.6.0(Parrot_oo_get_class_str+0x5f) [0xb7d16c1f]
/usr/local/lib/libparrot.so.1.6.0 [0xb7c8cf05]
/usr/local/lib/libparrot.so.1.6.0 [0xb7d2762e]
/usr/local/lib/libparrot.so.1.6.0 [0xb7d2598f]
/usr/local/lib/libparrot.so.1.6.0 [0xb7cff6d5]
/usr/local/lib/libparrot.so.1.6.0 [0xb7cffaf0]
/usr/local/lib/libparrot.so.1.6.0(Parrot_runops_fromc_args+0xc6) [0xb7d00896]
/usr/local/lib/libparrot.so.1.6.0 [0xb7d1ec7e]
/usr/local/lib/libparrot.so.1.6.0 [0xb7d1ef41]
/usr/local/lib/libparrot.so.1.6.0(do_sub_pragmas+0x1b0) [0xb7d1f110]
/usr/local/lib/libparrot.so.1.6.0(PackFile_fixup_subs+0x7c) [0xb7d1f20c]
/usr/local/lib/libparrot.so.1.6.0 [0xb7f46b3a]
/usr/local/lib/libparrot.so.1.6.0(imcc_run+0x39c) [0xb7f4774c]
parrot [0x8048938]
/lib/libc.so.6(__libc_start_main+0xe5) [0xb7a6d775]
parrot [0x80487d1]

Change History

Changed 7 years ago by NotFound

  • status changed from new to assigned
  • owner set to NotFound

Fixed in r42267 by changing the Parrot_oo_get_class_str signature to allow NULL and returning a PMCNULL.

Now we need to decide if this is the correct solution or we must throw instead, and add a test accordingly.

Changed 6 years ago by NotFound

If no one objects, after r45985 returning PMCNULL will be the expected semantic, both for Parrot_oo_get_class_str and for Parrot_oo_get_class. Tests added.

Changed 6 years ago by NotFound

  • status changed from assigned to closed
  • resolution set to fixed

No objections in 4 weeks, closing ticket.

Note: See TracTickets for help on using tickets.