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

Segfault when serializing class with single String field #2245

Closed
jtfmumm opened this issue Sep 22, 2017 · 4 comments · Fixed by #2247
Closed

Segfault when serializing class with single String field #2245

jtfmumm opened this issue Sep 22, 2017 · 4 comments · Fixed by #2247
Assignees

Comments

@jtfmumm
Copy link
Contributor

jtfmumm commented Sep 22, 2017

The following segfaults when attempting to serialize a class with a single String field.

use "serialise"

actor Main
  new create(env: Env) =>
    try
      let auth = env.root as AmbientAuth
      let psd: V = V
      Serialised(SerialiseAuth(auth), psd)?
    end

class V
  let _v: String = ""

however, with

class V
  let _v: String = "A"

it works.

@jtfmumm jtfmumm closed this as completed Sep 22, 2017
@jtfmumm jtfmumm reopened this Sep 22, 2017
@jtfmumm jtfmumm changed the title Segfault when serializing Segfault when serializing class with single String field Sep 22, 2017
@SeanTAllen
Copy link
Member

backtrace:

* thread #2: tid = 0x4f1fa8, 0x000000010000f31c serialization-jtf`pony_serialise_offset(ctx=0x0000000108fff448, p=0x00000001000184b0) + 188 at serialise.c:213, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x000000010000f31c serialization-jtf`pony_serialise_offset(ctx=0x0000000108fff448, p=0x00000001000184b0) + 188 at serialise.c:213
   210 	  // If we are not in the map, we are an untraced primitive. Return the type id
   211 	  // with the high bit set.
   212 	  pony_type_t* t = *(pony_type_t**)p;
-> 213 	  return (size_t)t->id | HIGH_BIT;
   214 	}
   215
   216 	PONY_API void pony_serialise(pony_ctx_t* ctx, void* p, pony_type_t* t,
(lldb) bt
warning: could not load any Objective-C class information. This will significantly reduce the quality of type information available.
* thread #2: tid = 0x4f1fa8, 0x000000010000f31c serialization-jtf`pony_serialise_offset(ctx=0x0000000108fff448, p=0x00000001000184b0) + 188 at serialise.c:213, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x000000010000f31c serialization-jtf`pony_serialise_offset(ctx=0x0000000108fff448, p=0x00000001000184b0) + 188 at serialise.c:213
    frame #1: 0x0000000100003998 serialization-jtf`String_Serialise + 88
    frame #2: 0x000000010000f4f2 serialization-jtf`pony_serialise(ctx=0x0000000108fff448, p=0x0000000108fd5860, t=0x0000000000000000, out=0x0000000108fd58a0, alloc_fn=(serialization-jtf`serialise_$2$0_apply_oZo at serialise.pony:76), throw_fn=(serialization-jtf`serialise_$2$1_apply_o at serialise.pony:79)) + 434 at serialise.c:245
    frame #3: 0x0000000100002324 serialization-jtf`serialise_Serialised_ref_create_ooo(this=0x0000000108fd5880, auth=0x00000001000223f0, data=0x0000000108fd5860) + 196 at serialise.pony:80
    frame #4: 0x00000001000016a2 serialization-jtf`Main_tag_create_oo(this=0x0000000108ffec00, env=0x0000000108ffe400) + 258 at a.pony:8
    frame #5: 0x0000000100000d55 serialization-jtf`Main_Dispatch + 117
    frame #6: 0x0000000100004269 serialization-jtf`handle_message(ctx=0x0000000108fff448, actor=0x0000000108ffec00, msg=0x0000000108fff340) + 457 at actor.c:152
    frame #7: 0x0000000100003f0b serialization-jtf`ponyint_actor_run(ctx=0x0000000108fff448, actor=0x0000000108ffec00, batch=100) + 107 at actor.c:209
    frame #8: 0x0000000100017299 serialization-jtf`run(sched=0x0000000108fff400) + 185 at scheduler.c:301
    frame #9: 0x0000000100016fa9 serialization-jtf`run_thread(arg=0x0000000108fff400) + 57 at scheduler.c:352
    frame #10: 0x00007fff97df399d libsystem_pthread.dylib`_pthread_body + 131
    frame #11: 0x00007fff97df391a libsystem_pthread.dylib`_pthread_start + 168
    frame #12: 0x00007fff97df1351 libsystem_pthread.dylib`thread_start + 13

@jtfmumm
Copy link
Contributor Author

jtfmumm commented Sep 22, 2017

The String has to be empty. Updated description.

@jtfmumm
Copy link
Contributor Author

jtfmumm commented Sep 22, 2017

Actually, serializing an empty string on its own segfaults.

@SeanTAllen
Copy link
Member

SeanTAllen commented Sep 22, 2017

This was introduced in b90ec8f

@Praetonus thoughts?

Praetonus pushed a commit to Praetonus/ponyc that referenced this issue Sep 22, 2017
This change fixes a bug in Array/String_Serialise_Trace where the data
pointer would be traced for immutable and opaque objects, instead of
mutable and immutable ones.

Closes ponylang#2245.
Praetonus pushed a commit to Praetonus/ponyc that referenced this issue Sep 22, 2017
This change fixes a bug in Array/String_Serialise_Trace where the data
pointer would be traced for immutable and opaque objects, instead of
mutable and immutable ones.

Closes ponylang#2245.
dipinhora added a commit to dipinhora/ponyc that referenced this issue Sep 24, 2017
This commit fixes a bug in how empty strings are serialised.

Resolves ponylang#2245.
SeanTAllen pushed a commit that referenced this issue Sep 24, 2017
This commit fixes a bug in how empty strings are serialised.

Resolves #2245.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants